@blade-hq/agent-react 2612.0.0-beta.99 → 2612.0.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/{McpAppCard-ADVDKC2C.js → McpAppCard-NJEKKEEN.js} +3 -3
- package/dist/McpAppFrame-IQK5AOMD.js +9 -0
- package/dist/{PlanGraph-3D5PCSIJ.js → PlanGraph-WTXKSHID.js} +31 -3
- package/dist/PlanGraph-WTXKSHID.js.map +1 -0
- package/dist/{SessionPluginConfigForm-DWVDFK6A.js → SessionPluginConfigForm-VXONUDM4.js} +2 -2
- package/dist/chat/AskUserQuestionBlock.d.ts +3 -2
- package/dist/chat/AssistantTurnBlock.d.ts +3 -2
- package/dist/chat/AttachmentPreviewDialog.d.ts +1 -6
- package/dist/chat/ChatLoadingIndicator.d.ts +2 -1
- package/dist/chat/ChatPanel.d.ts +3 -3
- package/dist/chat/LightComposer.d.ts +1 -1
- package/dist/chat/MessageList.d.ts +2 -2
- package/dist/chat/ToolCallBlock.d.ts +6 -11
- package/dist/chat/chat-run.d.ts +4 -0
- package/dist/chat/customization.d.ts +5 -5
- package/dist/chat/index.d.ts +1 -2
- package/dist/chat/message-list-blocks.d.ts +1 -0
- package/dist/chat/plan/PlanGraph.d.ts +1 -0
- package/dist/chat/runtime/actions.d.ts +2 -4
- package/dist/chat/runtime/environment.d.ts +3 -3
- package/dist/chat.css +113 -3
- package/dist/{chunk-3RFYXI6V.js → chunk-34YJQXTM.js} +8 -4
- package/dist/chunk-34YJQXTM.js.map +1 -0
- package/dist/{chunk-J6BSKVVK.js → chunk-3KJJIH5K.js} +1 -35
- package/dist/chunk-3KJJIH5K.js.map +1 -0
- package/dist/{chunk-IOIKCFRO.js → chunk-4WFRH7FG.js} +28 -8
- package/dist/{chunk-IOIKCFRO.js.map → chunk-4WFRH7FG.js.map} +1 -1
- package/dist/{chunk-WEOW475M.js → chunk-63G66FWM.js} +9 -5
- package/dist/{chunk-SVCTJ4VS.js → chunk-7DG4JFRS.js} +42 -22
- package/dist/chunk-7DG4JFRS.js.map +1 -0
- package/dist/{chunk-5JAFIDDP.js → chunk-DNND32V4.js} +25 -7
- package/dist/chunk-DNND32V4.js.map +1 -0
- package/dist/{chunk-GZHQQXYI.js → chunk-LFC3UTIJ.js} +12 -13
- package/dist/chunk-LFC3UTIJ.js.map +1 -0
- package/dist/{chunk-MG4RF573.js → chunk-NPDS3EEK.js} +3 -3
- package/dist/{chunk-67JW6ASD.js → chunk-VUUX2BIU.js} +9466 -9601
- package/dist/chunk-VUUX2BIU.js.map +1 -0
- package/dist/{chunk-YBTELD7P.js → chunk-XCASYOA6.js} +4 -4
- package/dist/components/ChatInput.d.ts +2 -1
- package/dist/components/McpAppFrame.d.ts +2 -0
- package/dist/components/use-session-plugin-activation.d.ts +3 -1
- package/dist/connectors.js +3 -3
- package/dist/embed/entry.d.ts +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8 -8
- package/dist/internal.js +192 -21
- package/dist/internal.js.map +1 -1
- package/dist/questions.js +4 -4
- package/dist/rich-input/ChatInput.d.ts +1 -1
- package/dist/rich-input/ComposerControls.d.ts +15 -0
- package/dist/rich-input.js +7086 -6830
- package/dist/rich-input.js.map +1 -1
- package/dist/style.full.css +114 -4
- package/dist/tool-details.js +5 -5
- package/node_modules/@tiptap/core/dist/index.cjs +7679 -6763
- package/node_modules/@tiptap/core/dist/index.cjs.map +1 -1
- package/node_modules/@tiptap/core/dist/index.d.cts +4468 -3614
- package/node_modules/@tiptap/core/dist/index.d.cts.map +1 -0
- package/node_modules/@tiptap/core/dist/index.d.ts +4467 -3614
- package/node_modules/@tiptap/core/dist/index.d.ts.map +1 -0
- package/node_modules/@tiptap/core/dist/index.js +7508 -6632
- package/node_modules/@tiptap/core/dist/index.js.map +1 -1
- package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.cjs +66 -52
- package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.cjs.map +1 -1
- package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.d.cts +17 -12
- package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.d.cts.map +1 -0
- package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.d.ts +17 -12
- package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.d.ts.map +1 -0
- package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js +60 -22
- package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js.map +1 -1
- package/node_modules/@tiptap/core/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/node_modules/@tiptap/core/package.json +27 -24
- package/node_modules/@tiptap/core/src/CommandManager.ts +72 -2
- package/node_modules/@tiptap/core/src/Editor.ts +108 -26
- package/node_modules/@tiptap/core/src/EventEmitter.ts +20 -7
- package/node_modules/@tiptap/core/src/Extendable.ts +52 -7
- package/node_modules/@tiptap/core/src/Extension.ts +7 -3
- package/node_modules/@tiptap/core/src/ExtensionManager.ts +158 -15
- package/node_modules/@tiptap/core/src/InputRule.ts +30 -3
- package/node_modules/@tiptap/core/src/Mark.ts +26 -6
- package/node_modules/@tiptap/core/src/MarkView.ts +13 -3
- package/node_modules/@tiptap/core/src/Node.ts +19 -6
- package/node_modules/@tiptap/core/src/NodePos.ts +17 -4
- package/node_modules/@tiptap/core/src/NodeView.ts +31 -9
- package/node_modules/@tiptap/core/src/PasteRule.ts +17 -4
- package/node_modules/@tiptap/core/src/Tracker.ts +9 -7
- package/node_modules/@tiptap/core/src/__tests__/Editor.spec.ts +73 -0
- package/node_modules/@tiptap/core/src/__tests__/htmlEntities.test.ts +55 -0
- package/node_modules/@tiptap/core/src/__tests__/inputRuleInlineAtoms.test.ts +111 -0
- package/node_modules/@tiptap/core/src/__tests__/isAndroid.test.ts +28 -0
- package/node_modules/@tiptap/core/src/__tests__/rewriteUnknownContent.test.ts +51 -0
- package/node_modules/@tiptap/core/src/__tests__/transformPastedHTML.test.ts +10 -4
- package/node_modules/@tiptap/core/src/commands/deleteSelection.ts +90 -2
- package/node_modules/@tiptap/core/src/commands/extendMarkRange.ts +3 -2
- package/node_modules/@tiptap/core/src/commands/index.ts +2 -0
- package/node_modules/@tiptap/core/src/commands/insertContent.ts +5 -1
- package/node_modules/@tiptap/core/src/commands/insertContentAt.ts +17 -21
- package/node_modules/@tiptap/core/src/commands/insertDefaultBlock.ts +97 -0
- package/node_modules/@tiptap/core/src/commands/resetAttributes.ts +9 -2
- package/node_modules/@tiptap/core/src/commands/setContent.ts +4 -1
- package/node_modules/@tiptap/core/src/commands/setMark.ts +7 -3
- package/node_modules/@tiptap/core/src/commands/setTextSelection.ts +2 -1
- package/node_modules/@tiptap/core/src/commands/splitBlock.ts +16 -4
- package/node_modules/@tiptap/core/src/commands/splitListItem.ts +14 -6
- package/node_modules/@tiptap/core/src/commands/toggleList.ts +106 -7
- package/node_modules/@tiptap/core/src/commands/undoInputRule.ts +1 -1
- package/node_modules/@tiptap/core/src/commands/unsetAllMarks.ts +17 -5
- package/node_modules/@tiptap/core/src/commands/updateDecorations.ts +28 -0
- package/node_modules/@tiptap/core/src/decorations/Decoration.ts +177 -0
- package/node_modules/@tiptap/core/src/decorations/DecorationManager.ts +440 -0
- package/node_modules/@tiptap/core/src/decorations/__tests__/DecorationManager.test.ts +821 -0
- package/node_modules/@tiptap/core/src/decorations/constants.ts +7 -0
- package/node_modules/@tiptap/core/src/decorations/createWidgetDecoration.ts +221 -0
- package/node_modules/@tiptap/core/src/decorations/decorationApplyScope.ts +45 -0
- package/node_modules/@tiptap/core/src/decorations/helpers/__tests__/getRebuildRanges.test.ts +147 -0
- package/node_modules/@tiptap/core/src/decorations/helpers/buildDecorationSet.ts +25 -0
- package/node_modules/@tiptap/core/src/decorations/helpers/decorationsToPMDecorations.ts +36 -0
- package/node_modules/@tiptap/core/src/decorations/helpers/filterOutOfRangeDecorations.ts +52 -0
- package/node_modules/@tiptap/core/src/decorations/helpers/findDuplicateWidgetKeys.ts +37 -0
- package/node_modules/@tiptap/core/src/decorations/helpers/getRebuildRanges.ts +96 -0
- package/node_modules/@tiptap/core/src/decorations/helpers/hasResolvableChangedRange.ts +24 -0
- package/node_modules/@tiptap/core/src/decorations/helpers/isAttrStep.ts +21 -0
- package/node_modules/@tiptap/core/src/decorations/helpers/mapDecorationSet.ts +31 -0
- package/node_modules/@tiptap/core/src/decorations/helpers/mapDecorations.ts +26 -0
- package/node_modules/@tiptap/core/src/decorations/helpers/mergeDecorationSets.ts +16 -0
- package/node_modules/@tiptap/core/src/decorations/helpers/rangeOwnsPosition.ts +38 -0
- package/node_modules/@tiptap/core/src/decorations/helpers/shouldRecomputeDecoration.ts +24 -0
- package/node_modules/@tiptap/core/src/decorations/helpers/unionWidgetKeys.ts +15 -0
- package/node_modules/@tiptap/core/src/decorations/helpers/validateDecorationSpec.ts +49 -0
- package/node_modules/@tiptap/core/src/decorations/helpers/widgetKeyOf.ts +11 -0
- package/node_modules/@tiptap/core/src/decorations/index.ts +28 -0
- package/node_modules/@tiptap/core/src/decorations/types.ts +87 -0
- package/node_modules/@tiptap/core/src/extensions/clipboardTextSerializer.ts +17 -8
- package/node_modules/@tiptap/core/src/extensions/delete.ts +33 -21
- package/node_modules/@tiptap/core/src/extensions/focusEvents.ts +6 -2
- package/node_modules/@tiptap/core/src/extensions/keymap.ts +8 -3
- package/node_modules/@tiptap/core/src/extensions/tabindex.ts +42 -2
- package/node_modules/@tiptap/core/src/extensions/textDirection.ts +3 -1
- package/node_modules/@tiptap/core/src/helpers/MappablePosition.ts +4 -1
- package/node_modules/@tiptap/core/src/helpers/__tests__/getChangedRanges.test.ts +48 -0
- package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorAddMarkStep.test.ts +19 -0
- package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorAddNodeMarkStep.test.ts +19 -0
- package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorAttrStep.test.ts +17 -0
- package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorCellSelection.test.ts +17 -0
- package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorDocAttrStep.test.ts +17 -0
- package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorFragment.test.ts +27 -0
- package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorNodeSelection.test.ts +35 -0
- package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorRemoveMarkStep.test.ts +19 -0
- package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorRemoveNodeMarkStep.test.ts +19 -0
- package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorReplaceAroundStep.test.ts +19 -0
- package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorReplaceStep.test.ts +17 -0
- package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorSlice.test.ts +16 -0
- package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorStep.test.ts +30 -0
- package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorStepResult.test.ts +17 -0
- package/node_modules/@tiptap/core/src/helpers/combineTransactionSteps.ts +4 -1
- package/node_modules/@tiptap/core/src/helpers/createChainableState.ts +4 -1
- package/node_modules/@tiptap/core/src/helpers/createNodeFromContent.ts +15 -6
- package/node_modules/@tiptap/core/src/helpers/findChildrenInRange.ts +5 -1
- package/node_modules/@tiptap/core/src/helpers/flattenExtensions.ts +5 -1
- package/node_modules/@tiptap/core/src/helpers/getAttributes.ts +4 -1
- package/node_modules/@tiptap/core/src/helpers/getAttributesFromExtensions.ts +3 -5
- package/node_modules/@tiptap/core/src/helpers/getMarkAttributes.ts +4 -1
- package/node_modules/@tiptap/core/src/helpers/getMarkRange.ts +20 -5
- package/node_modules/@tiptap/core/src/helpers/getMarkType.ts +3 -1
- package/node_modules/@tiptap/core/src/helpers/getNodeAtPosition.ts +6 -1
- package/node_modules/@tiptap/core/src/helpers/getNodeAttributes.ts +4 -1
- package/node_modules/@tiptap/core/src/helpers/getNodeType.ts +3 -1
- package/node_modules/@tiptap/core/src/helpers/getPreviousBlockSibling.ts +36 -0
- package/node_modules/@tiptap/core/src/helpers/getSchemaByResolvedExtensions.ts +73 -20
- package/node_modules/@tiptap/core/src/helpers/getTextBetween.ts +1 -1
- package/node_modules/@tiptap/core/src/helpers/getTextContentFromNodes.ts +17 -12
- package/node_modules/@tiptap/core/src/helpers/index.ts +16 -0
- package/node_modules/@tiptap/core/src/helpers/isActive.ts +5 -1
- package/node_modules/@tiptap/core/src/helpers/isFragment.ts +14 -0
- package/node_modules/@tiptap/core/src/helpers/isNodeViewSelected.ts +42 -0
- package/node_modules/@tiptap/core/src/helpers/isProseMirrorAddMarkStep.ts +31 -0
- package/node_modules/@tiptap/core/src/helpers/isProseMirrorAddNodeMarkStep.ts +31 -0
- package/node_modules/@tiptap/core/src/helpers/isProseMirrorAttrStep.ts +31 -0
- package/node_modules/@tiptap/core/src/helpers/isProseMirrorCellSelection.ts +18 -0
- package/node_modules/@tiptap/core/src/helpers/isProseMirrorContent.ts +14 -0
- package/node_modules/@tiptap/core/src/helpers/isProseMirrorDocAttrStep.ts +31 -0
- package/node_modules/@tiptap/core/src/helpers/isProseMirrorFragment.ts +34 -0
- package/node_modules/@tiptap/core/src/helpers/isProseMirrorNodeSelection.ts +18 -0
- package/node_modules/@tiptap/core/src/helpers/isProseMirrorRemoveMarkStep.ts +31 -0
- package/node_modules/@tiptap/core/src/helpers/isProseMirrorRemoveNodeMarkStep.ts +31 -0
- package/node_modules/@tiptap/core/src/helpers/isProseMirrorReplaceAroundStep.ts +31 -0
- package/node_modules/@tiptap/core/src/helpers/isProseMirrorReplaceStep.ts +31 -0
- package/node_modules/@tiptap/core/src/helpers/isProseMirrorSlice.ts +43 -0
- package/node_modules/@tiptap/core/src/helpers/isProseMirrorStep.ts +30 -0
- package/node_modules/@tiptap/core/src/helpers/isProseMirrorStepResult.ts +26 -0
- package/node_modules/@tiptap/core/src/helpers/resolveFocusPosition.ts +14 -3
- package/node_modules/@tiptap/core/src/helpers/rewriteUnknownContent.ts +19 -10
- package/node_modules/@tiptap/core/src/helpers/splitExtensions.ts +3 -1
- package/node_modules/@tiptap/core/src/helpers/warnOnDuplicatedProseMirrorModel.ts +40 -0
- package/node_modules/@tiptap/core/src/index.ts +1 -6
- package/node_modules/@tiptap/core/src/inputRules/markInputRule.ts +5 -1
- package/node_modules/@tiptap/core/src/inputRules/nodeInputRule.ts +9 -2
- package/node_modules/@tiptap/core/src/inputRules/textInputRule.ts +5 -1
- package/node_modules/@tiptap/core/src/inputRules/textblockTypeInputRule.ts +8 -2
- package/node_modules/@tiptap/core/src/inputRules/wrappingInputRule.ts +8 -2
- package/node_modules/@tiptap/core/src/jsx-runtime.ts +91 -11
- package/node_modules/@tiptap/core/src/lib/ResizableNodeView.ts +25 -6
- package/node_modules/@tiptap/core/src/pasteRules/markPasteRule.ts +12 -1
- package/node_modules/@tiptap/core/src/types.ts +65 -18
- package/node_modules/@tiptap/core/src/utilities/attrsEqual.ts +27 -0
- package/node_modules/@tiptap/core/src/utilities/callOrReturn.ts +5 -1
- package/node_modules/@tiptap/core/src/utilities/deleteProps.ts +4 -1
- package/node_modules/@tiptap/core/src/utilities/elementFromString.ts +3 -1
- package/node_modules/@tiptap/core/src/utilities/getStyleProperty.ts +52 -0
- package/node_modules/@tiptap/core/src/utilities/htmlEntities.ts +26 -0
- package/node_modules/@tiptap/core/src/utilities/index.ts +4 -0
- package/node_modules/@tiptap/core/src/utilities/isAndroid.ts +1 -1
- package/node_modules/@tiptap/core/src/utilities/isDev.ts +12 -0
- package/node_modules/@tiptap/core/src/utilities/isFunction.ts +1 -1
- package/node_modules/@tiptap/core/src/utilities/isSafari.ts +3 -1
- package/node_modules/@tiptap/core/src/utilities/isiOS.ts +3 -1
- package/node_modules/@tiptap/core/src/utilities/markdown/createAtomBlockMarkdownSpec.ts +2 -4
- package/node_modules/@tiptap/core/src/utilities/markdown/createBlockMarkdownSpec.ts +10 -6
- package/node_modules/@tiptap/core/src/utilities/markdown/createInlineMarkdownSpec.ts +4 -24
- package/node_modules/@tiptap/core/src/utilities/markdown/index.ts +2 -1
- package/node_modules/@tiptap/core/src/utilities/markdown/parseAttributes.ts +48 -0
- package/node_modules/@tiptap/core/src/utilities/markdown/parseShortcodeAttributes.ts +13 -0
- package/node_modules/@tiptap/core/src/utilities/markdown/renderNestedMarkdownContent.ts +2 -1
- package/node_modules/@tiptap/core/src/utilities/markdown/serializeAttributes.ts +42 -0
- package/node_modules/@tiptap/core/src/utilities/markdown/tokenizeAttributes.ts +163 -0
- package/node_modules/@tiptap/core/src/utilities/marksEqual.ts +44 -0
- package/node_modules/@tiptap/core/src/utilities/mergeAttributes.ts +22 -3
- package/node_modules/@tiptap/core/src/utilities/mergeDeep.ts +4 -1
- package/node_modules/@tiptap/extension-bubble-menu/dist/index.cjs +324 -453
- package/node_modules/@tiptap/extension-bubble-menu/dist/index.cjs.map +1 -1
- package/node_modules/@tiptap/extension-bubble-menu/dist/index.d.cts +152 -151
- package/node_modules/@tiptap/extension-bubble-menu/dist/index.d.cts.map +1 -0
- package/node_modules/@tiptap/extension-bubble-menu/dist/index.d.ts +152 -151
- package/node_modules/@tiptap/extension-bubble-menu/dist/index.d.ts.map +1 -0
- package/node_modules/@tiptap/extension-bubble-menu/dist/index.js +316 -433
- package/node_modules/@tiptap/extension-bubble-menu/dist/index.js.map +1 -1
- package/node_modules/@tiptap/extension-bubble-menu/package.json +25 -23
- package/node_modules/@tiptap/extension-bubble-menu/src/bubble-menu-plugin.ts +73 -13
- package/node_modules/@tiptap/extension-floating-menu/dist/index.cjs +265 -373
- package/node_modules/@tiptap/extension-floating-menu/dist/index.cjs.map +1 -1
- package/node_modules/@tiptap/extension-floating-menu/dist/index.d.cts +161 -160
- package/node_modules/@tiptap/extension-floating-menu/dist/index.d.cts.map +1 -0
- package/node_modules/@tiptap/extension-floating-menu/dist/index.d.ts +161 -160
- package/node_modules/@tiptap/extension-floating-menu/dist/index.d.ts.map +1 -0
- package/node_modules/@tiptap/extension-floating-menu/dist/index.js +258 -354
- package/node_modules/@tiptap/extension-floating-menu/dist/index.js.map +1 -1
- package/node_modules/@tiptap/extension-floating-menu/package.json +23 -21
- package/node_modules/@tiptap/extension-floating-menu/src/floating-menu-plugin.ts +66 -11
- package/node_modules/@tiptap/extension-mention/dist/index.cjs +232 -268
- package/node_modules/@tiptap/extension-mention/dist/index.cjs.map +1 -1
- package/node_modules/@tiptap/extension-mention/dist/index.d.cts +85 -84
- package/node_modules/@tiptap/extension-mention/dist/index.d.cts.map +1 -0
- package/node_modules/@tiptap/extension-mention/dist/index.d.ts +85 -84
- package/node_modules/@tiptap/extension-mention/dist/index.d.ts.map +1 -0
- package/node_modules/@tiptap/extension-mention/dist/index.js +226 -240
- package/node_modules/@tiptap/extension-mention/dist/index.js.map +1 -1
- package/node_modules/@tiptap/extension-mention/package.json +24 -22
- package/node_modules/@tiptap/extension-mention/src/mention.ts +23 -13
- package/node_modules/@tiptap/pm/README.md +1 -1
- package/node_modules/{prosemirror-schema-basic/LICENSE → @tiptap/pm/THIRD_PARTY_LICENSES.md} +28 -0
- package/node_modules/@tiptap/pm/dist/changeset/index.cjs +9 -2
- package/node_modules/@tiptap/pm/dist/changeset/index.d.cts +1 -18
- package/node_modules/@tiptap/pm/dist/changeset/index.d.ts +1 -18
- package/node_modules/@tiptap/pm/dist/changeset/index.js +1 -1
- package/node_modules/@tiptap/pm/dist/commands/index.cjs +9 -2
- package/node_modules/@tiptap/pm/dist/commands/index.d.cts +1 -1
- package/node_modules/@tiptap/pm/dist/commands/index.d.ts +1 -1
- package/node_modules/@tiptap/pm/dist/commands/index.js +1 -1
- package/node_modules/@tiptap/pm/dist/dropcursor/index.cjs +9 -2
- package/node_modules/@tiptap/pm/dist/dropcursor/index.d.cts +1 -1
- package/node_modules/@tiptap/pm/dist/dropcursor/index.d.ts +1 -1
- package/node_modules/@tiptap/pm/dist/dropcursor/index.js +1 -1
- package/node_modules/@tiptap/pm/dist/gapcursor/index.cjs +9 -2
- package/node_modules/@tiptap/pm/dist/gapcursor/index.d.cts +1 -1
- package/node_modules/@tiptap/pm/dist/gapcursor/index.d.ts +1 -1
- package/node_modules/@tiptap/pm/dist/gapcursor/index.js +1 -1
- package/node_modules/@tiptap/pm/dist/history/index.cjs +9 -2
- package/node_modules/@tiptap/pm/dist/history/index.d.cts +1 -1
- package/node_modules/@tiptap/pm/dist/history/index.d.ts +1 -1
- package/node_modules/@tiptap/pm/dist/history/index.js +1 -1
- package/node_modules/@tiptap/pm/dist/inputrules/index.cjs +9 -2
- package/node_modules/@tiptap/pm/dist/inputrules/index.d.cts +1 -1
- package/node_modules/@tiptap/pm/dist/inputrules/index.d.ts +1 -1
- package/node_modules/@tiptap/pm/dist/inputrules/index.js +1 -1
- package/node_modules/@tiptap/pm/dist/keymap/index.cjs +9 -2
- package/node_modules/@tiptap/pm/dist/keymap/index.d.cts +1 -1
- package/node_modules/@tiptap/pm/dist/keymap/index.d.ts +1 -1
- package/node_modules/@tiptap/pm/dist/keymap/index.js +1 -1
- package/node_modules/@tiptap/pm/dist/model/index.cjs +9 -2
- package/node_modules/@tiptap/pm/dist/model/index.d.cts +1 -1
- package/node_modules/@tiptap/pm/dist/model/index.d.ts +1 -1
- package/node_modules/@tiptap/pm/dist/model/index.js +1 -1
- package/node_modules/@tiptap/pm/dist/schema-list/index.cjs +9 -2
- package/node_modules/@tiptap/pm/dist/schema-list/index.d.cts +1 -1
- package/node_modules/@tiptap/pm/dist/schema-list/index.d.ts +1 -1
- package/node_modules/@tiptap/pm/dist/schema-list/index.js +1 -1
- package/node_modules/@tiptap/pm/dist/state/index.cjs +9 -2
- package/node_modules/@tiptap/pm/dist/state/index.d.cts +1 -1
- package/node_modules/@tiptap/pm/dist/state/index.d.ts +1 -1
- package/node_modules/@tiptap/pm/dist/state/index.js +1 -1
- package/node_modules/@tiptap/pm/dist/tables/index.cjs +9 -2
- package/node_modules/@tiptap/pm/dist/tables/index.d.cts +1 -1
- package/node_modules/@tiptap/pm/dist/tables/index.d.ts +1 -1
- package/node_modules/@tiptap/pm/dist/tables/index.js +1 -1
- package/node_modules/@tiptap/pm/dist/transform/index.cjs +9 -2
- package/node_modules/@tiptap/pm/dist/transform/index.d.cts +1 -1
- package/node_modules/@tiptap/pm/dist/transform/index.d.ts +1 -1
- package/node_modules/@tiptap/pm/dist/transform/index.js +1 -1
- package/node_modules/@tiptap/pm/dist/view/index.cjs +9 -2
- package/node_modules/@tiptap/pm/dist/view/index.d.cts +1 -1
- package/node_modules/@tiptap/pm/dist/view/index.d.ts +1 -1
- package/node_modules/@tiptap/pm/dist/view/index.js +1 -1
- package/node_modules/@tiptap/pm/package.json +54 -99
- package/node_modules/@tiptap/react/dist/index.cjs +1243 -1141
- package/node_modules/@tiptap/react/dist/index.cjs.map +1 -1
- package/node_modules/@tiptap/react/dist/index.d.cts +396 -294
- package/node_modules/@tiptap/react/dist/index.d.cts.map +1 -0
- package/node_modules/@tiptap/react/dist/index.d.ts +396 -294
- package/node_modules/@tiptap/react/dist/index.d.ts.map +1 -0
- package/node_modules/@tiptap/react/dist/index.js +1188 -1081
- package/node_modules/@tiptap/react/dist/index.js.map +1 -1
- package/node_modules/@tiptap/react/dist/menus/index.cjs +420 -450
- package/node_modules/@tiptap/react/dist/menus/index.cjs.map +1 -1
- package/node_modules/@tiptap/react/dist/menus/index.d.cts +13 -11
- package/node_modules/@tiptap/react/dist/menus/index.d.cts.map +1 -0
- package/node_modules/@tiptap/react/dist/menus/index.d.ts +13 -11
- package/node_modules/@tiptap/react/dist/menus/index.d.ts.map +1 -0
- package/node_modules/@tiptap/react/dist/menus/index.js +399 -416
- package/node_modules/@tiptap/react/dist/menus/index.js.map +1 -1
- package/node_modules/@tiptap/react/package.json +29 -27
- package/node_modules/@tiptap/react/src/Context.tsx +3 -1
- package/node_modules/@tiptap/react/src/Editor.ts +4 -1
- package/node_modules/@tiptap/react/src/EditorContent.spec.ts +39 -0
- package/node_modules/@tiptap/react/src/EditorContent.tsx +26 -41
- package/node_modules/@tiptap/react/src/ReactMarkViewRenderer.tsx +18 -10
- package/node_modules/@tiptap/react/src/ReactNodeViewRenderer.spec.ts +415 -0
- package/node_modules/@tiptap/react/src/ReactNodeViewRenderer.tsx +126 -24
- package/node_modules/@tiptap/react/src/ReactRenderer.tsx +30 -8
- package/node_modules/@tiptap/react/src/ReactWidgetRenderer.spec.ts +448 -0
- package/node_modules/@tiptap/react/src/ReactWidgetRenderer.tsx +97 -0
- package/node_modules/@tiptap/react/src/Tiptap.tsx +22 -15
- package/node_modules/@tiptap/react/src/captureDOMSelection.spec.ts +76 -0
- package/node_modules/@tiptap/react/src/captureDOMSelection.ts +35 -0
- package/node_modules/@tiptap/react/src/index.ts +3 -0
- package/node_modules/@tiptap/react/src/menus/BubbleMenu.spec.ts +7 -3
- package/node_modules/@tiptap/react/src/menus/BubbleMenu.tsx +10 -3
- package/node_modules/@tiptap/react/src/menus/FloatingMenu.spec.ts +7 -3
- package/node_modules/@tiptap/react/src/menus/FloatingMenu.tsx +28 -4
- package/node_modules/@tiptap/react/src/menus/index.ts +2 -0
- package/node_modules/@tiptap/react/src/menus/useMenuElementProps.ts +18 -3
- package/node_modules/@tiptap/react/src/use-client.spec.ts +26 -0
- package/node_modules/@tiptap/react/src/useEditor.ts +30 -33
- package/node_modules/@tiptap/react/src/useEditorState.spec.ts +121 -0
- package/node_modules/@tiptap/react/src/useEditorState.ts +17 -3
- package/node_modules/@tiptap/react/src/useReactNodeView.ts +12 -2
- package/node_modules/@tiptap/suggestion/dist/index.cjs +657 -361
- package/node_modules/@tiptap/suggestion/dist/index.cjs.map +1 -1
- package/node_modules/@tiptap/suggestion/dist/index.d.cts +395 -189
- package/node_modules/@tiptap/suggestion/dist/index.d.cts.map +1 -0
- package/node_modules/@tiptap/suggestion/dist/index.d.ts +395 -189
- package/node_modules/@tiptap/suggestion/dist/index.d.ts.map +1 -0
- package/node_modules/@tiptap/suggestion/dist/index.js +648 -330
- package/node_modules/@tiptap/suggestion/dist/index.js.map +1 -1
- package/node_modules/@tiptap/suggestion/package.json +25 -21
- package/node_modules/@tiptap/suggestion/src/__tests__/suggestion.test.ts +1123 -2
- package/node_modules/@tiptap/suggestion/src/findSuggestionMatch.ts +8 -1
- package/node_modules/@tiptap/suggestion/src/helpers.ts +129 -0
- package/node_modules/@tiptap/suggestion/src/plugin/async.ts +89 -0
- package/node_modules/@tiptap/suggestion/src/plugin/floating-ui.ts +204 -0
- package/node_modules/@tiptap/suggestion/src/plugin/props.ts +94 -0
- package/node_modules/@tiptap/suggestion/src/plugin/state.ts +182 -0
- package/node_modules/@tiptap/suggestion/src/plugin/view.ts +236 -0
- package/node_modules/@tiptap/suggestion/src/suggestion.ts +101 -535
- package/node_modules/@tiptap/suggestion/src/types.ts +439 -0
- package/node_modules/prosemirror-changeset/CHANGELOG.md +36 -0
- package/node_modules/prosemirror-changeset/README.md +1 -1
- package/node_modules/prosemirror-changeset/dist/index.cjs +35 -24
- package/node_modules/prosemirror-changeset/dist/index.d.cts +2 -1
- package/node_modules/prosemirror-changeset/dist/index.d.ts +2 -1
- package/node_modules/prosemirror-changeset/dist/index.js +23 -8
- package/node_modules/prosemirror-changeset/package.json +2 -2
- package/node_modules/prosemirror-changeset/src/README.md +1 -1
- package/node_modules/prosemirror-changeset/src/diff.ts +21 -8
- package/node_modules/prosemirror-changeset/src/simplify.ts +1 -1
- package/node_modules/prosemirror-changeset/test/test-diff.ts +26 -0
- package/node_modules/prosemirror-changeset/test/test-simplify.ts +3 -0
- package/node_modules/prosemirror-commands/CHANGELOG.md +6 -0
- package/node_modules/prosemirror-commands/CONTRIBUTING.md +19 -19
- package/node_modules/prosemirror-commands/README.md +3 -3
- package/node_modules/prosemirror-commands/dist/index.cjs +23 -22
- package/node_modules/prosemirror-commands/dist/index.js +11 -9
- package/node_modules/prosemirror-commands/package.json +2 -2
- package/node_modules/prosemirror-commands/src/commands.ts +11 -8
- package/node_modules/prosemirror-dropcursor/CHANGELOG.md +12 -0
- package/node_modules/prosemirror-dropcursor/CONTRIBUTING.md +22 -18
- package/node_modules/prosemirror-dropcursor/README.md +3 -3
- package/node_modules/prosemirror-dropcursor/dist/index.cjs +25 -10
- package/node_modules/prosemirror-dropcursor/dist/index.js +30 -13
- package/node_modules/prosemirror-dropcursor/package.json +2 -2
- package/node_modules/prosemirror-dropcursor/src/dropcursor.ts +26 -10
- package/node_modules/prosemirror-history/CHANGELOG.md +12 -0
- package/node_modules/prosemirror-history/CONTRIBUTING.md +19 -19
- package/node_modules/prosemirror-history/README.md +3 -3
- package/node_modules/prosemirror-history/dist/index.cjs +32 -11
- package/node_modules/prosemirror-history/dist/index.js +21 -4
- package/node_modules/prosemirror-history/package.json +2 -2
- package/node_modules/prosemirror-history/src/history.ts +24 -5
- package/node_modules/prosemirror-model/CHANGELOG.md +58 -0
- package/node_modules/prosemirror-model/CONTRIBUTING.md +19 -19
- package/node_modules/prosemirror-model/README.md +3 -3
- package/node_modules/prosemirror-model/dist/index.cjs +117 -110
- package/node_modules/prosemirror-model/dist/index.d.cts +36 -30
- package/node_modules/prosemirror-model/dist/index.d.ts +36 -30
- package/node_modules/prosemirror-model/dist/index.js +67 -56
- package/node_modules/prosemirror-model/package.json +2 -2
- package/node_modules/prosemirror-model/src/diff.ts +10 -5
- package/node_modules/prosemirror-model/src/fragment.ts +1 -1
- package/node_modules/prosemirror-model/src/from_dom.ts +5 -2
- package/node_modules/prosemirror-model/src/mark.ts +0 -1
- package/node_modules/prosemirror-model/src/node.ts +30 -10
- package/node_modules/prosemirror-model/src/replace.ts +8 -16
- package/node_modules/prosemirror-model/src/schema.ts +15 -28
- package/node_modules/prosemirror-model/src/to_dom.ts +24 -20
- package/node_modules/prosemirror-transform/CHANGELOG.md +56 -0
- package/node_modules/prosemirror-transform/CONTRIBUTING.md +19 -19
- package/node_modules/prosemirror-transform/README.md +3 -3
- package/node_modules/prosemirror-transform/dist/index.cjs +288 -176
- package/node_modules/prosemirror-transform/dist/index.d.cts +14 -4
- package/node_modules/prosemirror-transform/dist/index.d.ts +14 -4
- package/node_modules/prosemirror-transform/dist/index.js +156 -55
- package/node_modules/prosemirror-transform/package.json +2 -2
- package/node_modules/prosemirror-transform/src/attr_step.ts +1 -1
- package/node_modules/prosemirror-transform/src/map.ts +11 -6
- package/node_modules/prosemirror-transform/src/mark.ts +4 -21
- package/node_modules/prosemirror-transform/src/mark_step.ts +81 -10
- package/node_modules/prosemirror-transform/src/replace.ts +31 -9
- package/node_modules/prosemirror-transform/src/replace_step.ts +11 -2
- package/node_modules/prosemirror-transform/src/structure.ts +15 -9
- package/node_modules/prosemirror-view/CHANGELOG.md +52 -2
- package/node_modules/prosemirror-view/CONTRIBUTING.md +19 -19
- package/node_modules/prosemirror-view/README.md +3 -3
- package/node_modules/prosemirror-view/dist/index.cjs +287 -183
- package/node_modules/prosemirror-view/dist/index.d.cts +10 -2
- package/node_modules/prosemirror-view/dist/index.d.ts +10 -2
- package/node_modules/prosemirror-view/dist/index.js +180 -93
- package/node_modules/prosemirror-view/package.json +3 -3
- package/node_modules/prosemirror-view/src/clipboard.ts +21 -5
- package/node_modules/prosemirror-view/src/domchange.ts +8 -18
- package/node_modules/prosemirror-view/src/domcoords.ts +4 -1
- package/node_modules/prosemirror-view/src/domobserver.ts +4 -1
- package/node_modules/prosemirror-view/src/index.ts +4 -3
- package/node_modules/prosemirror-view/src/input.ts +96 -41
- package/node_modules/prosemirror-view/src/selection.ts +6 -6
- package/node_modules/prosemirror-view/src/viewdesc.ts +48 -23
- package/node_modules/prosemirror-view/style/prosemirror.css +1 -1
- package/package.json +19 -55
- package/public-api.md +34 -1
- package/dist/McpAppFrame-VEOUJL5E.js +0 -9
- package/dist/PlanGraph-3D5PCSIJ.js.map +0 -1
- package/dist/chat/LiteMessageList.d.ts +0 -93
- package/dist/chunk-3RFYXI6V.js.map +0 -1
- package/dist/chunk-5JAFIDDP.js.map +0 -1
- package/dist/chunk-67JW6ASD.js.map +0 -1
- package/dist/chunk-GZHQQXYI.js.map +0 -1
- package/dist/chunk-J6BSKVVK.js.map +0 -1
- package/dist/chunk-SVCTJ4VS.js.map +0 -1
- package/node_modules/@remirror/core-constants/LICENSE +0 -21
- package/node_modules/@remirror/core-constants/dist/_tsup-dts-rollup.d.cts +0 -612
- package/node_modules/@remirror/core-constants/dist/_tsup-dts-rollup.d.ts +0 -612
- package/node_modules/@remirror/core-constants/dist/remirror-core-constants.cjs +0 -314
- package/node_modules/@remirror/core-constants/dist/remirror-core-constants.d.cts +0 -20
- package/node_modules/@remirror/core-constants/dist/remirror-core-constants.d.ts +0 -20
- package/node_modules/@remirror/core-constants/dist/remirror-core-constants.js +0 -269
- package/node_modules/@remirror/core-constants/dist-types/core-constants.d.ts +0 -431
- package/node_modules/@remirror/core-constants/dist-types/error-constants.d.ts +0 -119
- package/node_modules/@remirror/core-constants/dist-types/index.d.ts +0 -2
- package/node_modules/@remirror/core-constants/dist-types/tsconfig.tsbuildinfo +0 -1
- package/node_modules/@remirror/core-constants/package.json +0 -45
- package/node_modules/@remirror/core-constants/readme.md +0 -17
- package/node_modules/@tiptap/core/src/utilities/markdown/attributeUtils.ts +0 -130
- package/node_modules/@tiptap/pm/collab/index.ts +0 -1
- package/node_modules/@tiptap/pm/dist/collab/index.cjs +0 -2
- package/node_modules/@tiptap/pm/dist/collab/index.d.cts +0 -1
- package/node_modules/@tiptap/pm/dist/collab/index.d.ts +0 -1
- package/node_modules/@tiptap/pm/dist/collab/index.js +0 -2
- package/node_modules/@tiptap/pm/dist/markdown/index.cjs +0 -2
- package/node_modules/@tiptap/pm/dist/markdown/index.d.cts +0 -1
- package/node_modules/@tiptap/pm/dist/markdown/index.d.ts +0 -1
- package/node_modules/@tiptap/pm/dist/markdown/index.js +0 -2
- package/node_modules/@tiptap/pm/dist/menu/index.cjs +0 -2
- package/node_modules/@tiptap/pm/dist/menu/index.d.cts +0 -1
- package/node_modules/@tiptap/pm/dist/menu/index.d.ts +0 -1
- package/node_modules/@tiptap/pm/dist/menu/index.js +0 -2
- package/node_modules/@tiptap/pm/dist/schema-basic/index.cjs +0 -2
- package/node_modules/@tiptap/pm/dist/schema-basic/index.d.cts +0 -1
- package/node_modules/@tiptap/pm/dist/schema-basic/index.d.ts +0 -1
- package/node_modules/@tiptap/pm/dist/schema-basic/index.js +0 -2
- package/node_modules/@tiptap/pm/dist/trailing-node/index.cjs +0 -2
- package/node_modules/@tiptap/pm/dist/trailing-node/index.d.cts +0 -1
- package/node_modules/@tiptap/pm/dist/trailing-node/index.d.ts +0 -1
- package/node_modules/@tiptap/pm/dist/trailing-node/index.js +0 -2
- package/node_modules/@tiptap/pm/markdown/index.ts +0 -1
- package/node_modules/@tiptap/pm/menu/index.ts +0 -1
- package/node_modules/@tiptap/pm/schema-basic/index.ts +0 -1
- package/node_modules/@tiptap/pm/trailing-node/index.ts +0 -1
- package/node_modules/@types/linkify-it/LICENSE +0 -21
- package/node_modules/@types/linkify-it/README.md +0 -15
- package/node_modules/@types/linkify-it/build/index.cjs.d.ts +0 -178
- package/node_modules/@types/linkify-it/index.d.mts +0 -174
- package/node_modules/@types/linkify-it/index.d.ts +0 -3
- package/node_modules/@types/linkify-it/package.json +0 -50
- package/node_modules/@types/markdown-it/LICENSE +0 -21
- package/node_modules/@types/markdown-it/README.md +0 -15
- package/node_modules/@types/markdown-it/dist/index.cjs.d.ts +0 -1236
- package/node_modules/@types/markdown-it/dist/markdown-it.d.ts +0 -5
- package/node_modules/@types/markdown-it/dist/markdown-it.min.d.ts +0 -5
- package/node_modules/@types/markdown-it/index.d.mts +0 -1
- package/node_modules/@types/markdown-it/index.d.ts +0 -3
- package/node_modules/@types/markdown-it/lib/common/html_blocks.d.mts +0 -7
- package/node_modules/@types/markdown-it/lib/common/html_re.d.mts +0 -2
- package/node_modules/@types/markdown-it/lib/common/utils.d.mts +0 -62
- package/node_modules/@types/markdown-it/lib/helpers/index.d.mts +0 -5
- package/node_modules/@types/markdown-it/lib/helpers/parse_link_destination.d.mts +0 -7
- package/node_modules/@types/markdown-it/lib/helpers/parse_link_label.d.mts +0 -3
- package/node_modules/@types/markdown-it/lib/helpers/parse_link_title.d.mts +0 -29
- package/node_modules/@types/markdown-it/lib/index.d.mts +0 -404
- package/node_modules/@types/markdown-it/lib/parser_block.d.mts +0 -25
- package/node_modules/@types/markdown-it/lib/parser_core.d.mts +0 -18
- package/node_modules/@types/markdown-it/lib/parser_inline.d.mts +0 -38
- package/node_modules/@types/markdown-it/lib/renderer.d.mts +0 -96
- package/node_modules/@types/markdown-it/lib/ruler.d.mts +0 -158
- package/node_modules/@types/markdown-it/lib/rules_block/state_block.d.mts +0 -124
- package/node_modules/@types/markdown-it/lib/rules_core/state_core.d.mts +0 -18
- package/node_modules/@types/markdown-it/lib/rules_inline/state_inline.d.mts +0 -73
- package/node_modules/@types/markdown-it/lib/token.d.mts +0 -108
- package/node_modules/@types/markdown-it/package.json +0 -54
- package/node_modules/@types/mdurl/LICENSE +0 -21
- package/node_modules/@types/mdurl/README.md +0 -15
- package/node_modules/@types/mdurl/build/index.cjs.d.ts +0 -52
- package/node_modules/@types/mdurl/index.d.mts +0 -6
- package/node_modules/@types/mdurl/index.d.ts +0 -3
- package/node_modules/@types/mdurl/lib/decode.d.mts +0 -10
- package/node_modules/@types/mdurl/lib/encode.d.mts +0 -15
- package/node_modules/@types/mdurl/lib/format.d.mts +0 -3
- package/node_modules/@types/mdurl/lib/parse.d.mts +0 -18
- package/node_modules/@types/mdurl/package.json +0 -36
- package/node_modules/argparse/LICENSE +0 -254
- package/node_modules/argparse/README.md +0 -84
- package/node_modules/argparse/argparse.js +0 -3707
- package/node_modules/argparse/lib/sub.js +0 -67
- package/node_modules/argparse/lib/textwrap.js +0 -440
- package/node_modules/argparse/package.json +0 -31
- package/node_modules/crelt/LICENSE +0 -19
- package/node_modules/crelt/README.md +0 -23
- package/node_modules/crelt/dist/index.cjs +0 -31
- package/node_modules/crelt/dist/index.d.cts +0 -4
- package/node_modules/crelt/index.d.ts +0 -4
- package/node_modules/crelt/index.js +0 -28
- package/node_modules/crelt/package.json +0 -35
- package/node_modules/crelt/rollup.config.js +0 -13
- package/node_modules/entities/LICENSE +0 -11
- package/node_modules/entities/lib/decode.d.ts +0 -211
- package/node_modules/entities/lib/decode.d.ts.map +0 -1
- package/node_modules/entities/lib/decode.js +0 -536
- package/node_modules/entities/lib/decode.js.map +0 -1
- package/node_modules/entities/lib/decode_codepoint.d.ts +0 -19
- package/node_modules/entities/lib/decode_codepoint.d.ts.map +0 -1
- package/node_modules/entities/lib/decode_codepoint.js +0 -76
- package/node_modules/entities/lib/decode_codepoint.js.map +0 -1
- package/node_modules/entities/lib/encode.d.ts +0 -22
- package/node_modules/entities/lib/encode.d.ts.map +0 -1
- package/node_modules/entities/lib/encode.js +0 -77
- package/node_modules/entities/lib/encode.js.map +0 -1
- package/node_modules/entities/lib/escape.d.ts +0 -43
- package/node_modules/entities/lib/escape.d.ts.map +0 -1
- package/node_modules/entities/lib/escape.js +0 -122
- package/node_modules/entities/lib/escape.js.map +0 -1
- package/node_modules/entities/lib/esm/decode.d.ts +0 -211
- package/node_modules/entities/lib/esm/decode.d.ts.map +0 -1
- package/node_modules/entities/lib/esm/decode.js +0 -496
- package/node_modules/entities/lib/esm/decode.js.map +0 -1
- package/node_modules/entities/lib/esm/decode_codepoint.d.ts +0 -19
- package/node_modules/entities/lib/esm/decode_codepoint.d.ts.map +0 -1
- package/node_modules/entities/lib/esm/decode_codepoint.js +0 -71
- package/node_modules/entities/lib/esm/decode_codepoint.js.map +0 -1
- package/node_modules/entities/lib/esm/encode.d.ts +0 -22
- package/node_modules/entities/lib/esm/encode.d.ts.map +0 -1
- package/node_modules/entities/lib/esm/encode.js +0 -69
- package/node_modules/entities/lib/esm/encode.js.map +0 -1
- package/node_modules/entities/lib/esm/escape.d.ts +0 -43
- package/node_modules/entities/lib/esm/escape.d.ts.map +0 -1
- package/node_modules/entities/lib/esm/escape.js +0 -116
- package/node_modules/entities/lib/esm/escape.js.map +0 -1
- package/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +0 -3
- package/node_modules/entities/lib/esm/generated/decode-data-html.d.ts.map +0 -1
- package/node_modules/entities/lib/esm/generated/decode-data-html.js +0 -7
- package/node_modules/entities/lib/esm/generated/decode-data-html.js.map +0 -1
- package/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +0 -3
- package/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts.map +0 -1
- package/node_modules/entities/lib/esm/generated/decode-data-xml.js +0 -7
- package/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +0 -1
- package/node_modules/entities/lib/esm/generated/encode-html.d.ts +0 -8
- package/node_modules/entities/lib/esm/generated/encode-html.d.ts.map +0 -1
- package/node_modules/entities/lib/esm/generated/encode-html.js +0 -10
- package/node_modules/entities/lib/esm/generated/encode-html.js.map +0 -1
- package/node_modules/entities/lib/esm/index.d.ts +0 -96
- package/node_modules/entities/lib/esm/index.d.ts.map +0 -1
- package/node_modules/entities/lib/esm/index.js +0 -99
- package/node_modules/entities/lib/esm/index.js.map +0 -1
- package/node_modules/entities/lib/esm/package.json +0 -1
- package/node_modules/entities/lib/generated/decode-data-html.d.ts +0 -3
- package/node_modules/entities/lib/generated/decode-data-html.d.ts.map +0 -1
- package/node_modules/entities/lib/generated/decode-data-html.js +0 -9
- package/node_modules/entities/lib/generated/decode-data-html.js.map +0 -1
- package/node_modules/entities/lib/generated/decode-data-xml.d.ts +0 -3
- package/node_modules/entities/lib/generated/decode-data-xml.d.ts.map +0 -1
- package/node_modules/entities/lib/generated/decode-data-xml.js +0 -9
- package/node_modules/entities/lib/generated/decode-data-xml.js.map +0 -1
- package/node_modules/entities/lib/generated/encode-html.d.ts +0 -8
- package/node_modules/entities/lib/generated/encode-html.d.ts.map +0 -1
- package/node_modules/entities/lib/generated/encode-html.js +0 -12
- package/node_modules/entities/lib/generated/encode-html.js.map +0 -1
- package/node_modules/entities/lib/index.d.ts +0 -96
- package/node_modules/entities/lib/index.d.ts.map +0 -1
- package/node_modules/entities/lib/index.js +0 -126
- package/node_modules/entities/lib/index.js.map +0 -1
- package/node_modules/entities/package.json +0 -90
- package/node_modules/entities/readme.md +0 -122
- package/node_modules/escape-string-regexp/index.d.ts +0 -18
- package/node_modules/escape-string-regexp/index.js +0 -13
- package/node_modules/escape-string-regexp/license +0 -9
- package/node_modules/escape-string-regexp/package.json +0 -38
- package/node_modules/escape-string-regexp/readme.md +0 -34
- package/node_modules/linkify-it/LICENSE +0 -22
- package/node_modules/linkify-it/README.md +0 -196
- package/node_modules/linkify-it/build/index.cjs.js +0 -832
- package/node_modules/linkify-it/index.mjs +0 -642
- package/node_modules/linkify-it/lib/re.mjs +0 -189
- package/node_modules/linkify-it/package.json +0 -58
- package/node_modules/markdown-it/LICENSE +0 -22
- package/node_modules/markdown-it/README.md +0 -324
- package/node_modules/markdown-it/bin/markdown-it.mjs +0 -107
- package/node_modules/markdown-it/dist/index.cjs.js +0 -5547
- package/node_modules/markdown-it/dist/markdown-it.js +0 -6969
- package/node_modules/markdown-it/dist/markdown-it.min.js +0 -2
- package/node_modules/markdown-it/index.mjs +0 -1
- package/node_modules/markdown-it/lib/common/html_blocks.mjs +0 -67
- package/node_modules/markdown-it/lib/common/html_re.mjs +0 -25
- package/node_modules/markdown-it/lib/common/utils.mjs +0 -304
- package/node_modules/markdown-it/lib/helpers/index.mjs +0 -11
- package/node_modules/markdown-it/lib/helpers/parse_link_destination.mjs +0 -77
- package/node_modules/markdown-it/lib/helpers/parse_link_label.mjs +0 -49
- package/node_modules/markdown-it/lib/helpers/parse_link_title.mjs +0 -66
- package/node_modules/markdown-it/lib/index.mjs +0 -565
- package/node_modules/markdown-it/lib/parser_block.mjs +0 -134
- package/node_modules/markdown-it/lib/parser_core.mjs +0 -62
- package/node_modules/markdown-it/lib/parser_inline.mjs +0 -197
- package/node_modules/markdown-it/lib/presets/commonmark.mjs +0 -88
- package/node_modules/markdown-it/lib/presets/default.mjs +0 -47
- package/node_modules/markdown-it/lib/presets/zero.mjs +0 -70
- package/node_modules/markdown-it/lib/renderer.mjs +0 -322
- package/node_modules/markdown-it/lib/ruler.mjs +0 -340
- package/node_modules/markdown-it/lib/rules_block/blockquote.mjs +0 -209
- package/node_modules/markdown-it/lib/rules_block/code.mjs +0 -30
- package/node_modules/markdown-it/lib/rules_block/fence.mjs +0 -94
- package/node_modules/markdown-it/lib/rules_block/heading.mjs +0 -51
- package/node_modules/markdown-it/lib/rules_block/hr.mjs +0 -40
- package/node_modules/markdown-it/lib/rules_block/html_block.mjs +0 -69
- package/node_modules/markdown-it/lib/rules_block/lheading.mjs +0 -82
- package/node_modules/markdown-it/lib/rules_block/list.mjs +0 -331
- package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +0 -46
- package/node_modules/markdown-it/lib/rules_block/reference.mjs +0 -212
- package/node_modules/markdown-it/lib/rules_block/state_block.mjs +0 -220
- package/node_modules/markdown-it/lib/rules_block/table.mjs +0 -228
- package/node_modules/markdown-it/lib/rules_core/block.mjs +0 -13
- package/node_modules/markdown-it/lib/rules_core/inline.mjs +0 -11
- package/node_modules/markdown-it/lib/rules_core/linkify.mjs +0 -134
- package/node_modules/markdown-it/lib/rules_core/normalize.mjs +0 -17
- package/node_modules/markdown-it/lib/rules_core/replacements.mjs +0 -101
- package/node_modules/markdown-it/lib/rules_core/smartquotes.mjs +0 -193
- package/node_modules/markdown-it/lib/rules_core/state_core.mjs +0 -17
- package/node_modules/markdown-it/lib/rules_core/text_join.mjs +0 -43
- package/node_modules/markdown-it/lib/rules_inline/autolink.mjs +0 -72
- package/node_modules/markdown-it/lib/rules_inline/backticks.mjs +0 -60
- package/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs +0 -124
- package/node_modules/markdown-it/lib/rules_inline/emphasis.mjs +0 -123
- package/node_modules/markdown-it/lib/rules_inline/entity.mjs +0 -51
- package/node_modules/markdown-it/lib/rules_inline/escape.mjs +0 -69
- package/node_modules/markdown-it/lib/rules_inline/fragments_join.mjs +0 -38
- package/node_modules/markdown-it/lib/rules_inline/html_inline.mjs +0 -50
- package/node_modules/markdown-it/lib/rules_inline/image.mjs +0 -138
- package/node_modules/markdown-it/lib/rules_inline/link.mjs +0 -139
- package/node_modules/markdown-it/lib/rules_inline/linkify.mjs +0 -63
- package/node_modules/markdown-it/lib/rules_inline/newline.mjs +0 -42
- package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +0 -123
- package/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs +0 -127
- package/node_modules/markdown-it/lib/rules_inline/text.mjs +0 -86
- package/node_modules/markdown-it/lib/token.mjs +0 -191
- package/node_modules/markdown-it/package.json +0 -92
- package/node_modules/mdurl/LICENSE +0 -45
- package/node_modules/mdurl/README.md +0 -102
- package/node_modules/mdurl/build/index.cjs.js +0 -534
- package/node_modules/mdurl/index.mjs +0 -11
- package/node_modules/mdurl/lib/decode.mjs +0 -112
- package/node_modules/mdurl/lib/encode.mjs +0 -89
- package/node_modules/mdurl/lib/format.mjs +0 -21
- package/node_modules/mdurl/lib/parse.mjs +0 -308
- package/node_modules/mdurl/package.json +0 -37
- package/node_modules/prosemirror-collab/.tern-project +0 -8
- package/node_modules/prosemirror-collab/CHANGELOG.md +0 -77
- package/node_modules/prosemirror-collab/CONTRIBUTING.md +0 -104
- package/node_modules/prosemirror-collab/LICENSE +0 -19
- package/node_modules/prosemirror-collab/README.md +0 -28
- package/node_modules/prosemirror-collab/dist/index.cjs +0 -155
- package/node_modules/prosemirror-collab/dist/index.d.cts +0 -60
- package/node_modules/prosemirror-collab/dist/index.d.ts +0 -60
- package/node_modules/prosemirror-collab/dist/index.js +0 -156
- package/node_modules/prosemirror-collab/package.json +0 -40
- package/node_modules/prosemirror-collab/src/README.md +0 -11
- package/node_modules/prosemirror-collab/src/collab.ts +0 -184
- package/node_modules/prosemirror-markdown/.tern-project +0 -8
- package/node_modules/prosemirror-markdown/CHANGELOG.md +0 -311
- package/node_modules/prosemirror-markdown/CONTRIBUTING.md +0 -100
- package/node_modules/prosemirror-markdown/LICENSE +0 -19
- package/node_modules/prosemirror-markdown/README.md +0 -276
- package/node_modules/prosemirror-markdown/dist/index.cjs +0 -966
- package/node_modules/prosemirror-markdown/dist/index.d.cts +0 -335
- package/node_modules/prosemirror-markdown/dist/index.d.ts +0 -335
- package/node_modules/prosemirror-markdown/dist/index.js +0 -878
- package/node_modules/prosemirror-markdown/package.json +0 -40
- package/node_modules/prosemirror-markdown/src/README.md +0 -42
- package/node_modules/prosemirror-markdown/src/from_markdown.ts +0 -272
- package/node_modules/prosemirror-markdown/src/index.ts +0 -5
- package/node_modules/prosemirror-markdown/src/schema.ts +0 -156
- package/node_modules/prosemirror-markdown/src/to_markdown.ts +0 -483
- package/node_modules/prosemirror-menu/.tern-project +0 -8
- package/node_modules/prosemirror-menu/CHANGELOG.md +0 -107
- package/node_modules/prosemirror-menu/CONTRIBUTING.md +0 -100
- package/node_modules/prosemirror-menu/LICENSE +0 -19
- package/node_modules/prosemirror-menu/README.md +0 -235
- package/node_modules/prosemirror-menu/dist/index.cjs +0 -798
- package/node_modules/prosemirror-menu/dist/index.d.cts +0 -281
- package/node_modules/prosemirror-menu/dist/index.d.ts +0 -281
- package/node_modules/prosemirror-menu/dist/index.js +0 -795
- package/node_modules/prosemirror-menu/package.json +0 -42
- package/node_modules/prosemirror-menu/src/README.md +0 -60
- package/node_modules/prosemirror-menu/src/icons.ts +0 -53
- package/node_modules/prosemirror-menu/src/index.ts +0 -4
- package/node_modules/prosemirror-menu/src/menu.ts +0 -628
- package/node_modules/prosemirror-menu/src/menubar.ts +0 -210
- package/node_modules/prosemirror-menu/style/menu.css +0 -169
- package/node_modules/prosemirror-schema-basic/.tern-project +0 -8
- package/node_modules/prosemirror-schema-basic/CHANGELOG.md +0 -81
- package/node_modules/prosemirror-schema-basic/CONTRIBUTING.md +0 -100
- package/node_modules/prosemirror-schema-basic/README.md +0 -28
- package/node_modules/prosemirror-schema-basic/dist/index.cjs +0 -246
- package/node_modules/prosemirror-schema-basic/dist/index.d.cts +0 -87
- package/node_modules/prosemirror-schema-basic/dist/index.d.ts +0 -87
- package/node_modules/prosemirror-schema-basic/dist/index.js +0 -183
- package/node_modules/prosemirror-schema-basic/package.json +0 -37
- package/node_modules/prosemirror-schema-basic/src/README.md +0 -8
- package/node_modules/prosemirror-schema-basic/src/schema-basic.ts +0 -166
- package/node_modules/prosemirror-trailing-node/LICENSE +0 -21
- package/node_modules/prosemirror-trailing-node/dist/_tsup-dts-rollup.d.cts +0 -41
- package/node_modules/prosemirror-trailing-node/dist/_tsup-dts-rollup.d.ts +0 -41
- package/node_modules/prosemirror-trailing-node/dist/prosemirror-trailing-node.cjs +0 -70
- package/node_modules/prosemirror-trailing-node/dist/prosemirror-trailing-node.d.cts +0 -2
- package/node_modules/prosemirror-trailing-node/dist/prosemirror-trailing-node.d.ts +0 -2
- package/node_modules/prosemirror-trailing-node/dist/prosemirror-trailing-node.js +0 -43
- package/node_modules/prosemirror-trailing-node/dist-types/index.d.ts +0 -2
- package/node_modules/prosemirror-trailing-node/dist-types/trailing-node-plugin.d.ts +0 -33
- package/node_modules/prosemirror-trailing-node/dist-types/tsconfig.tsbuildinfo +0 -1
- package/node_modules/prosemirror-trailing-node/package.json +0 -57
- package/node_modules/prosemirror-trailing-node/readme.md +0 -55
- package/node_modules/punycode.js/LICENSE-MIT.txt +0 -20
- package/node_modules/punycode.js/README.md +0 -148
- package/node_modules/punycode.js/package.json +0 -58
- package/node_modules/punycode.js/punycode.es6.js +0 -444
- package/node_modules/punycode.js/punycode.js +0 -443
- package/node_modules/uc.micro/LICENSE.txt +0 -20
- package/node_modules/uc.micro/README.md +0 -14
- package/node_modules/uc.micro/build/index.cjs.js +0 -20
- package/node_modules/uc.micro/categories/Cc/regex.mjs +0 -1
- package/node_modules/uc.micro/categories/Cf/regex.mjs +0 -1
- package/node_modules/uc.micro/categories/P/regex.mjs +0 -1
- package/node_modules/uc.micro/categories/S/regex.mjs +0 -1
- package/node_modules/uc.micro/categories/Z/regex.mjs +0 -1
- package/node_modules/uc.micro/index.mjs +0 -8
- package/node_modules/uc.micro/package.json +0 -37
- package/node_modules/uc.micro/properties/Any/regex.mjs +0 -1
- /package/dist/{McpAppCard-ADVDKC2C.js.map → McpAppCard-NJEKKEEN.js.map} +0 -0
- /package/dist/{McpAppFrame-VEOUJL5E.js.map → McpAppFrame-IQK5AOMD.js.map} +0 -0
- /package/dist/{SessionPluginConfigForm-DWVDFK6A.js.map → SessionPluginConfigForm-VXONUDM4.js.map} +0 -0
- /package/dist/{chunk-WEOW475M.js.map → chunk-63G66FWM.js.map} +0 -0
- /package/dist/{chunk-MG4RF573.js.map → chunk-NPDS3EEK.js.map} +0 -0
- /package/dist/{chunk-YBTELD7P.js.map → chunk-XCASYOA6.js.map} +0 -0
- /package/node_modules/@tiptap/pm/{LICENSE.md → LICENSE} +0 -0
|
@@ -1,1131 +1,1238 @@
|
|
|
1
|
-
|
|
2
|
-
import { createContext, useContext, useMemo } from "react";
|
|
3
|
-
|
|
4
|
-
// src/EditorContent.tsx
|
|
5
|
-
import React, { forwardRef } from "react";
|
|
6
|
-
import ReactDOM from "react-dom";
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { createContext, createElement, createRef, forwardRef, memo, useContext, useDebugValue, useEffect, useLayoutEffect, useMemo, useRef, useState, version } from "react";
|
|
3
|
+
import ReactDOM, { flushSync } from "react-dom";
|
|
7
4
|
import { useSyncExternalStore } from "use-sync-external-store/shim/index.js";
|
|
8
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
import { Editor, MarkView, NodeView, createWidgetDecoration, getRenderedAttributes, isNodeViewSelected } from "@tiptap/core";
|
|
7
|
+
import { deepEqual } from "fast-equals";
|
|
8
|
+
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector.js";
|
|
9
|
+
export * from "@tiptap/core";
|
|
10
|
+
//#region src/EditorContent.tsx
|
|
11
|
+
const mergeRefs = (...refs) => {
|
|
12
|
+
return (node) => {
|
|
13
|
+
refs.forEach((ref) => {
|
|
14
|
+
if (typeof ref === "function") ref(node);
|
|
15
|
+
else if (ref) ref.current = node;
|
|
16
|
+
});
|
|
17
|
+
};
|
|
20
18
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return /* @__PURE__ */ jsx(Fragment, { children: Object.values(renderers) });
|
|
19
|
+
/**
|
|
20
|
+
* This component renders all of the editor's node views.
|
|
21
|
+
*/
|
|
22
|
+
const Portals = ({ contentComponent }) => {
|
|
23
|
+
const renderers = useSyncExternalStore(contentComponent.subscribe, contentComponent.getSnapshot, contentComponent.getServerSnapshot);
|
|
24
|
+
return /* @__PURE__ */ jsx(Fragment, { children: Object.values(renderers) });
|
|
28
25
|
};
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
26
|
+
function createContentComponent() {
|
|
27
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
28
|
+
let renderers = {};
|
|
29
|
+
let isNotificationQueued = false;
|
|
30
|
+
const notifySubscribers = () => {
|
|
31
|
+
if (isNotificationQueued || !subscribers.size) return;
|
|
32
|
+
isNotificationQueued = true;
|
|
33
|
+
queueMicrotask(() => {
|
|
34
|
+
isNotificationQueued = false;
|
|
35
|
+
subscribers.forEach((subscriber) => subscriber());
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
/**
|
|
40
|
+
* Subscribe to the editor instance's changes.
|
|
41
|
+
*/
|
|
42
|
+
subscribe(callback) {
|
|
43
|
+
subscribers.add(callback);
|
|
44
|
+
return () => {
|
|
45
|
+
subscribers.delete(callback);
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
getSnapshot() {
|
|
49
|
+
return renderers;
|
|
50
|
+
},
|
|
51
|
+
getServerSnapshot() {
|
|
52
|
+
return renderers;
|
|
53
|
+
},
|
|
54
|
+
/**
|
|
55
|
+
* Adds a new NodeView Renderer to the editor.
|
|
56
|
+
*/
|
|
57
|
+
setRenderer(id, renderer) {
|
|
58
|
+
renderers = {
|
|
59
|
+
...renderers,
|
|
60
|
+
[id]: ReactDOM.createPortal(renderer.reactElement, renderer.element, id)
|
|
61
|
+
};
|
|
62
|
+
notifySubscribers();
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* Removes a NodeView Renderer from the editor.
|
|
66
|
+
*/
|
|
67
|
+
removeRenderer(id) {
|
|
68
|
+
const nextRenderers = { ...renderers };
|
|
69
|
+
delete nextRenderers[id];
|
|
70
|
+
renderers = nextRenderers;
|
|
71
|
+
notifySubscribers();
|
|
72
|
+
}
|
|
73
|
+
};
|
|
68
74
|
}
|
|
69
75
|
var PureEditorContent = class extends React.Component {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
componentWillUnmount() {
|
|
118
|
-
var _a;
|
|
119
|
-
const editor = this.props.editor;
|
|
120
|
-
if (!editor) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
this.initialized = false;
|
|
124
|
-
if (!editor.isDestroyed) {
|
|
125
|
-
editor.view.setProps({
|
|
126
|
-
nodeViews: {}
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
if (this.unsubscribeToContentComponent) {
|
|
130
|
-
this.unsubscribeToContentComponent();
|
|
131
|
-
}
|
|
132
|
-
editor.contentComponent = null;
|
|
133
|
-
try {
|
|
134
|
-
if (!((_a = editor.view.dom) == null ? void 0 : _a.parentNode)) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
const newElement = document.createElement("div");
|
|
138
|
-
newElement.append(...editor.view.dom.parentNode.childNodes);
|
|
139
|
-
editor.setOptions({
|
|
140
|
-
element: newElement
|
|
141
|
-
});
|
|
142
|
-
} catch {
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
render() {
|
|
146
|
-
const { editor, innerRef, ...rest } = this.props;
|
|
147
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
148
|
-
/* @__PURE__ */ jsx("div", { ref: mergeRefs(innerRef, this.editorContentRef), ...rest }),
|
|
149
|
-
(editor == null ? void 0 : editor.contentComponent) && /* @__PURE__ */ jsx(Portals, { contentComponent: editor.contentComponent })
|
|
150
|
-
] });
|
|
151
|
-
}
|
|
76
|
+
constructor(props) {
|
|
77
|
+
super(props);
|
|
78
|
+
this.editorContentRef = React.createRef();
|
|
79
|
+
}
|
|
80
|
+
componentDidMount() {
|
|
81
|
+
this.init();
|
|
82
|
+
}
|
|
83
|
+
componentDidUpdate() {
|
|
84
|
+
this.init();
|
|
85
|
+
}
|
|
86
|
+
init() {
|
|
87
|
+
var _editor$view$dom;
|
|
88
|
+
const editor = this.props.editor;
|
|
89
|
+
if (editor && !editor.isDestroyed && ((_editor$view$dom = editor.view.dom) === null || _editor$view$dom === void 0 ? void 0 : _editor$view$dom.parentNode)) {
|
|
90
|
+
if (editor.contentComponent) return;
|
|
91
|
+
const element = this.editorContentRef.current;
|
|
92
|
+
element.append(...editor.view.dom.parentNode.childNodes);
|
|
93
|
+
editor.setOptions({ element });
|
|
94
|
+
editor.contentComponent = createContentComponent();
|
|
95
|
+
editor.createNodeViews();
|
|
96
|
+
editor.isEditorContentInitialized = true;
|
|
97
|
+
this.forceUpdate();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
componentWillUnmount() {
|
|
101
|
+
const editor = this.props.editor;
|
|
102
|
+
if (!editor) return;
|
|
103
|
+
editor.isEditorContentInitialized = false;
|
|
104
|
+
if (!editor.isDestroyed) editor.view.setProps({ nodeViews: {} });
|
|
105
|
+
editor.contentComponent = null;
|
|
106
|
+
try {
|
|
107
|
+
var _editor$view$dom2;
|
|
108
|
+
if (!((_editor$view$dom2 = editor.view.dom) === null || _editor$view$dom2 === void 0 ? void 0 : _editor$view$dom2.parentNode)) return;
|
|
109
|
+
const newElement = document.createElement("div");
|
|
110
|
+
newElement.append(...editor.view.dom.parentNode.childNodes);
|
|
111
|
+
editor.setOptions({ element: newElement });
|
|
112
|
+
} catch {}
|
|
113
|
+
}
|
|
114
|
+
render() {
|
|
115
|
+
const { editor, innerRef, ...rest } = this.props;
|
|
116
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
117
|
+
ref: mergeRefs(innerRef, this.editorContentRef),
|
|
118
|
+
...rest
|
|
119
|
+
}), (editor === null || editor === void 0 ? void 0 : editor.contentComponent) && /* @__PURE__ */ jsx(Portals, { contentComponent: editor.contentComponent })] });
|
|
120
|
+
}
|
|
152
121
|
};
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
// src/useEditorState.ts
|
|
173
|
-
import { deepEqual } from "fast-equals";
|
|
174
|
-
import { useDebugValue, useEffect, useLayoutEffect, useState } from "react";
|
|
175
|
-
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector.js";
|
|
176
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
122
|
+
const EditorContentWithKey = forwardRef((props, ref) => {
|
|
123
|
+
const key = React.useMemo(() => {
|
|
124
|
+
return Math.floor(Math.random() * 4294967295).toString();
|
|
125
|
+
}, [props.editor]);
|
|
126
|
+
return React.createElement(PureEditorContent, {
|
|
127
|
+
key,
|
|
128
|
+
innerRef: ref,
|
|
129
|
+
...props
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
const EditorContent = React.memo(EditorContentWithKey);
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/useEditorState.ts
|
|
135
|
+
const useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
136
|
+
/**
|
|
137
|
+
* To synchronize the editor instance with the component state,
|
|
138
|
+
* we need to create a separate instance that is not affected by the component re-renders.
|
|
139
|
+
*/
|
|
177
140
|
var EditorStateManager = class {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
141
|
+
constructor(initialEditor) {
|
|
142
|
+
this.transactionNumber = 0;
|
|
143
|
+
this.lastTransactionNumber = 0;
|
|
144
|
+
this.subscribers = /* @__PURE__ */ new Set();
|
|
145
|
+
this.editor = initialEditor;
|
|
146
|
+
this.lastSnapshot = {
|
|
147
|
+
editor: initialEditor,
|
|
148
|
+
transactionNumber: 0
|
|
149
|
+
};
|
|
150
|
+
this.getSnapshot = this.getSnapshot.bind(this);
|
|
151
|
+
this.getServerSnapshot = this.getServerSnapshot.bind(this);
|
|
152
|
+
this.watch = this.watch.bind(this);
|
|
153
|
+
this.subscribe = this.subscribe.bind(this);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get the current editor instance.
|
|
157
|
+
*/
|
|
158
|
+
getSnapshot() {
|
|
159
|
+
if (this.transactionNumber === this.lastTransactionNumber) return this.lastSnapshot;
|
|
160
|
+
this.lastTransactionNumber = this.transactionNumber;
|
|
161
|
+
this.lastSnapshot = {
|
|
162
|
+
editor: this.editor,
|
|
163
|
+
transactionNumber: this.transactionNumber
|
|
164
|
+
};
|
|
165
|
+
return this.lastSnapshot;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Always disable the editor on the server-side.
|
|
169
|
+
*/
|
|
170
|
+
getServerSnapshot() {
|
|
171
|
+
return {
|
|
172
|
+
editor: null,
|
|
173
|
+
transactionNumber: 0
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Subscribe to the editor instance's changes.
|
|
178
|
+
*/
|
|
179
|
+
subscribe(callback) {
|
|
180
|
+
this.subscribers.add(callback);
|
|
181
|
+
return () => {
|
|
182
|
+
this.subscribers.delete(callback);
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Watch the editor instance for changes.
|
|
187
|
+
*/
|
|
188
|
+
watch(nextEditor) {
|
|
189
|
+
this.editor = nextEditor;
|
|
190
|
+
if (this.editor) {
|
|
191
|
+
/**
|
|
192
|
+
* This will force a re-render when the editor state changes.
|
|
193
|
+
* This is to support things like `editor.can().toggleBold()` in components that `useEditor`.
|
|
194
|
+
* This could be more efficient, but it's a good trade-off for now.
|
|
195
|
+
*/
|
|
196
|
+
let lastTransaction;
|
|
197
|
+
const fn = (props) => {
|
|
198
|
+
if ((props === null || props === void 0 ? void 0 : props.transaction) !== void 0 && props.transaction === lastTransaction) return;
|
|
199
|
+
lastTransaction = props === null || props === void 0 ? void 0 : props.transaction;
|
|
200
|
+
this.transactionNumber += 1;
|
|
201
|
+
this.subscribers.forEach((callback) => callback());
|
|
202
|
+
};
|
|
203
|
+
const currentEditor = this.editor;
|
|
204
|
+
currentEditor.on("transaction", fn);
|
|
205
|
+
currentEditor.on("update", fn);
|
|
206
|
+
return () => {
|
|
207
|
+
currentEditor.off("transaction", fn);
|
|
208
|
+
currentEditor.off("update", fn);
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
233
212
|
};
|
|
213
|
+
/**
|
|
214
|
+
* This hook allows you to watch for changes on the editor instance.
|
|
215
|
+
* It will allow you to select a part of the editor state and re-render the component when it changes.
|
|
216
|
+
* @example
|
|
217
|
+
* ```tsx
|
|
218
|
+
* const editor = useEditor({...options})
|
|
219
|
+
* const { currentSelection } = useEditorState({
|
|
220
|
+
* editor,
|
|
221
|
+
* selector: snapshot => ({ currentSelection: snapshot.editor.state.selection }),
|
|
222
|
+
* })
|
|
223
|
+
*/
|
|
234
224
|
function useEditorState(options) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
);
|
|
244
|
-
useIsomorphicLayoutEffect(() => {
|
|
245
|
-
return editorStateManager.watch(options.editor);
|
|
246
|
-
}, [options.editor, editorStateManager]);
|
|
247
|
-
useDebugValue(selectedState);
|
|
248
|
-
return selectedState;
|
|
225
|
+
var _options$equalityFn;
|
|
226
|
+
const [editorStateManager] = useState(() => new EditorStateManager(options.editor));
|
|
227
|
+
const selectedState = useSyncExternalStoreWithSelector(editorStateManager.subscribe, editorStateManager.getSnapshot, editorStateManager.getServerSnapshot, options.selector, (_options$equalityFn = options.equalityFn) !== null && _options$equalityFn !== void 0 ? _options$equalityFn : deepEqual);
|
|
228
|
+
useIsomorphicLayoutEffect(() => {
|
|
229
|
+
return editorStateManager.watch(options.editor);
|
|
230
|
+
}, [options.editor, editorStateManager]);
|
|
231
|
+
useDebugValue(selectedState);
|
|
232
|
+
return selectedState;
|
|
249
233
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
if (this.previousDeps === null) {
|
|
463
|
-
this.previousDeps = deps;
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
466
|
-
const depsAreEqual = this.previousDeps.length === deps.length && this.previousDeps.every((dep, index) => dep === deps[index]);
|
|
467
|
-
if (depsAreEqual) {
|
|
468
|
-
return;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
if (this.editor && !this.editor.isDestroyed) {
|
|
472
|
-
this.editor.destroy();
|
|
473
|
-
}
|
|
474
|
-
this.setEditor(this.createEditor());
|
|
475
|
-
this.previousDeps = deps;
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* Schedule the destruction of the editor instance.
|
|
479
|
-
* This will only destroy the editor if it was not mounted on the next tick.
|
|
480
|
-
* This is to avoid destroying the editor instance when it's actually still mounted.
|
|
481
|
-
*/
|
|
482
|
-
scheduleDestroy() {
|
|
483
|
-
const currentInstanceId = this.instanceId;
|
|
484
|
-
const currentEditor = this.editor;
|
|
485
|
-
this.scheduledDestructionTimeout = setTimeout(() => {
|
|
486
|
-
if (this.isComponentMounted && this.instanceId === currentInstanceId) {
|
|
487
|
-
if (currentEditor) {
|
|
488
|
-
currentEditor.setOptions(this.options.current);
|
|
489
|
-
}
|
|
490
|
-
return;
|
|
491
|
-
}
|
|
492
|
-
if (currentEditor && !currentEditor.isDestroyed) {
|
|
493
|
-
currentEditor.destroy();
|
|
494
|
-
if (this.instanceId === currentInstanceId) {
|
|
495
|
-
this.setEditor(null);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
}, 1);
|
|
499
|
-
}
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/useEditor.ts
|
|
236
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
237
|
+
const isSSR = typeof window === "undefined";
|
|
238
|
+
const isNext = isSSR || Boolean(typeof window !== "undefined" && window.next);
|
|
239
|
+
/**
|
|
240
|
+
* This class handles the creation, destruction, and re-creation of the editor instance.
|
|
241
|
+
*/
|
|
242
|
+
var EditorInstanceManager = class EditorInstanceManager {
|
|
243
|
+
constructor(options) {
|
|
244
|
+
this.editor = null;
|
|
245
|
+
this.subscriptions = /* @__PURE__ */ new Set();
|
|
246
|
+
this.isComponentMounted = false;
|
|
247
|
+
this.previousDeps = null;
|
|
248
|
+
this.instanceId = "";
|
|
249
|
+
this.options = options;
|
|
250
|
+
this.subscriptions = /* @__PURE__ */ new Set();
|
|
251
|
+
this.setEditor(this.getInitialEditor());
|
|
252
|
+
this.scheduleDestroy();
|
|
253
|
+
this.getEditor = this.getEditor.bind(this);
|
|
254
|
+
this.getServerSnapshot = this.getServerSnapshot.bind(this);
|
|
255
|
+
this.subscribe = this.subscribe.bind(this);
|
|
256
|
+
this.refreshEditorInstance = this.refreshEditorInstance.bind(this);
|
|
257
|
+
this.scheduleDestroy = this.scheduleDestroy.bind(this);
|
|
258
|
+
this.onRender = this.onRender.bind(this);
|
|
259
|
+
this.createEditor = this.createEditor.bind(this);
|
|
260
|
+
}
|
|
261
|
+
setEditor(editor) {
|
|
262
|
+
this.editor = editor;
|
|
263
|
+
this.instanceId = Math.random().toString(36).slice(2, 9);
|
|
264
|
+
this.subscriptions.forEach((cb) => cb());
|
|
265
|
+
}
|
|
266
|
+
getInitialEditor() {
|
|
267
|
+
const explicit = this.options.current.immediatelyRender;
|
|
268
|
+
let immediatelyRender = explicit !== null && explicit !== void 0 ? explicit : true;
|
|
269
|
+
if (isSSR) {
|
|
270
|
+
if (immediatelyRender && isDev) console.warn("SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches");
|
|
271
|
+
immediatelyRender = false;
|
|
272
|
+
} else if (isNext && explicit === void 0) {
|
|
273
|
+
immediatelyRender = false;
|
|
274
|
+
if (isDev) console.warn("Next.js detected. `immediatelyRender` defaults to false to avoid hydration mismatches. Pass `immediatelyRender: true` explicitly if you are rendering the editor only on the client.");
|
|
275
|
+
}
|
|
276
|
+
return immediatelyRender ? this.createEditor() : null;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Create a new editor instance. And attach event listeners.
|
|
280
|
+
*/
|
|
281
|
+
createEditor() {
|
|
282
|
+
const optionsToApply = {
|
|
283
|
+
...this.options.current,
|
|
284
|
+
onBeforeCreate: (...args) => {
|
|
285
|
+
var _this$options$current, _this$options$current2;
|
|
286
|
+
return (_this$options$current = (_this$options$current2 = this.options.current).onBeforeCreate) === null || _this$options$current === void 0 ? void 0 : _this$options$current.call(_this$options$current2, ...args);
|
|
287
|
+
},
|
|
288
|
+
onBlur: (...args) => {
|
|
289
|
+
var _this$options$current3, _this$options$current4;
|
|
290
|
+
return (_this$options$current3 = (_this$options$current4 = this.options.current).onBlur) === null || _this$options$current3 === void 0 ? void 0 : _this$options$current3.call(_this$options$current4, ...args);
|
|
291
|
+
},
|
|
292
|
+
onCreate: (...args) => {
|
|
293
|
+
var _this$options$current5, _this$options$current6;
|
|
294
|
+
return (_this$options$current5 = (_this$options$current6 = this.options.current).onCreate) === null || _this$options$current5 === void 0 ? void 0 : _this$options$current5.call(_this$options$current6, ...args);
|
|
295
|
+
},
|
|
296
|
+
onDestroy: (...args) => {
|
|
297
|
+
var _this$options$current7, _this$options$current8;
|
|
298
|
+
return (_this$options$current7 = (_this$options$current8 = this.options.current).onDestroy) === null || _this$options$current7 === void 0 ? void 0 : _this$options$current7.call(_this$options$current8, ...args);
|
|
299
|
+
},
|
|
300
|
+
onFocus: (...args) => {
|
|
301
|
+
var _this$options$current9, _this$options$current10;
|
|
302
|
+
return (_this$options$current9 = (_this$options$current10 = this.options.current).onFocus) === null || _this$options$current9 === void 0 ? void 0 : _this$options$current9.call(_this$options$current10, ...args);
|
|
303
|
+
},
|
|
304
|
+
onSelectionUpdate: (...args) => {
|
|
305
|
+
var _this$options$current11, _this$options$current12;
|
|
306
|
+
return (_this$options$current11 = (_this$options$current12 = this.options.current).onSelectionUpdate) === null || _this$options$current11 === void 0 ? void 0 : _this$options$current11.call(_this$options$current12, ...args);
|
|
307
|
+
},
|
|
308
|
+
onTransaction: (...args) => {
|
|
309
|
+
var _this$options$current13, _this$options$current14;
|
|
310
|
+
return (_this$options$current13 = (_this$options$current14 = this.options.current).onTransaction) === null || _this$options$current13 === void 0 ? void 0 : _this$options$current13.call(_this$options$current14, ...args);
|
|
311
|
+
},
|
|
312
|
+
onUpdate: (...args) => {
|
|
313
|
+
var _this$options$current15, _this$options$current16;
|
|
314
|
+
return (_this$options$current15 = (_this$options$current16 = this.options.current).onUpdate) === null || _this$options$current15 === void 0 ? void 0 : _this$options$current15.call(_this$options$current16, ...args);
|
|
315
|
+
},
|
|
316
|
+
onContentError: (...args) => {
|
|
317
|
+
var _this$options$current17, _this$options$current18;
|
|
318
|
+
return (_this$options$current17 = (_this$options$current18 = this.options.current).onContentError) === null || _this$options$current17 === void 0 ? void 0 : _this$options$current17.call(_this$options$current18, ...args);
|
|
319
|
+
},
|
|
320
|
+
onDrop: (...args) => {
|
|
321
|
+
var _this$options$current19, _this$options$current20;
|
|
322
|
+
return (_this$options$current19 = (_this$options$current20 = this.options.current).onDrop) === null || _this$options$current19 === void 0 ? void 0 : _this$options$current19.call(_this$options$current20, ...args);
|
|
323
|
+
},
|
|
324
|
+
onPaste: (...args) => {
|
|
325
|
+
var _this$options$current21, _this$options$current22;
|
|
326
|
+
return (_this$options$current21 = (_this$options$current22 = this.options.current).onPaste) === null || _this$options$current21 === void 0 ? void 0 : _this$options$current21.call(_this$options$current22, ...args);
|
|
327
|
+
},
|
|
328
|
+
onDelete: (...args) => {
|
|
329
|
+
var _this$options$current23, _this$options$current24;
|
|
330
|
+
return (_this$options$current23 = (_this$options$current24 = this.options.current).onDelete) === null || _this$options$current23 === void 0 ? void 0 : _this$options$current23.call(_this$options$current24, ...args);
|
|
331
|
+
},
|
|
332
|
+
onMount: (...args) => {
|
|
333
|
+
var _this$options$current25, _this$options$current26;
|
|
334
|
+
return (_this$options$current25 = (_this$options$current26 = this.options.current).onMount) === null || _this$options$current25 === void 0 ? void 0 : _this$options$current25.call(_this$options$current26, ...args);
|
|
335
|
+
},
|
|
336
|
+
onUnmount: (...args) => {
|
|
337
|
+
var _this$options$current27, _this$options$current28;
|
|
338
|
+
return (_this$options$current27 = (_this$options$current28 = this.options.current).onUnmount) === null || _this$options$current27 === void 0 ? void 0 : _this$options$current27.call(_this$options$current28, ...args);
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
return new Editor(optionsToApply);
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Get the current editor instance.
|
|
345
|
+
*/
|
|
346
|
+
getEditor() {
|
|
347
|
+
return this.editor;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Always disable the editor on the server-side.
|
|
351
|
+
*/
|
|
352
|
+
getServerSnapshot() {
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Subscribe to the editor instance's changes.
|
|
357
|
+
*/
|
|
358
|
+
subscribe(onStoreChange) {
|
|
359
|
+
this.subscriptions.add(onStoreChange);
|
|
360
|
+
return () => {
|
|
361
|
+
this.subscriptions.delete(onStoreChange);
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
static compareOptions(a, b) {
|
|
365
|
+
return Object.keys(a).every((key) => {
|
|
366
|
+
if ([
|
|
367
|
+
"onCreate",
|
|
368
|
+
"onBeforeCreate",
|
|
369
|
+
"onDestroy",
|
|
370
|
+
"onUpdate",
|
|
371
|
+
"onTransaction",
|
|
372
|
+
"onFocus",
|
|
373
|
+
"onBlur",
|
|
374
|
+
"onSelectionUpdate",
|
|
375
|
+
"onContentError",
|
|
376
|
+
"onDrop",
|
|
377
|
+
"onPaste"
|
|
378
|
+
].includes(key)) return true;
|
|
379
|
+
if (key === "extensions" && a.extensions && b.extensions) {
|
|
380
|
+
if (a.extensions.length !== b.extensions.length) return false;
|
|
381
|
+
return a.extensions.every((extension, index) => {
|
|
382
|
+
var _b$extensions;
|
|
383
|
+
if (extension !== ((_b$extensions = b.extensions) === null || _b$extensions === void 0 ? void 0 : _b$extensions[index])) return false;
|
|
384
|
+
return true;
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
if (a[key] !== b[key]) return false;
|
|
388
|
+
return true;
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* On each render, we will create, update, or destroy the editor instance.
|
|
393
|
+
* @param deps The dependencies to watch for changes
|
|
394
|
+
* @returns A cleanup function
|
|
395
|
+
*/
|
|
396
|
+
onRender(deps) {
|
|
397
|
+
return () => {
|
|
398
|
+
this.isComponentMounted = true;
|
|
399
|
+
clearTimeout(this.scheduledDestructionTimeout);
|
|
400
|
+
if (this.editor && !this.editor.isDestroyed && deps.length === 0) {
|
|
401
|
+
if (!EditorInstanceManager.compareOptions(this.options.current, this.editor.options)) this.editor.setOptions({
|
|
402
|
+
...this.options.current,
|
|
403
|
+
editable: this.editor.isEditable
|
|
404
|
+
});
|
|
405
|
+
} else this.refreshEditorInstance(deps);
|
|
406
|
+
return () => {
|
|
407
|
+
this.isComponentMounted = false;
|
|
408
|
+
this.scheduleDestroy();
|
|
409
|
+
};
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Recreate the editor instance if the dependencies have changed.
|
|
414
|
+
*/
|
|
415
|
+
refreshEditorInstance(deps) {
|
|
416
|
+
if (this.editor && !this.editor.isDestroyed) {
|
|
417
|
+
if (this.previousDeps === null) {
|
|
418
|
+
this.previousDeps = deps;
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
if (this.previousDeps.length === deps.length && this.previousDeps.every((dep, index) => dep === deps[index])) return;
|
|
422
|
+
}
|
|
423
|
+
if (this.editor && !this.editor.isDestroyed) this.editor.destroy();
|
|
424
|
+
this.setEditor(this.createEditor());
|
|
425
|
+
this.previousDeps = deps;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Schedule the destruction of the editor instance.
|
|
429
|
+
* This will only destroy the editor if it was not mounted on the next tick.
|
|
430
|
+
* This is to avoid destroying the editor instance when it's actually still mounted.
|
|
431
|
+
*/
|
|
432
|
+
scheduleDestroy() {
|
|
433
|
+
const currentInstanceId = this.instanceId;
|
|
434
|
+
const currentEditor = this.editor;
|
|
435
|
+
this.scheduledDestructionTimeout = setTimeout(() => {
|
|
436
|
+
if (this.isComponentMounted && this.instanceId === currentInstanceId) {
|
|
437
|
+
if (currentEditor) currentEditor.setOptions(this.options.current);
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
if (currentEditor && !currentEditor.isDestroyed) {
|
|
441
|
+
currentEditor.destroy();
|
|
442
|
+
if (this.instanceId === currentInstanceId) this.setEditor(null);
|
|
443
|
+
}
|
|
444
|
+
}, 1);
|
|
445
|
+
}
|
|
500
446
|
};
|
|
501
447
|
function useEditor(options = {}, deps = []) {
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
}
|
|
518
|
-
if (options.immediatelyRender && transactionNumber === 0) {
|
|
519
|
-
return 0;
|
|
520
|
-
}
|
|
521
|
-
return transactionNumber + 1;
|
|
522
|
-
}
|
|
523
|
-
});
|
|
524
|
-
return editor;
|
|
448
|
+
const mostRecentOptions = useRef(options);
|
|
449
|
+
mostRecentOptions.current = options;
|
|
450
|
+
const [instanceManager] = useState(() => new EditorInstanceManager(mostRecentOptions));
|
|
451
|
+
const editor = useSyncExternalStore(instanceManager.subscribe, instanceManager.getEditor, instanceManager.getServerSnapshot);
|
|
452
|
+
useDebugValue(editor);
|
|
453
|
+
useEffect(instanceManager.onRender(deps));
|
|
454
|
+
useEditorState({
|
|
455
|
+
editor,
|
|
456
|
+
selector: ({ transactionNumber }) => {
|
|
457
|
+
if (options.shouldRerenderOnTransaction === false || options.shouldRerenderOnTransaction === void 0) return null;
|
|
458
|
+
if (options.immediatelyRender && transactionNumber === 0) return 0;
|
|
459
|
+
return transactionNumber + 1;
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
return editor;
|
|
525
463
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region src/Context.tsx
|
|
466
|
+
const EditorContext = createContext({ editor: null });
|
|
467
|
+
const EditorConsumer = EditorContext.Consumer;
|
|
468
|
+
/**
|
|
469
|
+
* A hook to get the current editor instance.
|
|
470
|
+
*/
|
|
471
|
+
const useCurrentEditor = () => useContext(EditorContext);
|
|
472
|
+
/**
|
|
473
|
+
* This is the provider component for the editor.
|
|
474
|
+
* It allows the editor to be accessible across the entire component tree
|
|
475
|
+
* with `useCurrentEditor`.
|
|
476
|
+
*/
|
|
477
|
+
function EditorProvider({ children, slotAfter, slotBefore, editorContainerProps = {}, ...editorOptions }) {
|
|
478
|
+
const editor = useEditor(editorOptions);
|
|
479
|
+
const contextValue = useMemo(() => ({ editor }), [editor]);
|
|
480
|
+
if (!editor) return null;
|
|
481
|
+
return /* @__PURE__ */ jsxs(EditorContext.Provider, {
|
|
482
|
+
value: contextValue,
|
|
483
|
+
children: [
|
|
484
|
+
slotBefore,
|
|
485
|
+
/* @__PURE__ */ jsx(EditorConsumer, { children: ({ editor: currentEditor }) => /* @__PURE__ */ jsx(EditorContent, {
|
|
486
|
+
editor: currentEditor,
|
|
487
|
+
...editorContainerProps
|
|
488
|
+
}) }),
|
|
489
|
+
children,
|
|
490
|
+
slotAfter
|
|
491
|
+
]
|
|
492
|
+
});
|
|
552
493
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
nodeViewContentChildren: void 0,
|
|
560
|
-
nodeViewContentRef: () => {
|
|
561
|
-
}
|
|
494
|
+
//#endregion
|
|
495
|
+
//#region src/useReactNodeView.ts
|
|
496
|
+
const ReactNodeViewContext = createContext({
|
|
497
|
+
onDragStart: () => {},
|
|
498
|
+
nodeViewContentChildren: void 0,
|
|
499
|
+
nodeViewContentRef: () => {}
|
|
562
500
|
});
|
|
563
|
-
|
|
564
|
-
|
|
501
|
+
const ReactNodeViewContentProvider = ({ children, content }) => {
|
|
502
|
+
return createElement(ReactNodeViewContext.Provider, { value: { nodeViewContentChildren: content } }, children);
|
|
565
503
|
};
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
ref: nodeViewContentRef,
|
|
582
|
-
"data-node-view-content": "",
|
|
583
|
-
style: {
|
|
584
|
-
whiteSpace: "pre-wrap",
|
|
585
|
-
...props.style
|
|
586
|
-
},
|
|
587
|
-
children: nodeViewContentChildren
|
|
588
|
-
}
|
|
589
|
-
)
|
|
590
|
-
);
|
|
504
|
+
const useReactNodeView = () => useContext(ReactNodeViewContext);
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region src/NodeViewContent.tsx
|
|
507
|
+
function NodeViewContent({ as: Tag = "div", ...props }) {
|
|
508
|
+
const { nodeViewContentRef, nodeViewContentChildren } = useReactNodeView();
|
|
509
|
+
return /* @__PURE__ */ jsx(Tag, {
|
|
510
|
+
...props,
|
|
511
|
+
ref: nodeViewContentRef,
|
|
512
|
+
"data-node-view-content": "",
|
|
513
|
+
style: {
|
|
514
|
+
whiteSpace: "pre-wrap",
|
|
515
|
+
...props.style
|
|
516
|
+
},
|
|
517
|
+
children: nodeViewContentChildren
|
|
518
|
+
});
|
|
591
519
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
onDragStart,
|
|
608
|
-
style: {
|
|
609
|
-
whiteSpace: "normal",
|
|
610
|
-
...props.style
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
)
|
|
614
|
-
);
|
|
520
|
+
//#endregion
|
|
521
|
+
//#region src/NodeViewWrapper.tsx
|
|
522
|
+
const NodeViewWrapper = React.forwardRef((props, ref) => {
|
|
523
|
+
const { onDragStart } = useReactNodeView();
|
|
524
|
+
const Tag = props.as || "div";
|
|
525
|
+
return /* @__PURE__ */ jsx(Tag, {
|
|
526
|
+
...props,
|
|
527
|
+
ref,
|
|
528
|
+
"data-node-view-wrapper": "",
|
|
529
|
+
onDragStart,
|
|
530
|
+
style: {
|
|
531
|
+
whiteSpace: "normal",
|
|
532
|
+
...props.style
|
|
533
|
+
}
|
|
534
|
+
});
|
|
615
535
|
});
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
import { flushSync } from "react-dom";
|
|
624
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
536
|
+
//#endregion
|
|
537
|
+
//#region src/ReactRenderer.tsx
|
|
538
|
+
/**
|
|
539
|
+
* Check if a component is a class component.
|
|
540
|
+
* @param Component
|
|
541
|
+
* @returns {boolean}
|
|
542
|
+
*/
|
|
625
543
|
function isClassComponent(Component) {
|
|
626
|
-
|
|
544
|
+
return !!(typeof Component === "function" && Component.prototype && Component.prototype.isReactComponent);
|
|
627
545
|
}
|
|
546
|
+
/**
|
|
547
|
+
* Check if a component is a forward ref component.
|
|
548
|
+
* @param Component
|
|
549
|
+
* @returns {boolean}
|
|
550
|
+
*/
|
|
628
551
|
function isForwardRefComponent(Component) {
|
|
629
|
-
|
|
552
|
+
return !!(typeof Component === "object" && Component.$$typeof && (Component.$$typeof.toString() === "Symbol(react.forward_ref)" || Component.$$typeof.description === "react.forward_ref"));
|
|
630
553
|
}
|
|
554
|
+
/**
|
|
555
|
+
* Check if a component is a memoized component.
|
|
556
|
+
* @param Component
|
|
557
|
+
* @returns {boolean}
|
|
558
|
+
*/
|
|
631
559
|
function isMemoComponent(Component) {
|
|
632
|
-
|
|
560
|
+
return !!(typeof Component === "object" && Component.$$typeof && (Component.$$typeof.toString() === "Symbol(react.memo)" || Component.$$typeof.description === "react.memo"));
|
|
633
561
|
}
|
|
562
|
+
/**
|
|
563
|
+
* Check if a component can safely receive a ref prop.
|
|
564
|
+
* This includes class components, forwardRef components, and memoized components
|
|
565
|
+
* that wrap forwardRef or class components.
|
|
566
|
+
* @param Component
|
|
567
|
+
* @returns {boolean}
|
|
568
|
+
*/
|
|
634
569
|
function canReceiveRef(Component) {
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
const wrappedComponent = Component.type;
|
|
643
|
-
if (wrappedComponent) {
|
|
644
|
-
return isClassComponent(wrappedComponent) || isForwardRefComponent(wrappedComponent);
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
return false;
|
|
570
|
+
if (isClassComponent(Component)) return true;
|
|
571
|
+
if (isForwardRefComponent(Component)) return true;
|
|
572
|
+
if (isMemoComponent(Component)) {
|
|
573
|
+
const wrappedComponent = Component.type;
|
|
574
|
+
if (wrappedComponent) return isClassComponent(wrappedComponent) || isForwardRefComponent(wrappedComponent);
|
|
575
|
+
}
|
|
576
|
+
return false;
|
|
648
577
|
}
|
|
578
|
+
/**
|
|
579
|
+
* Check if we're running React 19+ by detecting if function components support ref props
|
|
580
|
+
* @returns {boolean}
|
|
581
|
+
*/
|
|
649
582
|
function isReact19Plus() {
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
}
|
|
655
|
-
} catch {
|
|
656
|
-
}
|
|
657
|
-
return false;
|
|
583
|
+
try {
|
|
584
|
+
if (version) return parseInt(version.split(".")[0], 10) >= 19;
|
|
585
|
+
} catch {}
|
|
586
|
+
return false;
|
|
658
587
|
}
|
|
588
|
+
/**
|
|
589
|
+
* The ReactRenderer class. It's responsible for rendering React components inside the editor.
|
|
590
|
+
* @example
|
|
591
|
+
* new ReactRenderer(MyComponent, {
|
|
592
|
+
* editor,
|
|
593
|
+
* props: {
|
|
594
|
+
* foo: 'bar',
|
|
595
|
+
* },
|
|
596
|
+
* as: 'span',
|
|
597
|
+
* })
|
|
598
|
+
*/
|
|
659
599
|
var ReactRenderer = class {
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
}
|
|
744
|
-
/**
|
|
745
|
-
* Update the attributes of the element that holds the React component.
|
|
746
|
-
*/
|
|
747
|
-
updateAttributes(attributes) {
|
|
748
|
-
Object.keys(attributes).forEach((key) => {
|
|
749
|
-
this.element.setAttribute(key, attributes[key]);
|
|
750
|
-
});
|
|
751
|
-
}
|
|
600
|
+
/**
|
|
601
|
+
* Immediately creates element and renders the provided React component.
|
|
602
|
+
*/
|
|
603
|
+
constructor(component, { editor, props = {}, as = "div", className = "" }) {
|
|
604
|
+
this.ref = null;
|
|
605
|
+
this.destroyed = false;
|
|
606
|
+
this.id = Math.floor(Math.random() * 4294967295).toString();
|
|
607
|
+
this.component = component;
|
|
608
|
+
this.editor = editor;
|
|
609
|
+
this.props = props;
|
|
610
|
+
this.element = document.createElement(as);
|
|
611
|
+
this.element.classList.add("react-renderer");
|
|
612
|
+
if (className) this.element.classList.add(...className.split(" "));
|
|
613
|
+
if (this.editor.isEditorContentInitialized) flushSync(() => {
|
|
614
|
+
this.render();
|
|
615
|
+
});
|
|
616
|
+
else queueMicrotask(() => {
|
|
617
|
+
if (this.destroyed) return;
|
|
618
|
+
this.render();
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Render the React component.
|
|
623
|
+
*/
|
|
624
|
+
render() {
|
|
625
|
+
var _editor$contentCompon;
|
|
626
|
+
if (this.destroyed) return;
|
|
627
|
+
const Component = this.component;
|
|
628
|
+
const props = this.props;
|
|
629
|
+
const editor = this.editor;
|
|
630
|
+
const isReact19 = isReact19Plus();
|
|
631
|
+
const componentCanReceiveRef = canReceiveRef(Component);
|
|
632
|
+
const elementProps = { ...props };
|
|
633
|
+
if (elementProps.ref && !(isReact19 || componentCanReceiveRef)) delete elementProps.ref;
|
|
634
|
+
if (!elementProps.ref && (isReact19 || componentCanReceiveRef)) elementProps.ref = (ref) => {
|
|
635
|
+
this.ref = ref;
|
|
636
|
+
};
|
|
637
|
+
this.reactElement = /* @__PURE__ */ jsx(Component, { ...elementProps });
|
|
638
|
+
editor === null || editor === void 0 || (_editor$contentCompon = editor.contentComponent) === null || _editor$contentCompon === void 0 || _editor$contentCompon.setRenderer(this.id, this);
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Re-renders the React component with new props.
|
|
642
|
+
* Skips the render if none of the supplied props actually changed,
|
|
643
|
+
* to avoid unnecessary portal re-creation.
|
|
644
|
+
*/
|
|
645
|
+
updateProps(props = {}) {
|
|
646
|
+
if (this.destroyed) return;
|
|
647
|
+
let changed = false;
|
|
648
|
+
const keys = Object.keys(props);
|
|
649
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
650
|
+
const key = keys[i];
|
|
651
|
+
if (props[key] !== this.props[key]) {
|
|
652
|
+
changed = true;
|
|
653
|
+
break;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
if (!changed) return;
|
|
657
|
+
this.props = {
|
|
658
|
+
...this.props,
|
|
659
|
+
...props
|
|
660
|
+
};
|
|
661
|
+
this.render();
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Destroy the React component.
|
|
665
|
+
*/
|
|
666
|
+
destroy() {
|
|
667
|
+
var _editor$contentCompon2;
|
|
668
|
+
this.destroyed = true;
|
|
669
|
+
const editor = this.editor;
|
|
670
|
+
editor === null || editor === void 0 || (_editor$contentCompon2 = editor.contentComponent) === null || _editor$contentCompon2 === void 0 || _editor$contentCompon2.removeRenderer(this.id);
|
|
671
|
+
try {
|
|
672
|
+
if (this.element && this.element.parentNode) this.element.parentNode.removeChild(this.element);
|
|
673
|
+
} catch {}
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* Update the attributes of the element that holds the React component.
|
|
677
|
+
*/
|
|
678
|
+
updateAttributes(attributes) {
|
|
679
|
+
Object.keys(attributes).forEach((key) => {
|
|
680
|
+
this.element.setAttribute(key, attributes[key]);
|
|
681
|
+
});
|
|
682
|
+
}
|
|
752
683
|
};
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
// @ts-ignore
|
|
765
|
-
/* @__PURE__ */ jsx6(Tag, { ...rest, ref: markViewContentRef, "data-mark-view-content": "" })
|
|
766
|
-
);
|
|
684
|
+
//#endregion
|
|
685
|
+
//#region src/ReactMarkViewRenderer.tsx
|
|
686
|
+
const ReactMarkViewContext = React.createContext({ markViewContentRef: () => {} });
|
|
687
|
+
const MarkViewContent = (props) => {
|
|
688
|
+
const { as: Tag = "span", ...rest } = props;
|
|
689
|
+
const { markViewContentRef } = React.useContext(ReactMarkViewContext);
|
|
690
|
+
return /* @__PURE__ */ jsx(Tag, {
|
|
691
|
+
...rest,
|
|
692
|
+
ref: markViewContentRef,
|
|
693
|
+
"data-mark-view-content": ""
|
|
694
|
+
});
|
|
767
695
|
};
|
|
768
696
|
var ReactMarkView = class extends MarkView {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
697
|
+
constructor(component, props, options) {
|
|
698
|
+
super(component, props, options);
|
|
699
|
+
const { as = "span", attrs, className = "" } = options || {};
|
|
700
|
+
const componentProps = {
|
|
701
|
+
...props,
|
|
702
|
+
updateAttributes: this.updateAttributes.bind(this)
|
|
703
|
+
};
|
|
704
|
+
this.contentDOMElement = document.createElement("span");
|
|
705
|
+
const markViewContentRef = (el) => {
|
|
706
|
+
if (el && !el.contains(this.contentDOMElement)) el.appendChild(this.contentDOMElement);
|
|
707
|
+
};
|
|
708
|
+
const context = { markViewContentRef };
|
|
709
|
+
const ReactMarkViewProvider = React.memo((componentProps) => {
|
|
710
|
+
return /* @__PURE__ */ jsx(ReactMarkViewContext.Provider, {
|
|
711
|
+
value: context,
|
|
712
|
+
children: React.createElement(component, componentProps)
|
|
713
|
+
});
|
|
714
|
+
});
|
|
715
|
+
ReactMarkViewProvider.displayName = "ReactMarkView";
|
|
716
|
+
this.renderer = new ReactRenderer(ReactMarkViewProvider, {
|
|
717
|
+
editor: props.editor,
|
|
718
|
+
props: componentProps,
|
|
719
|
+
as,
|
|
720
|
+
className: `mark-${props.mark.type.name} ${className}`.trim()
|
|
721
|
+
});
|
|
722
|
+
if (attrs) this.renderer.updateAttributes(attrs);
|
|
723
|
+
}
|
|
724
|
+
get dom() {
|
|
725
|
+
return this.renderer.element;
|
|
726
|
+
}
|
|
727
|
+
get contentDOM() {
|
|
728
|
+
return this.contentDOMElement;
|
|
729
|
+
}
|
|
802
730
|
};
|
|
803
731
|
function ReactMarkViewRenderer(component, options = {}) {
|
|
804
|
-
|
|
732
|
+
return (props) => new ReactMarkView(component, props, options);
|
|
805
733
|
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
734
|
+
//#endregion
|
|
735
|
+
//#region src/captureDOMSelection.ts
|
|
736
|
+
/**
|
|
737
|
+
* Saves the DOM selection inside `element`, returns a function to put it back.
|
|
738
|
+
* Browsers drop the selection when an element moves, so restore it after the move.
|
|
739
|
+
*/
|
|
740
|
+
function captureDOMSelection(element) {
|
|
741
|
+
var _element$ownerDocumen;
|
|
742
|
+
const root = element.getRootNode();
|
|
743
|
+
const selection = typeof root.getSelection === "function" ? root.getSelection() : (_element$ownerDocumen = element.ownerDocument) === null || _element$ownerDocumen === void 0 || (_element$ownerDocumen = _element$ownerDocumen.defaultView) === null || _element$ownerDocumen === void 0 ? void 0 : _element$ownerDocumen.getSelection();
|
|
744
|
+
if (!selection || selection.rangeCount === 0) return null;
|
|
745
|
+
const { anchorNode, anchorOffset, focusNode, focusOffset } = selection;
|
|
746
|
+
if (!anchorNode || !focusNode) return null;
|
|
747
|
+
if (!element.contains(anchorNode) || !element.contains(focusNode)) return null;
|
|
748
|
+
return () => {
|
|
749
|
+
try {
|
|
750
|
+
selection.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
|
|
751
|
+
} catch {}
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
//#endregion
|
|
755
|
+
//#region src/ReactNodeViewRenderer.tsx
|
|
811
756
|
var ReactNodeView = class extends NodeView {
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
757
|
+
constructor(component, props, options) {
|
|
758
|
+
super(component, props, options);
|
|
759
|
+
this.selectionRafId = null;
|
|
760
|
+
this.handlePositionUpdate = () => {
|
|
761
|
+
const newPos = this.getPos();
|
|
762
|
+
if (typeof newPos !== "number" || newPos === this.currentPos) return;
|
|
763
|
+
this.currentPos = newPos;
|
|
764
|
+
this.renderer.updateProps({ getPos: () => this.getPos() });
|
|
765
|
+
if (typeof this.options.attrs === "function") this.updateElementAttributes();
|
|
766
|
+
};
|
|
767
|
+
this.cachedExtensionWithSyncedStorage = null;
|
|
768
|
+
if (!this.node.isLeaf) {
|
|
769
|
+
if (this.options.contentDOMElementTag) this.contentDOMElement = document.createElement(this.options.contentDOMElementTag);
|
|
770
|
+
else this.contentDOMElement = document.createElement(this.node.isInline ? "span" : "div");
|
|
771
|
+
this.contentDOMElement.dataset.nodeViewContentReact = "";
|
|
772
|
+
this.contentDOMElement.dataset.nodeViewWrapper = "";
|
|
773
|
+
this.contentDOMElement.style.whiteSpace = "inherit";
|
|
774
|
+
const contentTarget = this.dom.querySelector("[data-node-view-content]");
|
|
775
|
+
if (contentTarget) contentTarget.appendChild(this.contentDOMElement);
|
|
776
|
+
else this.dom.appendChild(this.contentDOMElement);
|
|
777
|
+
}
|
|
778
|
+
if (this.options.trackNodeViewPosition) this.editor.on("update", this.handlePositionUpdate);
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Returns a proxy of the extension that redirects storage access to the editor's mutable storage.
|
|
782
|
+
* This preserves the original prototype chain (instanceof checks, methods like configure/extend work).
|
|
783
|
+
* Cached to avoid proxy creation on every update.
|
|
784
|
+
*/
|
|
785
|
+
get extensionWithSyncedStorage() {
|
|
786
|
+
if (!this.cachedExtensionWithSyncedStorage) {
|
|
787
|
+
const editor = this.editor;
|
|
788
|
+
const extension = this.extension;
|
|
789
|
+
this.cachedExtensionWithSyncedStorage = new Proxy(extension, { get(target, prop, receiver) {
|
|
790
|
+
if (prop === "storage") {
|
|
791
|
+
var _editor$storage;
|
|
792
|
+
return (_editor$storage = editor.storage[extension.name]) !== null && _editor$storage !== void 0 ? _editor$storage : {};
|
|
793
|
+
}
|
|
794
|
+
return Reflect.get(target, prop, receiver);
|
|
795
|
+
} });
|
|
796
|
+
}
|
|
797
|
+
return this.cachedExtensionWithSyncedStorage;
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Setup the React component.
|
|
801
|
+
* Called on initialization.
|
|
802
|
+
*/
|
|
803
|
+
mount() {
|
|
804
|
+
const mountProps = {
|
|
805
|
+
editor: this.editor,
|
|
806
|
+
node: this.node,
|
|
807
|
+
decorations: this.decorations,
|
|
808
|
+
innerDecorations: this.innerDecorations,
|
|
809
|
+
view: this.view,
|
|
810
|
+
selected: false,
|
|
811
|
+
extension: this.extensionWithSyncedStorage,
|
|
812
|
+
HTMLAttributes: this.HTMLAttributes,
|
|
813
|
+
getPos: () => this.getPos(),
|
|
814
|
+
updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
|
|
815
|
+
deleteNode: () => this.deleteNode(),
|
|
816
|
+
ref: createRef()
|
|
817
|
+
};
|
|
818
|
+
if (!this.component.displayName) {
|
|
819
|
+
const capitalizeFirstChar = (string) => {
|
|
820
|
+
return string.charAt(0).toUpperCase() + string.substring(1);
|
|
821
|
+
};
|
|
822
|
+
this.component.displayName = capitalizeFirstChar(this.extension.name);
|
|
823
|
+
}
|
|
824
|
+
const onDragStart = this.onDragStart.bind(this);
|
|
825
|
+
const nodeViewContentRef = (element) => {
|
|
826
|
+
if (element && this.contentDOMElement && element.firstChild !== this.contentDOMElement) {
|
|
827
|
+
if (element.hasAttribute("data-node-view-wrapper")) element.removeAttribute("data-node-view-wrapper");
|
|
828
|
+
const restoreSelection = captureDOMSelection(this.contentDOMElement);
|
|
829
|
+
element.appendChild(this.contentDOMElement);
|
|
830
|
+
restoreSelection === null || restoreSelection === void 0 || restoreSelection();
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
const context = {
|
|
834
|
+
onDragStart,
|
|
835
|
+
nodeViewContentRef
|
|
836
|
+
};
|
|
837
|
+
const Component = this.component;
|
|
838
|
+
const ReactNodeViewProvider = memo((componentProps) => {
|
|
839
|
+
return /* @__PURE__ */ jsx(ReactNodeViewContext.Provider, {
|
|
840
|
+
value: context,
|
|
841
|
+
children: createElement(Component, componentProps)
|
|
842
|
+
});
|
|
843
|
+
});
|
|
844
|
+
ReactNodeViewProvider.displayName = "ReactNodeView";
|
|
845
|
+
let as = this.node.isInline ? "span" : "div";
|
|
846
|
+
if (this.options.as) as = this.options.as;
|
|
847
|
+
const { className = "" } = this.options;
|
|
848
|
+
this.handleSelectionUpdate = this.handleSelectionUpdate.bind(this);
|
|
849
|
+
this.renderer = new ReactRenderer(ReactNodeViewProvider, {
|
|
850
|
+
editor: this.editor,
|
|
851
|
+
props: mountProps,
|
|
852
|
+
as,
|
|
853
|
+
className: `node-${this.node.type.name} ${className}`.trim()
|
|
854
|
+
});
|
|
855
|
+
this.editor.on("selectionUpdate", this.handleSelectionUpdate);
|
|
856
|
+
this.updateElementAttributes();
|
|
857
|
+
this.currentPos = this.getPos();
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Return the DOM element.
|
|
861
|
+
* This is the element that will be used to display the node view.
|
|
862
|
+
*/
|
|
863
|
+
get dom() {
|
|
864
|
+
var _this$renderer$elemen;
|
|
865
|
+
if (this.renderer.element.firstElementChild && !((_this$renderer$elemen = this.renderer.element.firstElementChild) === null || _this$renderer$elemen === void 0 ? void 0 : _this$renderer$elemen.hasAttribute("data-node-view-wrapper"))) throw Error("Please use the NodeViewWrapper component for your node view.");
|
|
866
|
+
return this.renderer.element;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Return the content DOM element.
|
|
870
|
+
* This is the element that will be used to display the rich-text content of the node.
|
|
871
|
+
*/
|
|
872
|
+
get contentDOM() {
|
|
873
|
+
if (this.node.isLeaf) return null;
|
|
874
|
+
return this.contentDOMElement;
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* On editor selection update, check if the node is selected.
|
|
878
|
+
* If it is, call `selectNode`, otherwise call `deselectNode`.
|
|
879
|
+
*/
|
|
880
|
+
handleSelectionUpdate() {
|
|
881
|
+
if (this.selectionRafId) {
|
|
882
|
+
cancelAnimationFrame(this.selectionRafId);
|
|
883
|
+
this.selectionRafId = null;
|
|
884
|
+
}
|
|
885
|
+
this.selectionRafId = requestAnimationFrame(() => {
|
|
886
|
+
var _this$getPos;
|
|
887
|
+
this.selectionRafId = null;
|
|
888
|
+
const pos = (_this$getPos = this.getPos()) !== null && _this$getPos !== void 0 ? _this$getPos : this.currentPos;
|
|
889
|
+
if (typeof pos !== "number") return;
|
|
890
|
+
if (isNodeViewSelected({
|
|
891
|
+
selection: this.editor.state.selection,
|
|
892
|
+
pos,
|
|
893
|
+
nodeSize: this.node.nodeSize,
|
|
894
|
+
selectedOnTextSelection: this.options.selectedOnTextSelection
|
|
895
|
+
})) {
|
|
896
|
+
if (this.renderer.props.selected) return;
|
|
897
|
+
this.selectNode();
|
|
898
|
+
} else {
|
|
899
|
+
if (!this.renderer.props.selected) return;
|
|
900
|
+
this.deselectNode();
|
|
901
|
+
}
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* On update, update the React component.
|
|
906
|
+
* To prevent unnecessary updates, the `update` option can be used.
|
|
907
|
+
*/
|
|
908
|
+
update(node, decorations, innerDecorations) {
|
|
909
|
+
const rerenderComponent = (props) => {
|
|
910
|
+
this.renderer.updateProps(props);
|
|
911
|
+
if (typeof this.options.attrs === "function") this.updateElementAttributes();
|
|
912
|
+
};
|
|
913
|
+
if (node.type !== this.node.type) return false;
|
|
914
|
+
if (typeof this.options.update === "function") {
|
|
915
|
+
const oldNode = this.node;
|
|
916
|
+
const oldDecorations = this.decorations;
|
|
917
|
+
const oldInnerDecorations = this.innerDecorations;
|
|
918
|
+
this.node = node;
|
|
919
|
+
this.decorations = decorations;
|
|
920
|
+
this.innerDecorations = innerDecorations;
|
|
921
|
+
this.currentPos = this.getPos();
|
|
922
|
+
return this.options.update({
|
|
923
|
+
oldNode,
|
|
924
|
+
oldDecorations,
|
|
925
|
+
newNode: node,
|
|
926
|
+
newDecorations: decorations,
|
|
927
|
+
oldInnerDecorations,
|
|
928
|
+
innerDecorations,
|
|
929
|
+
updateProps: () => rerenderComponent({
|
|
930
|
+
node,
|
|
931
|
+
decorations,
|
|
932
|
+
innerDecorations,
|
|
933
|
+
extension: this.extensionWithSyncedStorage
|
|
934
|
+
})
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
if (!(node !== this.node)) {
|
|
938
|
+
this.node = node;
|
|
939
|
+
this.decorations = decorations;
|
|
940
|
+
this.innerDecorations = innerDecorations;
|
|
941
|
+
return true;
|
|
942
|
+
}
|
|
943
|
+
const newPos = this.getPos();
|
|
944
|
+
this.node = node;
|
|
945
|
+
this.decorations = decorations;
|
|
946
|
+
this.innerDecorations = innerDecorations;
|
|
947
|
+
this.currentPos = newPos;
|
|
948
|
+
const extraProps = {
|
|
949
|
+
node,
|
|
950
|
+
decorations,
|
|
951
|
+
innerDecorations,
|
|
952
|
+
extension: this.extensionWithSyncedStorage
|
|
953
|
+
};
|
|
954
|
+
if (this.options.trackNodeViewPosition) extraProps.getPos = () => this.getPos();
|
|
955
|
+
rerenderComponent(extraProps);
|
|
956
|
+
return true;
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Select the node.
|
|
960
|
+
* Add the `selected` prop and the `ProseMirror-selectednode` class.
|
|
961
|
+
*/
|
|
962
|
+
selectNode() {
|
|
963
|
+
this.renderer.updateProps({ selected: true });
|
|
964
|
+
this.renderer.element.classList.add("ProseMirror-selectednode");
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Deselect the node.
|
|
968
|
+
* Remove the `selected` prop and the `ProseMirror-selectednode` class.
|
|
969
|
+
*/
|
|
970
|
+
deselectNode() {
|
|
971
|
+
this.renderer.updateProps({ selected: false });
|
|
972
|
+
this.renderer.element.classList.remove("ProseMirror-selectednode");
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* Destroy the React component instance.
|
|
976
|
+
*/
|
|
977
|
+
destroy() {
|
|
978
|
+
this.renderer.destroy();
|
|
979
|
+
this.editor.off("selectionUpdate", this.handleSelectionUpdate);
|
|
980
|
+
if (this.options.trackNodeViewPosition) this.editor.off("update", this.handlePositionUpdate);
|
|
981
|
+
this.contentDOMElement = null;
|
|
982
|
+
if (this.selectionRafId) {
|
|
983
|
+
cancelAnimationFrame(this.selectionRafId);
|
|
984
|
+
this.selectionRafId = null;
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* Update the attributes of the top-level element that holds the React component.
|
|
989
|
+
* Applying the attributes defined in the `attrs` option.
|
|
990
|
+
*/
|
|
991
|
+
updateElementAttributes() {
|
|
992
|
+
if (this.options.attrs) {
|
|
993
|
+
let attrsObj = {};
|
|
994
|
+
if (typeof this.options.attrs === "function") {
|
|
995
|
+
const extensionAttributes = this.editor.extensionManager.attributes;
|
|
996
|
+
const HTMLAttributes = getRenderedAttributes(this.node, extensionAttributes);
|
|
997
|
+
attrsObj = this.options.attrs({
|
|
998
|
+
node: this.node,
|
|
999
|
+
HTMLAttributes
|
|
1000
|
+
});
|
|
1001
|
+
} else attrsObj = this.options.attrs;
|
|
1002
|
+
this.renderer.updateAttributes(attrsObj);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1050
1005
|
};
|
|
1006
|
+
/**
|
|
1007
|
+
* Create a React node view renderer.
|
|
1008
|
+
*/
|
|
1051
1009
|
function ReactNodeViewRenderer(component, options) {
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1010
|
+
return (props) => {
|
|
1011
|
+
if (!props.editor.contentComponent) return {
|
|
1012
|
+
dom: document.createElement("span"),
|
|
1013
|
+
contentDOM: null,
|
|
1014
|
+
update: () => false,
|
|
1015
|
+
destroy: () => {},
|
|
1016
|
+
selectNode: () => {},
|
|
1017
|
+
deselectNode: () => {},
|
|
1018
|
+
stopEvent: () => false,
|
|
1019
|
+
ignoreMutation: () => true
|
|
1020
|
+
};
|
|
1021
|
+
return new ReactNodeView(component, props, options);
|
|
1022
|
+
};
|
|
1058
1023
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1024
|
+
//#endregion
|
|
1025
|
+
//#region src/ReactWidgetRenderer.tsx
|
|
1026
|
+
const WIDGET_CACHE = Symbol("tiptapReactWidgetCache");
|
|
1027
|
+
/**
|
|
1028
|
+
* Renders a React component into a ProseMirror widget decoration.
|
|
1029
|
+
* Reuses Tiptap's `ReactRenderer` so the component lives in the editor's
|
|
1030
|
+
* React tree (context and hooks work as usual). Use a stable `key` for
|
|
1031
|
+
* stateful widgets.
|
|
1032
|
+
* @example
|
|
1033
|
+
* addDecorations() {
|
|
1034
|
+
* return {
|
|
1035
|
+
* create: ({ editor, state }) =>
|
|
1036
|
+
* findMatches(state.doc).map(match =>
|
|
1037
|
+
* ReactWidgetRenderer(MyWidget, {
|
|
1038
|
+
* editor, pos: match.pos, key: `match-${match.id}`,
|
|
1039
|
+
* props: { label: match.label },
|
|
1040
|
+
* }),
|
|
1041
|
+
* ),
|
|
1042
|
+
* }
|
|
1043
|
+
* }
|
|
1044
|
+
*/
|
|
1045
|
+
function ReactWidgetRenderer(component, options) {
|
|
1046
|
+
const { editor, props = {}, as = "span", className } = options;
|
|
1047
|
+
return createWidgetDecoration({
|
|
1048
|
+
...options,
|
|
1049
|
+
props,
|
|
1050
|
+
cacheKey: WIDGET_CACHE,
|
|
1051
|
+
context: (getPos) => ({
|
|
1052
|
+
editor,
|
|
1053
|
+
getPos
|
|
1054
|
+
}),
|
|
1055
|
+
create: (renderProps) => new ReactRenderer(component, {
|
|
1056
|
+
editor,
|
|
1057
|
+
as,
|
|
1058
|
+
className,
|
|
1059
|
+
props: renderProps
|
|
1060
|
+
}),
|
|
1061
|
+
materialize: (renderer) => {
|
|
1062
|
+
renderer.render();
|
|
1063
|
+
return renderer.element;
|
|
1064
|
+
}
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
//#endregion
|
|
1068
|
+
//#region src/Tiptap.tsx
|
|
1069
|
+
/**
|
|
1070
|
+
* React context that stores the current editor instance.
|
|
1071
|
+
*
|
|
1072
|
+
* Use `useTiptap()` to read from this context in child components.
|
|
1073
|
+
*/
|
|
1074
|
+
const TiptapContext = createContext({ get editor() {
|
|
1075
|
+
throw new Error("useTiptap must be used within a <Tiptap> provider");
|
|
1076
|
+
} });
|
|
1068
1077
|
TiptapContext.displayName = "TiptapContext";
|
|
1069
|
-
|
|
1078
|
+
/**
|
|
1079
|
+
* Hook to read the Tiptap context and access the editor instance.
|
|
1080
|
+
*
|
|
1081
|
+
* This is a small convenience wrapper around `useContext(TiptapContext)`.
|
|
1082
|
+
* The editor is always available when used within a `<Tiptap>` provider.
|
|
1083
|
+
*
|
|
1084
|
+
* @returns The current `TiptapContextType` value from the provider.
|
|
1085
|
+
*
|
|
1086
|
+
* @example
|
|
1087
|
+
* ```tsx
|
|
1088
|
+
* import { useTiptap } from '@tiptap/react'
|
|
1089
|
+
*
|
|
1090
|
+
* function Toolbar() {
|
|
1091
|
+
* const { editor } = useTiptap()
|
|
1092
|
+
*
|
|
1093
|
+
* return (
|
|
1094
|
+
* <button onClick={() => editor.chain().focus().toggleBold().run()}>
|
|
1095
|
+
* Bold
|
|
1096
|
+
* </button>
|
|
1097
|
+
* )
|
|
1098
|
+
* }
|
|
1099
|
+
* ```
|
|
1100
|
+
*/
|
|
1101
|
+
const useTiptap = () => useContext(TiptapContext);
|
|
1102
|
+
/**
|
|
1103
|
+
* Select a slice of the editor state using the context-provided editor.
|
|
1104
|
+
*
|
|
1105
|
+
* This is a thin wrapper around `useEditorState` that reads the `editor`
|
|
1106
|
+
* instance from `useTiptap()` so callers don't have to pass it manually.
|
|
1107
|
+
*
|
|
1108
|
+
* @typeParam TSelectorResult - The type returned by the selector.
|
|
1109
|
+
* @param selector - Function that receives the editor state snapshot and
|
|
1110
|
+
* returns the piece of state you want to subscribe to.
|
|
1111
|
+
* @param equalityFn - Optional function to compare previous/next selected
|
|
1112
|
+
* values and avoid unnecessary updates.
|
|
1113
|
+
* @returns The selected slice of the editor state.
|
|
1114
|
+
*
|
|
1115
|
+
* @example
|
|
1116
|
+
* ```tsx
|
|
1117
|
+
* function WordCount() {
|
|
1118
|
+
* const wordCount = useTiptapState(state => {
|
|
1119
|
+
* const text = state.editor.state.doc.textContent
|
|
1120
|
+
* return text.split(/\s+/).filter(Boolean).length
|
|
1121
|
+
* })
|
|
1122
|
+
*
|
|
1123
|
+
* return <span>{wordCount} words</span>
|
|
1124
|
+
* }
|
|
1125
|
+
* ```
|
|
1126
|
+
*/
|
|
1070
1127
|
function useTiptapState(selector, equalityFn) {
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1128
|
+
const { editor } = useTiptap();
|
|
1129
|
+
return useEditorState({
|
|
1130
|
+
editor,
|
|
1131
|
+
selector,
|
|
1132
|
+
equalityFn
|
|
1133
|
+
});
|
|
1077
1134
|
}
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1135
|
+
/**
|
|
1136
|
+
* Top-level provider component that makes the editor instance available via
|
|
1137
|
+
* React context to all child components.
|
|
1138
|
+
*
|
|
1139
|
+
* This component also provides backwards compatibility with the legacy
|
|
1140
|
+
* `EditorContext`, so components using `useCurrentEditor()` will work
|
|
1141
|
+
* inside a `<Tiptap>` provider.
|
|
1142
|
+
*
|
|
1143
|
+
* @param props - Component props.
|
|
1144
|
+
* @returns A context provider element wrapping `children`.
|
|
1145
|
+
*
|
|
1146
|
+
* @example
|
|
1147
|
+
* ```tsx
|
|
1148
|
+
* import { Tiptap, useEditor } from '@tiptap/react'
|
|
1149
|
+
*
|
|
1150
|
+
* function App() {
|
|
1151
|
+
* const editor = useEditor({ extensions: [...] })
|
|
1152
|
+
*
|
|
1153
|
+
* return (
|
|
1154
|
+
* <Tiptap editor={editor}>
|
|
1155
|
+
* <Toolbar />
|
|
1156
|
+
* <Tiptap.Content />
|
|
1157
|
+
* </Tiptap>
|
|
1158
|
+
* )
|
|
1159
|
+
* }
|
|
1160
|
+
* ```
|
|
1161
|
+
*/
|
|
1162
|
+
function TiptapWrapper({ children, ...props }) {
|
|
1163
|
+
const resolvedEditor = "editor" in props ? props.editor : props.instance;
|
|
1164
|
+
if (!resolvedEditor) throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");
|
|
1165
|
+
const tiptapContextValue = useMemo(() => ({ editor: resolvedEditor }), [resolvedEditor]);
|
|
1166
|
+
const legacyContextValue = useMemo(() => ({ editor: resolvedEditor }), [resolvedEditor]);
|
|
1167
|
+
return /* @__PURE__ */ jsx(EditorContext.Provider, {
|
|
1168
|
+
value: legacyContextValue,
|
|
1169
|
+
children: /* @__PURE__ */ jsx(TiptapContext.Provider, {
|
|
1170
|
+
value: tiptapContextValue,
|
|
1171
|
+
children
|
|
1172
|
+
})
|
|
1173
|
+
});
|
|
1086
1174
|
}
|
|
1087
1175
|
TiptapWrapper.displayName = "Tiptap";
|
|
1176
|
+
/**
|
|
1177
|
+
* Convenience component that renders `EditorContent` using the context-provided
|
|
1178
|
+
* editor instance. Use this instead of manually passing the `editor` prop.
|
|
1179
|
+
*
|
|
1180
|
+
* @param props - All `EditorContent` props except `editor` and `ref`.
|
|
1181
|
+
* @returns An `EditorContent` element bound to the context editor.
|
|
1182
|
+
*
|
|
1183
|
+
* @example
|
|
1184
|
+
* ```tsx
|
|
1185
|
+
* // inside a Tiptap provider
|
|
1186
|
+
* <Tiptap.Content className="editor" />
|
|
1187
|
+
* ```
|
|
1188
|
+
*/
|
|
1088
1189
|
function TiptapContent({ ...rest }) {
|
|
1089
|
-
|
|
1090
|
-
|
|
1190
|
+
const { editor } = useTiptap();
|
|
1191
|
+
return /* @__PURE__ */ jsx(EditorContent, {
|
|
1192
|
+
editor,
|
|
1193
|
+
...rest
|
|
1194
|
+
});
|
|
1091
1195
|
}
|
|
1092
1196
|
TiptapContent.displayName = "Tiptap.Content";
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1197
|
+
/**
|
|
1198
|
+
* Root `Tiptap` component. Use it as the provider for all child components.
|
|
1199
|
+
*
|
|
1200
|
+
* The exported object includes the `Content` subcomponent for rendering the
|
|
1201
|
+
* editor content area.
|
|
1202
|
+
*
|
|
1203
|
+
* This component provides both the new `TiptapContext` (accessed via `useTiptap()`)
|
|
1204
|
+
* and the legacy `EditorContext` (accessed via `useCurrentEditor()`) for
|
|
1205
|
+
* backwards compatibility.
|
|
1206
|
+
*
|
|
1207
|
+
* For bubble menus and floating menus, import them separately from
|
|
1208
|
+
* `@tiptap/react/menus` to keep floating-ui as an optional dependency.
|
|
1209
|
+
*
|
|
1210
|
+
* @example
|
|
1211
|
+
* ```tsx
|
|
1212
|
+
* import { Tiptap, useEditor } from '@tiptap/react'
|
|
1213
|
+
* import { BubbleMenu } from '@tiptap/react/menus'
|
|
1214
|
+
*
|
|
1215
|
+
* function App() {
|
|
1216
|
+
* const editor = useEditor({ extensions: [...] })
|
|
1217
|
+
*
|
|
1218
|
+
* return (
|
|
1219
|
+
* <Tiptap editor={editor}>
|
|
1220
|
+
* <Tiptap.Content />
|
|
1221
|
+
* <BubbleMenu>
|
|
1222
|
+
* <button onClick={() => editor.chain().focus().toggleBold().run()}>Bold</button>
|
|
1223
|
+
* </BubbleMenu>
|
|
1224
|
+
* </Tiptap>
|
|
1225
|
+
* )
|
|
1226
|
+
* }
|
|
1227
|
+
* ```
|
|
1228
|
+
*/
|
|
1229
|
+
const Tiptap = Object.assign(TiptapWrapper, {
|
|
1230
|
+
/**
|
|
1231
|
+
* The Tiptap Content component that renders the EditorContent with the editor instance from the context.
|
|
1232
|
+
* @see TiptapContent
|
|
1233
|
+
*/
|
|
1234
|
+
Content: TiptapContent });
|
|
1235
|
+
//#endregion
|
|
1236
|
+
export { EditorConsumer, EditorContent, EditorContext, EditorProvider, MarkViewContent, NodeViewContent, NodeViewWrapper, PureEditorContent, ReactMarkView, ReactMarkViewContext, ReactMarkViewRenderer, ReactNodeView, ReactNodeViewContentProvider, ReactNodeViewContext, ReactNodeViewRenderer, ReactRenderer, ReactWidgetRenderer, Tiptap, TiptapContent, TiptapContext, TiptapWrapper, createContentComponent, useCurrentEditor, useEditor, useEditorState, useReactNodeView, useTiptap, useTiptapState };
|
|
1100
1237
|
|
|
1101
|
-
// src/index.ts
|
|
1102
|
-
export * from "@tiptap/core";
|
|
1103
|
-
export {
|
|
1104
|
-
EditorConsumer,
|
|
1105
|
-
EditorContent,
|
|
1106
|
-
EditorContext,
|
|
1107
|
-
EditorProvider,
|
|
1108
|
-
MarkViewContent,
|
|
1109
|
-
NodeViewContent,
|
|
1110
|
-
NodeViewWrapper,
|
|
1111
|
-
PureEditorContent,
|
|
1112
|
-
ReactMarkView,
|
|
1113
|
-
ReactMarkViewContext,
|
|
1114
|
-
ReactMarkViewRenderer,
|
|
1115
|
-
ReactNodeView,
|
|
1116
|
-
ReactNodeViewContentProvider,
|
|
1117
|
-
ReactNodeViewContext,
|
|
1118
|
-
ReactNodeViewRenderer,
|
|
1119
|
-
ReactRenderer,
|
|
1120
|
-
Tiptap,
|
|
1121
|
-
TiptapContent,
|
|
1122
|
-
TiptapContext,
|
|
1123
|
-
TiptapWrapper,
|
|
1124
|
-
useCurrentEditor,
|
|
1125
|
-
useEditor,
|
|
1126
|
-
useEditorState,
|
|
1127
|
-
useReactNodeView,
|
|
1128
|
-
useTiptap,
|
|
1129
|
-
useTiptapState
|
|
1130
|
-
};
|
|
1131
1238
|
//# sourceMappingURL=index.js.map
|