@blocknote/core 0.30.0 → 0.31.0
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/blocknote.cjs +9 -9
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +2771 -2245
- package/dist/blocknote.js.map +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js.map +1 -1
- package/dist/{en-D4taoCs4.cjs → en-BXVKCwYt.cjs} +2 -2
- package/dist/en-BXVKCwYt.cjs.map +1 -0
- package/dist/{en-B7ycW7c8.js → en-qGo6sk9V.js} +2 -3
- package/dist/en-qGo6sk9V.js.map +1 -0
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +20 -39
- package/dist/locales.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +8 -7
- package/src/api/README.md +1 -1
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +19 -14
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +7 -8
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +3 -3
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +12 -12
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +14 -14
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +16 -16
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +8 -8
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +12 -12
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +8 -8
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +10 -10
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +2 -2
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +2816 -0
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +200 -42
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +104 -34
- package/src/api/blockManipulation/getBlock/getBlock.ts +9 -9
- package/src/api/blockManipulation/insertContentAt.ts +1 -1
- package/src/api/blockManipulation/selections/selection.ts +59 -12
- package/src/api/blockManipulation/selections/{textCursorPosition/textCursorPosition.ts → textCursorPosition.ts} +13 -13
- package/src/api/blockManipulation/tables/tables.test.ts +106 -106
- package/src/api/blockManipulation/tables/tables.ts +35 -35
- package/src/api/clipboard/fromClipboard/fileDropExtension.ts +2 -2
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +9 -9
- package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +3 -3
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +3 -3
- package/src/api/clipboard/toClipboard/copyExtension.ts +22 -22
- package/src/api/exporters/html/externalHTMLExporter.ts +6 -6
- package/src/api/exporters/html/internalHTMLSerializer.ts +3 -3
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +16 -16
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +14 -14
- package/src/api/exporters/markdown/markdownExporter.ts +3 -3
- package/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts +3 -3
- package/src/api/getBlockInfoFromPos.ts +6 -6
- package/src/api/nodeConversions/blockToNode.ts +31 -28
- package/src/api/nodeConversions/fragmentToBlocks.ts +1 -1
- package/src/api/nodeConversions/nodeToBlock.ts +240 -41
- package/src/api/nodeUtil.test.ts +16 -16
- package/src/api/nodeUtil.ts +10 -10
- package/src/api/parsers/html/parseHTML.ts +1 -1
- package/src/api/parsers/html/util/nestedLists.ts +2 -2
- package/src/api/parsers/markdown/parseMarkdown.ts +1 -1
- package/src/api/pmUtil.ts +7 -7
- package/src/api/positionMapping.test.ts +3 -3
- package/src/api/positionMapping.ts +5 -5
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +4 -4
- package/src/blocks/CodeBlockContent/CodeBlockContent.ts +18 -18
- package/src/blocks/FileBlockContent/FileBlockContent.ts +2 -2
- package/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.ts +2 -2
- package/src/blocks/FileBlockContent/helpers/render/createAddFileButton.ts +6 -6
- package/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.ts +2 -2
- package/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.ts +1 -1
- package/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts +7 -7
- package/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.ts +1 -1
- package/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.ts +1 -1
- package/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts +2 -2
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +6 -6
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +4 -4
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +4 -4
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +10 -10
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +1 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +1 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +4 -4
- package/src/blocks/ListItemBlockContent/getListItemContent.ts +5 -5
- package/src/blocks/PageBreakBlockContent/PageBreakBlockContent.ts +1 -1
- package/src/blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.ts +3 -3
- package/src/blocks/PageBreakBlockContent/schema.ts +2 -2
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +3 -3
- package/src/blocks/QuoteBlockContent/QuoteBlockContent.ts +4 -4
- package/src/blocks/README.md +1 -1
- package/src/blocks/TableBlockContent/TableBlockContent.ts +37 -7
- package/src/blocks/TableBlockContent/TableExtension.ts +3 -3
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +4 -4
- package/src/blocks/defaultBlockHelpers.ts +8 -8
- package/src/blocks/defaultBlockTypeGuards.ts +16 -16
- package/src/blocks/defaultBlocks.ts +3 -3
- package/src/comments/threadstore/DefaultThreadStoreAuth.ts +3 -3
- package/src/comments/threadstore/ThreadStore.ts +1 -1
- package/src/comments/threadstore/TipTapThreadStore.ts +10 -10
- package/src/comments/threadstore/yjs/RESTYjsThreadStore.ts +4 -4
- package/src/comments/threadstore/yjs/YjsThreadStore.test.ts +2 -2
- package/src/comments/threadstore/yjs/YjsThreadStore.ts +14 -14
- package/src/comments/threadstore/yjs/YjsThreadStoreBase.ts +1 -1
- package/src/comments/threadstore/yjs/yjsHelpers.ts +6 -6
- package/src/editor/Block.css +35 -1
- package/src/editor/BlockNoteEditor.test.ts +10 -3
- package/src/editor/BlockNoteEditor.ts +95 -38
- package/src/editor/BlockNoteExtension.ts +26 -0
- package/src/editor/BlockNoteExtensions.ts +38 -22
- package/src/editor/BlockNoteSchema.ts +4 -4
- package/src/editor/BlockNoteTipTapEditor.ts +33 -12
- package/src/editor/README.md +1 -1
- package/src/editor/cursorPositionTypes.ts +1 -1
- package/src/editor/editor.css +15 -3
- package/src/editor/selectionTypes.ts +1 -1
- package/src/editor/transformPasted.ts +2 -2
- package/src/exporter/Exporter.ts +5 -5
- package/src/exporter/mapping.ts +7 -7
- package/src/extensions/BackgroundColor/BackgroundColorMark.ts +1 -1
- package/src/extensions/Collaboration/CursorPlugin.ts +15 -9
- package/src/extensions/Collaboration/ForkYDocPlugin.test.ts +166 -0
- package/src/extensions/Collaboration/ForkYDocPlugin.ts +174 -0
- package/src/extensions/Collaboration/SyncPlugin.ts +7 -4
- package/src/extensions/Collaboration/UndoPlugin.ts +7 -4
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor-forked.json +30 -0
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor.json +30 -0
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-forked.html +1 -0
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap.html +1 -0
- package/src/extensions/Comments/CommentsPlugin.ts +80 -75
- package/src/extensions/Comments/userstore/UserStore.ts +2 -2
- package/src/extensions/FilePanel/FilePanelPlugin.ts +56 -55
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +60 -30
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +26 -26
- package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +33 -32
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +45 -42
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +113 -110
- package/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts +179 -170
- package/src/extensions/README.md +1 -1
- package/src/extensions/ShowSelection/ShowSelectionPlugin.ts +22 -19
- package/src/extensions/SideMenu/MultipleNodeSelection.ts +1 -1
- package/src/extensions/SideMenu/SideMenuPlugin.ts +49 -48
- package/src/extensions/SideMenu/dragging.ts +8 -8
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +176 -176
- package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +2 -2
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +16 -16
- package/src/extensions/Suggestions/SuggestionMarks.ts +175 -0
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +199 -195
- package/src/extensions/TrailingNode/TrailingNodeExtension.ts +1 -1
- package/src/extensions/UniqueID/UniqueID.ts +6 -6
- package/src/extensions/getDraggableBlockFromElement.ts +1 -1
- package/src/fonts/inter.css +18 -9
- package/src/i18n/locales/ar.ts +0 -1
- package/src/i18n/locales/de.ts +0 -1
- package/src/i18n/locales/en.ts +0 -1
- package/src/i18n/locales/es.ts +0 -1
- package/src/i18n/locales/fr.ts +0 -1
- package/src/i18n/locales/hr.ts +0 -1
- package/src/i18n/locales/is.ts +0 -1
- package/src/i18n/locales/it.ts +0 -1
- package/src/i18n/locales/ja.ts +0 -1
- package/src/i18n/locales/ko.ts +0 -1
- package/src/i18n/locales/nl.ts +0 -1
- package/src/i18n/locales/no.ts +0 -1
- package/src/i18n/locales/pl.ts +0 -1
- package/src/i18n/locales/pt.ts +0 -1
- package/src/i18n/locales/ru.ts +0 -1
- package/src/i18n/locales/sk.ts +0 -1
- package/src/i18n/locales/uk.ts +0 -1
- package/src/i18n/locales/vi.ts +0 -1
- package/src/i18n/locales/zh-tw.ts +0 -1
- package/src/i18n/locales/zh.ts +0 -1
- package/src/index.ts +18 -8
- package/src/locales.ts +1 -1
- package/src/pm-nodes/BlockContainer.ts +1 -1
- package/src/pm-nodes/BlockGroup.ts +2 -2
- package/src/pm-nodes/Doc.ts +5 -4
- package/src/schema/README.md +1 -1
- package/src/schema/blocks/createSpec.ts +14 -14
- package/src/schema/blocks/internal.ts +17 -17
- package/src/schema/blocks/types.ts +25 -25
- package/src/schema/inlineContent/createSpec.ts +16 -20
- package/src/schema/inlineContent/internal.ts +9 -9
- package/src/schema/inlineContent/types.ts +26 -26
- package/src/schema/propTypes.ts +8 -8
- package/src/schema/styles/createSpec.ts +2 -2
- package/src/schema/styles/internal.ts +7 -7
- package/src/schema/styles/types.ts +2 -2
- package/src/util/EventEmitter.ts +4 -4
- package/src/util/README.md +1 -1
- package/src/util/combineByGroup.ts +1 -1
- package/src/util/table.ts +33 -30
- package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.d.ts +1 -1
- package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.d.ts +4 -0
- package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.d.ts +1 -0
- package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.d.ts +3 -1
- package/types/src/api/blockManipulation/selections/selection.d.ts +10 -0
- package/types/src/api/blockManipulation/selections/textCursorPosition.d.ts +5 -0
- package/types/src/api/blockManipulation/transactions.test.d.ts +0 -0
- package/types/src/api/clipboard/clipboardExternal.test.d.ts +1 -0
- package/types/src/api/clipboard/clipboardInternal.test.d.ts +1 -0
- package/types/src/api/clipboard/testUtil.d.ts +541 -0
- package/types/src/api/exporters/html/htmlConversion.test.d.ts +1 -0
- package/types/src/api/exporters/markdown/markdownExporter.test.d.ts +1 -0
- package/types/src/api/nodeConversions/nodeConversions.test.d.ts +1 -0
- package/types/src/api/nodeConversions/nodeToBlock.d.ts +39 -2
- package/types/src/api/parsers/html/parseHTML.test.d.ts +1 -0
- package/types/src/api/parsers/markdown/parseMarkdown.test.d.ts +1 -0
- package/types/src/api/pmUtil.d.ts +3 -3
- package/types/src/api/testUtil/cases/customBlocks.d.ts +670 -0
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +558 -0
- package/types/src/api/testUtil/cases/customStyles.d.ts +552 -0
- package/types/src/api/testUtil/cases/defaultSchema.d.ts +4 -0
- package/types/src/api/testUtil/index.d.ts +14 -0
- package/types/src/api/testUtil/partialBlockTestUtil.d.ts +9 -0
- package/types/src/api/testUtil/paste.d.ts +2 -0
- package/types/src/blocks/CodeBlockContent/defaultSupportedLanguages.d.ts +6 -0
- package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +9 -1
- package/types/src/editor/BlockNoteEditor.d.ts +58 -10
- package/types/src/editor/BlockNoteExtension.d.ts +9 -0
- package/types/src/editor/BlockNoteExtensions.d.ts +2 -2
- package/types/src/editor/BlockNoteTipTapEditor.d.ts +2 -2
- package/types/src/extensions/Collaboration/CursorPlugin.d.ts +3 -3
- package/types/src/extensions/Collaboration/ForkYDocPlugin.d.ts +41 -0
- package/types/src/extensions/Collaboration/ForkYDocPlugin.test.d.ts +1 -0
- package/types/src/extensions/Collaboration/SyncPlugin.d.ts +3 -3
- package/types/src/extensions/Collaboration/UndoPlugin.d.ts +3 -3
- package/types/src/extensions/Collaboration/createCollaborationExtensions.d.ts +17 -0
- package/types/src/extensions/Comments/CommentsPlugin.d.ts +2 -4
- package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +3 -4
- package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +5 -5
- package/types/src/extensions/LinkToolbar/LinkToolbarPlugin.d.ts +3 -4
- package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.d.ts +2 -3
- package/types/src/extensions/Placeholder/PlaceholderPlugin.d.ts +2 -3
- package/types/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.d.ts +2 -3
- package/types/src/extensions/ShowSelection/ShowSelectionPlugin.d.ts +2 -3
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +3 -4
- package/types/src/extensions/SuggestionMenu/SuggestionPlugin.d.ts +2 -4
- package/types/src/extensions/Suggestions/SuggestionMarks.d.ts +4 -0
- package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +5 -6
- package/types/src/i18n/locales/en.d.ts +0 -1
- package/types/src/i18n/locales/sk.d.ts +0 -1
- package/types/src/index.d.ts +15 -8
- package/dist/en-B7ycW7c8.js.map +0 -1
- package/dist/en-D4taoCs4.cjs.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/api/blockManipulation/selections/__snapshots__/selection.test.ts.snap +0 -844
- package/src/api/blockManipulation/selections/selection.test.ts +0 -72
- package/src/api/blockManipulation/selections/textCursorPosition/__snapshots__/textCursorPosition.test.ts.snap +0 -316
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.ts +0 -74
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./types.js";
|
|
10
10
|
|
|
11
11
|
export function stylePropsToAttributes(
|
|
12
|
-
propSchema: StylePropSchema
|
|
12
|
+
propSchema: StylePropSchema,
|
|
13
13
|
): Attributes {
|
|
14
14
|
if (propSchema === "boolean") {
|
|
15
15
|
return {};
|
|
@@ -34,7 +34,7 @@ export function stylePropsToAttributes(
|
|
|
34
34
|
// on internal copy & paste.
|
|
35
35
|
export function addStyleAttributes<
|
|
36
36
|
SType extends string,
|
|
37
|
-
PSchema extends StylePropSchema
|
|
37
|
+
PSchema extends StylePropSchema,
|
|
38
38
|
>(
|
|
39
39
|
element: {
|
|
40
40
|
dom: HTMLElement;
|
|
@@ -42,7 +42,7 @@ export function addStyleAttributes<
|
|
|
42
42
|
},
|
|
43
43
|
styleType: SType,
|
|
44
44
|
styleValue: PSchema extends "boolean" ? undefined : string,
|
|
45
|
-
propSchema: PSchema
|
|
45
|
+
propSchema: PSchema,
|
|
46
46
|
): {
|
|
47
47
|
dom: HTMLElement;
|
|
48
48
|
contentDOM?: HTMLElement;
|
|
@@ -66,7 +66,7 @@ export function addStyleAttributes<
|
|
|
66
66
|
// config and implementation that conform to the type of Config
|
|
67
67
|
export function createInternalStyleSpec<T extends StyleConfig>(
|
|
68
68
|
config: T,
|
|
69
|
-
implementation: StyleImplementation
|
|
69
|
+
implementation: StyleImplementation,
|
|
70
70
|
) {
|
|
71
71
|
return {
|
|
72
72
|
config,
|
|
@@ -76,7 +76,7 @@ export function createInternalStyleSpec<T extends StyleConfig>(
|
|
|
76
76
|
|
|
77
77
|
export function createStyleSpecFromTipTapMark<
|
|
78
78
|
T extends Mark,
|
|
79
|
-
P extends StylePropSchema
|
|
79
|
+
P extends StylePropSchema,
|
|
80
80
|
>(mark: T, propSchema: P) {
|
|
81
81
|
return createInternalStyleSpec(
|
|
82
82
|
{
|
|
@@ -85,12 +85,12 @@ export function createStyleSpecFromTipTapMark<
|
|
|
85
85
|
},
|
|
86
86
|
{
|
|
87
87
|
mark,
|
|
88
|
-
}
|
|
88
|
+
},
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
export function getStyleSchemaFromSpecs<T extends StyleSpecs>(specs: T) {
|
|
93
93
|
return Object.fromEntries(
|
|
94
|
-
Object.entries(specs).map(([key, value]) => [key, value.config])
|
|
94
|
+
Object.entries(specs).map(([key, value]) => [key, value.config]),
|
|
95
95
|
) as StyleSchemaFromSpecs<T>;
|
|
96
96
|
}
|
package/src/util/EventEmitter.ts
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
type StringKeyOf<T> = Extract<keyof T, string>;
|
|
4
4
|
type CallbackType<
|
|
5
5
|
T extends Record<string, any>,
|
|
6
|
-
EventName extends StringKeyOf<T
|
|
6
|
+
EventName extends StringKeyOf<T>,
|
|
7
7
|
> = T[EventName] extends any[] ? T[EventName] : [T[EventName]];
|
|
8
8
|
type CallbackFunction<
|
|
9
9
|
T extends Record<string, any>,
|
|
10
|
-
EventName extends StringKeyOf<T
|
|
10
|
+
EventName extends StringKeyOf<T>,
|
|
11
11
|
> = (...props: CallbackType<T, EventName>) => any;
|
|
12
12
|
|
|
13
13
|
export class EventEmitter<T extends Record<string, any>> {
|
|
@@ -16,7 +16,7 @@ export class EventEmitter<T extends Record<string, any>> {
|
|
|
16
16
|
|
|
17
17
|
public on<EventName extends StringKeyOf<T>>(
|
|
18
18
|
event: EventName,
|
|
19
|
-
fn: CallbackFunction<T, EventName
|
|
19
|
+
fn: CallbackFunction<T, EventName>,
|
|
20
20
|
) {
|
|
21
21
|
if (!this.callbacks[event]) {
|
|
22
22
|
this.callbacks[event] = [];
|
|
@@ -40,7 +40,7 @@ export class EventEmitter<T extends Record<string, any>> {
|
|
|
40
40
|
|
|
41
41
|
public off<EventName extends StringKeyOf<T>>(
|
|
42
42
|
event: EventName,
|
|
43
|
-
fn?: CallbackFunction<T, EventName
|
|
43
|
+
fn?: CallbackFunction<T, EventName>,
|
|
44
44
|
) {
|
|
45
45
|
const callbacks = this.callbacks[event];
|
|
46
46
|
|
package/src/util/README.md
CHANGED
|
@@ -12,7 +12,7 @@ export function combineByGroup<T extends { group?: string }>(
|
|
|
12
12
|
for (const additionalItems of additionalItemsArray) {
|
|
13
13
|
for (const additionalItem of additionalItems) {
|
|
14
14
|
const lastItemWithSameGroup = combinedItems.findLastIndex(
|
|
15
|
-
(item) => item.group === additionalItem.group
|
|
15
|
+
(item) => item.group === additionalItem.group,
|
|
16
16
|
);
|
|
17
17
|
if (lastItemWithSameGroup === -1) {
|
|
18
18
|
combinedItems.push(additionalItem as T);
|
package/src/util/table.ts
CHANGED
|
@@ -13,47 +13,50 @@ import { PartialTableCell, TableCell } from "../schema/blocks/types.js";
|
|
|
13
13
|
*/
|
|
14
14
|
export function mapTableCell<
|
|
15
15
|
T extends InlineContentSchema,
|
|
16
|
-
S extends StyleSchema
|
|
16
|
+
S extends StyleSchema,
|
|
17
17
|
>(
|
|
18
|
-
content:
|
|
18
|
+
content:
|
|
19
|
+
| PartialInlineContent<T, S>
|
|
20
|
+
| PartialTableCell<T, S>
|
|
21
|
+
| TableCell<T, S>,
|
|
19
22
|
): TableCell<T, S> {
|
|
20
23
|
return isTableCell(content)
|
|
21
24
|
? { ...content }
|
|
22
25
|
: isPartialTableCell(content)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
26
|
+
? {
|
|
27
|
+
type: "tableCell",
|
|
28
|
+
content: ([] as InlineContent<T, S>[]).concat(content.content as any),
|
|
29
|
+
props: {
|
|
30
|
+
backgroundColor: content.props?.backgroundColor ?? "default",
|
|
31
|
+
textColor: content.props?.textColor ?? "default",
|
|
32
|
+
textAlignment: content.props?.textAlignment ?? "left",
|
|
33
|
+
colspan: content.props?.colspan ?? 1,
|
|
34
|
+
rowspan: content.props?.rowspan ?? 1,
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
: {
|
|
38
|
+
type: "tableCell",
|
|
39
|
+
content: ([] as InlineContent<T, S>[]).concat(content as any),
|
|
40
|
+
props: {
|
|
41
|
+
backgroundColor: "default",
|
|
42
|
+
textColor: "default",
|
|
43
|
+
textAlignment: "left",
|
|
44
|
+
colspan: 1,
|
|
45
|
+
rowspan: 1,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
export function isPartialTableCell<
|
|
48
51
|
T extends InlineContentSchema,
|
|
49
|
-
S extends StyleSchema
|
|
52
|
+
S extends StyleSchema,
|
|
50
53
|
>(
|
|
51
54
|
content:
|
|
52
55
|
| TableCell<T, S>
|
|
53
56
|
| PartialInlineContent<T, S>
|
|
54
57
|
| PartialTableCell<T, S>
|
|
55
58
|
| undefined
|
|
56
|
-
| null
|
|
59
|
+
| null,
|
|
57
60
|
): content is PartialTableCell<T, S> {
|
|
58
61
|
return (
|
|
59
62
|
content !== undefined &&
|
|
@@ -66,14 +69,14 @@ export function isPartialTableCell<
|
|
|
66
69
|
|
|
67
70
|
export function isTableCell<
|
|
68
71
|
T extends InlineContentSchema,
|
|
69
|
-
S extends StyleSchema
|
|
72
|
+
S extends StyleSchema,
|
|
70
73
|
>(
|
|
71
74
|
content:
|
|
72
75
|
| TableCell<T, S>
|
|
73
76
|
| PartialInlineContent<T, S>
|
|
74
77
|
| PartialTableCell<T, S>
|
|
75
78
|
| undefined
|
|
76
|
-
| null
|
|
79
|
+
| null,
|
|
77
80
|
): content is TableCell<T, S> {
|
|
78
81
|
return (
|
|
79
82
|
isPartialTableCell(content) &&
|
|
@@ -86,7 +89,7 @@ export function getColspan(
|
|
|
86
89
|
cell:
|
|
87
90
|
| TableCell<any, any>
|
|
88
91
|
| PartialTableCell<any, any>
|
|
89
|
-
| PartialInlineContent<any, any
|
|
92
|
+
| PartialInlineContent<any, any>,
|
|
90
93
|
): number {
|
|
91
94
|
if (isTableCell(cell)) {
|
|
92
95
|
return cell.props.colspan ?? 1;
|
|
@@ -98,7 +101,7 @@ export function getRowspan(
|
|
|
98
101
|
cell:
|
|
99
102
|
| TableCell<any, any>
|
|
100
103
|
| PartialTableCell<any, any>
|
|
101
|
-
| PartialInlineContent<any, any
|
|
104
|
+
| PartialInlineContent<any, any>,
|
|
102
105
|
): number {
|
|
103
106
|
if (isTableCell(cell)) {
|
|
104
107
|
return cell.props.rowspan ?? 1;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
import type { Transaction } from "prosemirror-state";
|
|
1
2
|
import { Block, PartialBlock } from "../../../../blocks/defaultBlocks.js";
|
|
2
3
|
import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../../schema/index.js";
|
|
3
|
-
import type { Transaction } from "prosemirror-state";
|
|
4
4
|
export declare function insertBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(tr: Transaction, blocksToInsert: PartialBlock<BSchema, I, S>[], referenceBlock: BlockIdentifier, placement?: "before" | "after"): Block<BSchema, I, S>[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Block } from "../../../../blocks/defaultBlocks.js";
|
|
2
|
+
import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor";
|
|
3
|
+
import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../../schema/index.js";
|
|
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>[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Transaction } from "prosemirror-state";
|
|
2
|
+
import { Transform } from "prosemirror-transform";
|
|
2
3
|
import type { Block, PartialBlock } from "../../../../blocks/defaultBlocks.js";
|
|
3
4
|
import type { BlockIdentifier, BlockSchema } from "../../../../schema/blocks/types.js";
|
|
4
5
|
import type { InlineContentSchema } from "../../../../schema/inlineContent/types.js";
|
|
@@ -7,4 +8,5 @@ export declare const updateBlockCommand: <BSchema extends BlockSchema, I extends
|
|
|
7
8
|
tr: Transaction;
|
|
8
9
|
dispatch?: () => void;
|
|
9
10
|
}) => boolean;
|
|
10
|
-
export declare function
|
|
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: Transaction, blockToUpdate: BlockIdentifier, update: PartialBlock<BSchema, I, S>, replaceFromPos?: number, replaceToPos?: number): Block<BSchema, I, S>;
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { type Transaction } from "prosemirror-state";
|
|
2
|
+
import { Block } from "../../../blocks/defaultBlocks.js";
|
|
2
3
|
import { Selection } from "../../../editor/selectionTypes.js";
|
|
3
4
|
import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema/index.js";
|
|
4
5
|
export declare function getSelection<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(tr: Transaction): Selection<BSchema, I, S> | undefined;
|
|
5
6
|
export declare function setSelection(tr: Transaction, startBlock: BlockIdentifier, endBlock: BlockIdentifier): void;
|
|
7
|
+
export declare function getSelectionCutBlocks(tr: Transaction): {
|
|
8
|
+
blocks: Block<Record<string, import("../../../index.js").BlockConfig>, InlineContentSchema, StyleSchema>[];
|
|
9
|
+
blockCutAtStart: string | undefined;
|
|
10
|
+
blockCutAtEnd: string | undefined;
|
|
11
|
+
_meta: {
|
|
12
|
+
startPos: number;
|
|
13
|
+
endPos: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Transaction } from "prosemirror-state";
|
|
2
|
+
import type { TextCursorPosition } from "../../../editor/cursorPositionTypes.js";
|
|
3
|
+
import type { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema/index.js";
|
|
4
|
+
export declare function getTextCursorPosition<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(tr: Transaction): TextCursorPosition<BSchema, I, S>;
|
|
5
|
+
export declare function setTextCursorPosition(tr: Transaction, targetBlock: BlockIdentifier, placement?: "start" | "end"): void;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|