@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
package/src/helpers/getSchema.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Schema } from 'prosemirror-model'
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { ExtensionManager } from '../ExtensionManager'
|
|
4
4
|
import { Extensions } from '../types'
|
|
5
|
+
import { getSchemaByResolvedExtensions } from './getSchemaByResolvedExtensions'
|
|
5
6
|
|
|
6
7
|
export function getSchema(extensions: Extensions): Schema {
|
|
7
8
|
const resolvedExtensions = ExtensionManager.resolve(extensions)
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MarkSpec, NodeSpec, Schema } from 'prosemirror-model'
|
|
2
|
+
|
|
3
|
+
import { MarkConfig, NodeConfig } from '..'
|
|
2
4
|
import { AnyConfig, Extensions } from '../types'
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
+
import { callOrReturn } from '../utilities/callOrReturn'
|
|
6
|
+
import { isEmptyObject } from '../utilities/isEmptyObject'
|
|
5
7
|
import { getAttributesFromExtensions } from './getAttributesFromExtensions'
|
|
8
|
+
import { getExtensionField } from './getExtensionField'
|
|
6
9
|
import { getRenderedAttributes } from './getRenderedAttributes'
|
|
7
|
-
import { isEmptyObject } from '../utilities/isEmptyObject'
|
|
8
10
|
import { injectExtensionAttributesToParseRule } from './injectExtensionAttributesToParseRule'
|
|
9
|
-
import {
|
|
10
|
-
import { getExtensionField } from './getExtensionField'
|
|
11
|
+
import { splitExtensions } from './splitExtensions'
|
|
11
12
|
|
|
12
13
|
function cleanUpSchemaItem<T>(data: T) {
|
|
13
14
|
return Object.fromEntries(Object.entries(data).filter(([key, value]) => {
|
package/src/helpers/getText.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Range, TextSerializer } from '../types'
|
|
2
1
|
import { Node as ProseMirrorNode } from 'prosemirror-model'
|
|
3
2
|
|
|
3
|
+
import { Range, TextSerializer } from '../types'
|
|
4
|
+
|
|
4
5
|
export function getTextBetween(
|
|
5
6
|
startNode: ProseMirrorNode,
|
|
6
7
|
range: Range,
|
|
@@ -31,9 +32,10 @@ export function getTextBetween(
|
|
|
31
32
|
pos,
|
|
32
33
|
parent,
|
|
33
34
|
index,
|
|
35
|
+
range,
|
|
34
36
|
})
|
|
35
37
|
} else if (node.isText) {
|
|
36
|
-
text += node?.text?.slice(Math.max(from, pos) - pos, to - pos)
|
|
38
|
+
text += node?.text?.slice(Math.max(from, pos) - pos, to - pos) // eslint-disable-line
|
|
37
39
|
separated = false
|
|
38
40
|
} else if (node.isBlock && !separated) {
|
|
39
41
|
text += blockSeparator
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ResolvedPos } from 'prosemirror-model'
|
|
2
|
+
|
|
3
|
+
export const getTextContentFromNodes = ($from: ResolvedPos<any>, maxMatch = 500) => {
|
|
4
|
+
let textBefore = ''
|
|
5
|
+
|
|
6
|
+
$from.parent.nodesBetween(
|
|
7
|
+
Math.max(0, $from.parentOffset - maxMatch),
|
|
8
|
+
$from.parentOffset,
|
|
9
|
+
(node, pos, parent, index) => {
|
|
10
|
+
textBefore += node.type.spec.toText?.({
|
|
11
|
+
node, pos, parent, index,
|
|
12
|
+
}) || node.textContent || '%leaf%'
|
|
13
|
+
},
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
return textBefore
|
|
17
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Schema } from 'prosemirror-model'
|
|
2
|
+
|
|
2
3
|
import { TextSerializer } from '../types'
|
|
3
4
|
|
|
4
|
-
export function
|
|
5
|
+
export function getTextSerializersFromSchema(schema: Schema): Record<string, TextSerializer> {
|
|
5
6
|
return Object.fromEntries(Object
|
|
6
7
|
.entries(schema.nodes)
|
|
7
8
|
.filter(([, node]) => node.spec.toText)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export * from './combineTransactionSteps'
|
|
2
|
+
export * from './defaultBlockAt'
|
|
3
|
+
export * from './findChildren'
|
|
4
|
+
export * from './findChildrenInRange'
|
|
5
|
+
export * from './findParentNode'
|
|
6
|
+
export * from './findParentNodeClosestToPos'
|
|
7
|
+
export * from './generateHTML'
|
|
8
|
+
export * from './generateJSON'
|
|
9
|
+
export * from './generateText'
|
|
10
|
+
export * from './getAttributes'
|
|
11
|
+
export * from './getChangedRanges'
|
|
12
|
+
export * from './getDebugJSON'
|
|
13
|
+
export * from './getExtensionField'
|
|
14
|
+
export * from './getHTMLFromFragment'
|
|
15
|
+
export * from './getMarkAttributes'
|
|
16
|
+
export * from './getMarkRange'
|
|
17
|
+
export * from './getMarksBetween'
|
|
18
|
+
export * from './getMarkType'
|
|
19
|
+
export * from './getNodeAttributes'
|
|
20
|
+
export * from './getNodeType'
|
|
21
|
+
export * from './getSchema'
|
|
22
|
+
export * from './getText'
|
|
23
|
+
export * from './getTextBetween'
|
|
24
|
+
export * from './getTextContentFromNodes'
|
|
25
|
+
export * from './getTextSerializersFromSchema'
|
|
26
|
+
export * from './isActive'
|
|
27
|
+
export * from './isList'
|
|
28
|
+
export * from './isMarkActive'
|
|
29
|
+
export * from './isNodeActive'
|
|
30
|
+
export * from './isNodeEmpty'
|
|
31
|
+
export * from './isNodeSelection'
|
|
32
|
+
export * from './isTextSelection'
|
|
33
|
+
export * from './posToDOMRect'
|
package/src/helpers/isActive.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { EditorState } from 'prosemirror-state'
|
|
2
|
-
|
|
3
|
-
import { isMarkActive } from './isMarkActive'
|
|
2
|
+
|
|
4
3
|
import { getSchemaTypeNameByName } from './getSchemaTypeNameByName'
|
|
4
|
+
import { isMarkActive } from './isMarkActive'
|
|
5
|
+
import { isNodeActive } from './isNodeActive'
|
|
5
6
|
|
|
6
7
|
export function isActive(state: EditorState, name: string | null, attributes: Record<string, any> = {}): boolean {
|
|
7
8
|
if (!name) {
|
package/src/helpers/isList.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Extensions } from '../types'
|
|
2
1
|
import { NodeConfig } from '..'
|
|
3
|
-
import { splitExtensions } from './splitExtensions'
|
|
4
|
-
import { callOrReturn } from '../utilities/callOrReturn'
|
|
5
2
|
import { getExtensionField } from '../helpers/getExtensionField'
|
|
3
|
+
import { Extensions } from '../types'
|
|
4
|
+
import { callOrReturn } from '../utilities/callOrReturn'
|
|
5
|
+
import { splitExtensions } from './splitExtensions'
|
|
6
6
|
|
|
7
7
|
export function isList(name: string, extensions: Extensions): boolean {
|
|
8
8
|
const { nodeExtensions } = splitExtensions(extensions)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { EditorState } from 'prosemirror-state'
|
|
2
1
|
import { MarkType } from 'prosemirror-model'
|
|
2
|
+
import { EditorState } from 'prosemirror-state'
|
|
3
|
+
|
|
4
|
+
import { MarkRange } from '../types'
|
|
3
5
|
import { objectIncludes } from '../utilities/objectIncludes'
|
|
4
6
|
import { getMarkType } from './getMarkType'
|
|
5
|
-
import { MarkRange } from '../types'
|
|
6
7
|
|
|
7
8
|
export function isMarkActive(
|
|
8
9
|
state: EditorState,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { EditorState } from 'prosemirror-state'
|
|
2
1
|
import { NodeType } from 'prosemirror-model'
|
|
2
|
+
import { EditorState } from 'prosemirror-state'
|
|
3
|
+
|
|
4
|
+
import { NodeRange } from '../types'
|
|
3
5
|
import { objectIncludes } from '../utilities/objectIncludes'
|
|
4
6
|
import { getNodeType } from './getNodeType'
|
|
5
|
-
import { NodeRange } from '../types'
|
|
6
7
|
|
|
7
8
|
export function isNodeActive(
|
|
8
9
|
state: EditorState,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Selection, Transaction } from 'prosemirror-state'
|
|
2
|
-
import {
|
|
2
|
+
import { ReplaceAroundStep, ReplaceStep } from 'prosemirror-transform'
|
|
3
3
|
|
|
4
4
|
// source: https://github.com/ProseMirror/prosemirror-state/blob/master/src/selection.js#L466
|
|
5
5
|
export function selectionToInsertionEnd(tr: Transaction, startLen: number, bias: number) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Extensions } from '../types'
|
|
2
1
|
import { Extension } from '../Extension'
|
|
3
|
-
import { Node } from '../Node'
|
|
4
2
|
import { Mark } from '../Mark'
|
|
3
|
+
import { Node } from '../Node'
|
|
4
|
+
import { Extensions } from '../types'
|
|
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,60 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { extensions }
|
|
1
|
+
export * from './CommandManager'
|
|
4
2
|
export * from './Editor'
|
|
5
3
|
export * from './Extension'
|
|
6
|
-
export * from './
|
|
4
|
+
export * as extensions from './extensions'
|
|
5
|
+
export * from './helpers'
|
|
6
|
+
export * from './InputRule'
|
|
7
|
+
export * from './inputRules'
|
|
7
8
|
export * from './Mark'
|
|
9
|
+
export * from './Node'
|
|
8
10
|
export * from './NodeView'
|
|
9
|
-
export * from './Tracker'
|
|
10
|
-
export * from './InputRule'
|
|
11
11
|
export * from './PasteRule'
|
|
12
|
-
export * from './
|
|
12
|
+
export * from './pasteRules'
|
|
13
|
+
export * from './Tracker'
|
|
13
14
|
export * from './types'
|
|
14
|
-
|
|
15
|
-
export * from './inputRules/nodeInputRule'
|
|
16
|
-
export * from './inputRules/markInputRule'
|
|
17
|
-
export * from './inputRules/textblockTypeInputRule'
|
|
18
|
-
export * from './inputRules/textInputRule'
|
|
19
|
-
export * from './inputRules/wrappingInputRule'
|
|
20
|
-
export * from './pasteRules/markPasteRule'
|
|
21
|
-
export * from './pasteRules/textPasteRule'
|
|
22
|
-
|
|
23
|
-
export * from './utilities/callOrReturn'
|
|
24
|
-
export * from './utilities/escapeForRegEx'
|
|
25
|
-
export * from './utilities/mergeAttributes'
|
|
26
|
-
|
|
27
|
-
export * from './helpers/combineTransactionSteps'
|
|
28
|
-
export * from './helpers/defaultBlockAt'
|
|
29
|
-
export * from './helpers/getExtensionField'
|
|
30
|
-
export * from './helpers/findChildren'
|
|
31
|
-
export * from './helpers/findChildrenInRange'
|
|
32
|
-
export * from './helpers/findParentNode'
|
|
33
|
-
export * from './helpers/findParentNodeClosestToPos'
|
|
34
|
-
export * from './helpers/generateHTML'
|
|
35
|
-
export * from './helpers/generateJSON'
|
|
36
|
-
export * from './helpers/generateText'
|
|
37
|
-
export * from './helpers/getChangedRanges'
|
|
38
|
-
export * from './helpers/getSchema'
|
|
39
|
-
export * from './helpers/getHTMLFromFragment'
|
|
40
|
-
export * from './helpers/getDebugJSON'
|
|
41
|
-
export * from './helpers/getAttributes'
|
|
42
|
-
export * from './helpers/getMarkAttributes'
|
|
43
|
-
export * from './helpers/getMarkRange'
|
|
44
|
-
export * from './helpers/getMarkType'
|
|
45
|
-
export * from './helpers/getMarksBetween'
|
|
46
|
-
export * from './helpers/getNodeAttributes'
|
|
47
|
-
export * from './helpers/getNodeType'
|
|
48
|
-
export * from './helpers/getText'
|
|
49
|
-
export * from './helpers/getTextBetween'
|
|
50
|
-
export * from './helpers/isActive'
|
|
51
|
-
export * from './helpers/isList'
|
|
52
|
-
export * from './helpers/isMarkActive'
|
|
53
|
-
export * from './helpers/isNodeActive'
|
|
54
|
-
export * from './helpers/isNodeEmpty'
|
|
55
|
-
export * from './helpers/isNodeSelection'
|
|
56
|
-
export * from './helpers/isTextSelection'
|
|
57
|
-
export * from './helpers/posToDOMRect'
|
|
15
|
+
export * from './utilities'
|
|
58
16
|
|
|
59
17
|
// eslint-disable-next-line
|
|
60
18
|
export interface Commands<ReturnType = any> {}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { InputRule, InputRuleFinder } from '../InputRule'
|
|
2
1
|
import { MarkType } from 'prosemirror-model'
|
|
2
|
+
|
|
3
3
|
import { getMarksBetween } from '../helpers/getMarksBetween'
|
|
4
|
-
import {
|
|
4
|
+
import { InputRule, InputRuleFinder } from '../InputRule'
|
|
5
5
|
import { ExtendedRegExpMatchArray } from '../types'
|
|
6
|
+
import { callOrReturn } from '../utilities/callOrReturn'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Build an input rule that adds a mark when the
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { InputRule, InputRuleFinder } from '../InputRule'
|
|
2
1
|
import { NodeType } from 'prosemirror-model'
|
|
2
|
+
|
|
3
|
+
import { InputRule, InputRuleFinder } from '../InputRule'
|
|
3
4
|
import { ExtendedRegExpMatchArray } from '../types'
|
|
4
5
|
import { callOrReturn } from '../utilities/callOrReturn'
|
|
5
6
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Node as ProseMirrorNode, NodeType } from 'prosemirror-model'
|
|
2
|
+
import { canJoin, findWrapping } from 'prosemirror-transform'
|
|
3
|
+
|
|
1
4
|
import { InputRule, InputRuleFinder } from '../InputRule'
|
|
2
|
-
import { NodeType, Node as ProseMirrorNode } from 'prosemirror-model'
|
|
3
|
-
import { findWrapping, canJoin } from 'prosemirror-transform'
|
|
4
5
|
import { ExtendedRegExpMatchArray } from '../types'
|
|
5
6
|
import { callOrReturn } from '../utilities/callOrReturn'
|
|
6
7
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { PasteRule, PasteRuleFinder } from '../PasteRule'
|
|
2
1
|
import { MarkType } from 'prosemirror-model'
|
|
2
|
+
|
|
3
3
|
import { getMarksBetween } from '../helpers/getMarksBetween'
|
|
4
|
-
import {
|
|
4
|
+
import { PasteRule, PasteRuleFinder } from '../PasteRule'
|
|
5
5
|
import { ExtendedRegExpMatchArray } from '../types'
|
|
6
|
+
import { callOrReturn } from '../utilities/callOrReturn'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Build an paste rule that adds a mark when the
|
package/src/types.ts
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Node as ProseMirrorNode,
|
|
3
2
|
Mark as ProseMirrorMark,
|
|
3
|
+
Node as ProseMirrorNode,
|
|
4
4
|
ParseOptions,
|
|
5
5
|
} from 'prosemirror-model'
|
|
6
|
+
import { EditorState, Transaction } from 'prosemirror-state'
|
|
6
7
|
import {
|
|
7
|
-
EditorView,
|
|
8
8
|
Decoration,
|
|
9
|
-
NodeView,
|
|
10
9
|
EditorProps,
|
|
10
|
+
EditorView,
|
|
11
|
+
NodeView,
|
|
11
12
|
} from 'prosemirror-view'
|
|
12
|
-
|
|
13
|
-
import { Extension } from './Extension'
|
|
14
|
-
import { Node } from './Node'
|
|
15
|
-
import { Mark } from './Mark'
|
|
16
|
-
import { Editor } from './Editor'
|
|
13
|
+
|
|
17
14
|
import {
|
|
18
15
|
Commands,
|
|
19
16
|
ExtensionConfig,
|
|
20
|
-
NodeConfig,
|
|
21
17
|
MarkConfig,
|
|
18
|
+
NodeConfig,
|
|
22
19
|
} from '.'
|
|
20
|
+
import { Editor } from './Editor'
|
|
21
|
+
import { Extension } from './Extension'
|
|
22
|
+
import { Mark } from './Mark'
|
|
23
|
+
import { Node } from './Node'
|
|
23
24
|
|
|
24
25
|
export type AnyConfig = ExtensionConfig | NodeConfig | MarkConfig
|
|
25
26
|
export type AnyExtension = Extension | Node | Mark
|
|
@@ -70,6 +71,7 @@ export interface EditorOptions {
|
|
|
70
71
|
content: Content,
|
|
71
72
|
extensions: Extensions,
|
|
72
73
|
injectCSS: boolean,
|
|
74
|
+
injectNonce: string | undefined,
|
|
73
75
|
autofocus: FocusPosition,
|
|
74
76
|
editable: boolean,
|
|
75
77
|
editorProps: EditorProps,
|
|
@@ -127,6 +129,7 @@ export type Attribute = {
|
|
|
127
129
|
renderHTML?: ((attributes: Record<string, any>) => Record<string, any> | null) | null,
|
|
128
130
|
parseHTML?: ((element: HTMLElement) => any | null) | null,
|
|
129
131
|
keepOnSplit: boolean,
|
|
132
|
+
isRequired?: boolean,
|
|
130
133
|
}
|
|
131
134
|
|
|
132
135
|
export type Attributes = {
|
|
@@ -243,6 +246,7 @@ export type TextSerializer = (props: {
|
|
|
243
246
|
pos: number,
|
|
244
247
|
parent: ProseMirrorNode,
|
|
245
248
|
index: number,
|
|
249
|
+
range: Range,
|
|
246
250
|
}) => string
|
|
247
251
|
|
|
248
252
|
export type ExtendedRegExpMatchArray = RegExpMatchArray & {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function createStyleTag(style: string): HTMLStyleElement {
|
|
1
|
+
export function createStyleTag(style: string, nonce?: string): HTMLStyleElement {
|
|
2
2
|
const tipTapStyleTag = (<HTMLStyleElement>document.querySelector('style[data-tiptap-style]'))
|
|
3
3
|
|
|
4
4
|
if (tipTapStyleTag !== null) {
|
|
@@ -7,6 +7,10 @@ export function createStyleTag(style: string): HTMLStyleElement {
|
|
|
7
7
|
|
|
8
8
|
const styleNode = document.createElement('style')
|
|
9
9
|
|
|
10
|
+
if (nonce) {
|
|
11
|
+
styleNode.setAttribute('nonce', nonce)
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
styleNode.setAttribute('data-tiptap-style', '')
|
|
11
15
|
styleNode.innerHTML = style
|
|
12
16
|
document.getElementsByTagName('head')[0].appendChild(styleNode)
|