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

YJS Extension editing interrupted by PlaceholderExtension decorations when collaborating #1993

Open
jeffrafter opened this issue Feb 11, 2023 · 0 comments · May be fixed by #1994
Open

YJS Extension editing interrupted by PlaceholderExtension decorations when collaborating #1993

jeffrafter opened this issue Feb 11, 2023 · 0 comments · May be fixed by #1994
Labels
type: bug 🪲 Something isn't working

Comments

@jeffrafter
Copy link

Summary

When at least two users are collaborating (for example using the WebrtcProvider) and a user selects all and deletes the document becomes empty. This triggers the PlaceholderExtension which creates a decoration node for the placeholder message. Typing (collaborative) becomes disabled in the editing user window until they hit enter. This is because the node position / selection is confused and YJS can't sync.

Steps to reproduce

"use client";

import React from "react";
import { YjsExtension } from "@remirror/extension-yjs";
import { WebrtcProvider } from "y-webrtc";
import * as Y from "yjs";
import {
  Remirror,
  ThemeProvider,
  useRemirror,
} from "@remirror/react";

const room = "test-placeholder-yjs";
const ydoc = new Y.Doc();
const provider = new WebrtcProvider(room, ydoc);

const extensions = () => [
  new YjsExtension({ getProvider: () => provider, disableUndo: true })  
];

const RemirrorPage = (): JSX.Element => {
  const { manager } = useRemirror({
    extensions,
    core: { excludeExtensions: ["history"] },
  });

  return (
    <ThemeProvider>
      <Remirror manager={manager} autoFocus autoRender="end">
      </Remirror>
    </ThemeProvider>
  );
};

export default RemirrorPage;

Expected results

After deleting the content of the document you should be able to immediately begin typing.

Actual results

User can't type until they press enter or another user inserts content collaboratively.

Possible Solution

  1. Make it possible to remove the PlaceholderExtension from the ReactExtension core (excludePlaceholder or core: { excludeExtensions: ["history", "placeholder"] }).
  2. Create a new option on the PlaceholderExtension called disabled. If the extension is disabled do not apply the decorations.
  3. Implement the decoration as a Mark so it is shared (this seems very problematic and is probably not a good idea).

Screenshot(s)

@jeffrafter jeffrafter added the type: bug 🪲 Something isn't working label Feb 11, 2023
@jeffrafter jeffrafter linked a pull request Feb 11, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🪲 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant