@tiptap/core 2.0.0-beta.138 → 2.0.0-beta.141
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/helpers/isExtensionRulesEnabled.d.ts +2 -0
- package/dist/packages/core/src/style.d.ts +1 -1
- package/dist/packages/core/src/types.d.ts +4 -3
- package/dist/tiptap-core.cjs.js +26 -4
- package/dist/tiptap-core.cjs.js.map +1 -1
- package/dist/tiptap-core.esm.js +26 -4
- package/dist/tiptap-core.esm.js.map +1 -1
- package/dist/tiptap-core.umd.js +26 -4
- package/dist/tiptap-core.umd.js.map +1 -1
- package/package.json +3 -3
- package/src/ExtensionManager.ts +3 -2
- package/src/NodeView.ts +6 -1
- package/src/commands/focus.ts +9 -2
- package/src/helpers/isExtensionRulesEnabled.ts +15 -0
- package/src/style.ts +1 -0
- package/src/types.ts +5 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/core",
|
|
3
3
|
"description": "headless rich text editor",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.141",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"prosemirror-schema-list": "^1.1.6",
|
|
38
38
|
"prosemirror-state": "^1.3.4",
|
|
39
39
|
"prosemirror-transform": "^1.3.3",
|
|
40
|
-
"prosemirror-view": "^1.
|
|
40
|
+
"prosemirror-view": "^1.23.1"
|
|
41
41
|
},
|
|
42
42
|
"repository": {
|
|
43
43
|
"type": "git",
|
|
44
44
|
"url": "https://github.com/ueberdosis/tiptap",
|
|
45
45
|
"directory": "packages/core"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "53f6ad47bcb6c6f718faef6245061fe023c94d61"
|
|
48
48
|
}
|
package/src/ExtensionManager.ts
CHANGED
|
@@ -13,6 +13,7 @@ import getNodeType from './helpers/getNodeType'
|
|
|
13
13
|
import splitExtensions from './helpers/splitExtensions'
|
|
14
14
|
import getAttributesFromExtensions from './helpers/getAttributesFromExtensions'
|
|
15
15
|
import getRenderedAttributes from './helpers/getRenderedAttributes'
|
|
16
|
+
import isExtensionRulesEnabled from './helpers/isExtensionRulesEnabled'
|
|
16
17
|
import callOrReturn from './utilities/callOrReturn'
|
|
17
18
|
import findDuplicates from './utilities/findDuplicates'
|
|
18
19
|
import { NodeConfig } from '.'
|
|
@@ -270,7 +271,7 @@ export default class ExtensionManager {
|
|
|
270
271
|
context,
|
|
271
272
|
)
|
|
272
273
|
|
|
273
|
-
if (editor.options.enableInputRules && addInputRules) {
|
|
274
|
+
if (isExtensionRulesEnabled(extension, editor.options.enableInputRules) && addInputRules) {
|
|
274
275
|
inputRules.push(...addInputRules())
|
|
275
276
|
}
|
|
276
277
|
|
|
@@ -280,7 +281,7 @@ export default class ExtensionManager {
|
|
|
280
281
|
context,
|
|
281
282
|
)
|
|
282
283
|
|
|
283
|
-
if (editor.options.enablePasteRules && addPasteRules) {
|
|
284
|
+
if (isExtensionRulesEnabled(extension, editor.options.enablePasteRules) && addPasteRules) {
|
|
284
285
|
pasteRules.push(...addPasteRules())
|
|
285
286
|
}
|
|
286
287
|
|
package/src/NodeView.ts
CHANGED
|
@@ -202,7 +202,12 @@ export class NodeView<
|
|
|
202
202
|
// this is because ProseMirror can’t preventDispatch on enter
|
|
203
203
|
// this will lead to a re-render of the node view on enter
|
|
204
204
|
// see: https://github.com/ueberdosis/tiptap/issues/1214
|
|
205
|
-
if (
|
|
205
|
+
if (
|
|
206
|
+
this.dom.contains(mutation.target)
|
|
207
|
+
&& mutation.type === 'childList'
|
|
208
|
+
&& isiOS()
|
|
209
|
+
&& this.editor.isFocused
|
|
210
|
+
) {
|
|
206
211
|
const changedNodes = [
|
|
207
212
|
...Array.from(mutation.addedNodes),
|
|
208
213
|
...Array.from(mutation.removedNodes),
|
package/src/commands/focus.ts
CHANGED
|
@@ -16,15 +16,22 @@ function resolveSelection(state: EditorState, position: FocusPosition = null) {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
const { size } = state.doc.content
|
|
19
|
+
const { size } = state.doc.content
|
|
21
20
|
|
|
21
|
+
if (position === 'end') {
|
|
22
22
|
return {
|
|
23
23
|
from: size,
|
|
24
24
|
to: size,
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
if (position === 'all') {
|
|
29
|
+
return {
|
|
30
|
+
from: 0,
|
|
31
|
+
to: size,
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
return {
|
|
29
36
|
from: position,
|
|
30
37
|
to: position,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AnyExtension, EnableRules } from '../types'
|
|
2
|
+
|
|
3
|
+
export default function isExtensionRulesEnabled(extension: AnyExtension, enabled: EnableRules): boolean {
|
|
4
|
+
if (Array.isArray(enabled)) {
|
|
5
|
+
return enabled.some(enabledExtension => {
|
|
6
|
+
const name = typeof enabledExtension === 'string'
|
|
7
|
+
? enabledExtension
|
|
8
|
+
: enabledExtension.name
|
|
9
|
+
|
|
10
|
+
return name === extension.name
|
|
11
|
+
})
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return enabled
|
|
15
|
+
}
|
package/src/style.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -63,6 +63,8 @@ export interface EditorEvents {
|
|
|
63
63
|
destroy: void,
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
export type EnableRules = (AnyExtension | string)[] | boolean
|
|
67
|
+
|
|
66
68
|
export interface EditorOptions {
|
|
67
69
|
element: Element,
|
|
68
70
|
content: Content,
|
|
@@ -72,8 +74,8 @@ export interface EditorOptions {
|
|
|
72
74
|
editable: boolean,
|
|
73
75
|
editorProps: EditorProps,
|
|
74
76
|
parseOptions: ParseOptions,
|
|
75
|
-
enableInputRules:
|
|
76
|
-
enablePasteRules:
|
|
77
|
+
enableInputRules: EnableRules,
|
|
78
|
+
enablePasteRules: EnableRules,
|
|
77
79
|
enableCoreExtensions: boolean,
|
|
78
80
|
onBeforeCreate: (props: EditorEvents['beforeCreate']) => void,
|
|
79
81
|
onCreate: (props: EditorEvents['create']) => void,
|
|
@@ -210,7 +212,7 @@ export type ChainedCommands = {
|
|
|
210
212
|
|
|
211
213
|
export type CanCommands = SingleCommands & { chain: () => ChainedCommands }
|
|
212
214
|
|
|
213
|
-
export type FocusPosition = 'start' | 'end' | number | boolean | null
|
|
215
|
+
export type FocusPosition = 'start' | 'end' | 'all' | number | boolean | null
|
|
214
216
|
|
|
215
217
|
export type Range = {
|
|
216
218
|
from: number,
|