@tiptap/react 2.0.0-alpha.2 → 2.0.0-beta.101
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/LICENSE.md +1 -1
- package/README.md +2 -2
- package/dist/packages/core/src/CommandManager.d.ts +20 -0
- package/dist/packages/core/src/Editor.d.ts +147 -0
- package/dist/packages/core/src/EventEmitter.d.ts +11 -0
- package/dist/packages/core/src/Extension.d.ts +227 -0
- package/dist/packages/core/src/ExtensionManager.d.ts +18 -0
- package/dist/packages/core/src/InputRule.d.ts +42 -0
- package/dist/packages/core/src/Mark.d.ts +319 -0
- package/dist/packages/core/src/Node.d.ts +388 -0
- package/dist/packages/core/src/NodeView.d.ts +27 -0
- package/dist/packages/core/src/PasteRule.d.ts +42 -0
- package/dist/packages/core/src/Tracker.d.ts +11 -0
- package/dist/packages/core/src/commands/blur.d.ts +12 -0
- package/dist/packages/core/src/commands/clearContent.d.ts +12 -0
- package/dist/packages/core/src/commands/clearNodes.d.ts +12 -0
- package/dist/packages/core/src/commands/command.d.ts +12 -0
- package/dist/packages/core/src/commands/createParagraphNear.d.ts +12 -0
- package/dist/packages/core/src/commands/deleteNode.d.ts +13 -0
- package/dist/packages/core/src/commands/deleteRange.d.ts +12 -0
- package/dist/packages/core/src/commands/deleteSelection.d.ts +12 -0
- package/dist/packages/core/src/commands/enter.d.ts +12 -0
- package/dist/packages/core/src/commands/exitCode.d.ts +12 -0
- package/dist/packages/core/src/commands/extendMarkRange.d.ts +13 -0
- package/dist/packages/core/src/commands/first.d.ts +12 -0
- package/dist/packages/core/src/commands/focus.d.ts +14 -0
- package/dist/packages/core/src/commands/forEach.d.ts +14 -0
- package/dist/packages/core/src/commands/insertContent.d.ts +16 -0
- package/dist/packages/core/src/commands/insertContentAt.d.ts +16 -0
- package/dist/packages/core/src/commands/joinBackward.d.ts +12 -0
- package/dist/packages/core/src/commands/joinForward.d.ts +12 -0
- package/dist/packages/core/src/commands/keyboardShortcut.d.ts +12 -0
- package/dist/packages/core/src/commands/lift.d.ts +13 -0
- package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +12 -0
- package/dist/packages/core/src/commands/liftListItem.d.ts +13 -0
- package/dist/packages/core/src/commands/newlineInCode.d.ts +12 -0
- package/dist/packages/core/src/commands/resetAttributes.d.ts +13 -0
- package/dist/packages/core/src/commands/scrollIntoView.d.ts +12 -0
- package/dist/packages/core/src/commands/selectAll.d.ts +12 -0
- package/dist/packages/core/src/commands/selectNodeBackward.d.ts +12 -0
- package/dist/packages/core/src/commands/selectNodeForward.d.ts +12 -0
- package/dist/packages/core/src/commands/selectParentNode.d.ts +12 -0
- package/dist/packages/core/src/commands/setContent.d.ts +13 -0
- package/dist/packages/core/src/commands/setMark.d.ts +13 -0
- package/dist/packages/core/src/commands/setMeta.d.ts +12 -0
- package/dist/packages/core/src/commands/setNode.d.ts +13 -0
- package/dist/packages/core/src/commands/setNodeSelection.d.ts +12 -0
- package/dist/packages/core/src/commands/setTextSelection.d.ts +12 -0
- package/dist/packages/core/src/commands/sinkListItem.d.ts +13 -0
- package/dist/packages/core/src/commands/splitBlock.d.ts +14 -0
- package/dist/packages/core/src/commands/splitListItem.d.ts +13 -0
- package/dist/packages/core/src/commands/toggleList.d.ts +13 -0
- package/dist/packages/core/src/commands/toggleMark.d.ts +18 -0
- package/dist/packages/core/src/commands/toggleNode.d.ts +13 -0
- package/dist/packages/core/src/commands/toggleWrap.d.ts +13 -0
- package/dist/packages/core/src/commands/undoInputRule.d.ts +12 -0
- package/dist/packages/core/src/commands/unsetAllMarks.d.ts +12 -0
- package/dist/packages/core/src/commands/unsetMark.d.ts +18 -0
- package/dist/packages/core/src/commands/updateAttributes.d.ts +13 -0
- package/dist/packages/core/src/commands/wrapIn.d.ts +13 -0
- package/dist/packages/core/src/commands/wrapInList.d.ts +13 -0
- package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +2 -0
- package/dist/packages/core/src/extensions/commands.d.ts +98 -0
- package/dist/packages/core/src/extensions/editable.d.ts +2 -0
- package/dist/packages/core/src/extensions/focusEvents.d.ts +2 -0
- package/dist/packages/core/src/extensions/index.d.ts +6 -0
- package/dist/packages/core/src/extensions/keymap.d.ts +2 -0
- package/dist/packages/core/src/extensions/tabindex.d.ts +2 -0
- package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +7 -0
- package/dist/packages/core/src/helpers/createChainableState.d.ts +5 -0
- package/dist/packages/core/src/helpers/createDocument.d.ts +3 -0
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +7 -0
- package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +2 -0
- package/dist/packages/core/src/helpers/findChildren.d.ts +3 -0
- package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +6 -0
- package/dist/packages/core/src/helpers/findParentNode.d.ts +9 -0
- package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +8 -0
- package/dist/packages/core/src/helpers/generateHTML.d.ts +2 -0
- package/dist/packages/core/src/helpers/generateJSON.d.ts +2 -0
- package/dist/packages/core/src/helpers/generateText.d.ts +5 -0
- package/dist/packages/core/src/helpers/getAttributes.d.ts +3 -0
- package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +6 -0
- package/dist/packages/core/src/helpers/getChangedRanges.d.ts +11 -0
- package/dist/packages/core/src/helpers/getDebugJSON.d.ts +8 -0
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +2 -0
- package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +2 -0
- package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +3 -0
- package/dist/packages/core/src/helpers/getMarkRange.d.ts +3 -0
- package/dist/packages/core/src/helpers/getMarkType.d.ts +2 -0
- package/dist/packages/core/src/helpers/getMarksBetween.d.ts +3 -0
- package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +3 -0
- package/dist/packages/core/src/helpers/getNodeType.d.ts +2 -0
- package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +3 -0
- package/dist/packages/core/src/helpers/getSchema.d.ts +3 -0
- package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +3 -0
- package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +2 -0
- package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +2 -0
- package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +2 -0
- package/dist/packages/core/src/helpers/getText.d.ts +6 -0
- package/dist/packages/core/src/helpers/getTextBetween.d.ts +6 -0
- package/dist/packages/core/src/helpers/getTextSeralizersFromSchema.d.ts +3 -0
- package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +9 -0
- package/dist/packages/core/src/helpers/isActive.d.ts +2 -0
- package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +2 -0
- package/dist/packages/core/src/helpers/isList.d.ts +2 -0
- package/dist/packages/core/src/helpers/isMarkActive.d.ts +3 -0
- package/dist/packages/core/src/helpers/isNodeActive.d.ts +3 -0
- package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +2 -0
- package/dist/packages/core/src/helpers/isNodeSelection.d.ts +2 -0
- package/dist/packages/core/src/helpers/isTextSelection.d.ts +2 -0
- package/dist/packages/core/src/helpers/posToDOMRect.d.ts +2 -0
- package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +4 -0
- package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +2 -0
- package/dist/packages/core/src/helpers/splitExtensions.d.ts +9 -0
- package/dist/packages/core/src/index.d.ts +60 -0
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +12 -0
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +12 -0
- package/dist/packages/core/src/inputRules/textInputRule.d.ts +9 -0
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +14 -0
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +23 -0
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +12 -0
- package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +9 -0
- package/dist/packages/core/src/style.d.ts +1 -0
- package/dist/packages/core/src/types.d.ts +210 -0
- package/dist/packages/core/src/utilities/callOrReturn.d.ts +9 -0
- package/dist/packages/core/src/utilities/createStyleTag.d.ts +1 -0
- package/dist/packages/core/src/utilities/deleteProps.d.ts +6 -0
- package/dist/packages/core/src/utilities/elementFromString.d.ts +1 -0
- package/dist/packages/core/src/utilities/findDuplicates.d.ts +1 -0
- package/dist/packages/core/src/utilities/fromString.d.ts +1 -0
- package/dist/packages/core/src/utilities/isClass.d.ts +1 -0
- package/dist/packages/core/src/utilities/isEmptyObject.d.ts +1 -0
- package/dist/packages/core/src/utilities/isFunction.d.ts +1 -0
- package/dist/packages/core/src/utilities/isNumber.d.ts +1 -0
- package/dist/packages/core/src/utilities/isObject.d.ts +1 -0
- package/dist/packages/core/src/utilities/isPlainObject.d.ts +1 -0
- package/dist/packages/core/src/utilities/isRegExp.d.ts +1 -0
- package/dist/packages/core/src/utilities/isString.d.ts +1 -0
- package/dist/packages/core/src/utilities/isiOS.d.ts +1 -0
- package/dist/packages/core/src/utilities/mergeAttributes.d.ts +1 -0
- package/dist/packages/core/src/utilities/mergeDeep.d.ts +1 -0
- package/dist/packages/core/src/utilities/minMax.d.ts +1 -0
- package/dist/packages/core/src/utilities/objectIncludes.d.ts +8 -0
- package/dist/packages/core/src/utilities/removeDuplicates.d.ts +8 -0
- package/dist/packages/extension-blockquote/src/blockquote.d.ts +24 -0
- package/dist/packages/extension-blockquote/src/index.d.ts +3 -0
- package/dist/packages/extension-bold/src/bold.d.ts +27 -0
- package/dist/packages/extension-bold/src/index.d.ts +3 -0
- package/dist/packages/extension-bubble-menu/src/bubble-menu-plugin.d.ts +43 -0
- package/dist/packages/extension-bubble-menu/src/bubble-menu.d.ts +6 -0
- package/dist/packages/extension-bubble-menu/src/index.d.ts +4 -0
- package/dist/packages/extension-bullet-list/src/bullet-list.d.ts +17 -0
- package/dist/packages/extension-bullet-list/src/index.d.ts +3 -0
- package/dist/packages/extension-character-count/src/character-count.d.ts +28 -0
- package/dist/packages/extension-character-count/src/index.d.ts +3 -0
- package/dist/packages/extension-code/src/code.d.ts +25 -0
- package/dist/packages/extension-code/src/index.d.ts +3 -0
- package/dist/packages/extension-code-block/src/code-block.d.ts +26 -0
- package/dist/packages/extension-code-block/src/index.d.ts +3 -0
- package/dist/packages/extension-code-block-lowlight/src/code-block-lowlight.d.ts +6 -0
- package/dist/packages/extension-code-block-lowlight/src/index.d.ts +3 -0
- package/dist/packages/extension-code-block-lowlight/src/lowlight-plugin.d.ts +6 -0
- package/dist/packages/extension-collaboration/src/collaboration.d.ts +30 -0
- package/dist/packages/extension-collaboration/src/helpers/isChangeOrigin.d.ts +2 -0
- package/dist/packages/extension-collaboration/src/index.d.ts +4 -0
- package/dist/packages/extension-collaboration-cursor/src/collaboration-cursor.d.ts +37 -0
- package/dist/packages/extension-collaboration-cursor/src/index.d.ts +3 -0
- package/dist/packages/extension-color/src/color.d.ts +20 -0
- package/dist/packages/extension-color/src/index.d.ts +3 -0
- package/dist/packages/extension-document/src/document.d.ts +2 -0
- package/dist/packages/extension-document/src/index.d.ts +3 -0
- package/dist/packages/extension-dropcursor/src/dropcursor.d.ts +7 -0
- package/dist/packages/extension-dropcursor/src/index.d.ts +3 -0
- package/dist/packages/extension-floating-menu/src/floating-menu-plugin.d.ts +40 -0
- package/dist/packages/extension-floating-menu/src/floating-menu.d.ts +6 -0
- package/dist/packages/extension-floating-menu/src/index.d.ts +4 -0
- package/dist/packages/extension-focus/src/focus.d.ts +6 -0
- package/dist/packages/extension-focus/src/index.d.ts +3 -0
- package/dist/packages/extension-font-family/src/font-family.d.ts +21 -0
- package/dist/packages/extension-font-family/src/index.d.ts +3 -0
- package/dist/packages/extension-gapcursor/src/gapcursor.d.ts +15 -0
- package/dist/packages/extension-gapcursor/src/index.d.ts +3 -0
- package/dist/packages/extension-hard-break/src/hard-break.d.ts +16 -0
- package/dist/packages/extension-hard-break/src/index.d.ts +3 -0
- package/dist/packages/extension-heading/src/heading.d.ts +26 -0
- package/dist/packages/extension-heading/src/index.d.ts +3 -0
- package/dist/packages/extension-highlight/src/highlight.d.ts +30 -0
- package/dist/packages/extension-highlight/src/index.d.ts +3 -0
- package/dist/packages/extension-history/src/history.d.ts +20 -0
- package/dist/packages/extension-history/src/index.d.ts +3 -0
- package/dist/packages/extension-horizontal-rule/src/horizontal-rule.d.ts +15 -0
- package/dist/packages/extension-horizontal-rule/src/index.d.ts +3 -0
- package/dist/packages/extension-image/src/image.d.ts +21 -0
- package/dist/packages/extension-image/src/index.d.ts +3 -0
- package/dist/packages/extension-italic/src/index.d.ts +3 -0
- package/dist/packages/extension-italic/src/italic.d.ts +27 -0
- package/dist/packages/extension-link/src/helpers/autolink.d.ts +7 -0
- package/dist/packages/extension-link/src/helpers/clickHandler.d.ts +7 -0
- package/dist/packages/extension-link/src/helpers/pasteHandler.d.ts +9 -0
- package/dist/packages/extension-link/src/index.d.ts +3 -0
- package/dist/packages/extension-link/src/link.d.ts +44 -0
- package/dist/packages/extension-list-item/src/index.d.ts +3 -0
- package/dist/packages/extension-list-item/src/list-item.d.ts +5 -0
- package/dist/packages/extension-mention/src/index.d.ts +3 -0
- package/dist/packages/extension-mention/src/mention.d.ts +14 -0
- package/dist/packages/extension-ordered-list/src/index.d.ts +3 -0
- package/dist/packages/extension-ordered-list/src/ordered-list.d.ts +17 -0
- package/dist/packages/extension-paragraph/src/index.d.ts +3 -0
- package/dist/packages/extension-paragraph/src/paragraph.d.ts +15 -0
- package/dist/packages/extension-placeholder/src/index.d.ts +3 -0
- package/dist/packages/extension-placeholder/src/placeholder.d.ts +15 -0
- package/dist/packages/extension-strike/src/index.d.ts +3 -0
- package/dist/packages/extension-strike/src/strike.d.ts +25 -0
- package/dist/packages/extension-subscript/src/index.d.ts +3 -0
- package/dist/packages/extension-subscript/src/subscript.d.ts +23 -0
- package/dist/packages/extension-superscript/src/index.d.ts +3 -0
- package/dist/packages/extension-superscript/src/superscript.d.ts +23 -0
- package/dist/packages/extension-table/src/TableView.d.ts +17 -0
- package/dist/packages/extension-table/src/index.d.ts +4 -0
- package/dist/packages/extension-table/src/table.d.ts +55 -0
- package/dist/packages/extension-table/src/utilities/createCell.d.ts +2 -0
- package/dist/packages/extension-table/src/utilities/createTable.d.ts +2 -0
- package/dist/packages/extension-table/src/utilities/deleteTableWhenAllCellsSelected.d.ts +2 -0
- package/dist/packages/extension-table/src/utilities/getTableNodeTypes.d.ts +4 -0
- package/dist/packages/extension-table/src/utilities/isCellSelection.d.ts +2 -0
- package/dist/packages/extension-table-cell/src/index.d.ts +3 -0
- package/dist/packages/extension-table-cell/src/table-cell.d.ts +5 -0
- package/dist/packages/extension-table-header/src/index.d.ts +3 -0
- package/dist/packages/extension-table-header/src/table-header.d.ts +5 -0
- package/dist/packages/extension-table-row/src/index.d.ts +3 -0
- package/dist/packages/extension-table-row/src/table-row.d.ts +5 -0
- package/dist/packages/extension-task-item/src/index.d.ts +3 -0
- package/dist/packages/extension-task-item/src/task-item.d.ts +7 -0
- package/dist/packages/extension-task-list/src/index.d.ts +3 -0
- package/dist/packages/extension-task-list/src/task-list.d.ts +16 -0
- package/dist/packages/extension-text/src/index.d.ts +3 -0
- package/dist/packages/extension-text/src/text.d.ts +2 -0
- package/dist/packages/extension-text-align/src/index.d.ts +3 -0
- package/dist/packages/extension-text-align/src/text-align.d.ts +21 -0
- package/dist/packages/extension-text-style/src/index.d.ts +3 -0
- package/dist/packages/extension-text-style/src/text-style.d.ts +15 -0
- package/dist/packages/extension-typography/src/index.d.ts +3 -0
- package/dist/packages/extension-typography/src/typography.d.ts +23 -0
- package/dist/packages/extension-underline/src/index.d.ts +3 -0
- package/dist/packages/extension-underline/src/underline.d.ts +23 -0
- package/dist/packages/html/src/generateHTML.d.ts +2 -0
- package/dist/packages/html/src/generateJSON.d.ts +2 -0
- package/dist/packages/html/src/getHTMLFromFragment.d.ts +2 -0
- package/dist/packages/html/src/index.d.ts +2 -0
- package/dist/packages/react/src/BubbleMenu.d.ts +8 -0
- package/dist/packages/react/src/Editor.d.ts +6 -0
- package/dist/packages/react/src/EditorContent.d.ts +19 -0
- package/dist/packages/react/src/FloatingMenu.d.ts +8 -0
- package/dist/packages/react/src/NodeViewContent.d.ts +6 -0
- package/dist/packages/react/src/NodeViewWrapper.d.ts +6 -0
- package/dist/packages/react/src/ReactNodeViewRenderer.d.ts +13 -1
- package/dist/packages/react/src/ReactRenderer.d.ts +26 -1
- package/dist/packages/react/src/index.d.ts +9 -3
- package/dist/packages/react/src/useEditor.d.ts +4 -0
- package/dist/packages/react/src/useReactNodeView.d.ts +7 -0
- package/dist/packages/starter-kit/src/index.d.ts +3 -0
- package/dist/packages/starter-kit/src/starter-kit.d.ts +37 -0
- package/dist/packages/suggestion/src/findSuggestionMatch.d.ts +15 -0
- package/dist/packages/suggestion/src/index.d.ts +4 -0
- package/dist/packages/suggestion/src/suggestion.d.ts +49 -0
- package/dist/tests/cypress/integration/core/can.spec.d.ts +1 -0
- package/dist/tests/cypress/integration/core/editorProps.spec.d.ts +1 -0
- package/dist/tests/cypress/integration/core/extendExtensions.spec.d.ts +1 -0
- package/dist/tests/cypress/integration/core/extendMarkRange.spec.d.ts +1 -0
- package/dist/tests/cypress/integration/core/extensionOptions.spec.d.ts +1 -0
- package/dist/tests/cypress/integration/core/fromString.spec.d.ts +1 -0
- package/dist/tests/cypress/integration/core/generateHTML.spec.d.ts +1 -0
- package/dist/tests/cypress/integration/core/generateJSON.spec.d.ts +1 -0
- package/dist/tests/cypress/integration/core/isActive.spec.d.ts +1 -0
- package/dist/tests/cypress/integration/core/isClass.spec.d.ts +1 -0
- package/dist/tests/cypress/integration/core/mergeAttributes.spec.d.ts +1 -0
- package/dist/tests/cypress/integration/core/mergeDeep.spec.d.ts +1 -0
- package/dist/tests/cypress/integration/core/pluginOrder.spec.d.ts +1 -0
- package/dist/tests/cypress/integration/extensions/bold.spec.d.ts +1 -0
- package/dist/tests/cypress/integration/extensions/codeBlockLowlight.spec.d.ts +1 -0
- package/dist/tests/cypress/integration/html/generateHTML.spec.d.ts +1 -0
- package/dist/tests/cypress/integration/html/generateJSON.spec.d.ts +1 -0
- package/dist/tiptap-react.cjs.js +349 -30
- package/dist/tiptap-react.cjs.js.map +1 -1
- package/dist/tiptap-react.esm.js +344 -29
- package/dist/tiptap-react.esm.js.map +1 -1
- package/dist/tiptap-react.umd.js +351 -35
- package/dist/tiptap-react.umd.js.map +1 -1
- package/package.json +19 -6
- package/src/BubbleMenu.tsx +46 -0
- package/src/Editor.ts +7 -0
- package/src/EditorContent.tsx +110 -0
- package/src/FloatingMenu.tsx +46 -0
- package/src/NodeViewContent.tsx +24 -0
- package/src/NodeViewWrapper.tsx +25 -0
- package/src/ReactNodeViewRenderer.tsx +184 -0
- package/src/ReactRenderer.tsx +109 -0
- package/src/index.ts +9 -6
- package/src/useEditor.ts +34 -0
- package/src/useReactNodeView.ts +12 -0
- package/CHANGELOG.md +0 -8
- package/dist/tiptap-react.bundle.umd.min.js +0 -15
- package/dist/tiptap-react.bundle.umd.min.js.map +0 -1
- package/src/ReactNodeViewRenderer.ts +0 -1
- package/src/ReactRenderer.ts +0 -1
- package/src/components/Editor.jsx +0 -34
package/dist/tiptap-react.umd.js
CHANGED
|
@@ -1,61 +1,377 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('react')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', 'react'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global[
|
|
5
|
-
}(this, (function (exports, core, React) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('react'), require('@tiptap/extension-bubble-menu'), require('@tiptap/extension-floating-menu'), require('react-dom')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', 'react', '@tiptap/extension-bubble-menu', '@tiptap/extension-floating-menu', 'react-dom'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/react"] = {}, global.core, global.React, global.extensionBubbleMenu, global.extensionFloatingMenu, global.ReactDOM));
|
|
5
|
+
})(this, (function (exports, core, React, extensionBubbleMenu, extensionFloatingMenu, ReactDOM) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
9
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
|
+
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
10
11
|
|
|
12
|
+
const BubbleMenu = props => {
|
|
13
|
+
const element = React.useRef(null);
|
|
14
|
+
React.useEffect(() => {
|
|
15
|
+
if (!element.current) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const { pluginKey = 'bubbleMenu', editor, tippyOptions = {}, shouldShow = null, } = props;
|
|
19
|
+
editor.registerPlugin(extensionBubbleMenu.BubbleMenuPlugin({
|
|
20
|
+
pluginKey,
|
|
21
|
+
editor,
|
|
22
|
+
element: element.current,
|
|
23
|
+
tippyOptions,
|
|
24
|
+
shouldShow,
|
|
25
|
+
}));
|
|
26
|
+
return () => {
|
|
27
|
+
editor.unregisterPlugin(pluginKey);
|
|
28
|
+
};
|
|
29
|
+
}, [
|
|
30
|
+
props.editor,
|
|
31
|
+
element.current,
|
|
32
|
+
]);
|
|
33
|
+
return (React__default["default"].createElement("div", { ref: element, className: props.className, style: { visibility: 'hidden' } }, props.children));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
class Editor extends core.Editor {
|
|
37
|
+
constructor() {
|
|
38
|
+
super(...arguments);
|
|
39
|
+
this.contentComponent = null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const FloatingMenu = props => {
|
|
44
|
+
const element = React.useRef(null);
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
if (!element.current) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const { pluginKey = 'floatingMenu', editor, tippyOptions = {}, shouldShow = null, } = props;
|
|
50
|
+
editor.registerPlugin(extensionFloatingMenu.FloatingMenuPlugin({
|
|
51
|
+
pluginKey,
|
|
52
|
+
editor,
|
|
53
|
+
element: element.current,
|
|
54
|
+
tippyOptions,
|
|
55
|
+
shouldShow,
|
|
56
|
+
}));
|
|
57
|
+
return () => {
|
|
58
|
+
editor.unregisterPlugin(pluginKey);
|
|
59
|
+
};
|
|
60
|
+
}, [
|
|
61
|
+
props.editor,
|
|
62
|
+
element.current,
|
|
63
|
+
]);
|
|
64
|
+
return (React__default["default"].createElement("div", { ref: element, className: props.className, style: { visibility: 'hidden' } }, props.children));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
function useForceUpdate() {
|
|
68
|
+
const [, setValue] = React.useState(0);
|
|
69
|
+
return () => setValue(value => value + 1);
|
|
70
|
+
}
|
|
71
|
+
const useEditor = (options = {}, deps = []) => {
|
|
72
|
+
const [editor, setEditor] = React.useState(null);
|
|
73
|
+
const forceUpdate = useForceUpdate();
|
|
74
|
+
React.useEffect(() => {
|
|
75
|
+
const instance = new Editor(options);
|
|
76
|
+
setEditor(instance);
|
|
77
|
+
instance.on('transaction', () => {
|
|
78
|
+
requestAnimationFrame(() => {
|
|
79
|
+
requestAnimationFrame(() => {
|
|
80
|
+
forceUpdate();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
return () => {
|
|
85
|
+
instance.destroy();
|
|
86
|
+
};
|
|
87
|
+
}, deps);
|
|
88
|
+
return editor;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
function isClassComponent(Component) {
|
|
92
|
+
return !!(typeof Component === 'function'
|
|
93
|
+
&& Component.prototype
|
|
94
|
+
&& Component.prototype.isReactComponent);
|
|
95
|
+
}
|
|
96
|
+
function isForwardRefComponent(Component) {
|
|
97
|
+
var _a;
|
|
98
|
+
return !!(typeof Component === 'object'
|
|
99
|
+
&& ((_a = Component.$$typeof) === null || _a === void 0 ? void 0 : _a.toString()) === 'Symbol(react.forward_ref)');
|
|
100
|
+
}
|
|
11
101
|
class ReactRenderer {
|
|
102
|
+
constructor(component, { editor, props = {}, as = 'div', className = '', }) {
|
|
103
|
+
this.ref = null;
|
|
104
|
+
this.id = Math.floor(Math.random() * 0xFFFFFFFF).toString();
|
|
105
|
+
this.component = component;
|
|
106
|
+
this.editor = editor;
|
|
107
|
+
this.props = props;
|
|
108
|
+
this.element = document.createElement(as);
|
|
109
|
+
this.element.classList.add('react-renderer');
|
|
110
|
+
if (className) {
|
|
111
|
+
this.element.classList.add(...className.split(' '));
|
|
112
|
+
}
|
|
113
|
+
this.render();
|
|
114
|
+
}
|
|
115
|
+
render() {
|
|
116
|
+
var _a;
|
|
117
|
+
const Component = this.component;
|
|
118
|
+
const props = this.props;
|
|
119
|
+
if (isClassComponent(Component) || isForwardRefComponent(Component)) {
|
|
120
|
+
props.ref = (ref) => {
|
|
121
|
+
this.ref = ref;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
this.reactElement = React__default["default"].createElement(Component, { ...props });
|
|
125
|
+
if ((_a = this.editor) === null || _a === void 0 ? void 0 : _a.contentComponent) {
|
|
126
|
+
this.editor.contentComponent.setState({
|
|
127
|
+
renderers: this.editor.contentComponent.state.renderers.set(this.id, this),
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
updateProps(props = {}) {
|
|
132
|
+
this.props = {
|
|
133
|
+
...this.props,
|
|
134
|
+
...props,
|
|
135
|
+
};
|
|
136
|
+
this.render();
|
|
137
|
+
}
|
|
138
|
+
destroy() {
|
|
139
|
+
var _a;
|
|
140
|
+
if ((_a = this.editor) === null || _a === void 0 ? void 0 : _a.contentComponent) {
|
|
141
|
+
const { renderers } = this.editor.contentComponent.state;
|
|
142
|
+
renderers.delete(this.id);
|
|
143
|
+
this.editor.contentComponent.setState({
|
|
144
|
+
renderers,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
12
148
|
}
|
|
13
149
|
|
|
14
|
-
|
|
150
|
+
const ReactNodeViewContext = React.createContext({
|
|
151
|
+
onDragStart: undefined,
|
|
152
|
+
});
|
|
153
|
+
const useReactNodeView = () => React.useContext(ReactNodeViewContext);
|
|
154
|
+
|
|
155
|
+
class ReactNodeView extends core.NodeView {
|
|
156
|
+
mount() {
|
|
157
|
+
const props = {
|
|
158
|
+
editor: this.editor,
|
|
159
|
+
node: this.node,
|
|
160
|
+
decorations: this.decorations,
|
|
161
|
+
selected: false,
|
|
162
|
+
extension: this.extension,
|
|
163
|
+
getPos: () => this.getPos(),
|
|
164
|
+
updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
|
|
165
|
+
deleteNode: () => this.deleteNode(),
|
|
166
|
+
};
|
|
167
|
+
if (!this.component.displayName) {
|
|
168
|
+
const capitalizeFirstChar = (string) => {
|
|
169
|
+
return string.charAt(0).toUpperCase() + string.substring(1);
|
|
170
|
+
};
|
|
171
|
+
this.component.displayName = capitalizeFirstChar(this.extension.name);
|
|
172
|
+
}
|
|
173
|
+
const ReactNodeViewProvider = componentProps => {
|
|
174
|
+
const Component = this.component;
|
|
175
|
+
const onDragStart = this.onDragStart.bind(this);
|
|
176
|
+
const nodeViewContentRef = element => {
|
|
177
|
+
if (element
|
|
178
|
+
&& this.contentDOMElement
|
|
179
|
+
&& element.firstChild !== this.contentDOMElement) {
|
|
180
|
+
element.appendChild(this.contentDOMElement);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
return (React__default["default"].createElement(ReactNodeViewContext.Provider, { value: { onDragStart, nodeViewContentRef } },
|
|
184
|
+
React__default["default"].createElement(Component, { ...componentProps })));
|
|
185
|
+
};
|
|
186
|
+
ReactNodeViewProvider.displayName = 'ReactNodeView';
|
|
187
|
+
this.contentDOMElement = this.node.isLeaf
|
|
188
|
+
? null
|
|
189
|
+
: document.createElement(this.node.isInline ? 'span' : 'div');
|
|
190
|
+
if (this.contentDOMElement) {
|
|
191
|
+
// For some reason the whiteSpace prop is not inherited properly in Chrome and Safari
|
|
192
|
+
// With this fix it seems to work fine
|
|
193
|
+
// See: https://github.com/ueberdosis/tiptap/issues/1197
|
|
194
|
+
this.contentDOMElement.style.whiteSpace = 'inherit';
|
|
195
|
+
}
|
|
196
|
+
let as = this.node.isInline ? 'span' : 'div';
|
|
197
|
+
if (this.options.as) {
|
|
198
|
+
as = this.options.as;
|
|
199
|
+
}
|
|
200
|
+
this.renderer = new ReactRenderer(ReactNodeViewProvider, {
|
|
201
|
+
editor: this.editor,
|
|
202
|
+
props,
|
|
203
|
+
as,
|
|
204
|
+
className: `node-${this.node.type.name}`,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
get dom() {
|
|
208
|
+
var _a;
|
|
209
|
+
if (this.renderer.element.firstElementChild
|
|
210
|
+
&& !((_a = this.renderer.element.firstElementChild) === null || _a === void 0 ? void 0 : _a.hasAttribute('data-node-view-wrapper'))) {
|
|
211
|
+
throw Error('Please use the NodeViewWrapper component for your node view.');
|
|
212
|
+
}
|
|
213
|
+
return this.renderer.element;
|
|
214
|
+
}
|
|
215
|
+
get contentDOM() {
|
|
216
|
+
if (this.node.isLeaf) {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
return this.contentDOMElement;
|
|
220
|
+
}
|
|
221
|
+
update(node, decorations) {
|
|
222
|
+
const updateProps = (props) => {
|
|
223
|
+
this.renderer.updateProps(props);
|
|
224
|
+
};
|
|
225
|
+
if (node.type !== this.node.type) {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
if (typeof this.options.update === 'function') {
|
|
229
|
+
const oldNode = this.node;
|
|
230
|
+
const oldDecorations = this.decorations;
|
|
231
|
+
this.node = node;
|
|
232
|
+
this.decorations = decorations;
|
|
233
|
+
return this.options.update({
|
|
234
|
+
oldNode,
|
|
235
|
+
oldDecorations,
|
|
236
|
+
newNode: node,
|
|
237
|
+
newDecorations: decorations,
|
|
238
|
+
updateProps: () => updateProps({ node, decorations }),
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
if (node === this.node && this.decorations === decorations) {
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
this.node = node;
|
|
245
|
+
this.decorations = decorations;
|
|
246
|
+
updateProps({ node, decorations });
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
selectNode() {
|
|
250
|
+
this.renderer.updateProps({
|
|
251
|
+
selected: true,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
deselectNode() {
|
|
255
|
+
this.renderer.updateProps({
|
|
256
|
+
selected: false,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
destroy() {
|
|
260
|
+
this.renderer.destroy();
|
|
261
|
+
this.contentDOMElement = null;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function ReactNodeViewRenderer(component, options) {
|
|
265
|
+
return (props) => {
|
|
266
|
+
// try to get the parent component
|
|
267
|
+
// this is important for vue devtools to show the component hierarchy correctly
|
|
268
|
+
// maybe it’s `undefined` because <editor-content> isn’t rendered yet
|
|
269
|
+
if (!props.editor.contentComponent) {
|
|
270
|
+
return {};
|
|
271
|
+
}
|
|
272
|
+
return new ReactNodeView(component, props, options);
|
|
273
|
+
};
|
|
15
274
|
}
|
|
16
275
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
276
|
+
const Portals = ({ renderers }) => {
|
|
277
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null, Array.from(renderers).map(([key, renderer]) => {
|
|
278
|
+
return ReactDOM__default["default"].createPortal(renderer.reactElement, renderer.element, key);
|
|
279
|
+
})));
|
|
280
|
+
};
|
|
281
|
+
class PureEditorContent extends React__default["default"].Component {
|
|
282
|
+
constructor(props) {
|
|
283
|
+
super(props);
|
|
284
|
+
this.editorContentRef = React__default["default"].createRef();
|
|
285
|
+
this.state = {
|
|
286
|
+
renderers: new Map(),
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
componentDidMount() {
|
|
290
|
+
this.init();
|
|
291
|
+
}
|
|
292
|
+
componentDidUpdate() {
|
|
293
|
+
this.init();
|
|
294
|
+
}
|
|
295
|
+
init() {
|
|
296
|
+
const { editor } = this.props;
|
|
297
|
+
if (editor && editor.options.element) {
|
|
298
|
+
if (editor.contentComponent) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const element = this.editorContentRef.current;
|
|
302
|
+
element.append(...editor.options.element.childNodes);
|
|
303
|
+
editor.setOptions({
|
|
304
|
+
element,
|
|
305
|
+
});
|
|
306
|
+
editor.contentComponent = this;
|
|
307
|
+
editor.createNodeViews();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
componentWillUnmount() {
|
|
311
|
+
const { editor } = this.props;
|
|
312
|
+
if (!editor) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (!editor.isDestroyed) {
|
|
316
|
+
editor.view.setProps({
|
|
317
|
+
nodeViews: {},
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
editor.contentComponent = null;
|
|
321
|
+
if (!editor.options.element.firstChild) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
const newElement = document.createElement('div');
|
|
325
|
+
newElement.append(...editor.options.element.childNodes);
|
|
326
|
+
editor.setOptions({
|
|
327
|
+
element: newElement,
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
render() {
|
|
331
|
+
const { editor, ...rest } = this.props;
|
|
332
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
333
|
+
React__default["default"].createElement("div", { ref: this.editorContentRef, ...rest }),
|
|
334
|
+
React__default["default"].createElement(Portals, { renderers: this.state.renderers })));
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
const EditorContent = React__default["default"].memo(PureEditorContent);
|
|
338
|
+
|
|
339
|
+
const NodeViewWrapper = React__default["default"].forwardRef((props, ref) => {
|
|
340
|
+
const { onDragStart } = useReactNodeView();
|
|
341
|
+
const Tag = props.as || 'div';
|
|
342
|
+
return (React__default["default"].createElement(Tag, { ...props, ref: ref, "data-node-view-wrapper": "", onDragStart: onDragStart, style: {
|
|
343
|
+
...props.style,
|
|
344
|
+
whiteSpace: 'normal',
|
|
345
|
+
} }));
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
const NodeViewContent = props => {
|
|
349
|
+
const Tag = props.as || 'div';
|
|
350
|
+
const { nodeViewContentRef } = useReactNodeView();
|
|
351
|
+
return (React__default["default"].createElement(Tag, { ...props, ref: nodeViewContentRef, "data-node-view-content": "", style: {
|
|
352
|
+
...props.style,
|
|
353
|
+
whiteSpace: 'pre-wrap',
|
|
354
|
+
} }));
|
|
42
355
|
};
|
|
43
356
|
|
|
357
|
+
exports.BubbleMenu = BubbleMenu;
|
|
44
358
|
exports.Editor = Editor;
|
|
45
|
-
exports.
|
|
359
|
+
exports.EditorContent = EditorContent;
|
|
360
|
+
exports.FloatingMenu = FloatingMenu;
|
|
361
|
+
exports.NodeViewContent = NodeViewContent;
|
|
362
|
+
exports.NodeViewWrapper = NodeViewWrapper;
|
|
363
|
+
exports.PureEditorContent = PureEditorContent;
|
|
46
364
|
exports.ReactNodeViewRenderer = ReactNodeViewRenderer;
|
|
47
365
|
exports.ReactRenderer = ReactRenderer;
|
|
48
366
|
exports.useEditor = useEditor;
|
|
49
367
|
Object.keys(core).forEach(function (k) {
|
|
50
368
|
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
51
369
|
enumerable: true,
|
|
52
|
-
get: function () {
|
|
53
|
-
return core[k];
|
|
54
|
-
}
|
|
370
|
+
get: function () { return core[k]; }
|
|
55
371
|
});
|
|
56
372
|
});
|
|
57
373
|
|
|
58
374
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
59
375
|
|
|
60
|
-
}))
|
|
376
|
+
}));
|
|
61
377
|
//# sourceMappingURL=tiptap-react.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-react.umd.js","sources":["../src/ReactRenderer.ts","../src/ReactNodeViewRenderer.ts","../src/components/Editor.jsx"],"sourcesContent":["export default class ReactRenderer {}\n","export default class ReactNodeViewRenderer {}\n","import React, {\n useState, useRef, useEffect, createContext, useContext,\n} from 'react'\nimport { Editor as Tiptap } from '@tiptap/core'\n\nexport const EditorContext = createContext({})\n\nexport const useEditor = () => useContext(EditorContext)\n\nexport const Editor = ({\n value, onChange, children, ...props\n}) => {\n const [editor, setEditor] = useState(null)\n const editorRef = useRef(null)\n\n useEffect(() => {\n const e = new Tiptap({\n element: editorRef.current,\n content: value,\n ...props,\n }).on('transaction', () => {\n onChange(e.getJSON())\n })\n\n setEditor(e)\n }, [])\n\n return (\n <EditorContext.Provider value={editor}>\n {editorRef.current && children}\n <div ref={editorRef} />\n </EditorContext.Provider>\n )\n}\n"],"names":["EditorContext","createContext","useEditor","useContext","Editor","value","onChange","children","props","editor","setEditor","useState","editorRef","useRef","useEffect","e","Tiptap","element","current","content","on","getJSON","React"],"mappings":";;;;;;;;;;QAAqB,aAAa;;;QCAb,qBAAqB;;;QCK7BA,aAAa,gBAAGC,mBAAa,CAAC,EAAD;QAE7BC,SAAS,GAAG,MAAMC,gBAAU,CAACH,aAAD;QAE5BI,MAAM,GAAG,CAAC;EACrBC,EAAAA,KADqB;EACdC,EAAAA,QADc;EACJC,EAAAA,QADI;EACM,KAAGC;EADT,CAAD,KAEhB;EACJ,QAAM,CAACC,MAAD,EAASC,SAAT,IAAsBC,cAAQ,CAAC,IAAD,CAApC;EACA,QAAMC,SAAS,GAAGC,YAAM,CAAC,IAAD,CAAxB;EAEAC,EAAAA,eAAS,CAAC,MAAM;EACd,UAAMC,CAAC,GAAG,IAAIC,WAAJ,CAAW;EACnBC,MAAAA,OAAO,EAAEL,SAAS,CAACM,OADA;EAEnBC,MAAAA,OAAO,EAAEd,KAFU;EAGnB,SAAGG;EAHgB,KAAX,EAIPY,EAJO,CAIJ,aAJI,EAIW,MAAM;EACzBd,MAAAA,QAAQ,CAACS,CAAC,CAACM,OAAF,EAAD,CAAR;EACD,KANS,CAAV;EAQAX,IAAAA,SAAS,CAACK,CAAD,CAAT;EACD,GAVQ,EAUN,EAVM,CAAT;EAYA,sBACEO,wCAAC,aAAD,CAAe,QAAf;EAAwB,IAAA,KAAK,EAAEb;EAA/B,KACGG,SAAS,CAACM,OAAV,IAAqBX,QADxB,eAEEe;EAAK,IAAA,GAAG,EAAEV;EAAV,IAFF,CADF;EAMD;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"tiptap-react.umd.js","sources":["../src/BubbleMenu.tsx","../src/Editor.ts","../src/FloatingMenu.tsx","../src/useEditor.ts","../src/ReactRenderer.tsx","../src/useReactNodeView.ts","../src/ReactNodeViewRenderer.tsx","../src/EditorContent.tsx","../src/NodeViewWrapper.tsx","../src/NodeViewContent.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react'\nimport { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type BubbleMenuProps = Omit<Optional<BubbleMenuPluginProps, 'pluginKey'>, 'element'> & {\n className?: string,\n}\n\nexport const BubbleMenu: React.FC<BubbleMenuProps> = props => {\n const element = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (!element.current) {\n return\n }\n\n const {\n pluginKey = 'bubbleMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n editor.registerPlugin(BubbleMenuPlugin({\n pluginKey,\n editor,\n element: element.current as HTMLElement,\n tippyOptions,\n shouldShow,\n }))\n\n return () => {\n editor.unregisterPlugin(pluginKey)\n }\n }, [\n props.editor,\n element.current,\n ])\n\n return (\n <div ref={element} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import React from 'react'\nimport { Editor as CoreEditor } from '@tiptap/core'\nimport { EditorContentProps, EditorContentState } from './EditorContent'\n\nexport class Editor extends CoreEditor {\n public contentComponent: React.Component<EditorContentProps, EditorContentState> | null = null\n}\n","import React, { useEffect, useRef } from 'react'\nimport { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type FloatingMenuProps = Omit<Optional<FloatingMenuPluginProps, 'pluginKey'>, 'element'> & {\n className?: string,\n}\n\nexport const FloatingMenu: React.FC<FloatingMenuProps> = props => {\n const element = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (!element.current) {\n return\n }\n\n const {\n pluginKey = 'floatingMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n editor.registerPlugin(FloatingMenuPlugin({\n pluginKey,\n editor,\n element: element.current as HTMLElement,\n tippyOptions,\n shouldShow,\n }))\n\n return () => {\n editor.unregisterPlugin(pluginKey)\n }\n }, [\n props.editor,\n element.current,\n ])\n\n return (\n <div ref={element} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import { useState, useEffect, DependencyList } from 'react'\nimport { EditorOptions } from '@tiptap/core'\nimport { Editor } from './Editor'\n\nfunction useForceUpdate() {\n const [, setValue] = useState(0)\n\n return () => setValue(value => value + 1)\n}\n\nexport const useEditor = (options: Partial<EditorOptions> = {}, deps: DependencyList = []) => {\n const [editor, setEditor] = useState<Editor | null>(null)\n const forceUpdate = useForceUpdate()\n\n useEffect(() => {\n const instance = new Editor(options)\n\n setEditor(instance)\n\n instance.on('transaction', () => {\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n forceUpdate()\n })\n })\n })\n\n return () => {\n instance.destroy()\n }\n }, deps)\n\n return editor\n}\n","import React from 'react'\nimport { Editor } from '@tiptap/core'\nimport { Editor as ExtendedEditor } from './Editor'\n\nfunction isClassComponent(Component: any) {\n return !!(\n typeof Component === 'function'\n && Component.prototype\n && Component.prototype.isReactComponent\n )\n}\n\nfunction isForwardRefComponent(Component: any) {\n return !!(\n typeof Component === 'object'\n && Component.$$typeof?.toString() === 'Symbol(react.forward_ref)'\n )\n}\n\nexport interface ReactRendererOptions {\n editor: Editor,\n props?: Record<string, any>,\n as?: string,\n className?: string,\n}\n\ntype ComponentType<R> =\n | React.ComponentClass\n | React.FunctionComponent\n | React.ForwardRefExoticComponent<{ items: any[], command: any } & React.RefAttributes<R>>\n\nexport class ReactRenderer<R = unknown> {\n id: string\n\n editor: ExtendedEditor\n\n component: any\n\n element: Element\n\n props: Record<string, any>\n\n reactElement: React.ReactNode\n\n ref: R | null = null\n\n constructor(component: ComponentType<R>, {\n editor,\n props = {},\n as = 'div',\n className = '',\n }: ReactRendererOptions) {\n this.id = Math.floor(Math.random() * 0xFFFFFFFF).toString()\n this.component = component\n this.editor = editor as ExtendedEditor\n this.props = props\n this.element = document.createElement(as)\n this.element.classList.add('react-renderer')\n\n if (className) {\n this.element.classList.add(...className.split(' '))\n }\n\n this.render()\n }\n\n render(): void {\n const Component = this.component\n const props = this.props\n\n if (isClassComponent(Component) || isForwardRefComponent(Component)) {\n props.ref = (ref: R) => {\n this.ref = ref\n }\n }\n\n this.reactElement = <Component {...props } />\n\n if (this.editor?.contentComponent) {\n this.editor.contentComponent.setState({\n renderers: this.editor.contentComponent.state.renderers.set(\n this.id,\n this,\n ),\n })\n }\n }\n\n updateProps(props: Record<string, any> = {}): void {\n this.props = {\n ...this.props,\n ...props,\n }\n\n this.render()\n }\n\n destroy(): void {\n if (this.editor?.contentComponent) {\n const { renderers } = this.editor.contentComponent.state\n\n renderers.delete(this.id)\n\n this.editor.contentComponent.setState({\n renderers,\n })\n }\n }\n}\n","import { createContext, useContext } from 'react'\n\nexport interface ReactNodeViewContextProps {\n onDragStart: (event: DragEvent) => void,\n nodeViewContentRef: (element: HTMLElement | null) => void,\n}\n\nexport const ReactNodeViewContext = createContext<Partial<ReactNodeViewContextProps>>({\n onDragStart: undefined,\n})\n\nexport const useReactNodeView = () => useContext(ReactNodeViewContext)\n","import React from 'react'\nimport {\n NodeView,\n NodeViewProps,\n NodeViewRenderer,\n NodeViewRendererProps,\n NodeViewRendererOptions,\n} from '@tiptap/core'\nimport { Decoration, NodeView as ProseMirrorNodeView } from 'prosemirror-view'\nimport { Node as ProseMirrorNode } from 'prosemirror-model'\nimport { Editor } from './Editor'\nimport { ReactRenderer } from './ReactRenderer'\nimport { ReactNodeViewContext, ReactNodeViewContextProps } from './useReactNodeView'\n\nexport interface ReactNodeViewRendererOptions extends NodeViewRendererOptions {\n update: ((props: {\n oldNode: ProseMirrorNode,\n oldDecorations: Decoration[],\n newNode: ProseMirrorNode,\n newDecorations: Decoration[],\n updateProps: () => void,\n }) => boolean) | null,\n as?: string,\n}\n\nclass ReactNodeView extends NodeView<React.FunctionComponent, Editor, ReactNodeViewRendererOptions> {\n\n renderer!: ReactRenderer\n\n contentDOMElement!: HTMLElement | null\n\n mount() {\n const props: NodeViewProps = {\n editor: this.editor,\n node: this.node,\n decorations: this.decorations,\n selected: false,\n extension: this.extension,\n getPos: () => this.getPos(),\n updateAttributes: (attributes = {}) => this.updateAttributes(attributes),\n deleteNode: () => this.deleteNode(),\n }\n\n if (!(this.component as any).displayName) {\n const capitalizeFirstChar = (string: string): string => {\n return string.charAt(0).toUpperCase() + string.substring(1)\n }\n\n this.component.displayName = capitalizeFirstChar(this.extension.name)\n }\n\n const ReactNodeViewProvider: React.FunctionComponent = componentProps => {\n const Component = this.component\n const onDragStart = this.onDragStart.bind(this)\n const nodeViewContentRef: ReactNodeViewContextProps['nodeViewContentRef'] = element => {\n if (\n element\n && this.contentDOMElement\n && element.firstChild !== this.contentDOMElement\n ) {\n element.appendChild(this.contentDOMElement)\n }\n }\n\n return (\n <ReactNodeViewContext.Provider value={{ onDragStart, nodeViewContentRef }}>\n <Component {...componentProps} />\n </ReactNodeViewContext.Provider>\n )\n }\n\n ReactNodeViewProvider.displayName = 'ReactNodeView'\n\n this.contentDOMElement = this.node.isLeaf\n ? null\n : document.createElement(this.node.isInline ? 'span' : 'div')\n\n if (this.contentDOMElement) {\n // For some reason the whiteSpace prop is not inherited properly in Chrome and Safari\n // With this fix it seems to work fine\n // See: https://github.com/ueberdosis/tiptap/issues/1197\n this.contentDOMElement.style.whiteSpace = 'inherit'\n }\n\n let as = this.node.isInline ? 'span' : 'div'\n\n if (this.options.as) {\n as = this.options.as\n }\n\n this.renderer = new ReactRenderer(ReactNodeViewProvider, {\n editor: this.editor,\n props,\n as,\n className: `node-${this.node.type.name}`,\n })\n }\n\n get dom() {\n if (\n this.renderer.element.firstElementChild\n && !this.renderer.element.firstElementChild?.hasAttribute('data-node-view-wrapper')\n ) {\n throw Error('Please use the NodeViewWrapper component for your node view.')\n }\n\n return this.renderer.element\n }\n\n get contentDOM() {\n if (this.node.isLeaf) {\n return null\n }\n\n return this.contentDOMElement\n }\n\n update(node: ProseMirrorNode, decorations: Decoration[]) {\n const updateProps = (props?: Record<string, any>) => {\n this.renderer.updateProps(props)\n }\n\n if (node.type !== this.node.type) {\n return false\n }\n\n if (typeof this.options.update === 'function') {\n const oldNode = this.node\n const oldDecorations = this.decorations\n\n this.node = node\n this.decorations = decorations\n\n return this.options.update({\n oldNode,\n oldDecorations,\n newNode: node,\n newDecorations: decorations,\n updateProps: () => updateProps({ node, decorations }),\n })\n }\n\n if (node === this.node && this.decorations === decorations) {\n return true\n }\n\n this.node = node\n this.decorations = decorations\n\n updateProps({ node, decorations })\n\n return true\n }\n\n selectNode() {\n this.renderer.updateProps({\n selected: true,\n })\n }\n\n deselectNode() {\n this.renderer.updateProps({\n selected: false,\n })\n }\n\n destroy() {\n this.renderer.destroy()\n this.contentDOMElement = null\n }\n}\n\nexport function ReactNodeViewRenderer(component: any, options?: Partial<ReactNodeViewRendererOptions>): NodeViewRenderer {\n return (props: NodeViewRendererProps) => {\n // try to get the parent component\n // this is important for vue devtools to show the component hierarchy correctly\n // maybe it’s `undefined` because <editor-content> isn’t rendered yet\n if (!(props.editor as Editor).contentComponent) {\n return {}\n }\n\n return new ReactNodeView(component, props, options) as ProseMirrorNodeView\n }\n}\n","import React, { HTMLProps } from 'react'\nimport ReactDOM from 'react-dom'\nimport { Editor } from './Editor'\nimport { ReactRenderer } from './ReactRenderer'\n\nconst Portals: React.FC<{ renderers: Map<string, ReactRenderer> }> = ({ renderers }) => {\n return (\n <>\n {Array.from(renderers).map(([key, renderer]) => {\n return ReactDOM.createPortal(\n renderer.reactElement,\n renderer.element,\n key,\n )\n })}\n </>\n )\n}\n\nexport interface EditorContentProps extends HTMLProps<HTMLDivElement> {\n editor: Editor | null,\n}\n\nexport interface EditorContentState {\n renderers: Map<string, ReactRenderer>\n}\n\nexport class PureEditorContent extends React.Component<EditorContentProps, EditorContentState> {\n editorContentRef: React.RefObject<any>\n\n constructor(props: EditorContentProps) {\n super(props)\n this.editorContentRef = React.createRef()\n\n this.state = {\n renderers: new Map(),\n }\n }\n\n componentDidMount() {\n this.init()\n }\n\n componentDidUpdate() {\n this.init()\n }\n\n init() {\n const { editor } = this.props\n\n if (editor && editor.options.element) {\n if (editor.contentComponent) {\n return\n }\n\n const element = this.editorContentRef.current\n\n element.append(...editor.options.element.childNodes)\n\n editor.setOptions({\n element,\n })\n\n editor.contentComponent = this\n\n editor.createNodeViews()\n }\n }\n\n componentWillUnmount() {\n const { editor } = this.props\n\n if (!editor) {\n return\n }\n\n if (!editor.isDestroyed) {\n editor.view.setProps({\n nodeViews: {},\n })\n }\n\n editor.contentComponent = null\n\n if (!editor.options.element.firstChild) {\n return\n }\n\n const newElement = document.createElement('div')\n\n newElement.append(...editor.options.element.childNodes)\n\n editor.setOptions({\n element: newElement,\n })\n }\n\n render() {\n const { editor, ...rest } = this.props\n\n return (\n <>\n <div ref={this.editorContentRef} {...rest} />\n <Portals renderers={this.state.renderers} />\n </>\n )\n }\n}\n\nexport const EditorContent = React.memo(PureEditorContent)\n","import React from 'react'\nimport { useReactNodeView } from './useReactNodeView'\n\nexport interface NodeViewWrapperProps {\n [key: string]: any,\n as?: React.ElementType,\n}\n\nexport const NodeViewWrapper: React.FC<NodeViewWrapperProps> = React.forwardRef((props, ref) => {\n const { onDragStart } = useReactNodeView()\n const Tag = props.as || 'div'\n\n return (\n <Tag\n {...props}\n ref={ref}\n data-node-view-wrapper=\"\"\n onDragStart={onDragStart}\n style={{\n ...props.style,\n whiteSpace: 'normal',\n }}\n />\n )\n})\n","import React from 'react'\nimport { useReactNodeView } from './useReactNodeView'\n\nexport interface NodeViewContentProps {\n [key: string]: any,\n as?: React.ElementType,\n}\n\nexport const NodeViewContent: React.FC<NodeViewContentProps> = props => {\n const Tag = props.as || 'div'\n const { nodeViewContentRef } = useReactNodeView()\n\n return (\n <Tag\n {...props}\n ref={nodeViewContentRef}\n data-node-view-content=\"\"\n style={{\n ...props.style,\n whiteSpace: 'pre-wrap',\n }}\n />\n )\n}\n"],"names":["useRef","useEffect","BubbleMenuPlugin","React","CoreEditor","FloatingMenuPlugin","useState","createContext","useContext","NodeView","ReactDOM"],"mappings":";;;;;;;;;;;QASa,UAAU,GAA8B,KAAK;MACxD,MAAM,OAAO,GAAGA,YAAM,CAAiB,IAAI,CAAC,CAAA;MAE5CC,eAAS,CAAC;UACR,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;cACpB,OAAM;WACP;UAED,MAAM,EACJ,SAAS,GAAG,YAAY,EACxB,MAAM,EACN,YAAY,GAAG,EAAE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,QACEA,wCAAC,GAAG,OACE,KAAK,EACT,GAAG,EAAE,kBAAkB,4BACA,EAAE,EACzB,KAAK,EAAE;cACL,GAAG,KAAK,CAAC,KAAK;cACd,UAAU,EAAE,UAAU;WACvB,GACD,EACH;EACH;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/react",
|
|
3
3
|
"description": "React components for tiptap",
|
|
4
|
-
"version": "2.0.0-
|
|
4
|
+
"version": "2.0.0-beta.101",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -15,18 +15,31 @@
|
|
|
15
15
|
"main": "dist/tiptap-react.cjs.js",
|
|
16
16
|
"umd": "dist/tiptap-react.umd.js",
|
|
17
17
|
"module": "dist/tiptap-react.esm.js",
|
|
18
|
-
"unpkg": "dist/tiptap-react.bundle.umd.min.js",
|
|
19
18
|
"types": "dist/packages/react/src/index.d.ts",
|
|
20
19
|
"files": [
|
|
21
20
|
"src",
|
|
22
21
|
"dist"
|
|
23
22
|
],
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/react": "^17.0.37",
|
|
25
|
+
"@types/react-dom": "^17.0.11",
|
|
26
|
+
"react": "^17.0.0",
|
|
27
|
+
"react-dom": "^17.0.0"
|
|
28
|
+
},
|
|
24
29
|
"peerDependencies": {
|
|
25
|
-
"@tiptap/core": "^2.0.0-
|
|
26
|
-
"react": "^17.0.
|
|
30
|
+
"@tiptap/core": "^2.0.0-beta.1",
|
|
31
|
+
"react": "^17.0.0",
|
|
32
|
+
"react-dom": "^17.0.0"
|
|
27
33
|
},
|
|
28
34
|
"dependencies": {
|
|
29
|
-
"
|
|
35
|
+
"@tiptap/extension-bubble-menu": "^2.0.0-beta.52",
|
|
36
|
+
"@tiptap/extension-floating-menu": "^2.0.0-beta.47",
|
|
37
|
+
"prosemirror-view": "^1.23.3"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/ueberdosis/tiptap",
|
|
42
|
+
"directory": "packages/react"
|
|
30
43
|
},
|
|
31
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "73fc527be900b5bc8ac90894118604693727a7e9"
|
|
32
45
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react'
|
|
2
|
+
import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'
|
|
3
|
+
|
|
4
|
+
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>
|
|
5
|
+
|
|
6
|
+
export type BubbleMenuProps = Omit<Optional<BubbleMenuPluginProps, 'pluginKey'>, 'element'> & {
|
|
7
|
+
className?: string,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const BubbleMenu: React.FC<BubbleMenuProps> = props => {
|
|
11
|
+
const element = useRef<HTMLDivElement>(null)
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (!element.current) {
|
|
15
|
+
return
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
pluginKey = 'bubbleMenu',
|
|
20
|
+
editor,
|
|
21
|
+
tippyOptions = {},
|
|
22
|
+
shouldShow = null,
|
|
23
|
+
} = props
|
|
24
|
+
|
|
25
|
+
editor.registerPlugin(BubbleMenuPlugin({
|
|
26
|
+
pluginKey,
|
|
27
|
+
editor,
|
|
28
|
+
element: element.current as HTMLElement,
|
|
29
|
+
tippyOptions,
|
|
30
|
+
shouldShow,
|
|
31
|
+
}))
|
|
32
|
+
|
|
33
|
+
return () => {
|
|
34
|
+
editor.unregisterPlugin(pluginKey)
|
|
35
|
+
}
|
|
36
|
+
}, [
|
|
37
|
+
props.editor,
|
|
38
|
+
element.current,
|
|
39
|
+
])
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div ref={element} className={props.className} style={{ visibility: 'hidden' }}>
|
|
43
|
+
{props.children}
|
|
44
|
+
</div>
|
|
45
|
+
)
|
|
46
|
+
}
|
package/src/Editor.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Editor as CoreEditor } from '@tiptap/core'
|
|
3
|
+
import { EditorContentProps, EditorContentState } from './EditorContent'
|
|
4
|
+
|
|
5
|
+
export class Editor extends CoreEditor {
|
|
6
|
+
public contentComponent: React.Component<EditorContentProps, EditorContentState> | null = null
|
|
7
|
+
}
|