@blocknote/core 0.19.0 → 0.19.1
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/README.md +2 -0
- package/dist/blocknote.js +2549 -2497
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +6 -6
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js +5 -1
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js.map +1 -1
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js +2 -40
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js.map +1 -1
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js +4 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js.map +1 -1
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js +51 -9
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js.map +1 -1
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js +2 -2
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js.map +1 -1
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js +1 -1
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js.map +1 -1
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js +4 -2
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js.map +1 -1
- package/dist/src/api/getBlockInfoFromPos.js +19 -25
- package/dist/src/api/getBlockInfoFromPos.js.map +1 -1
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js +8 -4
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js.map +1 -1
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js +5 -3
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js.map +1 -1
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js +12 -6
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js.map +1 -1
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js +5 -1
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js.map +1 -1
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js +4 -2
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js.map +1 -1
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js +2 -1
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js.map +1 -1
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js +0 -1
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js.map +1 -1
- package/dist/src/editor/BlockNoteEditor.js +39 -43
- package/dist/src/editor/BlockNoteEditor.js.map +1 -1
- package/dist/src/editor/BlockNoteEditor.test.js +2 -2
- package/dist/src/editor/BlockNoteEditor.test.js.map +1 -1
- package/dist/src/editor/BlockNoteExtensions.js +52 -6
- package/dist/src/editor/BlockNoteExtensions.js.map +1 -1
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js +36 -6
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js.map +1 -1
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js +35 -32
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js.map +1 -1
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +74 -71
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +1 -1
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js +153 -149
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +2 -2
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +0 -6
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +0 -5
- package/src/api/blockManipulation/commands/moveBlock/__snapshots__/moveBlock.test.ts.snap +0 -8
- package/src/api/blockManipulation/commands/moveBlock/moveBlock.test.ts +7 -3
- package/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap +439 -2
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.ts +6 -0
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.ts +2 -82
- package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +0 -8
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +96 -20
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +0 -6
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +2 -5
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +0 -490
- package/src/api/clipboard/fromClipboard/acceptedMIMETypes.ts +1 -1
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +6 -5
- package/src/api/getBlockInfoFromPos.ts +20 -30
- package/src/api/parsers/html/__snapshots__/parse-notion-html.json +1 -2
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +16 -4
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +9 -3
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +22 -6
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +5 -3
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +8 -2
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +4 -1
- package/src/blocks/TableBlockContent/TableBlockContent.ts +0 -1
- package/src/editor/BlockNoteEditor.test.ts +2 -5
- package/src/editor/BlockNoteEditor.ts +71 -42
- package/src/editor/BlockNoteExtensions.ts +90 -14
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +36 -9
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +45 -42
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +94 -90
- package/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts +173 -169
- package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.d.ts +0 -3
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +4 -0
- package/types/src/api/blockManipulation/setupTestEnv.d.ts +0 -6
- package/types/src/api/clipboard/fromClipboard/acceptedMIMETypes.d.ts +1 -1
- package/types/src/api/getBlockInfoFromPos.d.ts +9 -34
- package/types/src/api/testUtil/cases/customBlocks.d.ts +0 -6
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +0 -6
- package/types/src/api/testUtil/cases/customStyles.d.ts +0 -6
- package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +0 -9
- package/types/src/blocks/defaultBlocks.d.ts +0 -12
- package/types/src/editor/BlockNoteEditor.d.ts +19 -2
- package/types/src/editor/BlockNoteExtensions.d.ts +14 -7
- package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.d.ts +4 -1
- package/types/src/extensions/Placeholder/PlaceholderPlugin.d.ts +4 -1
- package/types/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.d.ts +4 -5
|
@@ -23,195 +23,199 @@ const nodeAttributes: Record<string, string> = {
|
|
|
23
23
|
*
|
|
24
24
|
* Solution: When attributes change on a node, this plugin sets a data-* attribute with the "previous" value. This way we can still use CSS transitions. (See block.module.css)
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (this.key?.getState(view.state).updatedBlocks.size > 0) {
|
|
34
|
-
// use setTimeout 0 to clear the decorations so that at least
|
|
35
|
-
// for one DOM-render the decorations have been applied
|
|
36
|
-
timeout = setTimeout(() => {
|
|
37
|
-
view.dispatch(
|
|
38
|
-
view.state.tr.setMeta(PLUGIN_KEY, { clearUpdate: true })
|
|
39
|
-
);
|
|
40
|
-
}, 0);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
destroy: () => {
|
|
44
|
-
if (timeout) {
|
|
45
|
-
clearTimeout(timeout);
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
state: {
|
|
51
|
-
init() {
|
|
26
|
+
export class PreviousBlockTypePlugin {
|
|
27
|
+
public readonly plugin: Plugin;
|
|
28
|
+
constructor() {
|
|
29
|
+
let timeout: ReturnType<typeof setTimeout>;
|
|
30
|
+
this.plugin = new Plugin({
|
|
31
|
+
key: PLUGIN_KEY,
|
|
32
|
+
view(_editorView) {
|
|
52
33
|
return {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
34
|
+
update: async (view, _prevState) => {
|
|
35
|
+
if (this.key?.getState(view.state).updatedBlocks.size > 0) {
|
|
36
|
+
// use setTimeout 0 to clear the decorations so that at least
|
|
37
|
+
// for one DOM-render the decorations have been applied
|
|
38
|
+
timeout = setTimeout(() => {
|
|
39
|
+
view.dispatch(
|
|
40
|
+
view.state.tr.setMeta(PLUGIN_KEY, { clearUpdate: true })
|
|
41
|
+
);
|
|
42
|
+
}, 0);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
destroy: () => {
|
|
46
|
+
if (timeout) {
|
|
47
|
+
clearTimeout(timeout);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
59
50
|
};
|
|
60
51
|
},
|
|
52
|
+
state: {
|
|
53
|
+
init() {
|
|
54
|
+
return {
|
|
55
|
+
// Block attributes, by block ID, from just before the previous transaction.
|
|
56
|
+
prevTransactionOldBlockAttrs: {} as any,
|
|
57
|
+
// Block attributes, by block ID, from just before the current transaction.
|
|
58
|
+
currentTransactionOldBlockAttrs: {} as any,
|
|
59
|
+
// Set of IDs of blocks whose attributes changed from the current transaction.
|
|
60
|
+
updatedBlocks: new Set<string>(),
|
|
61
|
+
};
|
|
62
|
+
},
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
apply(transaction, prev, oldState, newState) {
|
|
65
|
+
prev.currentTransactionOldBlockAttrs = {};
|
|
66
|
+
prev.updatedBlocks.clear();
|
|
65
67
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
68
|
+
if (!transaction.docChanged || oldState.doc.eq(newState.doc)) {
|
|
69
|
+
return prev;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// TODO: Instead of iterating through the entire document, only check nodes affected by the transactions. Will
|
|
73
|
+
// also probably require checking nodes affected by the previous transaction too.
|
|
74
|
+
// We didn't get this to work yet:
|
|
75
|
+
// const transform = combineTransactionSteps(oldState.doc, [transaction]);
|
|
76
|
+
// // const { mapping } = transform;
|
|
77
|
+
// const changes = getChangedRanges(transform);
|
|
78
|
+
//
|
|
79
|
+
// changes.forEach(({ oldRange, newRange }) => {
|
|
80
|
+
// const oldNodes = findChildrenInRange(
|
|
81
|
+
// oldState.doc,
|
|
82
|
+
// oldRange,
|
|
83
|
+
// (node) => node.attrs.id
|
|
84
|
+
// );
|
|
85
|
+
//
|
|
86
|
+
// const newNodes = findChildrenInRange(
|
|
87
|
+
// newState.doc,
|
|
88
|
+
// newRange,
|
|
89
|
+
// (node) => node.attrs.id
|
|
90
|
+
// );
|
|
91
|
+
|
|
92
|
+
const currentTransactionOriginalOldBlockAttrs = {} as any;
|
|
93
|
+
|
|
94
|
+
const oldNodes = findChildren(oldState.doc, (node) => node.attrs.id);
|
|
95
|
+
const oldNodesById = new Map(
|
|
96
|
+
oldNodes.map((node) => [node.node.attrs.id, node])
|
|
97
|
+
);
|
|
98
|
+
const newNodes = findChildren(newState.doc, (node) => node.attrs.id);
|
|
99
|
+
|
|
100
|
+
// Traverses all block containers in the new editor state.
|
|
101
|
+
for (const node of newNodes) {
|
|
102
|
+
const oldNode = oldNodesById.get(node.node.attrs.id);
|
|
103
|
+
|
|
104
|
+
const oldContentNode = oldNode?.node.firstChild;
|
|
105
|
+
const newContentNode = node.node.firstChild;
|
|
106
|
+
|
|
107
|
+
if (oldNode && oldContentNode && newContentNode) {
|
|
108
|
+
const newAttrs = {
|
|
109
|
+
index: newContentNode.attrs.index,
|
|
110
|
+
level: newContentNode.attrs.level,
|
|
111
|
+
type: newContentNode.type.name,
|
|
112
|
+
depth: newState.doc.resolve(node.pos).depth,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
let oldAttrs = {
|
|
116
|
+
index: oldContentNode.attrs.index,
|
|
117
|
+
level: oldContentNode.attrs.level,
|
|
118
|
+
type: oldContentNode.type.name,
|
|
119
|
+
depth: oldState.doc.resolve(oldNode.pos).depth,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
currentTransactionOriginalOldBlockAttrs[node.node.attrs.id] =
|
|
123
|
+
oldAttrs;
|
|
124
|
+
|
|
125
|
+
// Whenever a transaction is appended by the OrderedListItemIndexPlugin, it's given the metadata:
|
|
126
|
+
// { "orderedListIndexing": true }
|
|
127
|
+
// These appended transactions happen immediately after any transaction which causes ordered list item
|
|
128
|
+
// indices to require updating, including those which trigger animations. Therefore, these animations are
|
|
129
|
+
// immediately overridden when the PreviousBlockTypePlugin processes the appended transaction, despite only
|
|
130
|
+
// the listItemIndex attribute changing. To solve this, oldAttrs must be edited for transactions with the
|
|
131
|
+
// "orderedListIndexing" metadata, so the correct animation can be re-triggered.
|
|
132
|
+
if (transaction.getMeta("numberedListIndexing")) {
|
|
133
|
+
// If the block existed before the transaction, gets the attributes from before the previous transaction
|
|
134
|
+
// (i.e. the transaction that caused list item indices to need updating).
|
|
135
|
+
if (node.node.attrs.id in prev.prevTransactionOldBlockAttrs) {
|
|
136
|
+
oldAttrs =
|
|
137
|
+
prev.prevTransactionOldBlockAttrs[node.node.attrs.id];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Stops list item indices themselves being animated (looks smoother), unless the block's content type is
|
|
141
|
+
// changing from a numbered list item to something else.
|
|
142
|
+
if (newAttrs.type === "numberedListItem") {
|
|
143
|
+
oldAttrs.index = newAttrs.index;
|
|
144
|
+
}
|
|
136
145
|
}
|
|
137
146
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
147
|
+
prev.currentTransactionOldBlockAttrs[node.node.attrs.id] =
|
|
148
|
+
oldAttrs;
|
|
149
|
+
|
|
150
|
+
// TODO: faster deep equal?
|
|
151
|
+
if (JSON.stringify(oldAttrs) !== JSON.stringify(newAttrs)) {
|
|
152
|
+
(oldAttrs as any)["depth-change"] =
|
|
153
|
+
oldAttrs.depth - newAttrs.depth;
|
|
154
|
+
|
|
155
|
+
// for debugging:
|
|
156
|
+
// console.log(
|
|
157
|
+
// "id:",
|
|
158
|
+
// node.node.attrs.id,
|
|
159
|
+
// "previousBlockTypePlugin changes detected, oldAttrs",
|
|
160
|
+
// oldAttrs,
|
|
161
|
+
// "new",
|
|
162
|
+
// newAttrs
|
|
163
|
+
// );
|
|
164
|
+
|
|
165
|
+
prev.updatedBlocks.add(node.node.attrs.id);
|
|
142
166
|
}
|
|
143
167
|
}
|
|
168
|
+
}
|
|
144
169
|
|
|
145
|
-
|
|
170
|
+
prev.prevTransactionOldBlockAttrs =
|
|
171
|
+
currentTransactionOriginalOldBlockAttrs;
|
|
146
172
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
173
|
+
return prev;
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
props: {
|
|
177
|
+
decorations(state) {
|
|
178
|
+
const pluginState = (this as Plugin).getState(state);
|
|
179
|
+
if (pluginState.updatedBlocks.size === 0) {
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
151
182
|
|
|
152
|
-
|
|
153
|
-
// console.log(
|
|
154
|
-
// "id:",
|
|
155
|
-
// node.node.attrs.id,
|
|
156
|
-
// "previousBlockTypePlugin changes detected, oldAttrs",
|
|
157
|
-
// oldAttrs,
|
|
158
|
-
// "new",
|
|
159
|
-
// newAttrs
|
|
160
|
-
// );
|
|
183
|
+
const decorations: Decoration[] = [];
|
|
161
184
|
|
|
162
|
-
|
|
185
|
+
state.doc.descendants((node, pos) => {
|
|
186
|
+
if (!node.attrs.id) {
|
|
187
|
+
return;
|
|
163
188
|
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
189
|
|
|
167
|
-
|
|
168
|
-
|
|
190
|
+
if (!pluginState.updatedBlocks.has(node.attrs.id)) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
169
193
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
props: {
|
|
174
|
-
decorations(state) {
|
|
175
|
-
const pluginState = (this as Plugin).getState(state);
|
|
176
|
-
if (pluginState.updatedBlocks.size === 0) {
|
|
177
|
-
return undefined;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const decorations: Decoration[] = [];
|
|
181
|
-
|
|
182
|
-
state.doc.descendants((node, pos) => {
|
|
183
|
-
if (!node.attrs.id) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
194
|
+
const prevAttrs =
|
|
195
|
+
pluginState.currentTransactionOldBlockAttrs[node.attrs.id];
|
|
196
|
+
const decorationAttrs: any = {};
|
|
186
197
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const prevAttrs =
|
|
192
|
-
pluginState.currentTransactionOldBlockAttrs[node.attrs.id];
|
|
193
|
-
const decorationAttrs: any = {};
|
|
198
|
+
for (const [nodeAttr, val] of Object.entries(prevAttrs)) {
|
|
199
|
+
decorationAttrs["data-prev-" + nodeAttributes[nodeAttr]] =
|
|
200
|
+
val || "none";
|
|
201
|
+
}
|
|
194
202
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
203
|
+
// for debugging:
|
|
204
|
+
// console.log(
|
|
205
|
+
// "previousBlockTypePlugin committing decorations",
|
|
206
|
+
// decorationAttrs
|
|
207
|
+
// );
|
|
199
208
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
// decorationAttrs
|
|
204
|
-
// );
|
|
209
|
+
const decoration = Decoration.node(pos, pos + node.nodeSize, {
|
|
210
|
+
...decorationAttrs,
|
|
211
|
+
});
|
|
205
212
|
|
|
206
|
-
|
|
207
|
-
...decorationAttrs,
|
|
213
|
+
decorations.push(decoration);
|
|
208
214
|
});
|
|
209
215
|
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return DecorationSet.create(state.doc, decorations);
|
|
216
|
+
return DecorationSet.create(state.doc, decorations);
|
|
217
|
+
},
|
|
214
218
|
},
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { Node } from "prosemirror-model";
|
|
2
|
-
import { Transaction } from "prosemirror-state";
|
|
3
1
|
import { Block } from "../../../../blocks/defaultBlocks.js";
|
|
4
2
|
import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor";
|
|
5
3
|
import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../../schema/index.js";
|
|
6
|
-
export declare function removeBlocksWithCallback<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>, blocksToRemove: BlockIdentifier[], callback?: (node: Node, pos: number, tr: Transaction, removedSize: number) => number): Block<BSchema, I, S>[];
|
|
7
4
|
export declare function removeBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>, blocksToRemove: BlockIdentifier[]): Block<BSchema, I, S>[];
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Block, PartialBlock } from "../../../../blocks/defaultBlocks.js";
|
|
2
2
|
import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor";
|
|
3
3
|
import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../../schema/index.js";
|
|
4
|
+
export declare function removeAndInsertBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>, blocksToRemove: BlockIdentifier[], blocksToInsert: PartialBlock<BSchema, I, S>[]): {
|
|
5
|
+
insertedBlocks: Block<BSchema, I, S>[];
|
|
6
|
+
removedBlocks: Block<BSchema, I, S>[];
|
|
7
|
+
};
|
|
4
8
|
export declare function replaceBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>, blocksToRemove: BlockIdentifier[], blocksToInsert: PartialBlock<BSchema, I, S>[]): {
|
|
5
9
|
insertedBlocks: Block<BSchema, I, S>[];
|
|
6
10
|
removedBlocks: Block<BSchema, I, S>[];
|
|
@@ -211,9 +211,6 @@ export declare function setupTestEnv(): () => BlockNoteEditor<import("../../inde
|
|
|
211
211
|
type: "table";
|
|
212
212
|
content: "table";
|
|
213
213
|
propSchema: {
|
|
214
|
-
backgroundColor: {
|
|
215
|
-
default: "default";
|
|
216
|
-
};
|
|
217
214
|
textColor: {
|
|
218
215
|
default: "default";
|
|
219
216
|
};
|
|
@@ -223,9 +220,6 @@ export declare function setupTestEnv(): () => BlockNoteEditor<import("../../inde
|
|
|
223
220
|
type: "table";
|
|
224
221
|
content: "table";
|
|
225
222
|
propSchema: {
|
|
226
|
-
backgroundColor: {
|
|
227
|
-
default: "default";
|
|
228
|
-
};
|
|
229
223
|
textColor: {
|
|
230
224
|
default: "default";
|
|
231
225
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const acceptedMIMETypes: readonly ["vscode-editor-data", "blocknote/html", "
|
|
1
|
+
export declare const acceptedMIMETypes: readonly ["vscode-editor-data", "blocknote/html", "text/html", "text/plain", "Files"];
|
|
@@ -37,18 +37,17 @@ export type BlockInfo = {
|
|
|
37
37
|
isBlockContainer: true;
|
|
38
38
|
});
|
|
39
39
|
/**
|
|
40
|
-
* Retrieves the position just before the nearest
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* just before the last blockContainer is returned.
|
|
40
|
+
* Retrieves the position just before the nearest block node in a ProseMirror
|
|
41
|
+
* doc, relative to a position. If the position is within a block node or its
|
|
42
|
+
* descendants, the position just before it is returned. If the position is not
|
|
43
|
+
* within a block node or its descendants, the position just before the next
|
|
44
|
+
* closest block node is returned. If the position is beyond the last block, the
|
|
45
|
+
* position just before the last block is returned.
|
|
47
46
|
* @param doc The ProseMirror doc.
|
|
48
47
|
* @param pos An integer position in the document.
|
|
49
48
|
* @returns The position just before the nearest blockContainer node.
|
|
50
49
|
*/
|
|
51
|
-
export declare function
|
|
50
|
+
export declare function getNearestBlockPos(doc: Node, pos: number): {
|
|
52
51
|
posBeforeNode: number;
|
|
53
52
|
node: Node;
|
|
54
53
|
};
|
|
@@ -60,7 +59,7 @@ export declare function getNearestBlockContainerPos(doc: Node, pos: number): {
|
|
|
60
59
|
* the ProseMirror positions just before & after each node.
|
|
61
60
|
* @param node The main `blockContainer` node that the block information should
|
|
62
61
|
* be retrieved from,
|
|
63
|
-
* @param
|
|
62
|
+
* @param bnBlockBeforePosOffset the position just before the
|
|
64
63
|
* `blockContainer` node in the document.
|
|
65
64
|
*/
|
|
66
65
|
export declare function getBlockInfoWithManualOffset(node: Node, bnBlockBeforePosOffset: number): BlockInfo;
|
|
@@ -92,29 +91,5 @@ export declare function getBlockInfoFromResolvedPos(resolvedPos: ResolvedPos): B
|
|
|
92
91
|
* selection.
|
|
93
92
|
* @param state The ProseMirror editor state.
|
|
94
93
|
*/
|
|
95
|
-
export declare function getBlockInfoFromSelection(state: EditorState):
|
|
96
|
-
/**
|
|
97
|
-
* The outer node that represents a BlockNote block. This is the node that has the ID.
|
|
98
|
-
* Most of the time, this will be a blockContainer node, but it could also be a Column or ColumnList
|
|
99
|
-
*/
|
|
100
|
-
bnBlock: SingleBlockInfo;
|
|
101
|
-
/**
|
|
102
|
-
* The type of BlockNote block that this node represents.
|
|
103
|
-
* When dealing with a blockContainer, this is retrieved from the blockContent node, otherwise it's retrieved from the bnBlock node.
|
|
104
|
-
*/
|
|
105
|
-
blockNoteType: string;
|
|
106
|
-
} & {
|
|
107
|
-
/**
|
|
108
|
-
* The Prosemirror node that holds block.children. For blockContainers, this is the blockGroup node, if it exists.
|
|
109
|
-
*/
|
|
110
|
-
childContainer?: SingleBlockInfo | undefined;
|
|
111
|
-
/**
|
|
112
|
-
* The Prosemirror node that wraps block.content and has most of the props
|
|
113
|
-
*/
|
|
114
|
-
blockContent: SingleBlockInfo;
|
|
115
|
-
/**
|
|
116
|
-
* Whether bnBlock is a blockContainer node
|
|
117
|
-
*/
|
|
118
|
-
isBlockContainer: true;
|
|
119
|
-
};
|
|
94
|
+
export declare function getBlockInfoFromSelection(state: EditorState): BlockInfo;
|
|
120
95
|
export {};
|
|
@@ -339,9 +339,6 @@ declare const schema: BlockNoteSchema<import("../../../schema/index.js").BlockSc
|
|
|
339
339
|
type: "table";
|
|
340
340
|
content: "table";
|
|
341
341
|
propSchema: {
|
|
342
|
-
backgroundColor: {
|
|
343
|
-
default: "default";
|
|
344
|
-
};
|
|
345
342
|
textColor: {
|
|
346
343
|
default: "default";
|
|
347
344
|
};
|
|
@@ -351,9 +348,6 @@ declare const schema: BlockNoteSchema<import("../../../schema/index.js").BlockSc
|
|
|
351
348
|
type: "table";
|
|
352
349
|
content: "table";
|
|
353
350
|
propSchema: {
|
|
354
|
-
backgroundColor: {
|
|
355
|
-
default: "default";
|
|
356
|
-
};
|
|
357
351
|
textColor: {
|
|
358
352
|
default: "default";
|
|
359
353
|
};
|
|
@@ -213,9 +213,6 @@ declare const schema: BlockNoteSchema<import("../../../index.js").BlockSchemaFro
|
|
|
213
213
|
type: "table";
|
|
214
214
|
content: "table";
|
|
215
215
|
propSchema: {
|
|
216
|
-
backgroundColor: {
|
|
217
|
-
default: "default";
|
|
218
|
-
};
|
|
219
216
|
textColor: {
|
|
220
217
|
default: "default";
|
|
221
218
|
};
|
|
@@ -225,9 +222,6 @@ declare const schema: BlockNoteSchema<import("../../../index.js").BlockSchemaFro
|
|
|
225
222
|
type: "table";
|
|
226
223
|
content: "table";
|
|
227
224
|
propSchema: {
|
|
228
|
-
backgroundColor: {
|
|
229
|
-
default: "default";
|
|
230
|
-
};
|
|
231
225
|
textColor: {
|
|
232
226
|
default: "default";
|
|
233
227
|
};
|
|
@@ -213,9 +213,6 @@ declare const schema: BlockNoteSchema<import("../../../index.js").BlockSchemaFro
|
|
|
213
213
|
type: "table";
|
|
214
214
|
content: "table";
|
|
215
215
|
propSchema: {
|
|
216
|
-
backgroundColor: {
|
|
217
|
-
default: "default";
|
|
218
|
-
};
|
|
219
216
|
textColor: {
|
|
220
217
|
default: "default";
|
|
221
218
|
};
|
|
@@ -225,9 +222,6 @@ declare const schema: BlockNoteSchema<import("../../../index.js").BlockSchemaFro
|
|
|
225
222
|
type: "table";
|
|
226
223
|
content: "table";
|
|
227
224
|
propSchema: {
|
|
228
|
-
backgroundColor: {
|
|
229
|
-
default: "default";
|
|
230
|
-
};
|
|
231
225
|
textColor: {
|
|
232
226
|
default: "default";
|
|
233
227
|
};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { Node } from "@tiptap/core";
|
|
2
2
|
export declare const tablePropSchema: {
|
|
3
|
-
backgroundColor: {
|
|
4
|
-
default: "default";
|
|
5
|
-
};
|
|
6
3
|
textColor: {
|
|
7
4
|
default: "default";
|
|
8
5
|
};
|
|
@@ -18,9 +15,6 @@ export declare const Table: {
|
|
|
18
15
|
type: "table";
|
|
19
16
|
content: "table";
|
|
20
17
|
propSchema: {
|
|
21
|
-
backgroundColor: {
|
|
22
|
-
default: "default";
|
|
23
|
-
};
|
|
24
18
|
textColor: {
|
|
25
19
|
default: "default";
|
|
26
20
|
};
|
|
@@ -30,9 +24,6 @@ export declare const Table: {
|
|
|
30
24
|
type: "table";
|
|
31
25
|
content: "table";
|
|
32
26
|
propSchema: {
|
|
33
|
-
backgroundColor: {
|
|
34
|
-
default: "default";
|
|
35
|
-
};
|
|
36
27
|
textColor: {
|
|
37
28
|
default: "default";
|
|
38
29
|
};
|
|
@@ -212,9 +212,6 @@ export declare const defaultBlockSpecs: {
|
|
|
212
212
|
type: "table";
|
|
213
213
|
content: "table";
|
|
214
214
|
propSchema: {
|
|
215
|
-
backgroundColor: {
|
|
216
|
-
default: "default";
|
|
217
|
-
};
|
|
218
215
|
textColor: {
|
|
219
216
|
default: "default";
|
|
220
217
|
};
|
|
@@ -224,9 +221,6 @@ export declare const defaultBlockSpecs: {
|
|
|
224
221
|
type: "table";
|
|
225
222
|
content: "table";
|
|
226
223
|
propSchema: {
|
|
227
|
-
backgroundColor: {
|
|
228
|
-
default: "default";
|
|
229
|
-
};
|
|
230
224
|
textColor: {
|
|
231
225
|
default: "default";
|
|
232
226
|
};
|
|
@@ -658,9 +652,6 @@ export declare const defaultBlockSchema: import("../schema/index.js").BlockSchem
|
|
|
658
652
|
type: "table";
|
|
659
653
|
content: "table";
|
|
660
654
|
propSchema: {
|
|
661
|
-
backgroundColor: {
|
|
662
|
-
default: "default";
|
|
663
|
-
};
|
|
664
655
|
textColor: {
|
|
665
656
|
default: "default";
|
|
666
657
|
};
|
|
@@ -670,9 +661,6 @@ export declare const defaultBlockSchema: import("../schema/index.js").BlockSchem
|
|
|
670
661
|
type: "table";
|
|
671
662
|
content: "table";
|
|
672
663
|
propSchema: {
|
|
673
|
-
backgroundColor: {
|
|
674
|
-
default: "default";
|
|
675
|
-
};
|
|
676
664
|
textColor: {
|
|
677
665
|
default: "default";
|
|
678
666
|
};
|