@blocknote/core 0.29.1 → 0.30.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 +125 -0
- package/dist/blocknote.cjs +9 -9
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +1501 -1359
- package/dist/blocknote.js.map +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js.map +1 -1
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +751 -9
- 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 +7 -8
- package/src/api/README.md +1 -1
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +0 -7
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +19 -14
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +5 -5
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +0 -5
- 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/__snapshots__/moveBlocks.test.ts.snap +0 -20
- 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/__snapshots__/replaceBlocks.test.ts.snap +0 -12
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +12 -12
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +7 -7
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +0 -6
- 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 +0 -17
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +42 -42
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +18 -18
- package/src/api/blockManipulation/getBlock/getBlock.ts +9 -9
- package/src/api/blockManipulation/insertContentAt.ts +1 -1
- package/src/api/blockManipulation/selections/selection.ts +11 -11
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.ts +7 -7
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +6 -6
- 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 +21 -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 +26 -26
- package/src/api/nodeConversions/fragmentToBlocks.ts +1 -1
- package/src/api/nodeConversions/nodeToBlock.ts +37 -33
- 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 +4 -4
- package/src/api/positionMapping.test.ts +3 -3
- package/src/api/positionMapping.ts +5 -5
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +9 -4
- package/src/blocks/CodeBlockContent/CodeBlockContent.ts +40 -26
- package/src/blocks/FileBlockContent/FileBlockContent.ts +7 -2
- package/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.ts +2 -2
- package/src/blocks/FileBlockContent/helpers/render/createAddFileButton.ts +5 -5
- 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 +15 -8
- 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 +9 -6
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +14 -6
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +13 -29
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +24 -13
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +1 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +1 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +13 -30
- package/src/blocks/ListItemBlockContent/getListItemContent.ts +115 -0
- 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 +9 -5
- package/src/blocks/QuoteBlockContent/QuoteBlockContent.ts +10 -5
- package/src/blocks/README.md +1 -1
- package/src/blocks/TableBlockContent/TableBlockContent.ts +76 -19
- package/src/blocks/TableBlockContent/TableExtension.ts +3 -3
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +14 -6
- package/src/blocks/defaultBlockHelpers.ts +24 -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 +10 -1
- package/src/editor/BlockNoteEditor.test.ts +3 -3
- package/src/editor/BlockNoteEditor.ts +110 -61
- package/src/editor/BlockNoteExtensions.ts +24 -15
- package/src/editor/BlockNoteSchema.ts +4 -4
- package/src/editor/BlockNoteTipTapEditor.ts +10 -10
- 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 +152 -0
- package/src/extensions/Collaboration/SyncPlugin.ts +15 -0
- package/src/extensions/Collaboration/UndoPlugin.ts +14 -0
- package/src/extensions/Comments/CommentsPlugin.ts +9 -9
- package/src/extensions/Comments/userstore/UserStore.ts +2 -2
- package/src/extensions/FilePanel/FilePanelPlugin.ts +37 -28
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +6 -8
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +29 -26
- package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +11 -11
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +4 -4
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +10 -10
- package/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts +2 -2
- package/src/extensions/README.md +1 -1
- package/src/extensions/SideMenu/MultipleNodeSelection.ts +1 -1
- package/src/extensions/SideMenu/SideMenuPlugin.ts +31 -31
- package/src/extensions/SideMenu/dragging.ts +8 -8
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +17 -17
- package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +2 -2
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +12 -12
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +54 -53
- 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/index.ts +2 -0
- package/src/i18n/locales/ru.ts +2 -2
- package/src/i18n/locales/sk.ts +355 -0
- package/src/i18n/locales/zh-tw.ts +390 -0
- package/src/locales.ts +1 -1
- package/src/pm-nodes/BlockContainer.ts +7 -6
- package/src/pm-nodes/BlockGroup.ts +1 -1
- package/src/pm-nodes/Doc.ts +4 -4
- package/src/schema/README.md +1 -1
- package/src/schema/blocks/createSpec.ts +15 -15
- package/src/schema/blocks/internal.ts +17 -18
- package/src/schema/blocks/types.ts +27 -26
- 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/setupTestEnv.d.ts +8 -4
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +8 -4
- package/types/src/blocks/ListItemBlockContent/getListItemContent.d.ts +28 -0
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +8 -4
- package/types/src/blocks/defaultBlockHelpers.d.ts +1 -0
- package/types/src/blocks/defaultBlocks.d.ts +16 -8
- package/types/src/editor/BlockNoteEditor.d.ts +21 -2
- package/types/src/extensions/Collaboration/CursorPlugin.d.ts +31 -0
- package/types/src/extensions/Collaboration/SyncPlugin.d.ts +7 -0
- package/types/src/extensions/Collaboration/UndoPlugin.d.ts +6 -0
- package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +1 -1
- package/types/src/i18n/locales/index.d.ts +2 -0
- package/types/src/i18n/locales/sk.d.ts +313 -0
- package/types/src/i18n/locales/zh-tw.d.ts +2 -0
- package/types/src/schema/blocks/types.d.ts +2 -1
- package/src/extensions/Collaboration/createCollaborationExtensions.ts +0 -147
- package/types/src/extensions/Collaboration/createCollaborationExtensions.d.ts +0 -17
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import type { Dictionary } from "../dictionary.js";
|
|
2
|
+
|
|
3
|
+
export const zhTW: Dictionary = {
|
|
4
|
+
slash_menu: {
|
|
5
|
+
heading: {
|
|
6
|
+
title: "一級標題",
|
|
7
|
+
subtext: "用於頂級標題",
|
|
8
|
+
aliases: ["h", "heading1", "h1", "標題", "一級標題"],
|
|
9
|
+
group: "標題",
|
|
10
|
+
},
|
|
11
|
+
heading_2: {
|
|
12
|
+
title: "二級標題",
|
|
13
|
+
subtext: "用於關鍵部分",
|
|
14
|
+
aliases: ["h2", "heading2", "subheading", "標題", "二級標題", "副標題"],
|
|
15
|
+
group: "標題",
|
|
16
|
+
},
|
|
17
|
+
heading_3: {
|
|
18
|
+
title: "三級標題",
|
|
19
|
+
subtext: "用於小節和分組標題",
|
|
20
|
+
aliases: ["h3", "heading3", "subheading", "標題", "三級標題"],
|
|
21
|
+
group: "標題",
|
|
22
|
+
},
|
|
23
|
+
quote: {
|
|
24
|
+
title: "引用",
|
|
25
|
+
subtext: "引用或摘錄",
|
|
26
|
+
aliases: ["quotation", "blockquote", "bq"],
|
|
27
|
+
group: "基本區塊",
|
|
28
|
+
},
|
|
29
|
+
numbered_list: {
|
|
30
|
+
title: "有序列表",
|
|
31
|
+
subtext: "用於顯示有序列表",
|
|
32
|
+
aliases: [
|
|
33
|
+
"ol",
|
|
34
|
+
"li",
|
|
35
|
+
"list",
|
|
36
|
+
"numberedlist",
|
|
37
|
+
"numbered list",
|
|
38
|
+
"列表",
|
|
39
|
+
"有序列表",
|
|
40
|
+
],
|
|
41
|
+
group: "基礎",
|
|
42
|
+
},
|
|
43
|
+
bullet_list: {
|
|
44
|
+
title: "無序列表",
|
|
45
|
+
subtext: "用於顯示無序列表",
|
|
46
|
+
aliases: [
|
|
47
|
+
"ul",
|
|
48
|
+
"li",
|
|
49
|
+
"list",
|
|
50
|
+
"bulletlist",
|
|
51
|
+
"bullet list",
|
|
52
|
+
"列表",
|
|
53
|
+
"無序列表",
|
|
54
|
+
],
|
|
55
|
+
group: "基礎",
|
|
56
|
+
},
|
|
57
|
+
check_list: {
|
|
58
|
+
title: "檢查清單",
|
|
59
|
+
subtext: "用於顯示帶有核取方塊的列表",
|
|
60
|
+
aliases: [
|
|
61
|
+
"ul",
|
|
62
|
+
"li",
|
|
63
|
+
"checklist",
|
|
64
|
+
"checked list",
|
|
65
|
+
"列表",
|
|
66
|
+
"檢查清單",
|
|
67
|
+
"勾選列表",
|
|
68
|
+
"核取方塊",
|
|
69
|
+
],
|
|
70
|
+
group: "基礎",
|
|
71
|
+
},
|
|
72
|
+
paragraph: {
|
|
73
|
+
title: "段落",
|
|
74
|
+
subtext: "用於文件正文",
|
|
75
|
+
aliases: ["p", "paragraph", "text", "正文"],
|
|
76
|
+
group: "基礎",
|
|
77
|
+
},
|
|
78
|
+
code_block: {
|
|
79
|
+
title: "程式碼區塊",
|
|
80
|
+
subtext: "用於顯示帶有語法標記的程式碼區塊",
|
|
81
|
+
aliases: ["code", "pre", "程式碼", "預格式"],
|
|
82
|
+
group: "基礎",
|
|
83
|
+
},
|
|
84
|
+
page_break: {
|
|
85
|
+
title: "分頁符",
|
|
86
|
+
subtext: "頁面分隔符",
|
|
87
|
+
aliases: ["page", "break", "separator", "分頁", "分隔符"],
|
|
88
|
+
group: "基礎",
|
|
89
|
+
},
|
|
90
|
+
table: {
|
|
91
|
+
title: "表格",
|
|
92
|
+
subtext: "使用表格",
|
|
93
|
+
aliases: ["table", "表格"],
|
|
94
|
+
group: "進階功能",
|
|
95
|
+
},
|
|
96
|
+
image: {
|
|
97
|
+
title: "圖片",
|
|
98
|
+
subtext: "插入圖片",
|
|
99
|
+
aliases: [
|
|
100
|
+
"圖片",
|
|
101
|
+
"上傳圖片",
|
|
102
|
+
"上傳",
|
|
103
|
+
"image",
|
|
104
|
+
"img",
|
|
105
|
+
"相簿",
|
|
106
|
+
"媒體",
|
|
107
|
+
"url",
|
|
108
|
+
],
|
|
109
|
+
group: "媒體",
|
|
110
|
+
},
|
|
111
|
+
video: {
|
|
112
|
+
title: "影片",
|
|
113
|
+
subtext: "插入影片",
|
|
114
|
+
aliases: [
|
|
115
|
+
"影片",
|
|
116
|
+
"影片上傳",
|
|
117
|
+
"上傳",
|
|
118
|
+
"video",
|
|
119
|
+
"mp4",
|
|
120
|
+
"電影",
|
|
121
|
+
"媒體",
|
|
122
|
+
"url",
|
|
123
|
+
"雲端硬碟",
|
|
124
|
+
"dropbox",
|
|
125
|
+
],
|
|
126
|
+
group: "媒體",
|
|
127
|
+
},
|
|
128
|
+
audio: {
|
|
129
|
+
title: "音訊",
|
|
130
|
+
subtext: "插入音訊",
|
|
131
|
+
aliases: [
|
|
132
|
+
"音訊",
|
|
133
|
+
"音訊上傳",
|
|
134
|
+
"上傳",
|
|
135
|
+
"audio",
|
|
136
|
+
"mp3",
|
|
137
|
+
"聲音",
|
|
138
|
+
"媒體",
|
|
139
|
+
"url",
|
|
140
|
+
"雲端硬碟",
|
|
141
|
+
"dropbox",
|
|
142
|
+
],
|
|
143
|
+
group: "媒體",
|
|
144
|
+
},
|
|
145
|
+
file: {
|
|
146
|
+
title: "檔案",
|
|
147
|
+
subtext: "插入檔案",
|
|
148
|
+
aliases: ["檔案", "上傳", "file", "嵌入", "媒體", "url"],
|
|
149
|
+
group: "媒體",
|
|
150
|
+
},
|
|
151
|
+
emoji: {
|
|
152
|
+
title: "表情符號",
|
|
153
|
+
subtext: "用於插入表情符號",
|
|
154
|
+
aliases: [
|
|
155
|
+
"表情符號",
|
|
156
|
+
"emoji",
|
|
157
|
+
"face",
|
|
158
|
+
"emote",
|
|
159
|
+
"表情",
|
|
160
|
+
"表情表達",
|
|
161
|
+
"表情",
|
|
162
|
+
],
|
|
163
|
+
group: "其他",
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
placeholders: {
|
|
167
|
+
default: "輸入 '/' 以使用指令",
|
|
168
|
+
heading: "標題",
|
|
169
|
+
bulletListItem: "列表",
|
|
170
|
+
numberedListItem: "列表",
|
|
171
|
+
checkListItem: "列表",
|
|
172
|
+
new_comment: "撰寫評論...",
|
|
173
|
+
edit_comment: "編輯評論...",
|
|
174
|
+
comment_reply: "新增評論...",
|
|
175
|
+
},
|
|
176
|
+
file_blocks: {
|
|
177
|
+
image: {
|
|
178
|
+
add_button_text: "新增圖片",
|
|
179
|
+
},
|
|
180
|
+
video: {
|
|
181
|
+
add_button_text: "新增影片",
|
|
182
|
+
},
|
|
183
|
+
audio: {
|
|
184
|
+
add_button_text: "新增音訊",
|
|
185
|
+
},
|
|
186
|
+
file: {
|
|
187
|
+
add_button_text: "新增檔案",
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
// from react package:
|
|
191
|
+
side_menu: {
|
|
192
|
+
add_block_label: "新增區塊",
|
|
193
|
+
drag_handle_label: "開啟選單",
|
|
194
|
+
},
|
|
195
|
+
drag_handle: {
|
|
196
|
+
delete_menuitem: "刪除",
|
|
197
|
+
colors_menuitem: "顏色",
|
|
198
|
+
header_row_menuitem: "列標題",
|
|
199
|
+
header_column_menuitem: "欄標題",
|
|
200
|
+
},
|
|
201
|
+
table_handle: {
|
|
202
|
+
delete_column_menuitem: "刪除欄",
|
|
203
|
+
delete_row_menuitem: "刪除列",
|
|
204
|
+
add_left_menuitem: "左側新增欄",
|
|
205
|
+
add_right_menuitem: "右側新增欄",
|
|
206
|
+
add_above_menuitem: "上方新增列",
|
|
207
|
+
add_below_menuitem: "下方新增列",
|
|
208
|
+
split_cell_menuitem: "分割儲存格",
|
|
209
|
+
merge_cells_menuitem: "合併儲存格",
|
|
210
|
+
background_color_menuitem: "背景色",
|
|
211
|
+
},
|
|
212
|
+
suggestion_menu: {
|
|
213
|
+
no_items_title: "無相符項目",
|
|
214
|
+
loading: "載入中…",
|
|
215
|
+
},
|
|
216
|
+
color_picker: {
|
|
217
|
+
text_title: "文字",
|
|
218
|
+
background_title: "背景色",
|
|
219
|
+
colors: {
|
|
220
|
+
default: "預設",
|
|
221
|
+
gray: "灰色",
|
|
222
|
+
brown: "棕色",
|
|
223
|
+
red: "紅色",
|
|
224
|
+
orange: "橙色",
|
|
225
|
+
yellow: "黃色",
|
|
226
|
+
green: "綠色",
|
|
227
|
+
blue: "藍色",
|
|
228
|
+
purple: "紫色",
|
|
229
|
+
pink: "粉色",
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
formatting_toolbar: {
|
|
234
|
+
bold: {
|
|
235
|
+
tooltip: "粗體",
|
|
236
|
+
secondary_tooltip: "Mod+B",
|
|
237
|
+
},
|
|
238
|
+
italic: {
|
|
239
|
+
tooltip: "斜體",
|
|
240
|
+
secondary_tooltip: "Mod+I",
|
|
241
|
+
},
|
|
242
|
+
underline: {
|
|
243
|
+
tooltip: "底線",
|
|
244
|
+
secondary_tooltip: "Mod+U",
|
|
245
|
+
},
|
|
246
|
+
strike: {
|
|
247
|
+
tooltip: "刪除線",
|
|
248
|
+
secondary_tooltip: "Mod+Shift+X",
|
|
249
|
+
},
|
|
250
|
+
code: {
|
|
251
|
+
tooltip: "程式碼標記",
|
|
252
|
+
secondary_tooltip: "",
|
|
253
|
+
},
|
|
254
|
+
colors: {
|
|
255
|
+
tooltip: "顏色",
|
|
256
|
+
},
|
|
257
|
+
link: {
|
|
258
|
+
tooltip: "新增連結",
|
|
259
|
+
secondary_tooltip: "Mod+K",
|
|
260
|
+
},
|
|
261
|
+
file_caption: {
|
|
262
|
+
tooltip: "編輯標題",
|
|
263
|
+
input_placeholder: "編輯標題",
|
|
264
|
+
},
|
|
265
|
+
file_replace: {
|
|
266
|
+
tooltip: {
|
|
267
|
+
image: "替換圖片",
|
|
268
|
+
video: "替換影片",
|
|
269
|
+
audio: "替換音訊",
|
|
270
|
+
file: "替換檔案",
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
file_rename: {
|
|
274
|
+
tooltip: {
|
|
275
|
+
image: "重新命名圖片",
|
|
276
|
+
video: "重新命名影片",
|
|
277
|
+
audio: "重新命名音訊",
|
|
278
|
+
file: "重新命名檔案",
|
|
279
|
+
},
|
|
280
|
+
input_placeholder: {
|
|
281
|
+
image: "重新命名圖片",
|
|
282
|
+
video: "重新命名影片",
|
|
283
|
+
audio: "重新命名音訊",
|
|
284
|
+
file: "重新命名檔案",
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
file_download: {
|
|
288
|
+
tooltip: {
|
|
289
|
+
image: "下載圖片",
|
|
290
|
+
video: "下載影片",
|
|
291
|
+
audio: "下載音訊",
|
|
292
|
+
file: "下載檔案",
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
file_delete: {
|
|
296
|
+
tooltip: {
|
|
297
|
+
image: "刪除圖片",
|
|
298
|
+
video: "刪除影片",
|
|
299
|
+
audio: "刪除音訊",
|
|
300
|
+
file: "刪除檔案",
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
file_preview_toggle: {
|
|
304
|
+
tooltip: "切換預覽",
|
|
305
|
+
},
|
|
306
|
+
nest: {
|
|
307
|
+
tooltip: "巢狀",
|
|
308
|
+
secondary_tooltip: "Tab",
|
|
309
|
+
},
|
|
310
|
+
unnest: {
|
|
311
|
+
tooltip: "取消巢狀",
|
|
312
|
+
secondary_tooltip: "Shift+Tab",
|
|
313
|
+
},
|
|
314
|
+
align_left: {
|
|
315
|
+
tooltip: "靠左對齊",
|
|
316
|
+
},
|
|
317
|
+
align_center: {
|
|
318
|
+
tooltip: "置中",
|
|
319
|
+
},
|
|
320
|
+
align_right: {
|
|
321
|
+
tooltip: "靠右對齊",
|
|
322
|
+
},
|
|
323
|
+
align_justify: {
|
|
324
|
+
tooltip: "兩端對齊",
|
|
325
|
+
},
|
|
326
|
+
table_cell_merge: {
|
|
327
|
+
tooltip: "合併儲存格",
|
|
328
|
+
},
|
|
329
|
+
comment: {
|
|
330
|
+
tooltip: "新增評論",
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
file_panel: {
|
|
334
|
+
upload: {
|
|
335
|
+
title: "上傳",
|
|
336
|
+
file_placeholder: {
|
|
337
|
+
image: "上傳圖片",
|
|
338
|
+
video: "上傳影片",
|
|
339
|
+
audio: "上傳音訊",
|
|
340
|
+
file: "上傳檔案",
|
|
341
|
+
},
|
|
342
|
+
upload_error: "錯誤:上傳失敗",
|
|
343
|
+
},
|
|
344
|
+
embed: {
|
|
345
|
+
title: "嵌入",
|
|
346
|
+
embed_button: {
|
|
347
|
+
image: "嵌入圖片",
|
|
348
|
+
video: "嵌入影片",
|
|
349
|
+
audio: "嵌入音訊",
|
|
350
|
+
file: "嵌入檔案",
|
|
351
|
+
},
|
|
352
|
+
url_placeholder: "輸入圖片網址",
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
link_toolbar: {
|
|
356
|
+
delete: {
|
|
357
|
+
tooltip: "清除連結",
|
|
358
|
+
},
|
|
359
|
+
edit: {
|
|
360
|
+
text: "編輯連結",
|
|
361
|
+
tooltip: "編輯",
|
|
362
|
+
},
|
|
363
|
+
open: {
|
|
364
|
+
tooltip: "在新視窗開啟",
|
|
365
|
+
},
|
|
366
|
+
form: {
|
|
367
|
+
title_placeholder: "編輯標題",
|
|
368
|
+
url_placeholder: "編輯連結網址",
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
comments: {
|
|
372
|
+
actions: {
|
|
373
|
+
add_reaction: "新增回應",
|
|
374
|
+
resolve: "解決",
|
|
375
|
+
edit_comment: "編輯評論",
|
|
376
|
+
delete_comment: "刪除評論",
|
|
377
|
+
more_actions: "更多操作",
|
|
378
|
+
},
|
|
379
|
+
reactions: {
|
|
380
|
+
reacted_by: "已回應",
|
|
381
|
+
},
|
|
382
|
+
sidebar: {
|
|
383
|
+
marked_as_resolved: "標記為已解決",
|
|
384
|
+
more_replies: (count) => `還有 ${count} 則回覆`,
|
|
385
|
+
},
|
|
386
|
+
},
|
|
387
|
+
generic: {
|
|
388
|
+
ctrl_shortcut: "Ctrl",
|
|
389
|
+
},
|
|
390
|
+
};
|
package/src/locales.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./i18n/index.js";
|
|
1
|
+
export * from "./i18n/index.js";
|
|
@@ -31,7 +31,7 @@ export const BlockContainer = Node.create<{
|
|
|
31
31
|
parseHTML() {
|
|
32
32
|
return [
|
|
33
33
|
{
|
|
34
|
-
tag: "div",
|
|
34
|
+
tag: "div[data-node-type=" + this.name + "]",
|
|
35
35
|
getAttrs: (element) => {
|
|
36
36
|
if (typeof element === "string") {
|
|
37
37
|
return false;
|
|
@@ -44,13 +44,14 @@ export const BlockContainer = Node.create<{
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
return attrs;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return false;
|
|
47
|
+
return attrs;
|
|
52
48
|
},
|
|
53
49
|
},
|
|
50
|
+
// Ignore `blockOuter` divs, but parse the `blockContainer` divs inside them.
|
|
51
|
+
{
|
|
52
|
+
tag: `div[data-node-type="blockOuter"]`,
|
|
53
|
+
skip: true,
|
|
54
|
+
},
|
|
54
55
|
];
|
|
55
56
|
},
|
|
56
57
|
|
|
@@ -37,7 +37,7 @@ export const BlockGroup = Node.create<{
|
|
|
37
37
|
const blockGroup = document.createElement("div");
|
|
38
38
|
blockGroup.className = mergeCSSClasses(
|
|
39
39
|
"bn-block-group",
|
|
40
|
-
blockGroupHTMLAttributes.class
|
|
40
|
+
blockGroupHTMLAttributes.class,
|
|
41
41
|
);
|
|
42
42
|
blockGroup.setAttribute("data-node-type", "blockGroup");
|
|
43
43
|
for (const [attribute, value] of Object.entries(blockGroupHTMLAttributes)) {
|
package/src/pm-nodes/Doc.ts
CHANGED
package/src/schema/README.md
CHANGED
|
@@ -26,7 +26,7 @@ export type CustomBlockConfig = BlockConfig & {
|
|
|
26
26
|
export type CustomBlockImplementation<
|
|
27
27
|
T extends CustomBlockConfig,
|
|
28
28
|
I extends InlineContentSchema,
|
|
29
|
-
S extends StyleSchema
|
|
29
|
+
S extends StyleSchema,
|
|
30
30
|
> = {
|
|
31
31
|
render: (
|
|
32
32
|
/**
|
|
@@ -38,7 +38,7 @@ export type CustomBlockImplementation<
|
|
|
38
38
|
* This is typed generically. If you want an editor with your custom schema, you need to
|
|
39
39
|
* cast it manually, e.g.: `const e = editor as BlockNoteEditor<typeof mySchema>;`
|
|
40
40
|
*/
|
|
41
|
-
editor: BlockNoteEditor<BlockSchemaWithBlock<T["type"], T>, I, S
|
|
41
|
+
editor: BlockNoteEditor<BlockSchemaWithBlock<T["type"], T>, I, S>,
|
|
42
42
|
// (note) if we want to fix the manual cast, we need to prevent circular references and separate block definition and render implementations
|
|
43
43
|
// or allow manually passing <BSchema>, but that's not possible without passing the other generics because Typescript doesn't support partial inferred generics
|
|
44
44
|
) => {
|
|
@@ -52,14 +52,14 @@ export type CustomBlockImplementation<
|
|
|
52
52
|
// TODO: Maybe can return undefined to ignore when serializing?
|
|
53
53
|
toExternalHTML?: (
|
|
54
54
|
block: BlockFromConfig<T, I, S>,
|
|
55
|
-
editor: BlockNoteEditor<BlockSchemaWithBlock<T["type"], T>, I, S
|
|
55
|
+
editor: BlockNoteEditor<BlockSchemaWithBlock<T["type"], T>, I, S>,
|
|
56
56
|
) => {
|
|
57
57
|
dom: HTMLElement;
|
|
58
58
|
contentDOM?: HTMLElement;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
parse?: (
|
|
62
|
-
el: HTMLElement
|
|
62
|
+
el: HTMLElement,
|
|
63
63
|
) => PartialBlockFromConfig<T, I, S>["props"] | undefined;
|
|
64
64
|
};
|
|
65
65
|
|
|
@@ -85,12 +85,12 @@ export function applyNonSelectableBlockFix(nodeView: NodeView, editor: Editor) {
|
|
|
85
85
|
// from the clipboard.
|
|
86
86
|
export function getParseRules(
|
|
87
87
|
config: BlockConfig,
|
|
88
|
-
customParseFunction: CustomBlockImplementation<any, any, any>["parse"]
|
|
88
|
+
customParseFunction: CustomBlockImplementation<any, any, any>["parse"],
|
|
89
89
|
) {
|
|
90
90
|
const rules: TagParseRule[] = [
|
|
91
91
|
{
|
|
92
92
|
tag: "[data-content-type=" + config.type + "]",
|
|
93
|
-
contentElement: "
|
|
93
|
+
contentElement: ".bn-inline-content",
|
|
94
94
|
},
|
|
95
95
|
];
|
|
96
96
|
|
|
@@ -136,10 +136,10 @@ export function getParseRules(
|
|
|
136
136
|
export function createBlockSpec<
|
|
137
137
|
T extends CustomBlockConfig,
|
|
138
138
|
I extends InlineContentSchema,
|
|
139
|
-
S extends StyleSchema
|
|
139
|
+
S extends StyleSchema,
|
|
140
140
|
>(
|
|
141
141
|
blockConfig: T,
|
|
142
|
-
blockImplementation: CustomBlockImplementation<NoInfer<T>, I, S
|
|
142
|
+
blockImplementation: CustomBlockImplementation<NoInfer<T>, I, S>,
|
|
143
143
|
) {
|
|
144
144
|
const node = createStronglyTypedTiptapNode({
|
|
145
145
|
name: blockConfig.type as T["type"],
|
|
@@ -173,7 +173,7 @@ export function createBlockSpec<
|
|
|
173
173
|
{},
|
|
174
174
|
blockConfig.propSchema,
|
|
175
175
|
blockConfig.isFileBlock,
|
|
176
|
-
HTMLAttributes
|
|
176
|
+
HTMLAttributes,
|
|
177
177
|
);
|
|
178
178
|
},
|
|
179
179
|
|
|
@@ -186,7 +186,7 @@ export function createBlockSpec<
|
|
|
186
186
|
getPos,
|
|
187
187
|
editor,
|
|
188
188
|
this.editor,
|
|
189
|
-
blockConfig.type
|
|
189
|
+
blockConfig.type,
|
|
190
190
|
);
|
|
191
191
|
// Gets the custom HTML attributes for `blockContent` nodes
|
|
192
192
|
const blockContentDOMAttributes =
|
|
@@ -199,7 +199,7 @@ export function createBlockSpec<
|
|
|
199
199
|
block.type,
|
|
200
200
|
block.props,
|
|
201
201
|
blockConfig.propSchema,
|
|
202
|
-
blockContentDOMAttributes
|
|
202
|
+
blockContentDOMAttributes,
|
|
203
203
|
);
|
|
204
204
|
|
|
205
205
|
if (blockConfig.isSelectable === false) {
|
|
@@ -213,7 +213,7 @@ export function createBlockSpec<
|
|
|
213
213
|
|
|
214
214
|
if (node.name !== blockConfig.type) {
|
|
215
215
|
throw new Error(
|
|
216
|
-
"Node name does not match block type. This is a bug in BlockNote."
|
|
216
|
+
"Node name does not match block type. This is a bug in BlockNote.",
|
|
217
217
|
);
|
|
218
218
|
}
|
|
219
219
|
|
|
@@ -231,7 +231,7 @@ export function createBlockSpec<
|
|
|
231
231
|
block.props,
|
|
232
232
|
blockConfig.propSchema,
|
|
233
233
|
blockConfig.isFileBlock,
|
|
234
|
-
blockContentDOMAttributes
|
|
234
|
+
blockContentDOMAttributes,
|
|
235
235
|
);
|
|
236
236
|
},
|
|
237
237
|
// TODO: this should not have wrapInBlockStructure and generally be a lot simpler
|
|
@@ -242,7 +242,7 @@ export function createBlockSpec<
|
|
|
242
242
|
|
|
243
243
|
let output = blockImplementation.toExternalHTML?.(
|
|
244
244
|
block as any,
|
|
245
|
-
editor as any
|
|
245
|
+
editor as any,
|
|
246
246
|
);
|
|
247
247
|
if (output === undefined) {
|
|
248
248
|
output = blockImplementation.render(block as any, editor as any);
|
|
@@ -252,7 +252,7 @@ export function createBlockSpec<
|
|
|
252
252
|
block.type,
|
|
253
253
|
block.props,
|
|
254
254
|
blockConfig.propSchema,
|
|
255
|
-
blockContentDOMAttributes
|
|
255
|
+
blockContentDOMAttributes,
|
|
256
256
|
);
|
|
257
257
|
},
|
|
258
258
|
});
|
|
@@ -99,17 +99,17 @@ export function getBlockFromPos<
|
|
|
99
99
|
Config extends BlockConfig,
|
|
100
100
|
BSchema extends BlockSchemaWithBlock<BType, Config>,
|
|
101
101
|
I extends InlineContentSchema,
|
|
102
|
-
S extends StyleSchema
|
|
102
|
+
S extends StyleSchema,
|
|
103
103
|
>(
|
|
104
104
|
getPos: (() => number) | boolean,
|
|
105
105
|
editor: BlockNoteEditor<BSchema, I, S>,
|
|
106
106
|
tipTapEditor: Editor,
|
|
107
|
-
type: BType
|
|
107
|
+
type: BType,
|
|
108
108
|
) {
|
|
109
109
|
// Gets position of the node
|
|
110
110
|
if (typeof getPos === "boolean") {
|
|
111
111
|
throw new Error(
|
|
112
|
-
"Cannot find node position as getPos is a boolean, not a function."
|
|
112
|
+
"Cannot find node position as getPos is a boolean, not a function.",
|
|
113
113
|
);
|
|
114
114
|
}
|
|
115
115
|
const pos = getPos();
|
|
@@ -142,7 +142,7 @@ export function getBlockFromPos<
|
|
|
142
142
|
// an `inlineContent` class to it.
|
|
143
143
|
export function wrapInBlockStructure<
|
|
144
144
|
BType extends string,
|
|
145
|
-
PSchema extends PropSchema
|
|
145
|
+
PSchema extends PropSchema,
|
|
146
146
|
>(
|
|
147
147
|
element: {
|
|
148
148
|
dom: HTMLElement;
|
|
@@ -153,7 +153,7 @@ export function wrapInBlockStructure<
|
|
|
153
153
|
blockProps: Props<PSchema>,
|
|
154
154
|
propSchema: PSchema,
|
|
155
155
|
isFileBlock = false,
|
|
156
|
-
domAttributes?: Record<string, string
|
|
156
|
+
domAttributes?: Record<string, string>,
|
|
157
157
|
): {
|
|
158
158
|
dom: HTMLElement;
|
|
159
159
|
contentDOM?: HTMLElement;
|
|
@@ -173,7 +173,7 @@ export function wrapInBlockStructure<
|
|
|
173
173
|
// Sets blockContent class
|
|
174
174
|
blockContent.className = mergeCSSClasses(
|
|
175
175
|
"bn-block-content",
|
|
176
|
-
domAttributes?.class || ""
|
|
176
|
+
domAttributes?.class || "",
|
|
177
177
|
);
|
|
178
178
|
// Sets content type attribute
|
|
179
179
|
blockContent.setAttribute("data-content-type", blockType);
|
|
@@ -197,9 +197,8 @@ export function wrapInBlockStructure<
|
|
|
197
197
|
if (element.contentDOM !== undefined) {
|
|
198
198
|
element.contentDOM.className = mergeCSSClasses(
|
|
199
199
|
"bn-inline-content",
|
|
200
|
-
element.contentDOM.className
|
|
200
|
+
element.contentDOM.className,
|
|
201
201
|
);
|
|
202
|
-
element.contentDOM.setAttribute("data-editable", "");
|
|
203
202
|
}
|
|
204
203
|
|
|
205
204
|
return {
|
|
@@ -216,7 +215,7 @@ type StronglyTypedTipTapNode<
|
|
|
216
215
|
| "tableRow+"
|
|
217
216
|
| "blockContainer+"
|
|
218
217
|
| "column column+"
|
|
219
|
-
| ""
|
|
218
|
+
| "",
|
|
220
219
|
> = Node & { name: Name; config: { content: Content } };
|
|
221
220
|
|
|
222
221
|
export function createStronglyTypedTiptapNode<
|
|
@@ -226,7 +225,7 @@ export function createStronglyTypedTiptapNode<
|
|
|
226
225
|
| "tableRow+"
|
|
227
226
|
| "blockContainer+"
|
|
228
227
|
| "column column+"
|
|
229
|
-
| ""
|
|
228
|
+
| "",
|
|
230
229
|
>(config: NodeConfig & { name: Name; content: Content }) {
|
|
231
230
|
return Node.create(config) as StronglyTypedTipTapNode<Name, Content>; // force re-typing (should be safe as it's type-checked from the config)
|
|
232
231
|
}
|
|
@@ -240,7 +239,7 @@ export function createInternalBlockSpec<T extends BlockConfig>(
|
|
|
240
239
|
any,
|
|
241
240
|
InlineContentSchema,
|
|
242
241
|
StyleSchema
|
|
243
|
-
|
|
242
|
+
>,
|
|
244
243
|
) {
|
|
245
244
|
return {
|
|
246
245
|
config,
|
|
@@ -250,7 +249,7 @@ export function createInternalBlockSpec<T extends BlockConfig>(
|
|
|
250
249
|
|
|
251
250
|
export function createBlockSpecFromStronglyTypedTiptapNode<
|
|
252
251
|
T extends Node,
|
|
253
|
-
P extends PropSchema
|
|
252
|
+
P extends PropSchema,
|
|
254
253
|
>(node: T, propSchema: P, requiredExtensions?: Array<Extension | Node>) {
|
|
255
254
|
return createInternalBlockSpec(
|
|
256
255
|
{
|
|
@@ -258,12 +257,12 @@ export function createBlockSpecFromStronglyTypedTiptapNode<
|
|
|
258
257
|
content: (node.config.content === "inline*"
|
|
259
258
|
? "inline"
|
|
260
259
|
: node.config.content === "tableRow+"
|
|
261
|
-
|
|
262
|
-
|
|
260
|
+
? "table"
|
|
261
|
+
: "none") as T["config"]["content"] extends "inline*"
|
|
263
262
|
? "inline"
|
|
264
263
|
: T["config"]["content"] extends "tableRow+"
|
|
265
|
-
|
|
266
|
-
|
|
264
|
+
? "table"
|
|
265
|
+
: "none",
|
|
267
266
|
propSchema,
|
|
268
267
|
},
|
|
269
268
|
{
|
|
@@ -272,12 +271,12 @@ export function createBlockSpecFromStronglyTypedTiptapNode<
|
|
|
272
271
|
toInternalHTML: defaultBlockToHTML,
|
|
273
272
|
toExternalHTML: defaultBlockToHTML,
|
|
274
273
|
// parse: () => undefined, // parse rules are in node already
|
|
275
|
-
}
|
|
274
|
+
},
|
|
276
275
|
);
|
|
277
276
|
}
|
|
278
277
|
|
|
279
278
|
export function getBlockSchemaFromSpecs<T extends BlockSpecs>(specs: T) {
|
|
280
279
|
return Object.fromEntries(
|
|
281
|
-
Object.entries(specs).map(([key, value]) => [key, value.config])
|
|
280
|
+
Object.entries(specs).map(([key, value]) => [key, value.config]),
|
|
282
281
|
) as BlockSchemaFromSpecs<T>;
|
|
283
282
|
}
|