@blocknote/core 0.12.3 → 0.13.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.js +1084 -690
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +6 -6
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +2 -2
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +1 -1
- package/src/editor/BlockNoteEditor.ts +24 -8
- package/src/editor/BlockNoteExtensions.ts +22 -11
- package/src/editor/BlockNoteTipTapEditor.ts +9 -6
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +24 -41
- package/src/extensions/ImagePanel/ImageToolbarPlugin.ts +27 -30
- package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +25 -3
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +95 -0
- package/src/extensions/SideMenu/SideMenuPlugin.ts +3 -2
- package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +3 -0
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +10 -9
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +18 -44
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +1 -1
- package/src/i18n/dictionary.ts +17 -0
- package/src/i18n/locales/en.ts +196 -0
- package/src/i18n/locales/index.ts +2 -0
- package/src/i18n/locales/nl.ts +197 -0
- package/src/index.ts +4 -1
- package/src/pm-nodes/BlockContainer.ts +17 -1
- package/src/util/browser.ts +2 -2
- package/src/util/typescript.ts +8 -0
- package/types/src/editor/BlockNoteEditor.d.ts +11 -1
- package/types/src/editor/BlockNoteExtensions.d.ts +3 -3
- package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +5 -4
- package/types/src/extensions/ImagePanel/ImageToolbarPlugin.d.ts +7 -5
- package/types/src/extensions/LinkToolbar/LinkToolbarPlugin.d.ts +3 -1
- package/types/src/extensions/Placeholder/PlaceholderPlugin.d.ts +3 -0
- package/types/src/extensions/SuggestionMenu/DefaultSuggestionItem.d.ts +2 -0
- package/types/src/extensions/SuggestionMenu/SuggestionPlugin.d.ts +2 -1
- package/types/src/i18n/dictionary.d.ts +2 -0
- package/types/src/i18n/locales/en.d.ts +184 -0
- package/types/src/i18n/locales/index.d.ts +2 -0
- package/types/src/i18n/locales/nl.d.ts +2 -0
- package/types/src/index.d.ts +4 -1
- package/types/src/pm-nodes/BlockContainer.d.ts +1 -1
- package/types/src/util/browser.d.ts +1 -1
- package/types/src/util/typescript.d.ts +1 -0
- package/src/extensions/Placeholder/PlaceholderExtension.ts +0 -124
- package/types/src/extensions/Placeholder/PlaceholderExtension.d.ts +0 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const isAppleOS: () => boolean;
|
|
2
|
-
export declare function formatKeyboardShortcut(shortcut: string): string;
|
|
2
|
+
export declare function formatKeyboardShortcut(shortcut: string, ctrlText?: string): string;
|
|
3
3
|
export declare function mergeCSSClasses(...classes: string[]): string;
|
|
4
4
|
export declare const isSafari: () => boolean;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { Extension } from "@tiptap/core";
|
|
2
|
-
import { Plugin, PluginKey } from "prosemirror-state";
|
|
3
|
-
import { Decoration, DecorationSet } from "prosemirror-view";
|
|
4
|
-
|
|
5
|
-
const PLUGIN_KEY = new PluginKey(`blocknote-placeholder`);
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This is a modified version of the tiptap
|
|
9
|
-
* placeholder plugin, that also sets hasAnchorClass
|
|
10
|
-
*
|
|
11
|
-
* It does not set a data-placeholder (text is currently done in css)
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
export interface PlaceholderOptions {
|
|
15
|
-
placeholders: Record<string | "default", string>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const Placeholder = Extension.create<PlaceholderOptions>({
|
|
19
|
-
name: "placeholder",
|
|
20
|
-
|
|
21
|
-
addOptions() {
|
|
22
|
-
return {
|
|
23
|
-
placeholders: {
|
|
24
|
-
default: "Enter text or type '/' for commands",
|
|
25
|
-
heading: "Heading",
|
|
26
|
-
bulletListItem: "List",
|
|
27
|
-
numberedListItem: "List",
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
addProseMirrorPlugins() {
|
|
33
|
-
const placeholders = this.options.placeholders;
|
|
34
|
-
return [
|
|
35
|
-
new Plugin({
|
|
36
|
-
key: PLUGIN_KEY,
|
|
37
|
-
view: () => {
|
|
38
|
-
const styleEl = document.createElement("style");
|
|
39
|
-
document.head.appendChild(styleEl);
|
|
40
|
-
const styleSheet = styleEl.sheet!;
|
|
41
|
-
|
|
42
|
-
const getBaseSelector = (additionalSelectors = "") =>
|
|
43
|
-
`.bn-block-content${additionalSelectors} .bn-inline-content:has(> .ProseMirror-trailingBreak):before`;
|
|
44
|
-
|
|
45
|
-
const getSelector = (
|
|
46
|
-
blockType: string | "default",
|
|
47
|
-
mustBeFocused = true
|
|
48
|
-
) => {
|
|
49
|
-
const mustBeFocusedSelector = mustBeFocused
|
|
50
|
-
? `[data-is-empty-and-focused]`
|
|
51
|
-
: ``;
|
|
52
|
-
|
|
53
|
-
if (blockType === "default") {
|
|
54
|
-
return getBaseSelector(mustBeFocusedSelector);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const blockTypeSelector = `[data-content-type="${blockType}"]`;
|
|
58
|
-
return getBaseSelector(mustBeFocusedSelector + blockTypeSelector);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
for (const [blockType, placeholder] of Object.entries(placeholders)) {
|
|
62
|
-
const mustBeFocused = blockType === "default";
|
|
63
|
-
|
|
64
|
-
styleSheet.insertRule(
|
|
65
|
-
`${getSelector(
|
|
66
|
-
blockType,
|
|
67
|
-
mustBeFocused
|
|
68
|
-
)}{ content: ${JSON.stringify(placeholder)}; }`
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
// For some reason, the placeholders which show when the block is focused
|
|
72
|
-
// take priority over ones which show depending on block type, so we need
|
|
73
|
-
// to make sure the block specific ones are also used when the block is
|
|
74
|
-
// focused.
|
|
75
|
-
if (!mustBeFocused) {
|
|
76
|
-
styleSheet.insertRule(
|
|
77
|
-
`${getSelector(blockType, true)}{ content: ${JSON.stringify(
|
|
78
|
-
placeholder
|
|
79
|
-
)}; }`
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
destroy: () => {
|
|
86
|
-
document.head.removeChild(styleEl);
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
},
|
|
90
|
-
props: {
|
|
91
|
-
// TODO: maybe also add placeholder for empty document ("e.g.: start writing..")
|
|
92
|
-
decorations: (state) => {
|
|
93
|
-
const { doc, selection } = state;
|
|
94
|
-
|
|
95
|
-
const active = this.editor.isEditable;
|
|
96
|
-
|
|
97
|
-
if (!active) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (!selection.empty) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const $pos = selection.$anchor;
|
|
106
|
-
const node = $pos.parent;
|
|
107
|
-
|
|
108
|
-
if (node.content.size > 0) {
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const before = $pos.before();
|
|
113
|
-
|
|
114
|
-
const dec = Decoration.node(before, before + node.nodeSize, {
|
|
115
|
-
"data-is-empty-and-focused": "true",
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
return DecorationSet.create(doc, [dec]);
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
}),
|
|
122
|
-
];
|
|
123
|
-
},
|
|
124
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Extension } from "@tiptap/core";
|
|
2
|
-
/**
|
|
3
|
-
* This is a modified version of the tiptap
|
|
4
|
-
* placeholder plugin, that also sets hasAnchorClass
|
|
5
|
-
*
|
|
6
|
-
* It does not set a data-placeholder (text is currently done in css)
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
export interface PlaceholderOptions {
|
|
10
|
-
placeholders: Record<string | "default", string>;
|
|
11
|
-
}
|
|
12
|
-
export declare const Placeholder: Extension<PlaceholderOptions, any>;
|