@blocknote/core 0.35.0 → 0.36.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/LICENSE +1 -1
- package/README.md +7 -25
- package/dist/blocknote.cjs +8 -8
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +1592 -1458
- package/dist/blocknote.js.map +1 -1
- package/dist/{en-Dx9fwHD4.js → en-CvDoFvhc.js} +4 -1
- package/dist/en-CvDoFvhc.js.map +1 -0
- package/dist/{en-CsgPjHa4.cjs → en-ub2yVBX0.cjs} +2 -2
- package/dist/en-ub2yVBX0.cjs.map +1 -0
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +62 -2
- package/dist/locales.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +17 -16
- package/src/api/__snapshots__/blocks-moved-down-twice-in-same-parent.json +44 -0
- package/src/api/__snapshots__/blocks-moved-insert-changes-sibling-order.json +26 -0
- package/src/api/__snapshots__/blocks-moved-nested-sibling-reorder.json +180 -0
- package/src/api/__snapshots__/blocks-moved-up-down-in-same-parent.json +44 -0
- package/src/api/__snapshots__/blocks-moved-up-down-in-same-transaction.json +44 -0
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +132 -4
- package/src/api/clipboard/toClipboard/copyExtension.ts +2 -0
- package/src/api/{nodeUtil.test.ts → getBlocksChangedByTransaction.test.ts} +117 -1
- package/src/api/getBlocksChangedByTransaction.ts +422 -0
- package/src/api/nodeUtil.ts +0 -250
- package/src/blocks/ImageBlockContent/parseImageElement.ts +2 -1
- package/src/blocks/TableBlockContent/TableBlockContent.ts +31 -4
- package/src/blocks/ToggleWrapper/createToggleWrapper.ts +2 -1
- package/src/editor/BlockNoteEditor.ts +1 -1
- package/src/editor/editor.css +8 -17
- package/src/extensions/BlockChange/BlockChangePlugin.ts +4 -2
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +53 -1
- package/src/extensions/SideMenu/SideMenuPlugin.ts +6 -15
- package/src/i18n/locales/ar.ts +3 -0
- package/src/i18n/locales/de.ts +4 -0
- package/src/i18n/locales/en.ts +3 -0
- package/src/i18n/locales/es.ts +3 -0
- package/src/i18n/locales/fr.ts +3 -0
- package/src/i18n/locales/he.ts +3 -0
- package/src/i18n/locales/hr.ts +3 -0
- package/src/i18n/locales/is.ts +3 -0
- package/src/i18n/locales/it.ts +3 -0
- package/src/i18n/locales/ja.ts +3 -0
- package/src/i18n/locales/ko.ts +4 -1
- package/src/i18n/locales/nl.ts +3 -0
- package/src/i18n/locales/no.ts +3 -0
- package/src/i18n/locales/pl.ts +4 -0
- package/src/i18n/locales/pt.ts +3 -0
- package/src/i18n/locales/ru.ts +3 -0
- package/src/i18n/locales/sk.ts +3 -0
- package/src/i18n/locales/uk.ts +3 -0
- package/src/i18n/locales/vi.ts +3 -0
- package/src/i18n/locales/zh-tw.ts +3 -0
- package/src/i18n/locales/zh.ts +3 -0
- package/src/index.ts +1 -0
- package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.d.ts +16 -3
- package/types/src/api/getBlocksChangedByTransaction.d.ts +63 -0
- package/types/src/api/nodeUtil.d.ts +0 -63
- package/types/src/blocks/ImageBlockContent/parseImageElement.d.ts +1 -0
- package/types/src/editor/BlockNoteEditor.d.ts +1 -1
- package/types/src/extensions/BlockChange/BlockChangePlugin.d.ts +1 -1
- package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +2 -2
- package/types/src/i18n/locales/en.d.ts +3 -0
- package/types/src/i18n/locales/sk.d.ts +3 -0
- package/types/src/index.d.ts +1 -0
- package/types/src/schema/inlineContent/internal.d.ts +1 -1
- package/dist/en-CsgPjHa4.cjs.map +0 -1
- package/dist/en-Dx9fwHD4.js.map +0 -1
- /package/types/src/api/{nodeUtil.test.d.ts → getBlocksChangedByTransaction.test.d.ts} +0 -0
|
@@ -34,8 +34,8 @@ export const TableBlockContent = createStronglyTypedTiptapNode({
|
|
|
34
34
|
];
|
|
35
35
|
},
|
|
36
36
|
|
|
37
|
-
renderHTML({ HTMLAttributes }) {
|
|
38
|
-
|
|
37
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
38
|
+
const domOutputSpec = createDefaultBlockDOMOutputSpec(
|
|
39
39
|
this.name,
|
|
40
40
|
"table",
|
|
41
41
|
{
|
|
@@ -44,6 +44,30 @@ export const TableBlockContent = createStronglyTypedTiptapNode({
|
|
|
44
44
|
},
|
|
45
45
|
this.options.domAttributes?.inlineContent || {},
|
|
46
46
|
);
|
|
47
|
+
|
|
48
|
+
// Need to manually add colgroup element
|
|
49
|
+
const colGroup = document.createElement("colgroup");
|
|
50
|
+
for (const tableCell of node.children[0].children) {
|
|
51
|
+
const colWidths: null | (number | undefined)[] =
|
|
52
|
+
tableCell.attrs["colwidth"];
|
|
53
|
+
|
|
54
|
+
if (colWidths) {
|
|
55
|
+
for (const colWidth of tableCell.attrs["colwidth"]) {
|
|
56
|
+
const col = document.createElement("col");
|
|
57
|
+
if (colWidth) {
|
|
58
|
+
col.style = `width: ${colWidth}px`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
colGroup.appendChild(col);
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
colGroup.appendChild(document.createElement("col"));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
domOutputSpec.dom.firstChild?.appendChild(colGroup);
|
|
69
|
+
|
|
70
|
+
return domOutputSpec;
|
|
47
71
|
},
|
|
48
72
|
|
|
49
73
|
// This node view is needed for the `columnResizing` plugin. By default, the
|
|
@@ -146,8 +170,11 @@ const TableParagraph = createStronglyTypedTiptapNode({
|
|
|
146
170
|
];
|
|
147
171
|
},
|
|
148
172
|
|
|
149
|
-
renderHTML({ HTMLAttributes }) {
|
|
150
|
-
|
|
173
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
174
|
+
// Insert a line break if there is no content, in order to preserve the
|
|
175
|
+
// correct cell height. Otherwise, the cell will have a height of zero +
|
|
176
|
+
// padding.
|
|
177
|
+
return ["p", HTMLAttributes, node.childCount ? 0 : ["br"]];
|
|
151
178
|
},
|
|
152
179
|
});
|
|
153
180
|
|
|
@@ -77,7 +77,8 @@ export const createToggleWrapper = (
|
|
|
77
77
|
const toggleAddBlockButton = document.createElement("button");
|
|
78
78
|
toggleAddBlockButton.className = "bn-toggle-add-block-button";
|
|
79
79
|
toggleAddBlockButton.type = "button";
|
|
80
|
-
toggleAddBlockButton.textContent =
|
|
80
|
+
toggleAddBlockButton.textContent =
|
|
81
|
+
editor.dictionary.toggle_blocks.add_block_button;
|
|
81
82
|
const toggleAddBlockButtonMouseDown = (event: MouseEvent) =>
|
|
82
83
|
event.preventDefault();
|
|
83
84
|
toggleAddBlockButton.addEventListener(
|
|
@@ -110,7 +110,7 @@ import { docToBlocks } from "../api/nodeConversions/nodeToBlock.js";
|
|
|
110
110
|
import {
|
|
111
111
|
BlocksChanged,
|
|
112
112
|
getBlocksChangedByTransaction,
|
|
113
|
-
} from "../api/
|
|
113
|
+
} from "../api/getBlocksChangedByTransaction.js";
|
|
114
114
|
import { nestedListsToBlockNoteStructure } from "../api/parsers/html/util/nestedLists.js";
|
|
115
115
|
import { CodeBlockOptions } from "../blocks/CodeBlockContent/CodeBlockContent.js";
|
|
116
116
|
import type { ThreadStore, User } from "../comments/index.js";
|
package/src/editor/editor.css
CHANGED
|
@@ -148,25 +148,16 @@ Tippy popups that are appended to document.body directly
|
|
|
148
148
|
transition: all 0.2s;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
/* .tableWrapper {
|
|
152
|
-
padding
|
|
153
|
-
} */
|
|
154
|
-
|
|
155
151
|
.bn-editor [data-content-type="table"] .tableWrapper {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
min-width: calc(100% + 16px);
|
|
161
|
-
padding-bottom: 16px;
|
|
152
|
+
/* Size of + buttons to add rows/columns. */
|
|
153
|
+
--bn-table-widget-size: 22px;
|
|
154
|
+
/* Size of table handles, divided by 2 since half the element is in the cell. */
|
|
155
|
+
--bn-table-handle-size: calc(18px / 2);
|
|
162
156
|
overflow-y: hidden;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
/* top: -16px;
|
|
168
|
-
left: -16px; */
|
|
169
|
-
padding: 16px;
|
|
157
|
+
padding: var(--bn-table-handle-size) var(--bn-table-widget-size)
|
|
158
|
+
var(--bn-table-widget-size) var(--bn-table-handle-size);
|
|
159
|
+
position: relative;
|
|
160
|
+
width: 100%;
|
|
170
161
|
}
|
|
171
162
|
|
|
172
163
|
/* table related: */
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Plugin, Transaction } from "prosemirror-state";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
BlocksChanged,
|
|
4
|
+
getBlocksChangedByTransaction,
|
|
5
|
+
} from "../../api/getBlocksChangedByTransaction.js";
|
|
3
6
|
import { BlockNoteExtension } from "../../editor/BlockNoteExtension.js";
|
|
4
|
-
import { BlocksChanged } from "../../index.js";
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* This plugin can filter transactions before they are applied to the editor, but with a higher-level API than `filterTransaction` from prosemirror.
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { isNodeSelection, isTextSelection, posToDOMRect } from "@tiptap/core";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
EditorState,
|
|
4
|
+
Plugin,
|
|
5
|
+
PluginKey,
|
|
6
|
+
PluginView,
|
|
7
|
+
TextSelection,
|
|
8
|
+
} from "prosemirror-state";
|
|
3
9
|
import { EditorView } from "prosemirror-view";
|
|
4
10
|
|
|
5
11
|
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
@@ -198,6 +204,52 @@ export class FormattingToolbarView implements PluginView {
|
|
|
198
204
|
// e.g. the download file button, should still be accessible. Therefore,
|
|
199
205
|
// logic for hiding when the editor is non-editable is handled
|
|
200
206
|
// individually in each button.
|
|
207
|
+
const newReferencePos = this.getSelectionBoundingBox();
|
|
208
|
+
|
|
209
|
+
// Workaround to ensure the correct reference position when rendering
|
|
210
|
+
// React components. Without this, e.g. updating styles on React inline
|
|
211
|
+
// content causes the formatting toolbar to be in the wrong place. We
|
|
212
|
+
// know the component has not yet rendered if the reference position has
|
|
213
|
+
// zero dimensions.
|
|
214
|
+
if (newReferencePos.height === 0 && newReferencePos.width === 0) {
|
|
215
|
+
// Updates the reference position again following the render.
|
|
216
|
+
queueMicrotask(() => {
|
|
217
|
+
const nextState = {
|
|
218
|
+
show: true,
|
|
219
|
+
referencePos: this.getSelectionBoundingBox(),
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
this.state = nextState;
|
|
223
|
+
this.emitUpdate();
|
|
224
|
+
|
|
225
|
+
// For some reason, while the selection doesn't actually change and
|
|
226
|
+
// remains correct, it visually appears to be collapsed. This forces
|
|
227
|
+
// a ProseMirror view update, which fixes the issue.
|
|
228
|
+
view.dispatch(
|
|
229
|
+
view.state.tr.setSelection(
|
|
230
|
+
TextSelection.create(
|
|
231
|
+
view.state.doc,
|
|
232
|
+
view.state.selection.from + 1,
|
|
233
|
+
view.state.selection.to,
|
|
234
|
+
),
|
|
235
|
+
),
|
|
236
|
+
);
|
|
237
|
+
// 2 separate `dispatch` calls are needed, else ProseMirror realizes
|
|
238
|
+
// that the transaction is a no-op and doesn't update the view.
|
|
239
|
+
view.dispatch(
|
|
240
|
+
view.state.tr.setSelection(
|
|
241
|
+
TextSelection.create(
|
|
242
|
+
view.state.doc,
|
|
243
|
+
view.state.selection.from - 1,
|
|
244
|
+
view.state.selection.to,
|
|
245
|
+
),
|
|
246
|
+
),
|
|
247
|
+
);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
|
|
201
253
|
const nextState = {
|
|
202
254
|
show: true,
|
|
203
255
|
referencePos: this.getSelectionBoundingBox(),
|
|
@@ -242,21 +242,11 @@ export class SideMenuView<
|
|
|
242
242
|
|
|
243
243
|
this.hoveredBlock = block.node;
|
|
244
244
|
|
|
245
|
-
// Gets the block's content node, which lets to ignore child blocks when determining the block menu's position.
|
|
246
|
-
// TODO: needed?
|
|
247
|
-
const blockContent = block.node.firstChild as HTMLElement;
|
|
248
|
-
|
|
249
|
-
if (!blockContent) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// TODO: needed?
|
|
254
|
-
|
|
255
245
|
// Shows or updates elements.
|
|
256
246
|
if (this.editor.isEditable) {
|
|
257
|
-
const blockContentBoundingBox =
|
|
247
|
+
const blockContentBoundingBox = block.node.getBoundingClientRect();
|
|
258
248
|
const column = block.node.closest("[data-node-type=column]");
|
|
259
|
-
this.
|
|
249
|
+
this.state = {
|
|
260
250
|
show: true,
|
|
261
251
|
referencePos: new DOMRect(
|
|
262
252
|
column
|
|
@@ -275,7 +265,8 @@ export class SideMenuView<
|
|
|
275
265
|
block: this.editor.getBlock(
|
|
276
266
|
this.hoveredBlock!.getAttribute("data-id")!,
|
|
277
267
|
)!,
|
|
278
|
-
}
|
|
268
|
+
};
|
|
269
|
+
this.updateState(this.state);
|
|
279
270
|
}
|
|
280
271
|
};
|
|
281
272
|
|
|
@@ -435,9 +426,9 @@ export class SideMenuView<
|
|
|
435
426
|
// We need to check if there is text content that is being dragged (select some text & just drag it)
|
|
436
427
|
const textContentIsBeingDragged =
|
|
437
428
|
!event.dataTransfer?.types.includes("blocknote/html") &&
|
|
438
|
-
|
|
429
|
+
!!this.pmView.dragging;
|
|
439
430
|
// This is the side menu drag from this plugin
|
|
440
|
-
const sideMenuIsBeingDragged =
|
|
431
|
+
const sideMenuIsBeingDragged = !!this.isDragOrigin;
|
|
441
432
|
// Tells us that the current editor instance has a drag ongoing (either text or side menu)
|
|
442
433
|
const isDragOrigin = textContentIsBeingDragged || sideMenuIsBeingDragged;
|
|
443
434
|
|
package/src/i18n/locales/ar.ts
CHANGED
package/src/i18n/locales/de.ts
CHANGED
|
@@ -217,6 +217,10 @@ export const de: Dictionary = {
|
|
|
217
217
|
add_button_text: "Datei hinzufügen",
|
|
218
218
|
},
|
|
219
219
|
},
|
|
220
|
+
toggle_blocks: {
|
|
221
|
+
add_block_button:
|
|
222
|
+
"Leerer aufklappbarer Bereich. Klicken, um einen Block hinzuzufügen.",
|
|
223
|
+
},
|
|
220
224
|
side_menu: {
|
|
221
225
|
add_block_label: "Block hinzufügen",
|
|
222
226
|
drag_handle_label: "Blockmenü öffnen",
|
package/src/i18n/locales/en.ts
CHANGED
package/src/i18n/locales/es.ts
CHANGED
|
@@ -197,6 +197,9 @@ export const es: Dictionary = {
|
|
|
197
197
|
add_button_text: "Agregar archivo",
|
|
198
198
|
},
|
|
199
199
|
},
|
|
200
|
+
toggle_blocks: {
|
|
201
|
+
add_block_button: "Toggle vacío. Haz clic para añadir un bloque.",
|
|
202
|
+
},
|
|
200
203
|
side_menu: {
|
|
201
204
|
add_block_label: "Agregar bloque",
|
|
202
205
|
drag_handle_label: "Abrir menú de bloque",
|
package/src/i18n/locales/fr.ts
CHANGED
|
@@ -243,6 +243,9 @@ export const fr: Dictionary = {
|
|
|
243
243
|
add_button_text: "Ajouter un fichier",
|
|
244
244
|
},
|
|
245
245
|
},
|
|
246
|
+
toggle_blocks: {
|
|
247
|
+
add_block_button: "Toggle vide. Cliquez pour ajouter un bloc.",
|
|
248
|
+
},
|
|
246
249
|
// from react package:
|
|
247
250
|
side_menu: {
|
|
248
251
|
add_block_label: "Ajouter un bloc",
|
package/src/i18n/locales/he.ts
CHANGED
|
@@ -199,6 +199,9 @@ export const he: Dictionary = {
|
|
|
199
199
|
add_button_text: "הוסף קובץ",
|
|
200
200
|
},
|
|
201
201
|
},
|
|
202
|
+
toggle_blocks: {
|
|
203
|
+
add_block_button: "מתג ריק. לחץ כדי להוסיף בלוק.",
|
|
204
|
+
},
|
|
202
205
|
side_menu: {
|
|
203
206
|
add_block_label: "הוסף בלוק",
|
|
204
207
|
drag_handle_label: "פתח תפריט בלוק",
|
package/src/i18n/locales/hr.ts
CHANGED
|
@@ -210,6 +210,9 @@ export const hr: Dictionary = {
|
|
|
210
210
|
add_button_text: "Dodaj datoteku",
|
|
211
211
|
},
|
|
212
212
|
},
|
|
213
|
+
toggle_blocks: {
|
|
214
|
+
add_block_button: "Prazan sklopivi blok. Klikni da dodaš sadržaj.",
|
|
215
|
+
},
|
|
213
216
|
// from react package:
|
|
214
217
|
side_menu: {
|
|
215
218
|
add_block_label: "Dodaj blok",
|
package/src/i18n/locales/is.ts
CHANGED
|
@@ -211,6 +211,9 @@ export const is: Dictionary = {
|
|
|
211
211
|
add_button_text: "Bæta við skrá",
|
|
212
212
|
},
|
|
213
213
|
},
|
|
214
|
+
toggle_blocks: {
|
|
215
|
+
add_block_button: "Tóm fellilína. Smelltu til að bæta við blokk.",
|
|
216
|
+
},
|
|
214
217
|
side_menu: {
|
|
215
218
|
add_block_label: "Bæta við blokki",
|
|
216
219
|
drag_handle_label: "Opna blokkarvalmynd",
|
package/src/i18n/locales/it.ts
CHANGED
|
@@ -219,6 +219,9 @@ export const it: Dictionary = {
|
|
|
219
219
|
add_button_text: "Aggiungi file",
|
|
220
220
|
},
|
|
221
221
|
},
|
|
222
|
+
toggle_blocks: {
|
|
223
|
+
add_block_button: "Toggle vuoto. Clicca per aggiungere un blocco.",
|
|
224
|
+
},
|
|
222
225
|
// from react package:
|
|
223
226
|
side_menu: {
|
|
224
227
|
add_block_label: "Aggiungi blocco",
|
package/src/i18n/locales/ja.ts
CHANGED
package/src/i18n/locales/ko.ts
CHANGED
|
@@ -42,7 +42,7 @@ export const ko: Dictionary = {
|
|
|
42
42
|
title: "접을 수 있는 제목1",
|
|
43
43
|
subtext: "내용을 표시하거나 숨길 수 있는 섹션 제목(대)",
|
|
44
44
|
aliases: ["h", "제목1", "h1", "대제목", "접기", "토글"],
|
|
45
|
-
group: "
|
|
45
|
+
group: "소제목",
|
|
46
46
|
},
|
|
47
47
|
toggle_heading_2: {
|
|
48
48
|
title: "접을 수 있는 제목2",
|
|
@@ -210,6 +210,9 @@ export const ko: Dictionary = {
|
|
|
210
210
|
add_button_text: "파일 추가",
|
|
211
211
|
},
|
|
212
212
|
},
|
|
213
|
+
toggle_blocks: {
|
|
214
|
+
add_block_button: "비어 있는 토글입니다. 클릭하여 블록을 추가하세요.",
|
|
215
|
+
},
|
|
213
216
|
// from react package:
|
|
214
217
|
side_menu: {
|
|
215
218
|
add_block_label: "블록 추가",
|
package/src/i18n/locales/nl.ts
CHANGED
|
@@ -198,6 +198,9 @@ export const nl: Dictionary = {
|
|
|
198
198
|
add_button_text: "Bestand toevoegen",
|
|
199
199
|
},
|
|
200
200
|
},
|
|
201
|
+
toggle_blocks: {
|
|
202
|
+
add_block_button: "Lege uitklapper. Klik om een blok toe te voegen.",
|
|
203
|
+
},
|
|
201
204
|
// from react package:
|
|
202
205
|
side_menu: {
|
|
203
206
|
add_block_label: "Nieuw blok",
|
package/src/i18n/locales/no.ts
CHANGED
|
@@ -216,6 +216,9 @@ export const no: Dictionary = {
|
|
|
216
216
|
add_button_text: "Legg til fil",
|
|
217
217
|
},
|
|
218
218
|
},
|
|
219
|
+
toggle_blocks: {
|
|
220
|
+
add_block_button: "Tomt toggle. Klikk for å legge til en blokk.",
|
|
221
|
+
},
|
|
219
222
|
side_menu: {
|
|
220
223
|
add_block_label: "Legg til blokk",
|
|
221
224
|
drag_handle_label: "Åpne blokkmeny",
|
package/src/i18n/locales/pl.ts
CHANGED
|
@@ -188,6 +188,10 @@ export const pl: Dictionary = {
|
|
|
188
188
|
add_button_text: "Dodaj plik",
|
|
189
189
|
},
|
|
190
190
|
},
|
|
191
|
+
toggle_blocks: {
|
|
192
|
+
add_block_button:
|
|
193
|
+
"Brak bloków do rozwinięcia. Kliknij, aby dodać pierwszego.",
|
|
194
|
+
},
|
|
191
195
|
side_menu: {
|
|
192
196
|
add_block_label: "Dodaj blok",
|
|
193
197
|
drag_handle_label: "Otwórz menu bloków",
|
package/src/i18n/locales/pt.ts
CHANGED
|
@@ -189,6 +189,9 @@ export const pt: Dictionary = {
|
|
|
189
189
|
add_button_text: "Adicionar arquivo",
|
|
190
190
|
},
|
|
191
191
|
},
|
|
192
|
+
toggle_blocks: {
|
|
193
|
+
add_block_button: "Toggle vazio. Clique para adicionar um bloco.",
|
|
194
|
+
},
|
|
192
195
|
// from react package:
|
|
193
196
|
side_menu: {
|
|
194
197
|
add_block_label: "Adicionar bloco",
|
package/src/i18n/locales/ru.ts
CHANGED
|
@@ -240,6 +240,9 @@ export const ru: Dictionary = {
|
|
|
240
240
|
add_button_text: "Добавить файл",
|
|
241
241
|
},
|
|
242
242
|
},
|
|
243
|
+
toggle_blocks: {
|
|
244
|
+
add_block_button: "Пустой переключатель. Нажмите, чтобы добавить блок.",
|
|
245
|
+
},
|
|
243
246
|
// from react package:
|
|
244
247
|
side_menu: {
|
|
245
248
|
add_block_label: "Добавить блок",
|
package/src/i18n/locales/sk.ts
CHANGED
|
@@ -197,6 +197,9 @@ export const sk = {
|
|
|
197
197
|
add_button_text: "Pridať súbor",
|
|
198
198
|
},
|
|
199
199
|
},
|
|
200
|
+
toggle_blocks: {
|
|
201
|
+
add_block_button: "Prázdne prepínanie. Kliknite pre pridanie bloku.",
|
|
202
|
+
},
|
|
200
203
|
side_menu: {
|
|
201
204
|
add_block_label: "Pridať blok",
|
|
202
205
|
drag_handle_label: "Otvoriť menu bloku",
|
package/src/i18n/locales/uk.ts
CHANGED
|
@@ -222,6 +222,9 @@ export const uk: Dictionary = {
|
|
|
222
222
|
add_button_text: "Додати файл",
|
|
223
223
|
},
|
|
224
224
|
},
|
|
225
|
+
toggle_blocks: {
|
|
226
|
+
add_block_button: "Порожній перемикач. Натисніть, щоб додати блок.",
|
|
227
|
+
},
|
|
225
228
|
// from react package:
|
|
226
229
|
side_menu: {
|
|
227
230
|
add_block_label: "Додати блок",
|
package/src/i18n/locales/vi.ts
CHANGED
package/src/i18n/locales/zh.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./api/blockManipulation/commands/updateBlock/updateBlock.js";
|
|
|
4
4
|
export * from "./api/exporters/html/externalHTMLExporter.js";
|
|
5
5
|
export * from "./api/exporters/html/internalHTMLSerializer.js";
|
|
6
6
|
export * from "./api/getBlockInfoFromPos.js";
|
|
7
|
+
export * from "./api/getBlocksChangedByTransaction.js";
|
|
7
8
|
export * from "./api/nodeUtil.js";
|
|
8
9
|
export * from "./api/pmUtil.js";
|
|
9
10
|
export * from "./blocks/AudioBlockContent/AudioBlockContent.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Transaction } from "prosemirror-state";
|
|
2
2
|
import { Transform } from "prosemirror-transform";
|
|
3
3
|
import type { Block, PartialBlock } from "../../../../blocks/defaultBlocks.js";
|
|
4
4
|
import type { BlockIdentifier, BlockSchema } from "../../../../schema/blocks/types.js";
|
|
@@ -8,5 +8,18 @@ export declare const updateBlockCommand: <BSchema extends BlockSchema, I extends
|
|
|
8
8
|
tr: Transaction;
|
|
9
9
|
dispatch?: () => void;
|
|
10
10
|
}) => boolean;
|
|
11
|
-
export declare function updateBlockTr<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(tr: Transform, posBeforeBlock: number, block: PartialBlock<BSchema, I, S>, replaceFromPos?: number, replaceToPos?: number): void;
|
|
12
|
-
export declare function updateBlock<BSchema extends BlockSchema = any, I extends InlineContentSchema = any, S extends StyleSchema = any>(tr:
|
|
11
|
+
export declare function updateBlockTr<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(tr: Transform | Transaction, posBeforeBlock: number, block: PartialBlock<BSchema, I, S>, replaceFromPos?: number, replaceToPos?: number): void;
|
|
12
|
+
export declare function updateBlock<BSchema extends BlockSchema = any, I extends InlineContentSchema = any, S extends StyleSchema = any>(tr: Transform, blockToUpdate: BlockIdentifier, update: PartialBlock<BSchema, I, S>, replaceFromPos?: number, replaceToPos?: number): Block<BSchema, I, S>;
|
|
13
|
+
type CellAnchor = {
|
|
14
|
+
row: number;
|
|
15
|
+
col: number;
|
|
16
|
+
offset: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Captures the cell anchor from the current selection.
|
|
20
|
+
* @param tr - The transaction to capture the cell anchor from.
|
|
21
|
+
*
|
|
22
|
+
* @returns The cell anchor, or null if no cell is selected.
|
|
23
|
+
*/
|
|
24
|
+
export declare function captureCellAnchor(tr: Transform): CellAnchor | null;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Transaction } from "prosemirror-state";
|
|
2
|
+
import { Block, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema } from "../blocks/defaultBlocks.js";
|
|
3
|
+
import type { BlockSchema } from "../schema/index.js";
|
|
4
|
+
import type { InlineContentSchema } from "../schema/inlineContent/types.js";
|
|
5
|
+
import type { StyleSchema } from "../schema/styles/types.js";
|
|
6
|
+
/**
|
|
7
|
+
* This attributes the changes to a specific source.
|
|
8
|
+
*/
|
|
9
|
+
export type BlockChangeSource = {
|
|
10
|
+
type: "local";
|
|
11
|
+
} | {
|
|
12
|
+
type: "paste";
|
|
13
|
+
} | {
|
|
14
|
+
type: "drop";
|
|
15
|
+
} | {
|
|
16
|
+
type: "undo" | "redo" | "undo-redo";
|
|
17
|
+
} | {
|
|
18
|
+
type: "yjs-remote";
|
|
19
|
+
};
|
|
20
|
+
export type BlocksChanged<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> = Array<{
|
|
21
|
+
/**
|
|
22
|
+
* The affected block.
|
|
23
|
+
*/
|
|
24
|
+
block: Block<BSchema, ISchema, SSchema>;
|
|
25
|
+
/**
|
|
26
|
+
* The source of the change.
|
|
27
|
+
*/
|
|
28
|
+
source: BlockChangeSource;
|
|
29
|
+
} & ({
|
|
30
|
+
type: "insert" | "delete";
|
|
31
|
+
/**
|
|
32
|
+
* Insert and delete changes don't have a previous block.
|
|
33
|
+
*/
|
|
34
|
+
prevBlock: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
type: "update";
|
|
37
|
+
/**
|
|
38
|
+
* The previous block.
|
|
39
|
+
*/
|
|
40
|
+
prevBlock: Block<BSchema, ISchema, SSchema>;
|
|
41
|
+
} | {
|
|
42
|
+
type: "move";
|
|
43
|
+
/**
|
|
44
|
+
* The affected block.
|
|
45
|
+
*/
|
|
46
|
+
block: Block<BSchema, ISchema, SSchema>;
|
|
47
|
+
/**
|
|
48
|
+
* The block before the move.
|
|
49
|
+
*/
|
|
50
|
+
prevBlock: Block<BSchema, ISchema, SSchema>;
|
|
51
|
+
/**
|
|
52
|
+
* The previous parent block (if it existed).
|
|
53
|
+
*/
|
|
54
|
+
prevParent?: Block<BSchema, ISchema, SSchema>;
|
|
55
|
+
/**
|
|
56
|
+
* The current parent block (if it exists).
|
|
57
|
+
*/
|
|
58
|
+
currentParent?: Block<BSchema, ISchema, SSchema>;
|
|
59
|
+
})>;
|
|
60
|
+
/**
|
|
61
|
+
* Get the blocks that were changed by a transaction.
|
|
62
|
+
*/
|
|
63
|
+
export declare function getBlocksChangedByTransaction<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema>(transaction: Transaction, appendedTransactions?: Transaction[]): BlocksChanged<BSchema, ISchema, SSchema>;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import type { Node } from "prosemirror-model";
|
|
2
|
-
import type { Transaction } from "prosemirror-state";
|
|
3
|
-
import { Block, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema } from "../blocks/defaultBlocks.js";
|
|
4
|
-
import type { BlockSchema } from "../schema/index.js";
|
|
5
|
-
import type { InlineContentSchema } from "../schema/inlineContent/types.js";
|
|
6
|
-
import type { StyleSchema } from "../schema/styles/types.js";
|
|
7
2
|
/**
|
|
8
3
|
* Get a TipTap node by id
|
|
9
4
|
*/
|
|
@@ -12,61 +7,3 @@ export declare function getNodeById(id: string, doc: Node): {
|
|
|
12
7
|
posBeforeNode: number;
|
|
13
8
|
} | undefined;
|
|
14
9
|
export declare function isNodeBlock(node: Node): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* This attributes the changes to a specific source.
|
|
17
|
-
*/
|
|
18
|
-
export type BlockChangeSource = {
|
|
19
|
-
type: "local";
|
|
20
|
-
} | {
|
|
21
|
-
type: "paste";
|
|
22
|
-
} | {
|
|
23
|
-
type: "drop";
|
|
24
|
-
} | {
|
|
25
|
-
type: "undo" | "redo" | "undo-redo";
|
|
26
|
-
} | {
|
|
27
|
-
type: "yjs-remote";
|
|
28
|
-
};
|
|
29
|
-
export type BlocksChanged<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> = Array<{
|
|
30
|
-
/**
|
|
31
|
-
* The affected block.
|
|
32
|
-
*/
|
|
33
|
-
block: Block<BSchema, ISchema, SSchema>;
|
|
34
|
-
/**
|
|
35
|
-
* The source of the change.
|
|
36
|
-
*/
|
|
37
|
-
source: BlockChangeSource;
|
|
38
|
-
} & ({
|
|
39
|
-
type: "insert" | "delete";
|
|
40
|
-
/**
|
|
41
|
-
* Insert and delete changes don't have a previous block.
|
|
42
|
-
*/
|
|
43
|
-
prevBlock: undefined;
|
|
44
|
-
} | {
|
|
45
|
-
type: "update";
|
|
46
|
-
/**
|
|
47
|
-
* The previous block.
|
|
48
|
-
*/
|
|
49
|
-
prevBlock: Block<BSchema, ISchema, SSchema>;
|
|
50
|
-
} | {
|
|
51
|
-
type: "move";
|
|
52
|
-
/**
|
|
53
|
-
* The affected block.
|
|
54
|
-
*/
|
|
55
|
-
block: Block<BSchema, ISchema, SSchema>;
|
|
56
|
-
/**
|
|
57
|
-
* The block before the move.
|
|
58
|
-
*/
|
|
59
|
-
prevBlock: Block<BSchema, ISchema, SSchema>;
|
|
60
|
-
/**
|
|
61
|
-
* The previous parent block (if it existed).
|
|
62
|
-
*/
|
|
63
|
-
prevParent?: Block<BSchema, ISchema, SSchema>;
|
|
64
|
-
/**
|
|
65
|
-
* The current parent block (if it exists).
|
|
66
|
-
*/
|
|
67
|
-
currentParent?: Block<BSchema, ISchema, SSchema>;
|
|
68
|
-
})>;
|
|
69
|
-
/**
|
|
70
|
-
* Get the blocks that were changed by a transaction.
|
|
71
|
-
*/
|
|
72
|
-
export declare function getBlocksChangedByTransaction<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema>(transaction: Transaction, appendedTransactions?: Transaction[]): BlocksChanged<BSchema, ISchema, SSchema>;
|