Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CJK Input stuttering with dispatchTransaction #41

@bentongxyz

Description

@bentongxyz

I noticed that using the README.md example code:

import { ProseMirror } from "@nytimes/react-prosemirror";
import { useState } from "react";
import { EditorState } from "prosemirror-state";
import { schema } from "prosemirror-schema-basic";

export function ProseMirrorEditor() {
  const [mount, setMount] = useState<HTMLElement | null>(null);
  const [editorState, setEditorState] = useState(
    EditorState.create({schema})
  );

  return (
    <ProseMirror
      mount={mount}
      state={editorState}
      dispatchTransaction={(tr) => {
        setEditorState((s) => s.apply(tr));
      }}
    >
      <div ref={setMount} />
    </ProseMirror>
  );
}

the CJK input in browser is stuttering.

Screencast.from.2023-06-26.02-37-59.webm

However, if I remove dispatchTransaction prop, i.e.

import { ProseMirror } from "@nytimes/react-prosemirror";
import { useState } from "react";
import { EditorState } from "prosemirror-state";
import { schema } from "prosemirror-schema-basic";

export function ProseMirrorEditor() {
  const [mount, setMount] = useState<HTMLElement | null>(null);
  const [editorState, setEditorState] = useState(
    EditorState.create({schema})
  );

  return (
    <ProseMirror
      mount={mount}
      state={editorState}
    >
      <div ref={setMount} />
    </ProseMirror>
  );
}

it behaves normally:

Screencast.from.2023-06-26.02-38-52.webm

Any idea what is the source of problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions