@tiptap/core 2.1.0-rc.9 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +384 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +373 -98
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +384 -99
- package/dist/index.umd.js.map +1 -1
- package/dist/packages/core/src/CommandManager.d.ts +2 -2
- package/dist/packages/core/src/Editor.d.ts +4 -4
- package/dist/packages/core/src/Extension.d.ts +7 -7
- package/dist/packages/core/src/ExtensionManager.d.ts +2 -2
- package/dist/packages/core/src/InputRule.d.ts +2 -2
- package/dist/packages/core/src/Mark.d.ts +6 -6
- package/dist/packages/core/src/Node.d.ts +5 -5
- package/dist/packages/core/src/NodeView.d.ts +3 -3
- package/dist/packages/core/src/PasteRule.d.ts +2 -2
- package/dist/packages/core/src/commands/blur.d.ts +1 -1
- package/dist/packages/core/src/commands/clearContent.d.ts +1 -1
- package/dist/packages/core/src/commands/clearNodes.d.ts +1 -1
- package/dist/packages/core/src/commands/command.d.ts +1 -1
- package/dist/packages/core/src/commands/createParagraphNear.d.ts +1 -1
- package/dist/packages/core/src/commands/cut.d.ts +15 -0
- package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +1 -1
- package/dist/packages/core/src/commands/deleteNode.d.ts +1 -1
- package/dist/packages/core/src/commands/deleteRange.d.ts +1 -1
- package/dist/packages/core/src/commands/deleteSelection.d.ts +1 -1
- package/dist/packages/core/src/commands/enter.d.ts +1 -1
- package/dist/packages/core/src/commands/exitCode.d.ts +1 -1
- package/dist/packages/core/src/commands/extendMarkRange.d.ts +1 -1
- package/dist/packages/core/src/commands/first.d.ts +1 -1
- package/dist/packages/core/src/commands/focus.d.ts +1 -1
- package/dist/packages/core/src/commands/forEach.d.ts +1 -1
- package/dist/packages/core/src/commands/index.d.ts +53 -50
- package/dist/packages/core/src/commands/insertContent.d.ts +1 -1
- package/dist/packages/core/src/commands/insertContentAt.d.ts +1 -1
- package/dist/packages/core/src/commands/join.d.ts +1 -1
- package/dist/packages/core/src/commands/joinItemBackward.d.ts +12 -0
- package/dist/packages/core/src/commands/joinItemForward.d.ts +12 -0
- package/dist/packages/core/src/commands/keyboardShortcut.d.ts +1 -1
- package/dist/packages/core/src/commands/lift.d.ts +1 -1
- package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +1 -1
- package/dist/packages/core/src/commands/liftListItem.d.ts +1 -1
- package/dist/packages/core/src/commands/newlineInCode.d.ts +1 -1
- package/dist/packages/core/src/commands/resetAttributes.d.ts +1 -1
- package/dist/packages/core/src/commands/scrollIntoView.d.ts +1 -1
- package/dist/packages/core/src/commands/selectAll.d.ts +1 -1
- package/dist/packages/core/src/commands/selectNodeBackward.d.ts +1 -1
- package/dist/packages/core/src/commands/selectNodeForward.d.ts +1 -1
- package/dist/packages/core/src/commands/selectParentNode.d.ts +1 -1
- package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +1 -1
- package/dist/packages/core/src/commands/selectTextblockStart.d.ts +1 -1
- package/dist/packages/core/src/commands/setContent.d.ts +1 -1
- package/dist/packages/core/src/commands/setMark.d.ts +1 -1
- package/dist/packages/core/src/commands/setMeta.d.ts +1 -1
- package/dist/packages/core/src/commands/setNode.d.ts +1 -1
- package/dist/packages/core/src/commands/setNodeSelection.d.ts +1 -1
- package/dist/packages/core/src/commands/setTextSelection.d.ts +1 -1
- package/dist/packages/core/src/commands/sinkListItem.d.ts +1 -1
- package/dist/packages/core/src/commands/splitBlock.d.ts +1 -1
- package/dist/packages/core/src/commands/splitListItem.d.ts +1 -1
- package/dist/packages/core/src/commands/toggleList.d.ts +1 -1
- package/dist/packages/core/src/commands/toggleMark.d.ts +1 -1
- package/dist/packages/core/src/commands/toggleNode.d.ts +1 -1
- package/dist/packages/core/src/commands/toggleWrap.d.ts +1 -1
- package/dist/packages/core/src/commands/undoInputRule.d.ts +1 -1
- package/dist/packages/core/src/commands/unsetAllMarks.d.ts +1 -1
- package/dist/packages/core/src/commands/unsetMark.d.ts +1 -1
- package/dist/packages/core/src/commands/updateAttributes.d.ts +1 -1
- package/dist/packages/core/src/commands/wrapIn.d.ts +1 -1
- package/dist/packages/core/src/commands/wrapInList.d.ts +1 -1
- package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +1 -1
- package/dist/packages/core/src/extensions/commands.d.ts +2 -2
- package/dist/packages/core/src/extensions/editable.d.ts +1 -1
- package/dist/packages/core/src/extensions/focusEvents.d.ts +1 -1
- package/dist/packages/core/src/extensions/index.d.ts +6 -6
- package/dist/packages/core/src/extensions/keymap.d.ts +1 -1
- package/dist/packages/core/src/extensions/tabindex.d.ts +1 -1
- package/dist/packages/core/src/helpers/createDocument.d.ts +1 -1
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +1 -1
- package/dist/packages/core/src/helpers/findChildren.d.ts +1 -1
- package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +1 -1
- package/dist/packages/core/src/helpers/findParentNode.d.ts +1 -1
- package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +1 -1
- package/dist/packages/core/src/helpers/generateHTML.d.ts +1 -1
- package/dist/packages/core/src/helpers/generateJSON.d.ts +1 -1
- package/dist/packages/core/src/helpers/generateText.d.ts +1 -1
- package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +1 -1
- package/dist/packages/core/src/helpers/getChangedRanges.d.ts +1 -1
- package/dist/packages/core/src/helpers/getDebugJSON.d.ts +1 -1
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +1 -1
- package/dist/packages/core/src/helpers/getMarkRange.d.ts +1 -1
- package/dist/packages/core/src/helpers/getMarksBetween.d.ts +1 -1
- package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +1 -1
- package/dist/packages/core/src/helpers/getSchema.d.ts +2 -2
- package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +2 -2
- package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +1 -1
- package/dist/packages/core/src/helpers/getText.d.ts +1 -1
- package/dist/packages/core/src/helpers/getTextBetween.d.ts +1 -1
- package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +1 -1
- package/dist/packages/core/src/helpers/index.d.ts +51 -50
- package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +1 -1
- package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +1 -1
- package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +1 -1
- package/dist/packages/core/src/helpers/isList.d.ts +1 -1
- package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +1 -1
- package/dist/packages/core/src/helpers/splitExtensions.d.ts +4 -4
- package/dist/packages/core/src/index.d.ts +15 -15
- package/dist/packages/core/src/inputRules/index.d.ts +5 -5
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +2 -2
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +22 -2
- package/dist/packages/core/src/inputRules/textInputRule.d.ts +1 -1
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +2 -2
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +3 -3
- package/dist/packages/core/src/pasteRules/index.d.ts +3 -3
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +2 -2
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +2 -2
- package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +1 -1
- package/dist/packages/core/src/types.d.ts +5 -5
- package/dist/packages/core/src/utilities/callOrReturn.d.ts +1 -1
- package/dist/packages/core/src/utilities/createStyleTag.d.ts +1 -1
- package/dist/packages/core/src/utilities/index.d.ts +20 -20
- package/dist/packages/core/src/utilities/isAndroid.d.ts +1 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/findListItemPos.d.ts +6 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/getNextListDepth.d.ts +2 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/handleBackspace.d.ts +2 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/handleDelete.d.ts +2 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/hasListBefore.d.ts +2 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/hasListItemAfter.d.ts +2 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/hasListItemBefore.d.ts +2 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/index.d.ts +10 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/listItemHasSubList.d.ts +3 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/nextListIsDeeper.d.ts +2 -0
- package/dist/packages/extension-list-keymap/src/listHelpers/nextListIsHigher.d.ts +2 -0
- package/package.json +2 -2
- package/src/CommandManager.ts +4 -8
- package/src/Editor.ts +16 -16
- package/src/Extension.ts +10 -10
- package/src/ExtensionManager.ts +15 -15
- package/src/InputRule.ts +6 -6
- package/src/Mark.ts +9 -9
- package/src/Node.ts +8 -8
- package/src/NodeView.ts +8 -6
- package/src/PasteRule.ts +6 -6
- package/src/commands/blur.ts +1 -1
- package/src/commands/clearContent.ts +1 -1
- package/src/commands/clearNodes.ts +1 -1
- package/src/commands/command.ts +1 -1
- package/src/commands/createParagraphNear.ts +1 -1
- package/src/commands/cut.ts +29 -0
- package/src/commands/deleteCurrentNode.ts +1 -1
- package/src/commands/deleteNode.ts +2 -2
- package/src/commands/deleteRange.ts +1 -1
- package/src/commands/deleteSelection.ts +1 -1
- package/src/commands/enter.ts +1 -1
- package/src/commands/exitCode.ts +1 -1
- package/src/commands/extendMarkRange.ts +3 -3
- package/src/commands/first.ts +1 -1
- package/src/commands/focus.ts +4 -4
- package/src/commands/forEach.ts +1 -1
- package/src/commands/index.ts +53 -50
- package/src/commands/insertContent.ts +1 -1
- package/src/commands/insertContentAt.ts +4 -4
- package/src/commands/join.ts +1 -1
- package/src/commands/joinItemBackward.ts +36 -0
- package/src/commands/joinItemForward.ts +38 -0
- package/src/commands/keyboardShortcut.ts +3 -3
- package/src/commands/lift.ts +3 -3
- package/src/commands/liftEmptyBlock.ts +1 -1
- package/src/commands/liftListItem.ts +2 -2
- package/src/commands/newlineInCode.ts +1 -1
- package/src/commands/resetAttributes.ts +5 -5
- package/src/commands/scrollIntoView.ts +1 -1
- package/src/commands/selectAll.ts +1 -1
- package/src/commands/selectNodeBackward.ts +1 -1
- package/src/commands/selectNodeForward.ts +1 -1
- package/src/commands/selectParentNode.ts +1 -1
- package/src/commands/selectTextblockEnd.ts +1 -1
- package/src/commands/selectTextblockStart.ts +1 -1
- package/src/commands/setContent.ts +2 -2
- package/src/commands/setMark.ts +4 -4
- package/src/commands/setMeta.ts +1 -1
- package/src/commands/setNode.ts +2 -2
- package/src/commands/setNodeSelection.ts +2 -2
- package/src/commands/setTextSelection.ts +2 -2
- package/src/commands/sinkListItem.ts +2 -2
- package/src/commands/splitBlock.ts +3 -3
- package/src/commands/splitListItem.ts +3 -3
- package/src/commands/toggleList.ts +4 -4
- package/src/commands/toggleMark.ts +3 -3
- package/src/commands/toggleNode.ts +3 -3
- package/src/commands/toggleWrap.ts +3 -3
- package/src/commands/undoInputRule.ts +1 -1
- package/src/commands/unsetAllMarks.ts +1 -1
- package/src/commands/unsetMark.ts +3 -3
- package/src/commands/updateAttributes.ts +4 -4
- package/src/commands/wrapIn.ts +2 -2
- package/src/commands/wrapInList.ts +2 -2
- package/src/extensions/clipboardTextSerializer.ts +3 -3
- package/src/extensions/commands.ts +3 -3
- package/src/extensions/editable.ts +1 -1
- package/src/extensions/focusEvents.ts +1 -1
- package/src/extensions/index.ts +6 -6
- package/src/extensions/keymap.ts +7 -5
- package/src/extensions/tabindex.ts +1 -1
- package/src/helpers/createDocument.ts +2 -2
- package/src/helpers/createNodeFromContent.ts +2 -2
- package/src/helpers/findChildren.ts +1 -1
- package/src/helpers/findChildrenInRange.ts +1 -1
- package/src/helpers/findParentNode.ts +2 -2
- package/src/helpers/findParentNodeClosestToPos.ts +1 -1
- package/src/helpers/generateHTML.ts +3 -3
- package/src/helpers/generateJSON.ts +3 -3
- package/src/helpers/generateText.ts +4 -4
- package/src/helpers/getAttributes.ts +3 -3
- package/src/helpers/getAttributesFromExtensions.ts +4 -4
- package/src/helpers/getChangedRanges.ts +2 -2
- package/src/helpers/getDebugJSON.ts +1 -1
- package/src/helpers/getExtensionField.ts +1 -1
- package/src/helpers/getMarkAttributes.ts +1 -1
- package/src/helpers/getMarkRange.ts +2 -2
- package/src/helpers/getMarksBetween.ts +2 -2
- package/src/helpers/getNodeAttributes.ts +1 -1
- package/src/helpers/getRenderedAttributes.ts +2 -2
- package/src/helpers/getSchema.ts +4 -4
- package/src/helpers/getSchemaByResolvedExtensions.ts +9 -9
- package/src/helpers/getSplittedAttributes.ts +1 -1
- package/src/helpers/getText.ts +2 -2
- package/src/helpers/getTextBetween.ts +1 -1
- package/src/helpers/getTextSerializersFromSchema.ts +1 -1
- package/src/helpers/index.ts +51 -50
- package/src/helpers/injectExtensionAttributesToParseRule.ts +2 -2
- package/src/helpers/isActive.ts +3 -3
- package/src/helpers/isAtEndOfNode.ts +20 -2
- package/src/helpers/isExtensionRulesEnabled.ts +1 -1
- package/src/helpers/isList.ts +5 -5
- package/src/helpers/isMarkActive.ts +3 -3
- package/src/helpers/isNodeActive.ts +3 -3
- package/src/helpers/posToDOMRect.ts +1 -1
- package/src/helpers/resolveFocusPosition.ts +2 -2
- package/src/helpers/splitExtensions.ts +4 -4
- package/src/index.ts +15 -15
- package/src/inputRules/index.ts +5 -5
- package/src/inputRules/markInputRule.ts +5 -6
- package/src/inputRules/nodeInputRule.ts +60 -6
- package/src/inputRules/textInputRule.ts +1 -1
- package/src/inputRules/textblockTypeInputRule.ts +3 -3
- package/src/inputRules/wrappingInputRule.ts +4 -4
- package/src/pasteRules/index.ts +3 -3
- package/src/pasteRules/markPasteRule.ts +4 -4
- package/src/pasteRules/nodePasteRule.ts +3 -3
- package/src/pasteRules/textPasteRule.ts +1 -1
- package/src/types.ts +5 -5
- package/src/utilities/callOrReturn.ts +2 -2
- package/src/utilities/createStyleTag.ts +3 -3
- package/src/utilities/index.ts +20 -20
- package/src/utilities/isAndroid.ts +3 -0
- package/src/utilities/mergeAttributes.ts +8 -1
- package/src/utilities/mergeDeep.ts +1 -1
- package/src/utilities/objectIncludes.ts +1 -1
package/src/extensions/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { ClipboardTextSerializer } from './clipboardTextSerializer'
|
|
2
|
-
export { Commands } from './commands'
|
|
3
|
-
export { Editable } from './editable'
|
|
4
|
-
export { FocusEvents } from './focusEvents'
|
|
5
|
-
export { Keymap } from './keymap'
|
|
6
|
-
export { Tabindex } from './tabindex'
|
|
1
|
+
export { ClipboardTextSerializer } from './clipboardTextSerializer.js'
|
|
2
|
+
export { Commands } from './commands.js'
|
|
3
|
+
export { Editable } from './editable.js'
|
|
4
|
+
export { FocusEvents } from './focusEvents.js'
|
|
5
|
+
export { Keymap } from './keymap.js'
|
|
6
|
+
export { Tabindex } from './tabindex.js'
|
package/src/extensions/keymap.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Plugin, PluginKey, Selection } from '@tiptap/pm/state'
|
|
2
2
|
|
|
3
|
-
import { CommandManager } from '../CommandManager'
|
|
4
|
-
import { Extension } from '../Extension'
|
|
5
|
-
import { createChainableState } from '../helpers/createChainableState'
|
|
6
|
-
import { isiOS } from '../utilities/isiOS'
|
|
7
|
-
import { isMacOS } from '../utilities/isMacOS'
|
|
3
|
+
import { CommandManager } from '../CommandManager.js'
|
|
4
|
+
import { Extension } from '../Extension.js'
|
|
5
|
+
import { createChainableState } from '../helpers/createChainableState.js'
|
|
6
|
+
import { isiOS } from '../utilities/isiOS.js'
|
|
7
|
+
import { isMacOS } from '../utilities/isMacOS.js'
|
|
8
8
|
|
|
9
9
|
export const Keymap = Extension.create({
|
|
10
10
|
name: 'keymap',
|
|
@@ -12,6 +12,7 @@ export const Keymap = Extension.create({
|
|
|
12
12
|
addKeyboardShortcuts() {
|
|
13
13
|
const handleBackspace = () => this.editor.commands.first(({ commands }) => [
|
|
14
14
|
() => commands.undoInputRule(),
|
|
15
|
+
|
|
15
16
|
// maybe convert first text block node to default node
|
|
16
17
|
() => commands.command(({ tr }) => {
|
|
17
18
|
const { selection, doc } = tr
|
|
@@ -32,6 +33,7 @@ export const Keymap = Extension.create({
|
|
|
32
33
|
|
|
33
34
|
return commands.clearNodes()
|
|
34
35
|
}),
|
|
36
|
+
|
|
35
37
|
() => commands.deleteSelection(),
|
|
36
38
|
() => commands.joinBackward(),
|
|
37
39
|
() => commands.selectNodeBackward(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Node as ProseMirrorNode, ParseOptions, Schema } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { Content } from '../types'
|
|
4
|
-
import { createNodeFromContent } from './createNodeFromContent'
|
|
3
|
+
import { Content } from '../types.js'
|
|
4
|
+
import { createNodeFromContent } from './createNodeFromContent.js'
|
|
5
5
|
|
|
6
6
|
export function createDocument(
|
|
7
7
|
content: Content,
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
Schema,
|
|
7
7
|
} from '@tiptap/pm/model'
|
|
8
8
|
|
|
9
|
-
import { Content } from '../types'
|
|
10
|
-
import { elementFromString } from '../utilities/elementFromString'
|
|
9
|
+
import { Content } from '../types.js'
|
|
10
|
+
import { elementFromString } from '../utilities/elementFromString.js'
|
|
11
11
|
|
|
12
12
|
export type CreateNodeFromContentOptions = {
|
|
13
13
|
slice?: boolean
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Node as ProseMirrorNode } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { NodeWithPos, Predicate } from '../types'
|
|
3
|
+
import { NodeWithPos, Predicate } from '../types.js'
|
|
4
4
|
|
|
5
5
|
export function findChildren(node: ProseMirrorNode, predicate: Predicate): NodeWithPos[] {
|
|
6
6
|
const nodesWithPos: NodeWithPos[] = []
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Selection } from '@tiptap/pm/state'
|
|
2
2
|
|
|
3
|
-
import { Predicate } from '../types'
|
|
4
|
-
import { findParentNodeClosestToPos } from './findParentNodeClosestToPos'
|
|
3
|
+
import { Predicate } from '../types.js'
|
|
4
|
+
import { findParentNodeClosestToPos } from './findParentNodeClosestToPos.js'
|
|
5
5
|
|
|
6
6
|
export function findParentNode(predicate: Predicate) {
|
|
7
7
|
return (selection: Selection) => findParentNodeClosestToPos(selection.$from, predicate)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Node } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { Extensions, JSONContent } from '../types'
|
|
4
|
-
import { getHTMLFromFragment } from './getHTMLFromFragment'
|
|
5
|
-
import { getSchema } from './getSchema'
|
|
3
|
+
import { Extensions, JSONContent } from '../types.js'
|
|
4
|
+
import { getHTMLFromFragment } from './getHTMLFromFragment.js'
|
|
5
|
+
import { getSchema } from './getSchema.js'
|
|
6
6
|
|
|
7
7
|
export function generateHTML(doc: JSONContent, extensions: Extensions): string {
|
|
8
8
|
const schema = getSchema(extensions)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DOMParser } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { Extensions } from '../types'
|
|
4
|
-
import { elementFromString } from '../utilities/elementFromString'
|
|
5
|
-
import { getSchema } from './getSchema'
|
|
3
|
+
import { Extensions } from '../types.js'
|
|
4
|
+
import { elementFromString } from '../utilities/elementFromString.js'
|
|
5
|
+
import { getSchema } from './getSchema.js'
|
|
6
6
|
|
|
7
7
|
export function generateJSON(html: string, extensions: Extensions): Record<string, any> {
|
|
8
8
|
const schema = getSchema(extensions)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Node } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { Extensions, JSONContent, TextSerializer } from '../types'
|
|
4
|
-
import { getSchema } from './getSchema'
|
|
5
|
-
import { getText } from './getText'
|
|
6
|
-
import { getTextSerializersFromSchema } from './getTextSerializersFromSchema'
|
|
3
|
+
import { Extensions, JSONContent, TextSerializer } from '../types.js'
|
|
4
|
+
import { getSchema } from './getSchema.js'
|
|
5
|
+
import { getText } from './getText.js'
|
|
6
|
+
import { getTextSerializersFromSchema } from './getTextSerializersFromSchema.js'
|
|
7
7
|
|
|
8
8
|
export function generateText(
|
|
9
9
|
doc: JSONContent,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { MarkType, NodeType } from '@tiptap/pm/model'
|
|
2
2
|
import { EditorState } from '@tiptap/pm/state'
|
|
3
3
|
|
|
4
|
-
import { getMarkAttributes } from './getMarkAttributes'
|
|
5
|
-
import { getNodeAttributes } from './getNodeAttributes'
|
|
6
|
-
import { getSchemaTypeNameByName } from './getSchemaTypeNameByName'
|
|
4
|
+
import { getMarkAttributes } from './getMarkAttributes.js'
|
|
5
|
+
import { getNodeAttributes } from './getNodeAttributes.js'
|
|
6
|
+
import { getSchemaTypeNameByName } from './getSchemaTypeNameByName.js'
|
|
7
7
|
|
|
8
8
|
export function getAttributes(
|
|
9
9
|
state: EditorState,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MarkConfig, NodeConfig } from '
|
|
1
|
+
import { MarkConfig, NodeConfig } from '../index.js'
|
|
2
2
|
import {
|
|
3
3
|
AnyConfig,
|
|
4
4
|
Attribute,
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
ExtensionAttribute,
|
|
7
7
|
Extensions,
|
|
8
8
|
GlobalAttributes,
|
|
9
|
-
} from '../types'
|
|
10
|
-
import { getExtensionField } from './getExtensionField'
|
|
11
|
-
import { splitExtensions } from './splitExtensions'
|
|
9
|
+
} from '../types.js'
|
|
10
|
+
import { getExtensionField } from './getExtensionField.js'
|
|
11
|
+
import { splitExtensions } from './splitExtensions.js'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Get a list of all extension attributes defined in `addAttribute` and `addGlobalAttribute`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Step, Transform } from '@tiptap/pm/transform'
|
|
2
2
|
|
|
3
|
-
import { Range } from '../types'
|
|
4
|
-
import { removeDuplicates } from '../utilities/removeDuplicates'
|
|
3
|
+
import { Range } from '../types.js'
|
|
4
|
+
import { removeDuplicates } from '../utilities/removeDuplicates.js'
|
|
5
5
|
|
|
6
6
|
export type ChangedRange = {
|
|
7
7
|
oldRange: Range,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Mark as ProseMirrorMark, MarkType, ResolvedPos } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { Range } from '../types'
|
|
4
|
-
import { objectIncludes } from '../utilities/objectIncludes'
|
|
3
|
+
import { Range } from '../types.js'
|
|
4
|
+
import { objectIncludes } from '../utilities/objectIncludes.js'
|
|
5
5
|
|
|
6
6
|
function findMarkInSet(
|
|
7
7
|
marks: ProseMirrorMark[],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Node as ProseMirrorNode } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { MarkRange } from '../types'
|
|
4
|
-
import { getMarkRange } from './getMarkRange'
|
|
3
|
+
import { MarkRange } from '../types.js'
|
|
4
|
+
import { getMarkRange } from './getMarkRange.js'
|
|
5
5
|
|
|
6
6
|
export function getMarksBetween(from: number, to: number, doc: ProseMirrorNode): MarkRange[] {
|
|
7
7
|
const marks: MarkRange[] = []
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Mark, Node } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { ExtensionAttribute } from '../types'
|
|
4
|
-
import { mergeAttributes } from '../utilities/mergeAttributes'
|
|
3
|
+
import { ExtensionAttribute } from '../types.js'
|
|
4
|
+
import { mergeAttributes } from '../utilities/mergeAttributes.js'
|
|
5
5
|
|
|
6
6
|
export function getRenderedAttributes(
|
|
7
7
|
nodeOrMark: Node | Mark,
|
package/src/helpers/getSchema.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Schema } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { Editor } from '../Editor'
|
|
4
|
-
import { ExtensionManager } from '../ExtensionManager'
|
|
5
|
-
import { Extensions } from '../types'
|
|
6
|
-
import { getSchemaByResolvedExtensions } from './getSchemaByResolvedExtensions'
|
|
3
|
+
import { Editor } from '../Editor.js'
|
|
4
|
+
import { ExtensionManager } from '../ExtensionManager.js'
|
|
5
|
+
import { Extensions } from '../types.js'
|
|
6
|
+
import { getSchemaByResolvedExtensions } from './getSchemaByResolvedExtensions.js'
|
|
7
7
|
|
|
8
8
|
export function getSchema(extensions: Extensions, editor?: Editor): Schema {
|
|
9
9
|
const resolvedExtensions = ExtensionManager.resolve(extensions)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { MarkSpec, NodeSpec, Schema } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { Editor, MarkConfig, NodeConfig } from '
|
|
4
|
-
import { AnyConfig, Extensions } from '../types'
|
|
5
|
-
import { callOrReturn } from '../utilities/callOrReturn'
|
|
6
|
-
import { isEmptyObject } from '../utilities/isEmptyObject'
|
|
7
|
-
import { getAttributesFromExtensions } from './getAttributesFromExtensions'
|
|
8
|
-
import { getExtensionField } from './getExtensionField'
|
|
9
|
-
import { getRenderedAttributes } from './getRenderedAttributes'
|
|
10
|
-
import { injectExtensionAttributesToParseRule } from './injectExtensionAttributesToParseRule'
|
|
11
|
-
import { splitExtensions } from './splitExtensions'
|
|
3
|
+
import { Editor, MarkConfig, NodeConfig } from '../index.js'
|
|
4
|
+
import { AnyConfig, Extensions } from '../types.js'
|
|
5
|
+
import { callOrReturn } from '../utilities/callOrReturn.js'
|
|
6
|
+
import { isEmptyObject } from '../utilities/isEmptyObject.js'
|
|
7
|
+
import { getAttributesFromExtensions } from './getAttributesFromExtensions.js'
|
|
8
|
+
import { getExtensionField } from './getExtensionField.js'
|
|
9
|
+
import { getRenderedAttributes } from './getRenderedAttributes.js'
|
|
10
|
+
import { injectExtensionAttributesToParseRule } from './injectExtensionAttributesToParseRule.js'
|
|
11
|
+
import { splitExtensions } from './splitExtensions.js'
|
|
12
12
|
|
|
13
13
|
function cleanUpSchemaItem<T>(data: T) {
|
|
14
14
|
return Object.fromEntries(
|
package/src/helpers/getText.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Node as ProseMirrorNode } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { TextSerializer } from '../types'
|
|
4
|
-
import { getTextBetween } from './getTextBetween'
|
|
3
|
+
import { TextSerializer } from '../types.js'
|
|
4
|
+
import { getTextBetween } from './getTextBetween.js'
|
|
5
5
|
|
|
6
6
|
export function getText(
|
|
7
7
|
node: ProseMirrorNode,
|
package/src/helpers/index.ts
CHANGED
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
export * from '
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './
|
|
14
|
-
export * from './
|
|
15
|
-
export * from './
|
|
16
|
-
export * from './
|
|
17
|
-
export * from './
|
|
18
|
-
export * from './
|
|
19
|
-
export * from './
|
|
20
|
-
export * from './
|
|
21
|
-
export * from './
|
|
22
|
-
export * from './
|
|
23
|
-
export * from './
|
|
24
|
-
export * from './
|
|
25
|
-
export * from './
|
|
26
|
-
export * from './
|
|
27
|
-
export * from './
|
|
28
|
-
export * from './
|
|
29
|
-
export * from './
|
|
30
|
-
export * from './
|
|
31
|
-
export * from './
|
|
32
|
-
export * from './
|
|
33
|
-
export * from './
|
|
34
|
-
export * from './
|
|
35
|
-
export * from './
|
|
36
|
-
export * from './
|
|
37
|
-
export * from './
|
|
38
|
-
export * from './
|
|
39
|
-
export * from './
|
|
40
|
-
export * from './
|
|
41
|
-
export * from './
|
|
42
|
-
export * from './
|
|
43
|
-
export * from './
|
|
44
|
-
export * from './
|
|
45
|
-
export * from './
|
|
46
|
-
export * from './
|
|
47
|
-
export * from './
|
|
48
|
-
export * from './
|
|
49
|
-
export * from './
|
|
50
|
-
export * from './
|
|
1
|
+
export * from '../../../extension-list-keymap/src/listHelpers/index.js'
|
|
2
|
+
export * from './combineTransactionSteps.js'
|
|
3
|
+
export * from './createChainableState.js'
|
|
4
|
+
export * from './createDocument.js'
|
|
5
|
+
export * from './createNodeFromContent.js'
|
|
6
|
+
export * from './defaultBlockAt.js'
|
|
7
|
+
export * from './findChildren.js'
|
|
8
|
+
export * from './findChildrenInRange.js'
|
|
9
|
+
export * from './findParentNode.js'
|
|
10
|
+
export * from './findParentNodeClosestToPos.js'
|
|
11
|
+
export * from './generateHTML.js'
|
|
12
|
+
export * from './generateJSON.js'
|
|
13
|
+
export * from './generateText.js'
|
|
14
|
+
export * from './getAttributes.js'
|
|
15
|
+
export * from './getAttributesFromExtensions.js'
|
|
16
|
+
export * from './getChangedRanges.js'
|
|
17
|
+
export * from './getDebugJSON.js'
|
|
18
|
+
export * from './getExtensionField.js'
|
|
19
|
+
export * from './getHTMLFromFragment.js'
|
|
20
|
+
export * from './getMarkAttributes.js'
|
|
21
|
+
export * from './getMarkRange.js'
|
|
22
|
+
export * from './getMarksBetween.js'
|
|
23
|
+
export * from './getMarkType.js'
|
|
24
|
+
export * from './getNodeAtPosition.js'
|
|
25
|
+
export * from './getNodeAttributes.js'
|
|
26
|
+
export * from './getNodeType.js'
|
|
27
|
+
export * from './getRenderedAttributes.js'
|
|
28
|
+
export * from './getSchema.js'
|
|
29
|
+
export * from './getSchemaByResolvedExtensions.js'
|
|
30
|
+
export * from './getSchemaTypeByName.js'
|
|
31
|
+
export * from './getSchemaTypeNameByName.js'
|
|
32
|
+
export * from './getSplittedAttributes.js'
|
|
33
|
+
export * from './getText.js'
|
|
34
|
+
export * from './getTextBetween.js'
|
|
35
|
+
export * from './getTextContentFromNodes.js'
|
|
36
|
+
export * from './getTextSerializersFromSchema.js'
|
|
37
|
+
export * from './injectExtensionAttributesToParseRule.js'
|
|
38
|
+
export * from './isActive.js'
|
|
39
|
+
export * from './isAtEndOfNode.js'
|
|
40
|
+
export * from './isAtStartOfNode.js'
|
|
41
|
+
export * from './isExtensionRulesEnabled.js'
|
|
42
|
+
export * from './isList.js'
|
|
43
|
+
export * from './isMarkActive.js'
|
|
44
|
+
export * from './isNodeActive.js'
|
|
45
|
+
export * from './isNodeEmpty.js'
|
|
46
|
+
export * from './isNodeSelection.js'
|
|
47
|
+
export * from './isTextSelection.js'
|
|
48
|
+
export * from './posToDOMRect.js'
|
|
49
|
+
export * from './resolveFocusPosition.js'
|
|
50
|
+
export * from './selectionToInsertionEnd.js'
|
|
51
|
+
export * from './splitExtensions.js'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ParseRule } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { ExtensionAttribute } from '../types'
|
|
4
|
-
import { fromString } from '../utilities/fromString'
|
|
3
|
+
import { ExtensionAttribute } from '../types.js'
|
|
4
|
+
import { fromString } from '../utilities/fromString.js'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* This function merges extension attributes into parserule attributes (`attrs` or `getAttrs`).
|
package/src/helpers/isActive.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EditorState } from '@tiptap/pm/state'
|
|
2
2
|
|
|
3
|
-
import { getSchemaTypeNameByName } from './getSchemaTypeNameByName'
|
|
4
|
-
import { isMarkActive } from './isMarkActive'
|
|
5
|
-
import { isNodeActive } from './isNodeActive'
|
|
3
|
+
import { getSchemaTypeNameByName } from './getSchemaTypeNameByName.js'
|
|
4
|
+
import { isMarkActive } from './isMarkActive.js'
|
|
5
|
+
import { isNodeActive } from './isNodeActive.js'
|
|
6
6
|
|
|
7
7
|
export function isActive(
|
|
8
8
|
state: EditorState,
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import { EditorState } from '@tiptap/pm/state'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { findParentNode } from './findParentNode.js'
|
|
4
|
+
|
|
5
|
+
export const isAtEndOfNode = (state: EditorState, nodeType?: string) => {
|
|
6
|
+
const { $from, $to, $anchor } = state.selection
|
|
7
|
+
|
|
8
|
+
if (nodeType) {
|
|
9
|
+
const parentNode = findParentNode(node => node.type.name === nodeType)(state.selection)
|
|
10
|
+
|
|
11
|
+
if (!parentNode) {
|
|
12
|
+
return false
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const $parentPos = state.doc.resolve(parentNode.pos + 1)
|
|
16
|
+
|
|
17
|
+
if ($anchor.pos + 1 === $parentPos.end()) {
|
|
18
|
+
return true
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return false
|
|
22
|
+
}
|
|
5
23
|
|
|
6
24
|
if ($to.parentOffset < $to.parent.nodeSize - 2 || $from.pos !== $to.pos) {
|
|
7
25
|
return false
|
package/src/helpers/isList.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Extensions } from '../types'
|
|
4
|
-
import { callOrReturn } from '../utilities/callOrReturn'
|
|
5
|
-
import { splitExtensions } from './splitExtensions'
|
|
1
|
+
import { getExtensionField } from '../helpers/getExtensionField.js'
|
|
2
|
+
import { NodeConfig } from '../index.js'
|
|
3
|
+
import { Extensions } from '../types.js'
|
|
4
|
+
import { callOrReturn } from '../utilities/callOrReturn.js'
|
|
5
|
+
import { splitExtensions } from './splitExtensions.js'
|
|
6
6
|
|
|
7
7
|
export function isList(name: string, extensions: Extensions): boolean {
|
|
8
8
|
const { nodeExtensions } = splitExtensions(extensions)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { MarkType } from '@tiptap/pm/model'
|
|
2
2
|
import { EditorState } from '@tiptap/pm/state'
|
|
3
3
|
|
|
4
|
-
import { MarkRange } from '../types'
|
|
5
|
-
import { objectIncludes } from '../utilities/objectIncludes'
|
|
6
|
-
import { getMarkType } from './getMarkType'
|
|
4
|
+
import { MarkRange } from '../types.js'
|
|
5
|
+
import { objectIncludes } from '../utilities/objectIncludes.js'
|
|
6
|
+
import { getMarkType } from './getMarkType.js'
|
|
7
7
|
|
|
8
8
|
export function isMarkActive(
|
|
9
9
|
state: EditorState,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { NodeType } from '@tiptap/pm/model'
|
|
2
2
|
import { EditorState } from '@tiptap/pm/state'
|
|
3
3
|
|
|
4
|
-
import { NodeRange } from '../types'
|
|
5
|
-
import { objectIncludes } from '../utilities/objectIncludes'
|
|
6
|
-
import { getNodeType } from './getNodeType'
|
|
4
|
+
import { NodeRange } from '../types.js'
|
|
5
|
+
import { objectIncludes } from '../utilities/objectIncludes.js'
|
|
6
|
+
import { getNodeType } from './getNodeType.js'
|
|
7
7
|
|
|
8
8
|
export function isNodeActive(
|
|
9
9
|
state: EditorState,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Node as ProseMirrorNode } from '@tiptap/pm/model'
|
|
2
2
|
import { Selection, TextSelection } from '@tiptap/pm/state'
|
|
3
3
|
|
|
4
|
-
import { FocusPosition } from '../types'
|
|
5
|
-
import { minMax } from '../utilities/minMax'
|
|
4
|
+
import { FocusPosition } from '../types.js'
|
|
5
|
+
import { minMax } from '../utilities/minMax.js'
|
|
6
6
|
|
|
7
7
|
export function resolveFocusPosition(
|
|
8
8
|
doc: ProseMirrorNode,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Extension } from '../Extension'
|
|
2
|
-
import { Mark } from '../Mark'
|
|
3
|
-
import { Node } from '../Node'
|
|
4
|
-
import { Extensions } from '../types'
|
|
1
|
+
import { Extension } from '../Extension.js'
|
|
2
|
+
import { Mark } from '../Mark.js'
|
|
3
|
+
import { Node } from '../Node.js'
|
|
4
|
+
import { Extensions } from '../types.js'
|
|
5
5
|
|
|
6
6
|
export function splitExtensions(extensions: Extensions) {
|
|
7
7
|
const baseExtensions = extensions.filter(extension => extension.type === 'extension') as Extension[]
|
package/src/index.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export * from './CommandManager'
|
|
2
|
-
export * from './Editor'
|
|
3
|
-
export * from './Extension'
|
|
4
|
-
export * as extensions from './extensions'
|
|
5
|
-
export * from './helpers'
|
|
6
|
-
export * from './InputRule'
|
|
7
|
-
export * from './inputRules'
|
|
8
|
-
export * from './Mark'
|
|
9
|
-
export * from './Node'
|
|
10
|
-
export * from './NodeView'
|
|
11
|
-
export * from './PasteRule'
|
|
12
|
-
export * from './pasteRules'
|
|
13
|
-
export * from './Tracker'
|
|
14
|
-
export * from './types'
|
|
15
|
-
export * from './utilities'
|
|
1
|
+
export * from './CommandManager.js'
|
|
2
|
+
export * from './Editor.js'
|
|
3
|
+
export * from './Extension.js'
|
|
4
|
+
export * as extensions from './extensions/index.js'
|
|
5
|
+
export * from './helpers/index.js'
|
|
6
|
+
export * from './InputRule.js'
|
|
7
|
+
export * from './inputRules/index.js'
|
|
8
|
+
export * from './Mark.js'
|
|
9
|
+
export * from './Node.js'
|
|
10
|
+
export * from './NodeView.js'
|
|
11
|
+
export * from './PasteRule.js'
|
|
12
|
+
export * from './pasteRules/index.js'
|
|
13
|
+
export * from './Tracker.js'
|
|
14
|
+
export * from './types.js'
|
|
15
|
+
export * from './utilities/index.js'
|
|
16
16
|
|
|
17
17
|
// eslint-disable-next-line
|
|
18
18
|
export interface Commands<ReturnType = any> {}
|