Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent infinite loop awareness #2

Open
wants to merge 1 commit into
base: gudjon/error-callback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions demo/dist/prosemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -26245,22 +26245,20 @@
head
});
}
} else if (
current.cursor != null &&
relativePositionToAbsolutePosition(
ystate.doc,
ystate.type,
createRelativePositionFromJSON(current.cursor.anchor),
ystate.binding.mapping
) !== null
) {
// delete cursor information if current cursor information is owned by this editor binding
}
};

const unsetCursorInfo = () => {
const current = awareness.getLocalState() || {};

if (current[cursorStateField]) {
awareness.setLocalStateField(cursorStateField, null);
}
};

awareness.on('change', awarenessListener);
view.dom.addEventListener('focusin', updateCursorInfo);
view.dom.addEventListener('focusout', updateCursorInfo);
view.dom.addEventListener('focusout', unsetCursorInfo);
return {
update: updateCursorInfo,
destroy: () => {
Expand Down
2 changes: 1 addition & 1 deletion demo/dist/prosemirror.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/src/plugins/sync-plugin.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export function isVisible(item: Y.Item, snapshot?: Y.Snapshot): boolean;
export function ySyncPlugin(yXmlFragment: Y.XmlFragment, { colors, colorMapping, permanentUserData, onFirstRender, onCreateNodeError, }?: YSyncOpts): any;
export function ySyncPlugin(yXmlFragment: Y.XmlFragment, { colors, colorMapping, permanentUserData, onFirstRender, onCreateNodeError }?: YSyncOpts): any;
export function getRelativeSelection(pmbinding: any, state: any): {
anchor: any;
head: any;
Expand Down
20 changes: 9 additions & 11 deletions dist/y-prosemirror.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1787,22 +1787,20 @@ const yCursorPlugin = (
head
});
}
} else if (
current.cursor != null &&
relativePositionToAbsolutePosition(
ystate.doc,
ystate.type,
Y__namespace.createRelativePositionFromJSON(current.cursor.anchor),
ystate.binding.mapping
) !== null
) {
// delete cursor information if current cursor information is owned by this editor binding
}
};

const unsetCursorInfo = () => {
const current = awareness.getLocalState() || {};

if (current[cursorStateField]) {
awareness.setLocalStateField(cursorStateField, null);
}
};

awareness.on('change', awarenessListener);
view.dom.addEventListener('focusin', updateCursorInfo);
view.dom.addEventListener('focusout', updateCursorInfo);
view.dom.addEventListener('focusout', unsetCursorInfo);
return {
update: updateCursorInfo,
destroy: () => {
Expand Down
2 changes: 1 addition & 1 deletion dist/y-prosemirror.cjs.map

Large diffs are not rendered by default.

20 changes: 9 additions & 11 deletions src/plugins/cursor-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,22 +224,20 @@ export const yCursorPlugin = (
head
})
}
} else if (
current.cursor != null &&
relativePositionToAbsolutePosition(
ystate.doc,
ystate.type,
Y.createRelativePositionFromJSON(current.cursor.anchor),
ystate.binding.mapping
) !== null
) {
// delete cursor information if current cursor information is owned by this editor binding
}
}

const unsetCursorInfo = () => {
const current = awareness.getLocalState() || {}

if (current[cursorStateField]) {
awareness.setLocalStateField(cursorStateField, null)
}
}

awareness.on('change', awarenessListener)
view.dom.addEventListener('focusin', updateCursorInfo)
view.dom.addEventListener('focusout', updateCursorInfo)
view.dom.addEventListener('focusout', unsetCursorInfo)
return {
update: updateCursorInfo,
destroy: () => {
Expand Down