@tiptap/core 2.5.3 → 2.5.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/dist/index.cjs +6 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +6 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/packages/core/src/Editor.d.ts +2 -4
- package/dist/packages/core/src/types.d.ts +5 -0
- package/package.json +3 -3
- package/src/Editor.ts +8 -5
- package/src/helpers/getTextContentFromNodes.ts +1 -1
- package/src/types.ts +1 -0
|
@@ -6,10 +6,8 @@ import { ExtensionManager } from './ExtensionManager.js';
|
|
|
6
6
|
import { NodePos } from './NodePos.js';
|
|
7
7
|
import { CanCommands, ChainedCommands, EditorEvents, EditorOptions, JSONContent, SingleCommands, TextSerializer } from './types.js';
|
|
8
8
|
export * as extensions from './extensions/index.js';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
editor?: Editor;
|
|
12
|
-
}
|
|
9
|
+
export interface TiptapEditorHTMLElement extends HTMLElement {
|
|
10
|
+
editor?: Editor;
|
|
13
11
|
}
|
|
14
12
|
export declare class Editor extends EventEmitter<EditorEvents> {
|
|
15
13
|
private commandManager;
|
|
@@ -40,6 +40,11 @@ export interface EditorEvents {
|
|
|
40
40
|
editor: Editor;
|
|
41
41
|
transaction: Transaction;
|
|
42
42
|
};
|
|
43
|
+
beforeTransaction: {
|
|
44
|
+
editor: Editor;
|
|
45
|
+
transaction: Transaction;
|
|
46
|
+
nextState: EditorState;
|
|
47
|
+
};
|
|
43
48
|
transaction: {
|
|
44
49
|
editor: Editor;
|
|
45
50
|
transaction: Transaction;
|
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.5.
|
|
4
|
+
"version": "2.5.5",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@tiptap/pm": "^2.5.
|
|
35
|
+
"@tiptap/pm": "^2.5.5"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@tiptap/pm": "^2.5.
|
|
38
|
+
"@tiptap/pm": "^2.5.5"
|
|
39
39
|
},
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|
package/src/Editor.ts
CHANGED
|
@@ -39,10 +39,8 @@ import { isFunction } from './utilities/isFunction.js'
|
|
|
39
39
|
|
|
40
40
|
export * as extensions from './extensions/index.js'
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
editor?: Editor;
|
|
45
|
-
}
|
|
42
|
+
export interface TiptapEditorHTMLElement extends HTMLElement {
|
|
43
|
+
editor?: Editor
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
export class Editor extends EventEmitter<EditorEvents> {
|
|
@@ -342,7 +340,7 @@ export class Editor extends EventEmitter<EditorEvents> {
|
|
|
342
340
|
|
|
343
341
|
// Let’s store the editor instance in the DOM element.
|
|
344
342
|
// So we’ll have access to it for tests.
|
|
345
|
-
const dom = this.view.dom as
|
|
343
|
+
const dom = this.view.dom as TiptapEditorHTMLElement
|
|
346
344
|
|
|
347
345
|
dom.editor = this
|
|
348
346
|
}
|
|
@@ -406,6 +404,11 @@ export class Editor extends EventEmitter<EditorEvents> {
|
|
|
406
404
|
const state = this.state.apply(transaction)
|
|
407
405
|
const selectionHasChanged = !this.state.selection.eq(state.selection)
|
|
408
406
|
|
|
407
|
+
this.emit('beforeTransaction', {
|
|
408
|
+
editor: this,
|
|
409
|
+
transaction,
|
|
410
|
+
nextState: state,
|
|
411
|
+
})
|
|
409
412
|
this.view.updateState(state)
|
|
410
413
|
this.emit('transaction', {
|
|
411
414
|
editor: this,
|
|
@@ -24,7 +24,7 @@ export const getTextContentFromNodes = ($from: ResolvedPos, maxMatch = 500) => {
|
|
|
24
24
|
|| node.textContent
|
|
25
25
|
|| '%leaf%'
|
|
26
26
|
|
|
27
|
-
textBefore += chunk.slice(0, Math.max(0, sliceEndPos - pos))
|
|
27
|
+
textBefore += node.isAtom ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos))
|
|
28
28
|
},
|
|
29
29
|
)
|
|
30
30
|
|
package/src/types.ts
CHANGED
|
@@ -50,6 +50,7 @@ export interface EditorEvents {
|
|
|
50
50
|
}
|
|
51
51
|
update: { editor: Editor; transaction: Transaction }
|
|
52
52
|
selectionUpdate: { editor: Editor; transaction: Transaction }
|
|
53
|
+
beforeTransaction: { editor: Editor; transaction: Transaction, nextState: EditorState }
|
|
53
54
|
transaction: { editor: Editor; transaction: Transaction }
|
|
54
55
|
focus: { editor: Editor; event: FocusEvent; transaction: Transaction }
|
|
55
56
|
blur: { editor: Editor; event: FocusEvent; transaction: Transaction }
|