It's a lot of content, it's a lot of times to execute marktext, and it's very difficult to edit, so how can you optimize it

this.markText({ origin: 'init' });

 private markText(changeObj?: { origin: string }) {

    replaceTextWithElement({
      changeObj,
      editor: this.instance,
      showDescription: true,
      CustomEventCaches: this.CustomEventCaches,
    });
  }

  if (!changeObj || changeObj?.origin === 'init' || changeObj?.origin === 'paste') {
      console.log(changeObj?.origin);
      // 清除所有的标记替换
      doc.getAllMarks().forEach(marker => {
        marker.clear();
      });
      doc.eachLine(lineHandle => {
        const lineNo = (lineHandle as any).lineNo();
        const tokens = editor.getLineTokens(lineNo);
        tokens.forEach(token => {
          replaceToken(token, tokens);
        });
      });
    }


 if (proxy.createEditorReplacement) {
    const position = { start: startPos, end: endPos };
    const replacement = proxy.createEditorReplacement({ editor, token, position });
    if (replacement && replacement.node) {
      if (replacement.destroyHost) {
        CustomEventCaches.push(replacement.destroyHost);
      }

      editor.getDoc().markText(startPos, endPos, {
        replacedWith: replacement.node,
      });
      return 1;
    }
  }

Edit content, open it, initialize it, perform a lot of Marktext replace, and render will be jammed

Check out the operation method.