@tiptap/core 3.0.0-next.4 → 3.0.0-next.5
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/LICENSE.md +1 -1
- package/dist/index.cjs +352 -238
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1084 -1431
- package/dist/index.d.ts +1084 -1431
- package/dist/index.js +344 -235
- package/dist/index.js.map +1 -1
- package/dist/jsx-runtime/jsx-runtime.cjs +56 -0
- package/dist/jsx-runtime/jsx-runtime.cjs.map +1 -0
- package/dist/jsx-runtime/jsx-runtime.d.cts +22 -0
- package/dist/jsx-runtime/jsx-runtime.d.ts +22 -0
- package/dist/jsx-runtime/jsx-runtime.js +26 -0
- package/dist/jsx-runtime/jsx-runtime.js.map +1 -0
- package/jsx-runtime/index.cjs +1 -0
- package/jsx-runtime/index.d.cts +1 -0
- package/jsx-runtime/index.d.ts +1 -0
- package/jsx-runtime/index.js +1 -0
- package/package.json +20 -3
- package/src/Editor.ts +104 -22
- package/src/Extendable.ts +483 -0
- package/src/Extension.ts +5 -490
- package/src/ExtensionManager.ts +55 -10
- package/src/Mark.ts +135 -623
- package/src/MarkView.ts +66 -0
- package/src/Node.ts +325 -829
- package/src/commands/clearContent.ts +9 -4
- package/src/commands/focus.ts +7 -1
- package/src/commands/insertContentAt.ts +6 -2
- package/src/commands/setContent.ts +15 -14
- package/src/extensions/delete.ts +89 -0
- package/src/extensions/index.ts +1 -0
- package/src/extensions/keymap.ts +4 -0
- package/src/helpers/getExtensionField.ts +10 -7
- package/src/index.ts +3 -7
- package/src/jsx-runtime.ts +64 -0
- package/src/types.ts +334 -19
- package/src/utilities/elementFromString.ts +3 -0
- package/src/utilities/index.ts +1 -0
- package/src/utilities/mergeAttributes.ts +1 -1
package/src/MarkView.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ViewMutationRecord } from '@tiptap/pm/view'
|
|
2
|
+
|
|
3
|
+
import { Editor } from './Editor.js'
|
|
4
|
+
import { MarkViewProps, MarkViewRendererOptions } from './types.js'
|
|
5
|
+
import { isAndroid, isiOS } from './utilities/index.js'
|
|
6
|
+
|
|
7
|
+
export class MarkView<Component, Options extends MarkViewRendererOptions = MarkViewRendererOptions> {
|
|
8
|
+
component: Component
|
|
9
|
+
editor: Editor
|
|
10
|
+
options: Options
|
|
11
|
+
mark: MarkViewProps['mark']
|
|
12
|
+
HTMLAttributes: MarkViewProps['HTMLAttributes']
|
|
13
|
+
|
|
14
|
+
constructor(component: Component, props: MarkViewProps, options?: Partial<Options>) {
|
|
15
|
+
this.component = component
|
|
16
|
+
this.editor = props.editor
|
|
17
|
+
this.options = { ...options } as Options
|
|
18
|
+
this.mark = props.mark
|
|
19
|
+
this.HTMLAttributes = props.HTMLAttributes
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get dom(): HTMLElement {
|
|
23
|
+
return this.editor.view.dom
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get contentDOM(): HTMLElement | null {
|
|
27
|
+
return null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
ignoreMutation(mutation: ViewMutationRecord): boolean {
|
|
31
|
+
if (!this.dom || !this.contentDOM) {
|
|
32
|
+
return true
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (typeof this.options.ignoreMutation === 'function') {
|
|
36
|
+
return this.options.ignoreMutation({ mutation })
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (mutation.type === 'selection') {
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (
|
|
44
|
+
this.dom.contains(mutation.target) &&
|
|
45
|
+
mutation.type === 'childList' &&
|
|
46
|
+
(isiOS() || isAndroid()) &&
|
|
47
|
+
this.editor.isFocused
|
|
48
|
+
) {
|
|
49
|
+
const changedNodes = [...Array.from(mutation.addedNodes), ...Array.from(mutation.removedNodes)] as HTMLElement[]
|
|
50
|
+
|
|
51
|
+
if (changedNodes.every(node => node.isContentEditable)) {
|
|
52
|
+
return false
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (this.contentDOM === mutation.target && mutation.type === 'attributes') {
|
|
57
|
+
return true
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (this.contentDOM.contains(mutation.target)) {
|
|
61
|
+
return false
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return true
|
|
65
|
+
}
|
|
66
|
+
}
|