@tiptap/core 2.0.0-beta.174 → 2.0.0-beta.179
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/packages/core/src/CommandManager.d.ts +1 -1
- package/dist/packages/core/src/Editor.d.ts +3 -3
- package/dist/packages/core/src/Extension.d.ts +5 -5
- package/dist/packages/core/src/InputRule.d.ts +1 -1
- package/dist/packages/core/src/Mark.d.ts +5 -5
- package/dist/packages/core/src/Node.d.ts +4 -4
- package/dist/packages/core/src/NodeView.d.ts +2 -2
- package/dist/packages/core/src/PasteRule.d.ts +1 -1
- package/dist/packages/core/src/commands/deleteRange.d.ts +1 -1
- package/dist/packages/core/src/commands/focus.d.ts +1 -1
- package/dist/packages/core/src/commands/index.d.ts +50 -0
- 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/resetAttributes.d.ts +1 -1
- package/dist/packages/core/src/commands/setContent.d.ts +1 -1
- package/dist/packages/core/src/commands/setTextSelection.d.ts +1 -1
- package/dist/packages/core/src/commands/updateAttributes.d.ts +1 -1
- package/dist/packages/core/src/extensions/commands.d.ts +1 -100
- 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/findParentNodeClosestToPos.d.ts +1 -1
- package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +1 -1
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +1 -1
- package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +1 -1
- package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +1 -1
- package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +1 -1
- package/dist/packages/core/src/helpers/getRenderedAttributes.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/getTextContentFromNodes.d.ts +2 -0
- package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +3 -0
- package/dist/packages/core/src/helpers/index.d.ts +33 -0
- package/dist/packages/core/src/helpers/isMarkActive.d.ts +1 -1
- package/dist/packages/core/src/helpers/isNodeActive.d.ts +1 -1
- package/dist/packages/core/src/helpers/splitExtensions.d.ts +2 -2
- package/dist/packages/core/src/index.d.ts +9 -47
- package/dist/packages/core/src/inputRules/index.d.ts +5 -0
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +1 -1
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +1 -1
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +1 -1
- package/dist/packages/core/src/pasteRules/index.d.ts +2 -0
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +1 -1
- package/dist/packages/core/src/types.d.ts +8 -5
- package/dist/packages/core/src/utilities/createStyleTag.d.ts +1 -1
- package/dist/packages/core/src/utilities/index.d.ts +3 -0
- package/dist/tiptap-core.cjs.js +3494 -3713
- package/dist/tiptap-core.cjs.js.map +1 -1
- package/dist/tiptap-core.esm.js +3454 -3675
- package/dist/tiptap-core.esm.js.map +1 -1
- package/dist/tiptap-core.umd.js +3271 -3490
- package/dist/tiptap-core.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/CommandManager.ts +4 -3
- package/src/Editor.ts +17 -15
- package/src/Extension.ts +10 -9
- package/src/ExtensionManager.ts +11 -10
- package/src/InputRule.ts +9 -12
- package/src/Mark.ts +11 -10
- package/src/Node.ts +11 -10
- package/src/NodeView.ts +10 -5
- package/src/PasteRule.ts +7 -6
- package/src/commands/clearNodes.ts +1 -0
- package/src/commands/createParagraphNear.ts +1 -0
- package/src/commands/deleteNode.ts +1 -0
- package/src/commands/deleteRange.ts +1 -1
- package/src/commands/deleteSelection.ts +1 -0
- package/src/commands/exitCode.ts +1 -0
- package/src/commands/extendMarkRange.ts +4 -3
- package/src/commands/focus.ts +3 -3
- package/src/commands/index.ts +50 -0
- package/src/commands/insertContent.ts +2 -1
- package/src/commands/insertContentAt.ts +2 -1
- package/src/commands/joinBackward.ts +1 -0
- package/src/commands/joinForward.ts +1 -0
- package/src/commands/lift.ts +3 -2
- package/src/commands/liftEmptyBlock.ts +1 -0
- package/src/commands/liftListItem.ts +3 -2
- package/src/commands/newlineInCode.ts +1 -0
- package/src/commands/resetAttributes.ts +4 -3
- package/src/commands/selectNodeBackward.ts +1 -0
- package/src/commands/selectNodeForward.ts +1 -0
- package/src/commands/selectParentNode.ts +1 -0
- package/src/commands/selectTextblockEnd.ts +1 -0
- package/src/commands/selectTextblockStart.ts +1 -0
- package/src/commands/setContent.ts +3 -2
- package/src/commands/setMark.ts +3 -2
- package/src/commands/setNode.ts +3 -2
- package/src/commands/setNodeSelection.ts +3 -2
- package/src/commands/setTextSelection.ts +2 -1
- package/src/commands/sinkListItem.ts +3 -2
- package/src/commands/splitBlock.ts +3 -2
- package/src/commands/splitListItem.ts +5 -4
- package/src/commands/toggleList.ts +3 -2
- package/src/commands/toggleMark.ts +2 -1
- package/src/commands/toggleNode.ts +3 -2
- package/src/commands/toggleWrap.ts +3 -2
- package/src/commands/unsetMark.ts +3 -2
- package/src/commands/updateAttributes.ts +3 -2
- package/src/commands/wrapIn.ts +2 -1
- package/src/commands/wrapInList.ts +3 -2
- package/src/extensions/clipboardTextSerializer.ts +3 -2
- package/src/extensions/commands.ts +3 -150
- package/src/extensions/editable.ts +1 -0
- package/src/extensions/focusEvents.ts +1 -0
- package/src/extensions/keymap.ts +3 -4
- package/src/extensions/tabindex.ts +1 -0
- package/src/helpers/createDocument.ts +2 -1
- package/src/helpers/createNodeFromContent.ts +4 -3
- package/src/helpers/findChildren.ts +2 -1
- package/src/helpers/findChildrenInRange.ts +2 -1
- package/src/helpers/findParentNode.ts +2 -1
- package/src/helpers/findParentNodeClosestToPos.ts +2 -1
- package/src/helpers/generateHTML.ts +3 -2
- package/src/helpers/generateJSON.ts +3 -2
- package/src/helpers/generateText.ts +4 -3
- package/src/helpers/getAttributes.ts +3 -2
- package/src/helpers/getAttributesFromExtensions.ts +18 -11
- package/src/helpers/getChangedRanges.ts +2 -1
- package/src/helpers/getDebugJSON.ts +1 -0
- package/src/helpers/getExtensionField.ts +1 -1
- package/src/helpers/getHTMLFromFragment.ts +1 -1
- package/src/helpers/getMarkAttributes.ts +2 -1
- package/src/helpers/getMarkRange.ts +8 -3
- package/src/helpers/getMarksBetween.ts +1 -0
- package/src/helpers/getNodeAttributes.ts +2 -1
- package/src/helpers/getRenderedAttributes.ts +2 -1
- package/src/helpers/getSchema.ts +2 -1
- package/src/helpers/getSchemaByResolvedExtensions.ts +7 -6
- package/src/helpers/getText.ts +2 -1
- package/src/helpers/getTextBetween.ts +4 -2
- package/src/helpers/getTextContentFromNodes.ts +17 -0
- package/src/helpers/{getTextSeralizersFromSchema.ts → getTextSerializersFromSchema.ts} +2 -1
- package/src/helpers/index.ts +33 -0
- package/src/helpers/injectExtensionAttributesToParseRule.ts +1 -0
- package/src/helpers/isActive.ts +3 -2
- package/src/helpers/isList.ts +3 -3
- package/src/helpers/isMarkActive.ts +3 -2
- package/src/helpers/isNodeActive.ts +3 -2
- package/src/helpers/isNodeSelection.ts +1 -0
- package/src/helpers/isTextSelection.ts +1 -0
- package/src/helpers/posToDOMRect.ts +1 -0
- package/src/helpers/resolveFocusPosition.ts +1 -0
- package/src/helpers/selectionToInsertionEnd.ts +1 -1
- package/src/helpers/splitExtensions.ts +2 -2
- package/src/index.ts +9 -51
- package/src/inputRules/index.ts +5 -0
- package/src/inputRules/markInputRule.ts +3 -2
- package/src/inputRules/nodeInputRule.ts +1 -0
- package/src/inputRules/textblockTypeInputRule.ts +2 -1
- package/src/inputRules/wrappingInputRule.ts +3 -2
- package/src/pasteRules/index.ts +2 -0
- package/src/pasteRules/markPasteRule.ts +3 -2
- package/src/types.ts +13 -9
- package/src/utilities/createStyleTag.ts +5 -1
- package/src/utilities/index.ts +3 -0
- package/dist/packages/core/src/helpers/getTextSeralizersFromSchema.d.ts +0 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { NodeSelection, Selection } from 'prosemirror-state'
|
|
2
|
+
|
|
3
3
|
import { RawCommands } from '../types'
|
|
4
|
+
import { minMax } from '../utilities/minMax'
|
|
4
5
|
|
|
5
6
|
declare module '@tiptap/core' {
|
|
6
7
|
interface Commands<ReturnType> {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { sinkListItem as originalSinkListItem } from 'prosemirror-schema-list'
|
|
2
1
|
import { NodeType } from 'prosemirror-model'
|
|
3
|
-
import {
|
|
2
|
+
import { sinkListItem as originalSinkListItem } from 'prosemirror-schema-list'
|
|
3
|
+
|
|
4
4
|
import { getNodeType } from '../helpers/getNodeType'
|
|
5
|
+
import { RawCommands } from '../types'
|
|
5
6
|
|
|
6
7
|
declare module '@tiptap/core' {
|
|
7
8
|
interface Commands<ReturnType> {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { canSplit } from 'prosemirror-transform'
|
|
2
1
|
import { ContentMatch } from 'prosemirror-model'
|
|
3
2
|
import { EditorState, NodeSelection, TextSelection } from 'prosemirror-state'
|
|
4
|
-
import {
|
|
3
|
+
import { canSplit } from 'prosemirror-transform'
|
|
4
|
+
|
|
5
5
|
import { getSplittedAttributes } from '../helpers/getSplittedAttributes'
|
|
6
|
+
import { RawCommands } from '../types'
|
|
6
7
|
|
|
7
8
|
function defaultBlockAt(match: ContentMatch) {
|
|
8
9
|
for (let i = 0; i < match.edgeCount; i += 1) {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
NodeType,
|
|
3
|
-
Node as ProseMirrorNode,
|
|
4
2
|
Fragment,
|
|
3
|
+
Node as ProseMirrorNode,
|
|
4
|
+
NodeType,
|
|
5
5
|
Slice,
|
|
6
6
|
} from 'prosemirror-model'
|
|
7
|
-
import { canSplit } from 'prosemirror-transform'
|
|
8
7
|
import { TextSelection } from 'prosemirror-state'
|
|
9
|
-
import {
|
|
8
|
+
import { canSplit } from 'prosemirror-transform'
|
|
9
|
+
|
|
10
10
|
import { getNodeType } from '../helpers/getNodeType'
|
|
11
11
|
import { getSplittedAttributes } from '../helpers/getSplittedAttributes'
|
|
12
|
+
import { RawCommands } from '../types'
|
|
12
13
|
|
|
13
14
|
declare module '@tiptap/core' {
|
|
14
15
|
interface Commands<ReturnType> {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { NodeType } from 'prosemirror-model'
|
|
2
2
|
import { Transaction } from 'prosemirror-state'
|
|
3
3
|
import { canJoin } from 'prosemirror-transform'
|
|
4
|
-
|
|
5
|
-
import { getNodeType } from '../helpers/getNodeType'
|
|
4
|
+
|
|
6
5
|
import { findParentNode } from '../helpers/findParentNode'
|
|
6
|
+
import { getNodeType } from '../helpers/getNodeType'
|
|
7
7
|
import { isList } from '../helpers/isList'
|
|
8
|
+
import { RawCommands } from '../types'
|
|
8
9
|
|
|
9
10
|
const joinListBackwards = (tr: Transaction, listType: NodeType): boolean => {
|
|
10
11
|
const list = findParentNode(node => node.type === listType)(tr.selection)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { MarkType } from 'prosemirror-model'
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { getMarkType } from '../helpers/getMarkType'
|
|
4
4
|
import { isMarkActive } from '../helpers/isMarkActive'
|
|
5
|
+
import { RawCommands } from '../types'
|
|
5
6
|
|
|
6
7
|
declare module '@tiptap/core' {
|
|
7
8
|
interface Commands<ReturnType> {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { NodeType } from 'prosemirror-model'
|
|
2
|
-
|
|
3
|
-
import { isNodeActive } from '../helpers/isNodeActive'
|
|
2
|
+
|
|
4
3
|
import { getNodeType } from '../helpers/getNodeType'
|
|
4
|
+
import { isNodeActive } from '../helpers/isNodeActive'
|
|
5
|
+
import { RawCommands } from '../types'
|
|
5
6
|
|
|
6
7
|
declare module '@tiptap/core' {
|
|
7
8
|
interface Commands<ReturnType> {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { NodeType } from 'prosemirror-model'
|
|
2
|
-
|
|
3
|
-
import { isNodeActive } from '../helpers/isNodeActive'
|
|
2
|
+
|
|
4
3
|
import { getNodeType } from '../helpers/getNodeType'
|
|
4
|
+
import { isNodeActive } from '../helpers/isNodeActive'
|
|
5
|
+
import { RawCommands } from '../types'
|
|
5
6
|
|
|
6
7
|
declare module '@tiptap/core' {
|
|
7
8
|
interface Commands<ReturnType> {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { MarkType } from 'prosemirror-model'
|
|
2
|
-
|
|
3
|
-
import { getMarkType } from '../helpers/getMarkType'
|
|
2
|
+
|
|
4
3
|
import { getMarkRange } from '../helpers/getMarkRange'
|
|
4
|
+
import { getMarkType } from '../helpers/getMarkType'
|
|
5
|
+
import { RawCommands } from '../types'
|
|
5
6
|
|
|
6
7
|
declare module '@tiptap/core' {
|
|
7
8
|
interface Commands<ReturnType> {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { MarkType, NodeType } from 'prosemirror-model'
|
|
2
|
+
|
|
3
3
|
import { getMarkType } from '../helpers/getMarkType'
|
|
4
|
+
import { getNodeType } from '../helpers/getNodeType'
|
|
4
5
|
import { getSchemaTypeNameByName } from '../helpers/getSchemaTypeNameByName'
|
|
5
6
|
import { RawCommands } from '../types'
|
|
6
7
|
|
package/src/commands/wrapIn.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { wrapIn as originalWrapIn } from 'prosemirror-commands'
|
|
2
2
|
import { NodeType } from 'prosemirror-model'
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import { getNodeType } from '../helpers/getNodeType'
|
|
5
|
+
import { RawCommands } from '../types'
|
|
5
6
|
|
|
6
7
|
declare module '@tiptap/core' {
|
|
7
8
|
interface Commands<ReturnType> {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { wrapInList as originalWrapInList } from 'prosemirror-schema-list'
|
|
2
1
|
import { NodeType } from 'prosemirror-model'
|
|
3
|
-
import {
|
|
2
|
+
import { wrapInList as originalWrapInList } from 'prosemirror-schema-list'
|
|
3
|
+
|
|
4
4
|
import { getNodeType } from '../helpers/getNodeType'
|
|
5
|
+
import { RawCommands } from '../types'
|
|
5
6
|
|
|
6
7
|
declare module '@tiptap/core' {
|
|
7
8
|
interface Commands<ReturnType> {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Plugin, PluginKey } from 'prosemirror-state'
|
|
2
|
+
|
|
2
3
|
import { Extension } from '../Extension'
|
|
3
4
|
import { getTextBetween } from '../helpers/getTextBetween'
|
|
4
|
-
import {
|
|
5
|
+
import { getTextSerializersFromSchema } from '../helpers/getTextSerializersFromSchema'
|
|
5
6
|
|
|
6
7
|
export const ClipboardTextSerializer = Extension.create({
|
|
7
8
|
name: 'clipboardTextSerializer',
|
|
@@ -18,7 +19,7 @@ export const ClipboardTextSerializer = Extension.create({
|
|
|
18
19
|
const { ranges } = selection
|
|
19
20
|
const from = Math.min(...ranges.map(range => range.$from.pos))
|
|
20
21
|
const to = Math.max(...ranges.map(range => range.$to.pos))
|
|
21
|
-
const textSerializers =
|
|
22
|
+
const textSerializers = getTextSerializersFromSchema(schema)
|
|
22
23
|
const range = { from, to }
|
|
23
24
|
|
|
24
25
|
return getTextBetween(doc, range, {
|
|
@@ -1,161 +1,14 @@
|
|
|
1
|
+
import * as commands from '../commands'
|
|
1
2
|
import { Extension } from '../Extension'
|
|
2
|
-
import * as blur from '../commands/blur'
|
|
3
|
-
import * as clearContent from '../commands/clearContent'
|
|
4
|
-
import * as clearNodes from '../commands/clearNodes'
|
|
5
|
-
import * as command from '../commands/command'
|
|
6
|
-
import * as createParagraphNear from '../commands/createParagraphNear'
|
|
7
|
-
import * as deleteNode from '../commands/deleteNode'
|
|
8
|
-
import * as deleteRange from '../commands/deleteRange'
|
|
9
|
-
import * as deleteSelection from '../commands/deleteSelection'
|
|
10
|
-
import * as enter from '../commands/enter'
|
|
11
|
-
import * as exitCode from '../commands/exitCode'
|
|
12
|
-
import * as extendMarkRange from '../commands/extendMarkRange'
|
|
13
|
-
import * as first from '../commands/first'
|
|
14
|
-
import * as focus from '../commands/focus'
|
|
15
|
-
import * as forEach from '../commands/forEach'
|
|
16
|
-
import * as insertContent from '../commands/insertContent'
|
|
17
|
-
import * as insertContentAt from '../commands/insertContentAt'
|
|
18
|
-
import * as joinBackward from '../commands/joinBackward'
|
|
19
|
-
import * as joinForward from '../commands/joinForward'
|
|
20
|
-
import * as keyboardShortcut from '../commands/keyboardShortcut'
|
|
21
|
-
import * as lift from '../commands/lift'
|
|
22
|
-
import * as liftEmptyBlock from '../commands/liftEmptyBlock'
|
|
23
|
-
import * as liftListItem from '../commands/liftListItem'
|
|
24
|
-
import * as newlineInCode from '../commands/newlineInCode'
|
|
25
|
-
import * as resetAttributes from '../commands/resetAttributes'
|
|
26
|
-
import * as scrollIntoView from '../commands/scrollIntoView'
|
|
27
|
-
import * as selectAll from '../commands/selectAll'
|
|
28
|
-
import * as selectNodeBackward from '../commands/selectNodeBackward'
|
|
29
|
-
import * as selectNodeForward from '../commands/selectNodeForward'
|
|
30
|
-
import * as selectParentNode from '../commands/selectParentNode'
|
|
31
|
-
import * as selectTextblockEnd from '../commands/selectTextblockEnd'
|
|
32
|
-
import * as selectTextblockStart from '../commands/selectTextblockStart'
|
|
33
|
-
import * as setContent from '../commands/setContent'
|
|
34
|
-
import * as setMark from '../commands/setMark'
|
|
35
|
-
import * as setMeta from '../commands/setMeta'
|
|
36
|
-
import * as setNode from '../commands/setNode'
|
|
37
|
-
import * as setNodeSelection from '../commands/setNodeSelection'
|
|
38
|
-
import * as setTextSelection from '../commands/setTextSelection'
|
|
39
|
-
import * as sinkListItem from '../commands/sinkListItem'
|
|
40
|
-
import * as splitBlock from '../commands/splitBlock'
|
|
41
|
-
import * as splitListItem from '../commands/splitListItem'
|
|
42
|
-
import * as toggleList from '../commands/toggleList'
|
|
43
|
-
import * as toggleMark from '../commands/toggleMark'
|
|
44
|
-
import * as toggleNode from '../commands/toggleNode'
|
|
45
|
-
import * as toggleWrap from '../commands/toggleWrap'
|
|
46
|
-
import * as undoInputRule from '../commands/undoInputRule'
|
|
47
|
-
import * as unsetAllMarks from '../commands/unsetAllMarks'
|
|
48
|
-
import * as unsetMark from '../commands/unsetMark'
|
|
49
|
-
import * as updateAttributes from '../commands/updateAttributes'
|
|
50
|
-
import * as wrapIn from '../commands/wrapIn'
|
|
51
|
-
import * as wrapInList from '../commands/wrapInList'
|
|
52
3
|
|
|
53
|
-
export
|
|
54
|
-
export { clearContent }
|
|
55
|
-
export { clearNodes }
|
|
56
|
-
export { command }
|
|
57
|
-
export { createParagraphNear }
|
|
58
|
-
export { deleteNode }
|
|
59
|
-
export { deleteRange }
|
|
60
|
-
export { deleteSelection }
|
|
61
|
-
export { enter }
|
|
62
|
-
export { exitCode }
|
|
63
|
-
export { extendMarkRange }
|
|
64
|
-
export { first }
|
|
65
|
-
export { focus }
|
|
66
|
-
export { forEach }
|
|
67
|
-
export { insertContent }
|
|
68
|
-
export { insertContentAt }
|
|
69
|
-
export { joinBackward }
|
|
70
|
-
export { joinForward }
|
|
71
|
-
export { keyboardShortcut }
|
|
72
|
-
export { lift }
|
|
73
|
-
export { liftEmptyBlock }
|
|
74
|
-
export { liftListItem }
|
|
75
|
-
export { newlineInCode }
|
|
76
|
-
export { resetAttributes }
|
|
77
|
-
export { scrollIntoView }
|
|
78
|
-
export { selectAll }
|
|
79
|
-
export { selectNodeBackward }
|
|
80
|
-
export { selectNodeForward }
|
|
81
|
-
export { selectParentNode }
|
|
82
|
-
export { selectTextblockEnd }
|
|
83
|
-
export { selectTextblockStart }
|
|
84
|
-
export { setContent }
|
|
85
|
-
export { setMark }
|
|
86
|
-
export { setMeta }
|
|
87
|
-
export { setNode }
|
|
88
|
-
export { setNodeSelection }
|
|
89
|
-
export { setTextSelection }
|
|
90
|
-
export { sinkListItem }
|
|
91
|
-
export { splitBlock }
|
|
92
|
-
export { splitListItem }
|
|
93
|
-
export { toggleList }
|
|
94
|
-
export { toggleMark }
|
|
95
|
-
export { toggleNode }
|
|
96
|
-
export { toggleWrap }
|
|
97
|
-
export { undoInputRule }
|
|
98
|
-
export { unsetAllMarks }
|
|
99
|
-
export { unsetMark }
|
|
100
|
-
export { updateAttributes }
|
|
101
|
-
export { wrapIn }
|
|
102
|
-
export { wrapInList }
|
|
4
|
+
export * from '../commands'
|
|
103
5
|
|
|
104
6
|
export const Commands = Extension.create({
|
|
105
7
|
name: 'commands',
|
|
106
8
|
|
|
107
9
|
addCommands() {
|
|
108
10
|
return {
|
|
109
|
-
...
|
|
110
|
-
...clearContent,
|
|
111
|
-
...clearNodes,
|
|
112
|
-
...command,
|
|
113
|
-
...createParagraphNear,
|
|
114
|
-
...deleteNode,
|
|
115
|
-
...deleteRange,
|
|
116
|
-
...deleteSelection,
|
|
117
|
-
...enter,
|
|
118
|
-
...exitCode,
|
|
119
|
-
...extendMarkRange,
|
|
120
|
-
...first,
|
|
121
|
-
...focus,
|
|
122
|
-
...forEach,
|
|
123
|
-
...insertContent,
|
|
124
|
-
...insertContentAt,
|
|
125
|
-
...joinBackward,
|
|
126
|
-
...joinForward,
|
|
127
|
-
...keyboardShortcut,
|
|
128
|
-
...lift,
|
|
129
|
-
...liftEmptyBlock,
|
|
130
|
-
...liftListItem,
|
|
131
|
-
...newlineInCode,
|
|
132
|
-
...resetAttributes,
|
|
133
|
-
...scrollIntoView,
|
|
134
|
-
...selectAll,
|
|
135
|
-
...selectNodeBackward,
|
|
136
|
-
...selectNodeForward,
|
|
137
|
-
...selectParentNode,
|
|
138
|
-
...selectTextblockEnd,
|
|
139
|
-
...selectTextblockStart,
|
|
140
|
-
...setContent,
|
|
141
|
-
...setMark,
|
|
142
|
-
...setMeta,
|
|
143
|
-
...setNode,
|
|
144
|
-
...setNodeSelection,
|
|
145
|
-
...setTextSelection,
|
|
146
|
-
...sinkListItem,
|
|
147
|
-
...splitBlock,
|
|
148
|
-
...splitListItem,
|
|
149
|
-
...toggleList,
|
|
150
|
-
...toggleMark,
|
|
151
|
-
...toggleNode,
|
|
152
|
-
...toggleWrap,
|
|
153
|
-
...undoInputRule,
|
|
154
|
-
...unsetAllMarks,
|
|
155
|
-
...unsetMark,
|
|
156
|
-
...updateAttributes,
|
|
157
|
-
...wrapIn,
|
|
158
|
-
...wrapInList,
|
|
11
|
+
...commands,
|
|
159
12
|
}
|
|
160
13
|
},
|
|
161
14
|
})
|
package/src/extensions/keymap.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Plugin, PluginKey, Selection } from 'prosemirror-state'
|
|
2
|
+
|
|
3
|
+
import { CommandManager } from '../CommandManager'
|
|
4
|
+
import { Extension } from '../Extension'
|
|
2
5
|
import { createChainableState } from '../helpers/createChainableState'
|
|
3
6
|
import { isiOS } from '../utilities/isiOS'
|
|
4
7
|
import { isMacOS } from '../utilities/isMacOS'
|
|
5
|
-
import { CommandManager } from '../CommandManager'
|
|
6
|
-
import { Extension } from '../Extension'
|
|
7
8
|
|
|
8
9
|
export const Keymap = Extension.create({
|
|
9
10
|
name: 'keymap',
|
|
@@ -60,8 +61,6 @@ export const Keymap = Extension.create({
|
|
|
60
61
|
|
|
61
62
|
const pcKeymap = {
|
|
62
63
|
...baseKeymap,
|
|
63
|
-
Home: () => this.editor.commands.selectTextblockStart(),
|
|
64
|
-
End: () => this.editor.commands.selectTextblockEnd(),
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
const macKeymap = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Node as ProseMirrorNode, ParseOptions, Schema } from 'prosemirror-model'
|
|
2
|
+
|
|
2
3
|
import { Content } from '../types'
|
|
3
4
|
import { createNodeFromContent } from './createNodeFromContent'
|
|
4
5
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Schema,
|
|
3
2
|
DOMParser,
|
|
4
|
-
Node as ProseMirrorNode,
|
|
5
3
|
Fragment,
|
|
4
|
+
Node as ProseMirrorNode,
|
|
6
5
|
ParseOptions,
|
|
6
|
+
Schema,
|
|
7
7
|
} from 'prosemirror-model'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
import { Content } from '../types'
|
|
10
|
+
import { elementFromString } from '../utilities/elementFromString'
|
|
10
11
|
|
|
11
12
|
export type CreateNodeFromContentOptions = {
|
|
12
13
|
slice?: boolean,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Node as ProseMirrorNode } from 'prosemirror-model'
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { NodeWithPos, Predicate } from '../types'
|
|
3
4
|
|
|
4
5
|
export function findChildren(node: ProseMirrorNode, predicate: Predicate): NodeWithPos[] {
|
|
5
6
|
const nodesWithPos: NodeWithPos[] = []
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Selection } from 'prosemirror-state'
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { Predicate } from '../types'
|
|
4
|
+
import { findParentNodeClosestToPos } from './findParentNodeClosestToPos'
|
|
4
5
|
|
|
5
6
|
export function findParentNode(predicate: Predicate) {
|
|
6
7
|
return (selection: Selection) => findParentNodeClosestToPos(selection.$from, predicate)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Node as ProseMirrorNode, ResolvedPos } from 'prosemirror-model'
|
|
2
|
+
|
|
2
3
|
import { Predicate } from '../types'
|
|
3
4
|
|
|
4
5
|
export function findParentNodeClosestToPos($pos: ResolvedPos, predicate: Predicate): ({
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Node } from 'prosemirror-model'
|
|
2
|
-
|
|
3
|
-
import { getHTMLFromFragment } from './getHTMLFromFragment'
|
|
2
|
+
|
|
4
3
|
import { Extensions, JSONContent } from '../types'
|
|
4
|
+
import { getHTMLFromFragment } from './getHTMLFromFragment'
|
|
5
|
+
import { getSchema } from './getSchema'
|
|
5
6
|
|
|
6
7
|
export function generateHTML(doc: JSONContent, extensions: Extensions): string {
|
|
7
8
|
const schema = getSchema(extensions)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { DOMParser } from 'prosemirror-model'
|
|
2
|
-
|
|
3
|
-
import { elementFromString } from '../utilities/elementFromString'
|
|
2
|
+
|
|
4
3
|
import { Extensions } from '../types'
|
|
4
|
+
import { elementFromString } from '../utilities/elementFromString'
|
|
5
|
+
import { getSchema } from './getSchema'
|
|
5
6
|
|
|
6
7
|
export function generateJSON(html: string, extensions: Extensions): Record<string, any> {
|
|
7
8
|
const schema = getSchema(extensions)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Node } from 'prosemirror-model'
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { Extensions, JSONContent, TextSerializer } from '../types'
|
|
4
|
-
import {
|
|
4
|
+
import { getSchema } from './getSchema'
|
|
5
5
|
import { getText } from './getText'
|
|
6
|
+
import { getTextSerializersFromSchema } from './getTextSerializersFromSchema'
|
|
6
7
|
|
|
7
8
|
export function generateText(
|
|
8
9
|
doc: JSONContent,
|
|
@@ -23,7 +24,7 @@ export function generateText(
|
|
|
23
24
|
blockSeparator,
|
|
24
25
|
textSerializers: {
|
|
25
26
|
...textSerializers,
|
|
26
|
-
...
|
|
27
|
+
...getTextSerializersFromSchema(schema),
|
|
27
28
|
},
|
|
28
29
|
})
|
|
29
30
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { MarkType, NodeType } from 'prosemirror-model'
|
|
2
2
|
import { EditorState } from 'prosemirror-state'
|
|
3
|
-
|
|
4
|
-
import { getNodeAttributes } from './getNodeAttributes'
|
|
3
|
+
|
|
5
4
|
import { getMarkAttributes } from './getMarkAttributes'
|
|
5
|
+
import { getNodeAttributes } from './getNodeAttributes'
|
|
6
|
+
import { getSchemaTypeNameByName } from './getSchemaTypeNameByName'
|
|
6
7
|
|
|
7
8
|
export function getAttributes(
|
|
8
9
|
state: EditorState,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getExtensionField } from './getExtensionField'
|
|
1
|
+
import { MarkConfig, NodeConfig } from '..'
|
|
3
2
|
import {
|
|
4
|
-
|
|
5
|
-
GlobalAttributes,
|
|
6
|
-
Attributes,
|
|
3
|
+
AnyConfig,
|
|
7
4
|
Attribute,
|
|
5
|
+
Attributes,
|
|
8
6
|
ExtensionAttribute,
|
|
9
|
-
|
|
7
|
+
Extensions,
|
|
8
|
+
GlobalAttributes,
|
|
10
9
|
} from '../types'
|
|
11
|
-
import {
|
|
10
|
+
import { getExtensionField } from './getExtensionField'
|
|
11
|
+
import { splitExtensions } from './splitExtensions'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Get a list of all extension attributes defined in `addAttribute` and `addGlobalAttribute`.
|
|
@@ -24,6 +24,7 @@ export function getAttributesFromExtensions(extensions: Extensions): ExtensionAt
|
|
|
24
24
|
renderHTML: null,
|
|
25
25
|
parseHTML: null,
|
|
26
26
|
keepOnSplit: true,
|
|
27
|
+
isRequired: false,
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
extensions.forEach(extension => {
|
|
@@ -87,13 +88,19 @@ export function getAttributesFromExtensions(extensions: Extensions): ExtensionAt
|
|
|
87
88
|
Object
|
|
88
89
|
.entries(attributes)
|
|
89
90
|
.forEach(([name, attribute]) => {
|
|
91
|
+
const mergedAttr = {
|
|
92
|
+
...defaultAttribute,
|
|
93
|
+
...attribute,
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (attribute.isRequired && attribute.default === undefined) {
|
|
97
|
+
delete mergedAttr.default
|
|
98
|
+
}
|
|
99
|
+
|
|
90
100
|
extensionAttributes.push({
|
|
91
101
|
type: extension.name,
|
|
92
102
|
name,
|
|
93
|
-
attribute:
|
|
94
|
-
...defaultAttribute,
|
|
95
|
-
...attribute,
|
|
96
|
-
},
|
|
103
|
+
attribute: mergedAttr,
|
|
97
104
|
})
|
|
98
105
|
})
|
|
99
106
|
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { EditorState } from 'prosemirror-state'
|
|
2
1
|
import { Mark, MarkType } from 'prosemirror-model'
|
|
2
|
+
import { EditorState } from 'prosemirror-state'
|
|
3
|
+
|
|
3
4
|
import { getMarkType } from './getMarkType'
|
|
4
5
|
|
|
5
6
|
export function getMarkAttributes(state: EditorState, typeOrName: string | MarkType): Record<string, any> {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Mark as ProseMirrorMark, MarkType, ResolvedPos } from 'prosemirror-model'
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { Range } from '../types'
|
|
4
|
+
import { objectIncludes } from '../utilities/objectIncludes'
|
|
4
5
|
|
|
5
6
|
function findMarkInSet(
|
|
6
7
|
marks: ProseMirrorMark[],
|
|
@@ -29,7 +30,11 @@ export function getMarkRange(
|
|
|
29
30
|
return
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
let start = $pos.parent.childAfter($pos.parentOffset)
|
|
34
|
+
|
|
35
|
+
if ($pos.parentOffset === start.offset && start.offset !== 0) {
|
|
36
|
+
start = $pos.parent.childBefore($pos.parentOffset)
|
|
37
|
+
}
|
|
33
38
|
|
|
34
39
|
if (!start.node) {
|
|
35
40
|
return
|
|
@@ -41,7 +46,7 @@ export function getMarkRange(
|
|
|
41
46
|
return
|
|
42
47
|
}
|
|
43
48
|
|
|
44
|
-
let startIndex =
|
|
49
|
+
let startIndex = start.index
|
|
45
50
|
let startPos = $pos.start() + start.offset
|
|
46
51
|
let endIndex = startIndex + 1
|
|
47
52
|
let endPos = startPos + start.node.nodeSize
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { EditorState } from 'prosemirror-state'
|
|
2
1
|
import { Node, NodeType } from 'prosemirror-model'
|
|
2
|
+
import { EditorState } from 'prosemirror-state'
|
|
3
|
+
|
|
3
4
|
import { getNodeType } from './getNodeType'
|
|
4
5
|
|
|
5
6
|
export function getNodeAttributes(state: EditorState, typeOrName: string | NodeType): Record<string, any> {
|