@tiptap/react 2.0.0-beta.99 → 2.0.0-rc.2
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 +3 -3
- package/dist/{tiptap-react.cjs.js → index.cjs} +229 -153
- package/dist/index.cjs.map +1 -0
- package/dist/{tiptap-react.esm.js → index.js} +229 -153
- package/dist/index.js.map +1 -0
- package/dist/{tiptap-react.umd.js → index.umd.js} +230 -154
- package/dist/index.umd.js.map +1 -0
- package/dist/packages/react/src/BubbleMenu.d.ts +4 -2
- package/dist/packages/react/src/Editor.d.ts +8 -2
- package/dist/packages/react/src/EditorContent.d.ts +5 -1
- package/dist/packages/react/src/FloatingMenu.d.ts +3 -2
- package/dist/packages/react/src/ReactNodeViewRenderer.d.ts +4 -2
- package/dist/packages/react/src/ReactRenderer.d.ts +5 -7
- package/dist/packages/react/src/index.d.ts +6 -6
- package/dist/packages/react/src/useEditor.d.ts +1 -1
- package/package.json +30 -16
- package/src/BubbleMenu.tsx +24 -24
- package/src/Editor.ts +9 -2
- package/src/EditorContent.tsx +51 -11
- package/src/FloatingMenu.tsx +18 -12
- package/src/NodeViewContent.tsx +2 -1
- package/src/NodeViewWrapper.tsx +2 -1
- package/src/ReactNodeViewRenderer.tsx +42 -27
- package/src/ReactRenderer.tsx +18 -24
- package/src/index.ts +6 -6
- package/src/useEditor.ts +68 -2
- package/LICENSE.md +0 -21
- package/dist/packages/core/src/CommandManager.d.ts +0 -20
- package/dist/packages/core/src/Editor.d.ts +0 -147
- package/dist/packages/core/src/EventEmitter.d.ts +0 -11
- package/dist/packages/core/src/Extension.d.ts +0 -227
- package/dist/packages/core/src/ExtensionManager.d.ts +0 -18
- package/dist/packages/core/src/InputRule.d.ts +0 -42
- package/dist/packages/core/src/Mark.d.ts +0 -319
- package/dist/packages/core/src/Node.d.ts +0 -388
- package/dist/packages/core/src/NodeView.d.ts +0 -27
- package/dist/packages/core/src/PasteRule.d.ts +0 -42
- package/dist/packages/core/src/Tracker.d.ts +0 -11
- package/dist/packages/core/src/commands/blur.d.ts +0 -12
- package/dist/packages/core/src/commands/clearContent.d.ts +0 -12
- package/dist/packages/core/src/commands/clearNodes.d.ts +0 -12
- package/dist/packages/core/src/commands/command.d.ts +0 -12
- package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -12
- package/dist/packages/core/src/commands/deleteNode.d.ts +0 -13
- package/dist/packages/core/src/commands/deleteRange.d.ts +0 -12
- package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -12
- package/dist/packages/core/src/commands/enter.d.ts +0 -12
- package/dist/packages/core/src/commands/exitCode.d.ts +0 -12
- package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -13
- package/dist/packages/core/src/commands/first.d.ts +0 -12
- package/dist/packages/core/src/commands/focus.d.ts +0 -14
- package/dist/packages/core/src/commands/forEach.d.ts +0 -14
- package/dist/packages/core/src/commands/insertContent.d.ts +0 -16
- package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -16
- package/dist/packages/core/src/commands/joinBackward.d.ts +0 -12
- package/dist/packages/core/src/commands/joinForward.d.ts +0 -12
- package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -12
- package/dist/packages/core/src/commands/lift.d.ts +0 -13
- package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -12
- package/dist/packages/core/src/commands/liftListItem.d.ts +0 -13
- package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -12
- package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -13
- package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -12
- package/dist/packages/core/src/commands/selectAll.d.ts +0 -12
- package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -12
- package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -12
- package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -12
- package/dist/packages/core/src/commands/setContent.d.ts +0 -13
- package/dist/packages/core/src/commands/setMark.d.ts +0 -13
- package/dist/packages/core/src/commands/setMeta.d.ts +0 -12
- package/dist/packages/core/src/commands/setNode.d.ts +0 -13
- package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -12
- package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -12
- package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -13
- package/dist/packages/core/src/commands/splitBlock.d.ts +0 -14
- package/dist/packages/core/src/commands/splitListItem.d.ts +0 -13
- package/dist/packages/core/src/commands/toggleList.d.ts +0 -13
- package/dist/packages/core/src/commands/toggleMark.d.ts +0 -18
- package/dist/packages/core/src/commands/toggleNode.d.ts +0 -13
- package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -13
- package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -12
- package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -12
- package/dist/packages/core/src/commands/unsetMark.d.ts +0 -18
- package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -13
- package/dist/packages/core/src/commands/wrapIn.d.ts +0 -13
- package/dist/packages/core/src/commands/wrapInList.d.ts +0 -13
- package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -2
- package/dist/packages/core/src/extensions/commands.d.ts +0 -98
- package/dist/packages/core/src/extensions/editable.d.ts +0 -2
- package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
- package/dist/packages/core/src/extensions/index.d.ts +0 -6
- package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
- package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
- package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -7
- package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -5
- package/dist/packages/core/src/helpers/createDocument.d.ts +0 -3
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -7
- package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -2
- package/dist/packages/core/src/helpers/findChildren.d.ts +0 -3
- package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -6
- package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -9
- package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -8
- package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -2
- package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -2
- package/dist/packages/core/src/helpers/generateText.d.ts +0 -5
- package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
- package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
- package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -2
- package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
- package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
- package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
- package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
- package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
- package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getSchema.d.ts +0 -3
- package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -3
- package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -2
- package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -2
- package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -2
- package/dist/packages/core/src/helpers/getText.d.ts +0 -6
- package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -6
- package/dist/packages/core/src/helpers/getTextSeralizersFromSchema.d.ts +0 -3
- package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
- package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
- package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
- package/dist/packages/core/src/helpers/isList.d.ts +0 -2
- package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
- package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
- package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -2
- package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
- package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
- package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
- package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
- package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
- package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
- package/dist/packages/core/src/index.d.ts +0 -60
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -12
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -12
- package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -9
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -14
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -23
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -12
- package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -9
- package/dist/packages/core/src/style.d.ts +0 -1
- package/dist/packages/core/src/types.d.ts +0 -210
- package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
- package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
- package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
- package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
- package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/isClass.d.ts +0 -1
- package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
- package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
- package/dist/packages/core/src/utilities/isObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
- package/dist/packages/core/src/utilities/isString.d.ts +0 -1
- package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
- package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
- package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
- package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
- package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
- package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
- package/dist/packages/extension-blockquote/src/blockquote.d.ts +0 -24
- package/dist/packages/extension-blockquote/src/index.d.ts +0 -3
- package/dist/packages/extension-bold/src/bold.d.ts +0 -27
- package/dist/packages/extension-bold/src/index.d.ts +0 -3
- package/dist/packages/extension-bubble-menu/src/bubble-menu-plugin.d.ts +0 -43
- package/dist/packages/extension-bubble-menu/src/bubble-menu.d.ts +0 -6
- package/dist/packages/extension-bubble-menu/src/index.d.ts +0 -4
- package/dist/packages/extension-bullet-list/src/bullet-list.d.ts +0 -17
- package/dist/packages/extension-bullet-list/src/index.d.ts +0 -3
- package/dist/packages/extension-character-count/src/character-count.d.ts +0 -28
- package/dist/packages/extension-character-count/src/index.d.ts +0 -3
- package/dist/packages/extension-code/src/code.d.ts +0 -25
- package/dist/packages/extension-code/src/index.d.ts +0 -3
- package/dist/packages/extension-code-block/src/code-block.d.ts +0 -26
- package/dist/packages/extension-code-block/src/index.d.ts +0 -3
- package/dist/packages/extension-code-block-lowlight/src/code-block-lowlight.d.ts +0 -6
- package/dist/packages/extension-code-block-lowlight/src/index.d.ts +0 -3
- package/dist/packages/extension-code-block-lowlight/src/lowlight-plugin.d.ts +0 -6
- package/dist/packages/extension-collaboration/src/collaboration.d.ts +0 -30
- package/dist/packages/extension-collaboration/src/helpers/isChangeOrigin.d.ts +0 -2
- package/dist/packages/extension-collaboration/src/index.d.ts +0 -4
- package/dist/packages/extension-collaboration-cursor/src/collaboration-cursor.d.ts +0 -37
- package/dist/packages/extension-collaboration-cursor/src/index.d.ts +0 -3
- package/dist/packages/extension-color/src/color.d.ts +0 -20
- package/dist/packages/extension-color/src/index.d.ts +0 -3
- package/dist/packages/extension-document/src/document.d.ts +0 -2
- package/dist/packages/extension-document/src/index.d.ts +0 -3
- package/dist/packages/extension-dropcursor/src/dropcursor.d.ts +0 -7
- package/dist/packages/extension-dropcursor/src/index.d.ts +0 -3
- package/dist/packages/extension-floating-menu/src/floating-menu-plugin.d.ts +0 -40
- package/dist/packages/extension-floating-menu/src/floating-menu.d.ts +0 -6
- package/dist/packages/extension-floating-menu/src/index.d.ts +0 -4
- package/dist/packages/extension-focus/src/focus.d.ts +0 -6
- package/dist/packages/extension-focus/src/index.d.ts +0 -3
- package/dist/packages/extension-font-family/src/font-family.d.ts +0 -21
- package/dist/packages/extension-font-family/src/index.d.ts +0 -3
- package/dist/packages/extension-gapcursor/src/gapcursor.d.ts +0 -15
- package/dist/packages/extension-gapcursor/src/index.d.ts +0 -3
- package/dist/packages/extension-hard-break/src/hard-break.d.ts +0 -16
- package/dist/packages/extension-hard-break/src/index.d.ts +0 -3
- package/dist/packages/extension-heading/src/heading.d.ts +0 -26
- package/dist/packages/extension-heading/src/index.d.ts +0 -3
- package/dist/packages/extension-highlight/src/highlight.d.ts +0 -30
- package/dist/packages/extension-highlight/src/index.d.ts +0 -3
- package/dist/packages/extension-history/src/history.d.ts +0 -20
- package/dist/packages/extension-history/src/index.d.ts +0 -3
- package/dist/packages/extension-horizontal-rule/src/horizontal-rule.d.ts +0 -15
- package/dist/packages/extension-horizontal-rule/src/index.d.ts +0 -3
- package/dist/packages/extension-image/src/image.d.ts +0 -21
- package/dist/packages/extension-image/src/index.d.ts +0 -3
- package/dist/packages/extension-italic/src/index.d.ts +0 -3
- package/dist/packages/extension-italic/src/italic.d.ts +0 -27
- package/dist/packages/extension-link/src/helpers/autolink.d.ts +0 -7
- package/dist/packages/extension-link/src/helpers/clickHandler.d.ts +0 -7
- package/dist/packages/extension-link/src/helpers/pasteHandler.d.ts +0 -9
- package/dist/packages/extension-link/src/index.d.ts +0 -3
- package/dist/packages/extension-link/src/link.d.ts +0 -44
- package/dist/packages/extension-list-item/src/index.d.ts +0 -3
- package/dist/packages/extension-list-item/src/list-item.d.ts +0 -5
- package/dist/packages/extension-mention/src/index.d.ts +0 -3
- package/dist/packages/extension-mention/src/mention.d.ts +0 -14
- package/dist/packages/extension-ordered-list/src/index.d.ts +0 -3
- package/dist/packages/extension-ordered-list/src/ordered-list.d.ts +0 -17
- package/dist/packages/extension-paragraph/src/index.d.ts +0 -3
- package/dist/packages/extension-paragraph/src/paragraph.d.ts +0 -15
- package/dist/packages/extension-placeholder/src/index.d.ts +0 -3
- package/dist/packages/extension-placeholder/src/placeholder.d.ts +0 -15
- package/dist/packages/extension-strike/src/index.d.ts +0 -3
- package/dist/packages/extension-strike/src/strike.d.ts +0 -25
- package/dist/packages/extension-subscript/src/index.d.ts +0 -3
- package/dist/packages/extension-subscript/src/subscript.d.ts +0 -23
- package/dist/packages/extension-superscript/src/index.d.ts +0 -3
- package/dist/packages/extension-superscript/src/superscript.d.ts +0 -23
- package/dist/packages/extension-table/src/TableView.d.ts +0 -17
- package/dist/packages/extension-table/src/index.d.ts +0 -4
- package/dist/packages/extension-table/src/table.d.ts +0 -55
- package/dist/packages/extension-table/src/utilities/createCell.d.ts +0 -2
- package/dist/packages/extension-table/src/utilities/createTable.d.ts +0 -2
- package/dist/packages/extension-table/src/utilities/deleteTableWhenAllCellsSelected.d.ts +0 -2
- package/dist/packages/extension-table/src/utilities/getTableNodeTypes.d.ts +0 -4
- package/dist/packages/extension-table/src/utilities/isCellSelection.d.ts +0 -2
- package/dist/packages/extension-table-cell/src/index.d.ts +0 -3
- package/dist/packages/extension-table-cell/src/table-cell.d.ts +0 -5
- package/dist/packages/extension-table-header/src/index.d.ts +0 -3
- package/dist/packages/extension-table-header/src/table-header.d.ts +0 -5
- package/dist/packages/extension-table-row/src/index.d.ts +0 -3
- package/dist/packages/extension-table-row/src/table-row.d.ts +0 -5
- package/dist/packages/extension-task-item/src/index.d.ts +0 -3
- package/dist/packages/extension-task-item/src/task-item.d.ts +0 -7
- package/dist/packages/extension-task-list/src/index.d.ts +0 -3
- package/dist/packages/extension-task-list/src/task-list.d.ts +0 -16
- package/dist/packages/extension-text/src/index.d.ts +0 -3
- package/dist/packages/extension-text/src/text.d.ts +0 -2
- package/dist/packages/extension-text-align/src/index.d.ts +0 -3
- package/dist/packages/extension-text-align/src/text-align.d.ts +0 -21
- package/dist/packages/extension-text-style/src/index.d.ts +0 -3
- package/dist/packages/extension-text-style/src/text-style.d.ts +0 -15
- package/dist/packages/extension-typography/src/index.d.ts +0 -3
- package/dist/packages/extension-typography/src/typography.d.ts +0 -23
- package/dist/packages/extension-underline/src/index.d.ts +0 -3
- package/dist/packages/extension-underline/src/underline.d.ts +0 -23
- package/dist/packages/html/src/generateHTML.d.ts +0 -2
- package/dist/packages/html/src/generateJSON.d.ts +0 -2
- package/dist/packages/html/src/getHTMLFromFragment.d.ts +0 -2
- package/dist/packages/html/src/index.d.ts +0 -2
- package/dist/packages/starter-kit/src/index.d.ts +0 -3
- package/dist/packages/starter-kit/src/starter-kit.d.ts +0 -37
- package/dist/packages/suggestion/src/findSuggestionMatch.d.ts +0 -15
- package/dist/packages/suggestion/src/index.d.ts +0 -4
- package/dist/packages/suggestion/src/suggestion.d.ts +0 -49
- package/dist/tests/cypress/integration/core/can.spec.d.ts +0 -1
- package/dist/tests/cypress/integration/core/editorProps.spec.d.ts +0 -1
- package/dist/tests/cypress/integration/core/extendExtensions.spec.d.ts +0 -1
- package/dist/tests/cypress/integration/core/extendMarkRange.spec.d.ts +0 -1
- package/dist/tests/cypress/integration/core/extensionOptions.spec.d.ts +0 -1
- package/dist/tests/cypress/integration/core/fromString.spec.d.ts +0 -1
- package/dist/tests/cypress/integration/core/generateHTML.spec.d.ts +0 -1
- package/dist/tests/cypress/integration/core/generateJSON.spec.d.ts +0 -1
- package/dist/tests/cypress/integration/core/isActive.spec.d.ts +0 -1
- package/dist/tests/cypress/integration/core/isClass.spec.d.ts +0 -1
- package/dist/tests/cypress/integration/core/mergeAttributes.spec.d.ts +0 -1
- package/dist/tests/cypress/integration/core/mergeDeep.spec.d.ts +0 -1
- package/dist/tests/cypress/integration/core/pluginOrder.spec.d.ts +0 -1
- package/dist/tests/cypress/integration/extensions/bold.spec.d.ts +0 -1
- package/dist/tests/cypress/integration/extensions/codeBlockLowlight.spec.d.ts +0 -1
- package/dist/tests/cypress/integration/html/generateHTML.spec.d.ts +0 -1
- package/dist/tests/cypress/integration/html/generateJSON.spec.d.ts +0 -1
- package/dist/tiptap-react.cjs.js.map +0 -1
- package/dist/tiptap-react.esm.js.map +0 -1
- package/dist/tiptap-react.umd.js.map +0 -1
package/src/useEditor.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { useState, useEffect, DependencyList } from 'react'
|
|
2
1
|
import { EditorOptions } from '@tiptap/core'
|
|
2
|
+
import { DependencyList, useEffect, useState } from 'react'
|
|
3
|
+
|
|
3
4
|
import { Editor } from './Editor'
|
|
4
5
|
|
|
5
6
|
function useForceUpdate() {
|
|
@@ -10,9 +11,71 @@ function useForceUpdate() {
|
|
|
10
11
|
|
|
11
12
|
export const useEditor = (options: Partial<EditorOptions> = {}, deps: DependencyList = []) => {
|
|
12
13
|
const [editor, setEditor] = useState<Editor | null>(null)
|
|
14
|
+
|
|
13
15
|
const forceUpdate = useForceUpdate()
|
|
14
16
|
|
|
17
|
+
const {
|
|
18
|
+
onBeforeCreate,
|
|
19
|
+
onBlur,
|
|
20
|
+
onCreate,
|
|
21
|
+
onDestroy,
|
|
22
|
+
onFocus,
|
|
23
|
+
onSelectionUpdate,
|
|
24
|
+
onTransaction,
|
|
25
|
+
onUpdate,
|
|
26
|
+
} = options
|
|
27
|
+
|
|
28
|
+
// This effect will handle updating the editor instance
|
|
29
|
+
// when the event handlers change.
|
|
15
30
|
useEffect(() => {
|
|
31
|
+
if (!editor) {
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (onBeforeCreate) {
|
|
36
|
+
editor.off('beforeCreate')
|
|
37
|
+
editor.on('beforeCreate', onBeforeCreate)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (onBlur) {
|
|
41
|
+
editor.off('blur')
|
|
42
|
+
editor.on('blur', onBlur)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (onCreate) {
|
|
46
|
+
editor.off('create')
|
|
47
|
+
editor.on('create', onCreate)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (onDestroy) {
|
|
51
|
+
editor.off('destroy')
|
|
52
|
+
editor.on('destroy', onDestroy)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (onFocus) {
|
|
56
|
+
editor.off('focus')
|
|
57
|
+
editor.on('focus', onFocus)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (onSelectionUpdate) {
|
|
61
|
+
editor.off('selectionUpdate')
|
|
62
|
+
editor.on('selectionUpdate', onSelectionUpdate)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (onTransaction) {
|
|
66
|
+
editor.off('transaction')
|
|
67
|
+
editor.on('transaction', onTransaction)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (onUpdate) {
|
|
71
|
+
editor.off('update')
|
|
72
|
+
editor.on('update', onUpdate)
|
|
73
|
+
}
|
|
74
|
+
}, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate])
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
let isMounted = true
|
|
78
|
+
|
|
16
79
|
const instance = new Editor(options)
|
|
17
80
|
|
|
18
81
|
setEditor(instance)
|
|
@@ -20,13 +83,16 @@ export const useEditor = (options: Partial<EditorOptions> = {}, deps: Dependency
|
|
|
20
83
|
instance.on('transaction', () => {
|
|
21
84
|
requestAnimationFrame(() => {
|
|
22
85
|
requestAnimationFrame(() => {
|
|
23
|
-
|
|
86
|
+
if (isMounted) {
|
|
87
|
+
forceUpdate()
|
|
88
|
+
}
|
|
24
89
|
})
|
|
25
90
|
})
|
|
26
91
|
})
|
|
27
92
|
|
|
28
93
|
return () => {
|
|
29
94
|
instance.destroy()
|
|
95
|
+
isMounted = false
|
|
30
96
|
}
|
|
31
97
|
}, deps)
|
|
32
98
|
|
package/LICENSE.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021, überdosis GbR
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { EditorState, Transaction } from 'prosemirror-state';
|
|
2
|
-
import { Editor } from './Editor';
|
|
3
|
-
import { SingleCommands, ChainedCommands, CanCommands, AnyCommands, CommandProps } from './types';
|
|
4
|
-
export declare class CommandManager {
|
|
5
|
-
editor: Editor;
|
|
6
|
-
rawCommands: AnyCommands;
|
|
7
|
-
customState?: EditorState;
|
|
8
|
-
constructor(props: {
|
|
9
|
-
editor: Editor;
|
|
10
|
-
state?: EditorState;
|
|
11
|
-
});
|
|
12
|
-
get hasCustomState(): boolean;
|
|
13
|
-
get state(): EditorState;
|
|
14
|
-
get commands(): SingleCommands;
|
|
15
|
-
get chain(): () => ChainedCommands;
|
|
16
|
-
get can(): () => CanCommands;
|
|
17
|
-
createChain(startTr?: Transaction, shouldDispatch?: boolean): ChainedCommands;
|
|
18
|
-
createCan(startTr?: Transaction): CanCommands;
|
|
19
|
-
buildProps(tr: Transaction, shouldDispatch?: boolean): CommandProps;
|
|
20
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { EditorState, Plugin, PluginKey, Transaction } from 'prosemirror-state';
|
|
2
|
-
import { EditorView } from 'prosemirror-view';
|
|
3
|
-
import { Schema, MarkType, NodeType } from 'prosemirror-model';
|
|
4
|
-
import { ExtensionManager } from './ExtensionManager';
|
|
5
|
-
import { EventEmitter } from './EventEmitter';
|
|
6
|
-
import { EditorOptions, CanCommands, ChainedCommands, JSONContent, SingleCommands, TextSerializer, EditorEvents } from './types';
|
|
7
|
-
import * as extensions from './extensions';
|
|
8
|
-
export { extensions };
|
|
9
|
-
export interface HTMLElement {
|
|
10
|
-
editor?: Editor;
|
|
11
|
-
}
|
|
12
|
-
export declare class Editor extends EventEmitter<EditorEvents> {
|
|
13
|
-
private commandManager;
|
|
14
|
-
extensionManager: ExtensionManager;
|
|
15
|
-
private css;
|
|
16
|
-
schema: Schema;
|
|
17
|
-
view: EditorView;
|
|
18
|
-
isFocused: boolean;
|
|
19
|
-
extensionStorage: Record<string, any>;
|
|
20
|
-
options: EditorOptions;
|
|
21
|
-
constructor(options?: Partial<EditorOptions>);
|
|
22
|
-
/**
|
|
23
|
-
* Returns the editor storage.
|
|
24
|
-
*/
|
|
25
|
-
get storage(): Record<string, any>;
|
|
26
|
-
/**
|
|
27
|
-
* An object of all registered commands.
|
|
28
|
-
*/
|
|
29
|
-
get commands(): SingleCommands;
|
|
30
|
-
/**
|
|
31
|
-
* Create a command chain to call multiple commands at once.
|
|
32
|
-
*/
|
|
33
|
-
chain(): ChainedCommands;
|
|
34
|
-
/**
|
|
35
|
-
* Check if a command or a command chain can be executed. Without executing it.
|
|
36
|
-
*/
|
|
37
|
-
can(): CanCommands;
|
|
38
|
-
/**
|
|
39
|
-
* Inject CSS styles.
|
|
40
|
-
*/
|
|
41
|
-
private injectCSS;
|
|
42
|
-
/**
|
|
43
|
-
* Update editor options.
|
|
44
|
-
*
|
|
45
|
-
* @param options A list of options
|
|
46
|
-
*/
|
|
47
|
-
setOptions(options?: Partial<EditorOptions>): void;
|
|
48
|
-
/**
|
|
49
|
-
* Update editable state of the editor.
|
|
50
|
-
*/
|
|
51
|
-
setEditable(editable: boolean): void;
|
|
52
|
-
/**
|
|
53
|
-
* Returns whether the editor is editable.
|
|
54
|
-
*/
|
|
55
|
-
get isEditable(): boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Returns the editor state.
|
|
58
|
-
*/
|
|
59
|
-
get state(): EditorState;
|
|
60
|
-
/**
|
|
61
|
-
* Register a ProseMirror plugin.
|
|
62
|
-
*
|
|
63
|
-
* @param plugin A ProseMirror plugin
|
|
64
|
-
* @param handlePlugins Control how to merge the plugin into the existing plugins.
|
|
65
|
-
*/
|
|
66
|
-
registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): void;
|
|
67
|
-
/**
|
|
68
|
-
* Unregister a ProseMirror plugin.
|
|
69
|
-
*
|
|
70
|
-
* @param nameOrPluginKey The plugins name
|
|
71
|
-
*/
|
|
72
|
-
unregisterPlugin(nameOrPluginKey: string | PluginKey): void;
|
|
73
|
-
/**
|
|
74
|
-
* Creates an extension manager.
|
|
75
|
-
*/
|
|
76
|
-
private createExtensionManager;
|
|
77
|
-
/**
|
|
78
|
-
* Creates an command manager.
|
|
79
|
-
*/
|
|
80
|
-
private createCommandManager;
|
|
81
|
-
/**
|
|
82
|
-
* Creates a ProseMirror schema.
|
|
83
|
-
*/
|
|
84
|
-
private createSchema;
|
|
85
|
-
/**
|
|
86
|
-
* Creates a ProseMirror view.
|
|
87
|
-
*/
|
|
88
|
-
private createView;
|
|
89
|
-
/**
|
|
90
|
-
* Creates all node views.
|
|
91
|
-
*/
|
|
92
|
-
createNodeViews(): void;
|
|
93
|
-
isCapturingTransaction: boolean;
|
|
94
|
-
private capturedTransaction;
|
|
95
|
-
captureTransaction(fn: Function): Transaction<any> | null;
|
|
96
|
-
/**
|
|
97
|
-
* The callback over which to send transactions (state updates) produced by the view.
|
|
98
|
-
*
|
|
99
|
-
* @param transaction An editor state transaction
|
|
100
|
-
*/
|
|
101
|
-
private dispatchTransaction;
|
|
102
|
-
/**
|
|
103
|
-
* Get attributes of the currently selected node or mark.
|
|
104
|
-
*/
|
|
105
|
-
getAttributes(nameOrType: string | NodeType | MarkType): Record<string, any>;
|
|
106
|
-
/**
|
|
107
|
-
* Returns if the currently selected node or mark is active.
|
|
108
|
-
*
|
|
109
|
-
* @param name Name of the node or mark
|
|
110
|
-
* @param attributes Attributes of the node or mark
|
|
111
|
-
*/
|
|
112
|
-
isActive(name: string, attributes?: {}): boolean;
|
|
113
|
-
isActive(attributes: {}): boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Get the document as JSON.
|
|
116
|
-
*/
|
|
117
|
-
getJSON(): JSONContent;
|
|
118
|
-
/**
|
|
119
|
-
* Get the document as HTML.
|
|
120
|
-
*/
|
|
121
|
-
getHTML(): string;
|
|
122
|
-
/**
|
|
123
|
-
* Get the document as text.
|
|
124
|
-
*/
|
|
125
|
-
getText(options?: {
|
|
126
|
-
blockSeparator?: string;
|
|
127
|
-
textSerializers?: Record<string, TextSerializer>;
|
|
128
|
-
}): string;
|
|
129
|
-
/**
|
|
130
|
-
* Check if there is no content.
|
|
131
|
-
*/
|
|
132
|
-
get isEmpty(): boolean;
|
|
133
|
-
/**
|
|
134
|
-
* Get the number of characters for the current document.
|
|
135
|
-
*
|
|
136
|
-
* @deprecated
|
|
137
|
-
*/
|
|
138
|
-
getCharacterCount(): number;
|
|
139
|
-
/**
|
|
140
|
-
* Destroy the editor.
|
|
141
|
-
*/
|
|
142
|
-
destroy(): void;
|
|
143
|
-
/**
|
|
144
|
-
* Check if the editor is already destroyed.
|
|
145
|
-
*/
|
|
146
|
-
get isDestroyed(): boolean;
|
|
147
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
declare type StringKeyOf<T> = Extract<keyof T, string>;
|
|
2
|
-
declare type CallbackType<T extends Record<string, any>, EventName extends StringKeyOf<T>> = T[EventName] extends any[] ? T[EventName] : [T[EventName]];
|
|
3
|
-
declare type CallbackFunction<T extends Record<string, any>, EventName extends StringKeyOf<T>> = (...props: CallbackType<T, EventName>) => any;
|
|
4
|
-
export declare class EventEmitter<T extends Record<string, any>> {
|
|
5
|
-
private callbacks;
|
|
6
|
-
on<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this;
|
|
7
|
-
protected emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): this;
|
|
8
|
-
off<EventName extends StringKeyOf<T>>(event: EventName, fn?: CallbackFunction<T, EventName>): this;
|
|
9
|
-
protected removeAllListeners(): void;
|
|
10
|
-
}
|
|
11
|
-
export {};
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { Plugin, Transaction } from 'prosemirror-state';
|
|
2
|
-
import { InputRule } from './InputRule';
|
|
3
|
-
import { PasteRule } from './PasteRule';
|
|
4
|
-
import { Editor } from './Editor';
|
|
5
|
-
import { Node } from './Node';
|
|
6
|
-
import { Mark } from './Mark';
|
|
7
|
-
import { Extensions, GlobalAttributes, RawCommands, ParentConfig, KeyboardShortcutCommand } from './types';
|
|
8
|
-
import { ExtensionConfig } from '.';
|
|
9
|
-
declare module '@tiptap/core' {
|
|
10
|
-
interface ExtensionConfig<Options = any, Storage = any> {
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
/**
|
|
13
|
-
* Name
|
|
14
|
-
*/
|
|
15
|
-
name: string;
|
|
16
|
-
/**
|
|
17
|
-
* Priority
|
|
18
|
-
*/
|
|
19
|
-
priority?: number;
|
|
20
|
-
/**
|
|
21
|
-
* Default options
|
|
22
|
-
*/
|
|
23
|
-
defaultOptions?: Options;
|
|
24
|
-
/**
|
|
25
|
-
* Default Options
|
|
26
|
-
*/
|
|
27
|
-
addOptions?: (this: {
|
|
28
|
-
name: string;
|
|
29
|
-
parent: Exclude<ParentConfig<ExtensionConfig<Options, Storage>>['addOptions'], undefined>;
|
|
30
|
-
}) => Options;
|
|
31
|
-
/**
|
|
32
|
-
* Default Storage
|
|
33
|
-
*/
|
|
34
|
-
addStorage?: (this: {
|
|
35
|
-
name: string;
|
|
36
|
-
options: Options;
|
|
37
|
-
parent: Exclude<ParentConfig<ExtensionConfig<Options, Storage>>['addStorage'], undefined>;
|
|
38
|
-
}) => Storage;
|
|
39
|
-
/**
|
|
40
|
-
* Global attributes
|
|
41
|
-
*/
|
|
42
|
-
addGlobalAttributes?: (this: {
|
|
43
|
-
name: string;
|
|
44
|
-
options: Options;
|
|
45
|
-
storage: Storage;
|
|
46
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addGlobalAttributes'];
|
|
47
|
-
}) => GlobalAttributes | {};
|
|
48
|
-
/**
|
|
49
|
-
* Raw
|
|
50
|
-
*/
|
|
51
|
-
addCommands?: (this: {
|
|
52
|
-
name: string;
|
|
53
|
-
options: Options;
|
|
54
|
-
storage: Storage;
|
|
55
|
-
editor: Editor;
|
|
56
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addCommands'];
|
|
57
|
-
}) => Partial<RawCommands>;
|
|
58
|
-
/**
|
|
59
|
-
* Keyboard shortcuts
|
|
60
|
-
*/
|
|
61
|
-
addKeyboardShortcuts?: (this: {
|
|
62
|
-
name: string;
|
|
63
|
-
options: Options;
|
|
64
|
-
storage: Storage;
|
|
65
|
-
editor: Editor;
|
|
66
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addKeyboardShortcuts'];
|
|
67
|
-
}) => {
|
|
68
|
-
[key: string]: KeyboardShortcutCommand;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Input rules
|
|
72
|
-
*/
|
|
73
|
-
addInputRules?: (this: {
|
|
74
|
-
name: string;
|
|
75
|
-
options: Options;
|
|
76
|
-
storage: Storage;
|
|
77
|
-
editor: Editor;
|
|
78
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addInputRules'];
|
|
79
|
-
}) => InputRule[];
|
|
80
|
-
/**
|
|
81
|
-
* Paste rules
|
|
82
|
-
*/
|
|
83
|
-
addPasteRules?: (this: {
|
|
84
|
-
name: string;
|
|
85
|
-
options: Options;
|
|
86
|
-
storage: Storage;
|
|
87
|
-
editor: Editor;
|
|
88
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addPasteRules'];
|
|
89
|
-
}) => PasteRule[];
|
|
90
|
-
/**
|
|
91
|
-
* ProseMirror plugins
|
|
92
|
-
*/
|
|
93
|
-
addProseMirrorPlugins?: (this: {
|
|
94
|
-
name: string;
|
|
95
|
-
options: Options;
|
|
96
|
-
storage: Storage;
|
|
97
|
-
editor: Editor;
|
|
98
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addProseMirrorPlugins'];
|
|
99
|
-
}) => Plugin[];
|
|
100
|
-
/**
|
|
101
|
-
* Extensions
|
|
102
|
-
*/
|
|
103
|
-
addExtensions?: (this: {
|
|
104
|
-
name: string;
|
|
105
|
-
options: Options;
|
|
106
|
-
storage: Storage;
|
|
107
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addExtensions'];
|
|
108
|
-
}) => Extensions;
|
|
109
|
-
/**
|
|
110
|
-
* Extend Node Schema
|
|
111
|
-
*/
|
|
112
|
-
extendNodeSchema?: ((this: {
|
|
113
|
-
name: string;
|
|
114
|
-
options: Options;
|
|
115
|
-
storage: Storage;
|
|
116
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['extendNodeSchema'];
|
|
117
|
-
}, extension: Node) => Record<string, any>) | null;
|
|
118
|
-
/**
|
|
119
|
-
* Extend Mark Schema
|
|
120
|
-
*/
|
|
121
|
-
extendMarkSchema?: ((this: {
|
|
122
|
-
name: string;
|
|
123
|
-
options: Options;
|
|
124
|
-
storage: Storage;
|
|
125
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['extendMarkSchema'];
|
|
126
|
-
}, extension: Mark) => Record<string, any>) | null;
|
|
127
|
-
/**
|
|
128
|
-
* The editor is not ready yet.
|
|
129
|
-
*/
|
|
130
|
-
onBeforeCreate?: ((this: {
|
|
131
|
-
name: string;
|
|
132
|
-
options: Options;
|
|
133
|
-
storage: Storage;
|
|
134
|
-
editor: Editor;
|
|
135
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onBeforeCreate'];
|
|
136
|
-
}) => void) | null;
|
|
137
|
-
/**
|
|
138
|
-
* The editor is ready.
|
|
139
|
-
*/
|
|
140
|
-
onCreate?: ((this: {
|
|
141
|
-
name: string;
|
|
142
|
-
options: Options;
|
|
143
|
-
storage: Storage;
|
|
144
|
-
editor: Editor;
|
|
145
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onCreate'];
|
|
146
|
-
}) => void) | null;
|
|
147
|
-
/**
|
|
148
|
-
* The content has changed.
|
|
149
|
-
*/
|
|
150
|
-
onUpdate?: ((this: {
|
|
151
|
-
name: string;
|
|
152
|
-
options: Options;
|
|
153
|
-
storage: Storage;
|
|
154
|
-
editor: Editor;
|
|
155
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onUpdate'];
|
|
156
|
-
}) => void) | null;
|
|
157
|
-
/**
|
|
158
|
-
* The selection has changed.
|
|
159
|
-
*/
|
|
160
|
-
onSelectionUpdate?: ((this: {
|
|
161
|
-
name: string;
|
|
162
|
-
options: Options;
|
|
163
|
-
storage: Storage;
|
|
164
|
-
editor: Editor;
|
|
165
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onSelectionUpdate'];
|
|
166
|
-
}) => void) | null;
|
|
167
|
-
/**
|
|
168
|
-
* The editor state has changed.
|
|
169
|
-
*/
|
|
170
|
-
onTransaction?: ((this: {
|
|
171
|
-
name: string;
|
|
172
|
-
options: Options;
|
|
173
|
-
storage: Storage;
|
|
174
|
-
editor: Editor;
|
|
175
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onTransaction'];
|
|
176
|
-
}, props: {
|
|
177
|
-
transaction: Transaction;
|
|
178
|
-
}) => void) | null;
|
|
179
|
-
/**
|
|
180
|
-
* The editor is focused.
|
|
181
|
-
*/
|
|
182
|
-
onFocus?: ((this: {
|
|
183
|
-
name: string;
|
|
184
|
-
options: Options;
|
|
185
|
-
storage: Storage;
|
|
186
|
-
editor: Editor;
|
|
187
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onFocus'];
|
|
188
|
-
}, props: {
|
|
189
|
-
event: FocusEvent;
|
|
190
|
-
}) => void) | null;
|
|
191
|
-
/**
|
|
192
|
-
* The editor isn’t focused anymore.
|
|
193
|
-
*/
|
|
194
|
-
onBlur?: ((this: {
|
|
195
|
-
name: string;
|
|
196
|
-
options: Options;
|
|
197
|
-
storage: Storage;
|
|
198
|
-
editor: Editor;
|
|
199
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onBlur'];
|
|
200
|
-
}, props: {
|
|
201
|
-
event: FocusEvent;
|
|
202
|
-
}) => void) | null;
|
|
203
|
-
/**
|
|
204
|
-
* The editor is destroyed.
|
|
205
|
-
*/
|
|
206
|
-
onDestroy?: ((this: {
|
|
207
|
-
name: string;
|
|
208
|
-
options: Options;
|
|
209
|
-
storage: Storage;
|
|
210
|
-
editor: Editor;
|
|
211
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onDestroy'];
|
|
212
|
-
}) => void) | null;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
export declare class Extension<Options = any, Storage = any> {
|
|
216
|
-
type: string;
|
|
217
|
-
name: string;
|
|
218
|
-
parent: Extension | null;
|
|
219
|
-
child: Extension | null;
|
|
220
|
-
options: Options;
|
|
221
|
-
storage: Storage;
|
|
222
|
-
config: ExtensionConfig;
|
|
223
|
-
constructor(config?: Partial<ExtensionConfig<Options, Storage>>);
|
|
224
|
-
static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>>): Extension<O, S>;
|
|
225
|
-
configure(options?: Partial<Options>): Extension<Options, Storage>;
|
|
226
|
-
extend<ExtendedOptions = Options, ExtendedStorage = Storage>(extendedConfig?: Partial<ExtensionConfig<ExtendedOptions, ExtendedStorage>>): Extension<ExtendedOptions, ExtendedStorage>;
|
|
227
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'prosemirror-model';
|
|
2
|
-
import { Plugin } from 'prosemirror-state';
|
|
3
|
-
import { Editor } from './Editor';
|
|
4
|
-
import { Extensions, RawCommands } from './types';
|
|
5
|
-
export declare class ExtensionManager {
|
|
6
|
-
editor: Editor;
|
|
7
|
-
schema: Schema;
|
|
8
|
-
extensions: Extensions;
|
|
9
|
-
splittableMarks: string[];
|
|
10
|
-
constructor(extensions: Extensions, editor: Editor);
|
|
11
|
-
static resolve(extensions: Extensions): Extensions;
|
|
12
|
-
static flatten(extensions: Extensions): Extensions;
|
|
13
|
-
static sort(extensions: Extensions): Extensions;
|
|
14
|
-
get commands(): RawCommands;
|
|
15
|
-
get plugins(): Plugin[];
|
|
16
|
-
get attributes(): import("@tiptap/core").ExtensionAttribute[];
|
|
17
|
-
get nodeViews(): any;
|
|
18
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { EditorState, Plugin } from 'prosemirror-state';
|
|
2
|
-
import { Editor } from './Editor';
|
|
3
|
-
import { Range, ExtendedRegExpMatchArray, SingleCommands, ChainedCommands, CanCommands } from './types';
|
|
4
|
-
export declare type InputRuleMatch = {
|
|
5
|
-
index: number;
|
|
6
|
-
text: string;
|
|
7
|
-
replaceWith?: string;
|
|
8
|
-
match?: RegExpMatchArray;
|
|
9
|
-
data?: Record<string, any>;
|
|
10
|
-
};
|
|
11
|
-
export declare type InputRuleFinder = RegExp | ((text: string) => InputRuleMatch | null);
|
|
12
|
-
export declare class InputRule {
|
|
13
|
-
find: InputRuleFinder;
|
|
14
|
-
handler: (props: {
|
|
15
|
-
state: EditorState;
|
|
16
|
-
range: Range;
|
|
17
|
-
match: ExtendedRegExpMatchArray;
|
|
18
|
-
commands: SingleCommands;
|
|
19
|
-
chain: () => ChainedCommands;
|
|
20
|
-
can: () => CanCommands;
|
|
21
|
-
}) => void;
|
|
22
|
-
constructor(config: {
|
|
23
|
-
find: InputRuleFinder;
|
|
24
|
-
handler: (props: {
|
|
25
|
-
state: EditorState;
|
|
26
|
-
range: Range;
|
|
27
|
-
match: ExtendedRegExpMatchArray;
|
|
28
|
-
commands: SingleCommands;
|
|
29
|
-
chain: () => ChainedCommands;
|
|
30
|
-
can: () => CanCommands;
|
|
31
|
-
}) => void;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Create an input rules plugin. When enabled, it will cause text
|
|
36
|
-
* input that matches any of the given rules to trigger the rule’s
|
|
37
|
-
* action.
|
|
38
|
-
*/
|
|
39
|
-
export declare function inputRulesPlugin(props: {
|
|
40
|
-
editor: Editor;
|
|
41
|
-
rules: InputRule[];
|
|
42
|
-
}): Plugin;
|