@blocknote/xl-multi-column 0.19.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/LICENSE +661 -0
- package/dist/blocknote-xl-multi-column.js +3038 -0
- package/dist/blocknote-xl-multi-column.js.map +1 -0
- package/dist/blocknote-xl-multi-column.umd.cjs +69 -0
- package/dist/blocknote-xl-multi-column.umd.cjs.map +1 -0
- package/dist/webpack-stats.json +1 -0
- package/package.json +80 -0
- package/src/blocks/Columns/index.ts +15 -0
- package/src/blocks/schema.ts +43 -0
- package/src/extensions/ColumnResize/ColumnResizeExtension.ts +357 -0
- package/src/extensions/DropCursor/MultiColumnDropCursorPlugin.ts +480 -0
- package/src/extensions/SuggestionMenu/getMultiColumnSlashMenuItems.tsx +105 -0
- package/src/i18n/dictionary.ts +27 -0
- package/src/i18n/locales/ar.ts +18 -0
- package/src/i18n/locales/de.ts +18 -0
- package/src/i18n/locales/en.ts +16 -0
- package/src/i18n/locales/es.ts +18 -0
- package/src/i18n/locales/fr.ts +18 -0
- package/src/i18n/locales/hr.ts +18 -0
- package/src/i18n/locales/index.ts +15 -0
- package/src/i18n/locales/is.ts +18 -0
- package/src/i18n/locales/ja.ts +18 -0
- package/src/i18n/locales/ko.ts +18 -0
- package/src/i18n/locales/nl.ts +18 -0
- package/src/i18n/locales/pl.ts +18 -0
- package/src/i18n/locales/pt.ts +18 -0
- package/src/i18n/locales/ru.ts +18 -0
- package/src/i18n/locales/vi.ts +18 -0
- package/src/i18n/locales/zh.ts +18 -0
- package/src/index.ts +7 -0
- package/src/pm-nodes/Column.ts +87 -0
- package/src/pm-nodes/ColumnList.ts +44 -0
- package/src/test/commands/__snapshots__/insertBlocks.test.ts.snap +757 -0
- package/src/test/commands/__snapshots__/textCursorPosition.test.ts.snap +169 -0
- package/src/test/commands/__snapshots__/updateBlock.test.ts.snap +964 -0
- package/src/test/commands/insertBlocks.test.ts +206 -0
- package/src/test/commands/textCursorPosition.test.ts +19 -0
- package/src/test/commands/updateBlock.test.ts +212 -0
- package/src/test/conversions/__snapshots__/multi-column/undefined/external.html +1 -0
- package/src/test/conversions/__snapshots__/multi-column/undefined/internal.html +1 -0
- package/src/test/conversions/__snapshots__/nodeConversion.test.ts.snap +118 -0
- package/src/test/conversions/htmlConversion.test.ts +100 -0
- package/src/test/conversions/nodeConversion.test.ts +84 -0
- package/src/test/conversions/testCases.ts +54 -0
- package/src/test/setupTestEnv.ts +99 -0
- package/src/vite-env.d.ts +1 -0
- package/types/src/blocks/Columns/index.d.ts +32 -0
- package/types/src/blocks/schema.d.ts +102 -0
- package/types/src/extensions/ColumnResize/ColumnResizeExtension.d.ts +3 -0
- package/types/src/extensions/DropCursor/MultiColumnDropCursorPlugin.d.ts +11 -0
- package/types/src/extensions/SuggestionMenu/getMultiColumnSlashMenuItems.d.ts +5 -0
- package/types/src/i18n/dictionary.d.ts +19 -0
- package/types/src/i18n/locales/ar.d.ts +2 -0
- package/types/src/i18n/locales/de.d.ts +2 -0
- package/types/src/i18n/locales/en.d.ts +16 -0
- package/types/src/i18n/locales/es.d.ts +2 -0
- package/types/src/i18n/locales/fr.d.ts +2 -0
- package/types/src/i18n/locales/hr.d.ts +2 -0
- package/types/src/i18n/locales/index.d.ts +15 -0
- package/types/src/i18n/locales/is.d.ts +2 -0
- package/types/src/i18n/locales/ja.d.ts +2 -0
- package/types/src/i18n/locales/ko.d.ts +2 -0
- package/types/src/i18n/locales/nl.d.ts +2 -0
- package/types/src/i18n/locales/pl.d.ts +2 -0
- package/types/src/i18n/locales/pt.d.ts +2 -0
- package/types/src/i18n/locales/ru.d.ts +2 -0
- package/types/src/i18n/locales/vi.d.ts +2 -0
- package/types/src/i18n/locales/zh.d.ts +2 -0
- package/types/src/index.d.ts +7 -0
- package/types/src/pm-nodes/Column.d.ts +6 -0
- package/types/src/pm-nodes/ColumnList.d.ts +6 -0
- package/types/src/test/commands/insertBlocks.test.d.ts +1 -0
- package/types/src/test/commands/textCursorPosition.test.d.ts +1 -0
- package/types/src/test/commands/updateBlock.test.d.ts +1 -0
- package/types/src/test/conversions/htmlConversion.test.d.ts +1 -0
- package/types/src/test/conversions/nodeConversion.test.d.ts +1 -0
- package/types/src/test/conversions/testCases.d.ts +3 -0
- package/types/src/test/setupTestEnv.d.ts +1041 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MultiColumnDictionary } from "../dictionary.js";
|
|
2
|
+
|
|
3
|
+
export const hr: MultiColumnDictionary = {
|
|
4
|
+
slash_menu: {
|
|
5
|
+
two_columns: {
|
|
6
|
+
title: "Dva Stupca",
|
|
7
|
+
subtext: "Dva stupca jedan pored drugog",
|
|
8
|
+
aliases: ["stupci", "redak", "podijeli"],
|
|
9
|
+
group: "Osnovni blokovi",
|
|
10
|
+
},
|
|
11
|
+
three_columns: {
|
|
12
|
+
title: "Tri Stupca",
|
|
13
|
+
subtext: "Tri stupca jedan pored drugog",
|
|
14
|
+
aliases: ["stupci", "redak", "podijeli"],
|
|
15
|
+
group: "Osnovni blokovi",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./ar.js";
|
|
2
|
+
export * from "./de.js";
|
|
3
|
+
export * from "./en.js";
|
|
4
|
+
export * from "./es.js";
|
|
5
|
+
export * from "./fr.js";
|
|
6
|
+
export * from "./hr.js";
|
|
7
|
+
export * from "./is.js";
|
|
8
|
+
export * from "./ja.js";
|
|
9
|
+
export * from "./ko.js";
|
|
10
|
+
export * from "./nl.js";
|
|
11
|
+
export * from "./pl.js";
|
|
12
|
+
export * from "./pt.js";
|
|
13
|
+
export * from "./ru.js";
|
|
14
|
+
export * from "./vi.js";
|
|
15
|
+
export * from "./zh.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MultiColumnDictionary } from "../dictionary.js";
|
|
2
|
+
|
|
3
|
+
export const is: MultiColumnDictionary = {
|
|
4
|
+
slash_menu: {
|
|
5
|
+
two_columns: {
|
|
6
|
+
title: "Tvær Dálkar",
|
|
7
|
+
subtext: "Tvær dálkar hlið við hlið",
|
|
8
|
+
aliases: ["dálkar", "röð", "skipta"],
|
|
9
|
+
group: "Grunnblokkar",
|
|
10
|
+
},
|
|
11
|
+
three_columns: {
|
|
12
|
+
title: "Þrír Dálkar",
|
|
13
|
+
subtext: "Þrír dálkar hlið við hlið",
|
|
14
|
+
aliases: ["dálkar", "röð", "skipta"],
|
|
15
|
+
group: "Grunnblokkar",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MultiColumnDictionary } from "../dictionary.js";
|
|
2
|
+
|
|
3
|
+
export const ja: MultiColumnDictionary = {
|
|
4
|
+
slash_menu: {
|
|
5
|
+
two_columns: {
|
|
6
|
+
title: "二列",
|
|
7
|
+
subtext: "二列並んで",
|
|
8
|
+
aliases: ["列", "行", "分割"],
|
|
9
|
+
group: "基本ブロック",
|
|
10
|
+
},
|
|
11
|
+
three_columns: {
|
|
12
|
+
title: "三列",
|
|
13
|
+
subtext: "三列並んで",
|
|
14
|
+
aliases: ["列", "行", "分割"],
|
|
15
|
+
group: "基本ブロック",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MultiColumnDictionary } from "../dictionary.js";
|
|
2
|
+
|
|
3
|
+
export const ko: MultiColumnDictionary = {
|
|
4
|
+
slash_menu: {
|
|
5
|
+
two_columns: {
|
|
6
|
+
title: "두 열",
|
|
7
|
+
subtext: "두 열 나란히",
|
|
8
|
+
aliases: ["열", "행", "분할"],
|
|
9
|
+
group: "기본 블록",
|
|
10
|
+
},
|
|
11
|
+
three_columns: {
|
|
12
|
+
title: "세 열",
|
|
13
|
+
subtext: "세 열 나란히",
|
|
14
|
+
aliases: ["열", "행", "분할"],
|
|
15
|
+
group: "기본 블록",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MultiColumnDictionary } from "../dictionary.js";
|
|
2
|
+
|
|
3
|
+
export const nl: MultiColumnDictionary = {
|
|
4
|
+
slash_menu: {
|
|
5
|
+
two_columns: {
|
|
6
|
+
title: "Twee Kolommen",
|
|
7
|
+
subtext: "Twee kolommen naast elkaar",
|
|
8
|
+
aliases: ["kolommen", "rij", "verdelen"],
|
|
9
|
+
group: "Basisblokken",
|
|
10
|
+
},
|
|
11
|
+
three_columns: {
|
|
12
|
+
title: "Drie Kolommen",
|
|
13
|
+
subtext: "Drie kolommen naast elkaar",
|
|
14
|
+
aliases: ["kolommen", "rij", "verdelen"],
|
|
15
|
+
group: "Basisblokken",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MultiColumnDictionary } from "../dictionary.js";
|
|
2
|
+
|
|
3
|
+
export const pl: MultiColumnDictionary = {
|
|
4
|
+
slash_menu: {
|
|
5
|
+
two_columns: {
|
|
6
|
+
title: "Dwie Kolumny",
|
|
7
|
+
subtext: "Dwie kolumny obok siebie",
|
|
8
|
+
aliases: ["kolumny", "rząd", "podzielić"],
|
|
9
|
+
group: "Podstawowe bloki",
|
|
10
|
+
},
|
|
11
|
+
three_columns: {
|
|
12
|
+
title: "Trzy Kolumny",
|
|
13
|
+
subtext: "Trzy kolumny obok siebie",
|
|
14
|
+
aliases: ["kolumny", "rząd", "podzielić"],
|
|
15
|
+
group: "Podstawowe bloki",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MultiColumnDictionary } from "../dictionary.js";
|
|
2
|
+
|
|
3
|
+
export const pt: MultiColumnDictionary = {
|
|
4
|
+
slash_menu: {
|
|
5
|
+
two_columns: {
|
|
6
|
+
title: "Duas Colunas",
|
|
7
|
+
subtext: "Duas colunas lado a lado",
|
|
8
|
+
aliases: ["colunas", "linha", "dividir"],
|
|
9
|
+
group: "Blocos básicos",
|
|
10
|
+
},
|
|
11
|
+
three_columns: {
|
|
12
|
+
title: "Três Colunas",
|
|
13
|
+
subtext: "Três colunas lado a lado",
|
|
14
|
+
aliases: ["colunas", "linha", "dividir"],
|
|
15
|
+
group: "Blocos básicos",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MultiColumnDictionary } from "../dictionary.js";
|
|
2
|
+
|
|
3
|
+
export const ru: MultiColumnDictionary = {
|
|
4
|
+
slash_menu: {
|
|
5
|
+
two_columns: {
|
|
6
|
+
title: "Два Столбца",
|
|
7
|
+
subtext: "Два столбца рядом",
|
|
8
|
+
aliases: ["столбцы", "ряд", "разделить"],
|
|
9
|
+
group: "Базовые блоки",
|
|
10
|
+
},
|
|
11
|
+
three_columns: {
|
|
12
|
+
title: "Три Столбца",
|
|
13
|
+
subtext: "Три столбца рядом",
|
|
14
|
+
aliases: ["столбцы", "ряд", "разделить"],
|
|
15
|
+
group: "Базовые блоки",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MultiColumnDictionary } from "../dictionary.js";
|
|
2
|
+
|
|
3
|
+
export const vi: MultiColumnDictionary = {
|
|
4
|
+
slash_menu: {
|
|
5
|
+
two_columns: {
|
|
6
|
+
title: "Hai Cột",
|
|
7
|
+
subtext: "Hai cột cạnh nhau",
|
|
8
|
+
aliases: ["cột", "hàng", "chia"],
|
|
9
|
+
group: "Khối cơ bản",
|
|
10
|
+
},
|
|
11
|
+
three_columns: {
|
|
12
|
+
title: "Ba Cột",
|
|
13
|
+
subtext: "Ba cột cạnh nhau",
|
|
14
|
+
aliases: ["cột", "hàng", "chia"],
|
|
15
|
+
group: "Khối cơ bản",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MultiColumnDictionary } from "../dictionary.js";
|
|
2
|
+
|
|
3
|
+
export const zh: MultiColumnDictionary = {
|
|
4
|
+
slash_menu: {
|
|
5
|
+
two_columns: {
|
|
6
|
+
title: "两列",
|
|
7
|
+
subtext: "两列并排",
|
|
8
|
+
aliases: ["列", "行", "分割"],
|
|
9
|
+
group: "基础",
|
|
10
|
+
},
|
|
11
|
+
three_columns: {
|
|
12
|
+
title: "三列",
|
|
13
|
+
subtext: "三列并排",
|
|
14
|
+
aliases: ["列", "行", "分割"],
|
|
15
|
+
group: "基础",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as locales from "./i18n/locales/index.js";
|
|
2
|
+
export { locales };
|
|
3
|
+
export * from "./i18n/dictionary.js";
|
|
4
|
+
export * from "./blocks/Columns/index.js";
|
|
5
|
+
export * from "./blocks/schema.js";
|
|
6
|
+
export * from "./extensions/DropCursor/MultiColumnDropCursorPlugin.js";
|
|
7
|
+
export * from "./extensions/SuggestionMenu/getMultiColumnSlashMenuItems.js";
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createStronglyTypedTiptapNode } from "@blocknote/core";
|
|
2
|
+
|
|
3
|
+
import { createColumnResizeExtension } from "../extensions/ColumnResize/ColumnResizeExtension.js";
|
|
4
|
+
|
|
5
|
+
export const Column = createStronglyTypedTiptapNode({
|
|
6
|
+
name: "column",
|
|
7
|
+
group: "bnBlock childContainer",
|
|
8
|
+
// A block always contains content, and optionally a blockGroup which contains nested blocks
|
|
9
|
+
content: "blockContainer+",
|
|
10
|
+
priority: 40,
|
|
11
|
+
defining: true,
|
|
12
|
+
addAttributes() {
|
|
13
|
+
return {
|
|
14
|
+
width: {
|
|
15
|
+
// Why does each column have a default width of 1, i.e. 100%? Because
|
|
16
|
+
// when creating a new column, we want to make sure that existing
|
|
17
|
+
// column widths are preserved, while the new one also has a sensible
|
|
18
|
+
// width. If we'd set it so all column widths must add up to 100%
|
|
19
|
+
// instead, then each time a new column is created, we'd have to assign
|
|
20
|
+
// it a width depending on the total number of columns and also adjust
|
|
21
|
+
// the widths of the other columns. The same can be said for using px
|
|
22
|
+
// instead of percent widths and making them add to the editor width. So
|
|
23
|
+
// using this method is both simpler and computationally cheaper. This
|
|
24
|
+
// is possible because we can set the `flex-grow` property to the width
|
|
25
|
+
// value, which handles all the resizing for us, instead of manually
|
|
26
|
+
// having to set the `width` property of each column.
|
|
27
|
+
default: 1,
|
|
28
|
+
parseHTML: (element) => {
|
|
29
|
+
const attr = element.getAttribute("data-width");
|
|
30
|
+
if (attr === null) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const parsed = parseFloat(attr);
|
|
35
|
+
if (isFinite(parsed)) {
|
|
36
|
+
return parsed;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return null;
|
|
40
|
+
},
|
|
41
|
+
renderHTML: (attributes) => {
|
|
42
|
+
return {
|
|
43
|
+
"data-width": (attributes.width as number).toString(),
|
|
44
|
+
style: `flex-grow: ${attributes.width as number};`,
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
parseHTML() {
|
|
52
|
+
return [
|
|
53
|
+
{
|
|
54
|
+
tag: "div",
|
|
55
|
+
getAttrs: (element) => {
|
|
56
|
+
if (typeof element === "string") {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (element.getAttribute("data-node-type") === this.name) {
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return false;
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
renderHTML({ HTMLAttributes }) {
|
|
71
|
+
const column = document.createElement("div");
|
|
72
|
+
column.className = "bn-block-column";
|
|
73
|
+
column.setAttribute("data-node-type", this.name);
|
|
74
|
+
for (const [attribute, value] of Object.entries(HTMLAttributes)) {
|
|
75
|
+
column.setAttribute(attribute, value as any); // TODO as any
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
dom: column,
|
|
80
|
+
contentDOM: column,
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
addExtensions() {
|
|
85
|
+
return [createColumnResizeExtension(this.options.editor)];
|
|
86
|
+
},
|
|
87
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createStronglyTypedTiptapNode } from "@blocknote/core";
|
|
2
|
+
|
|
3
|
+
export const ColumnList = createStronglyTypedTiptapNode({
|
|
4
|
+
name: "columnList",
|
|
5
|
+
group: "childContainer bnBlock blockGroupChild",
|
|
6
|
+
// A block always contains content, and optionally a blockGroup which contains nested blocks
|
|
7
|
+
content: "column column+", // min two columns
|
|
8
|
+
priority: 40, // should be below blockContainer
|
|
9
|
+
defining: true,
|
|
10
|
+
|
|
11
|
+
parseHTML() {
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
tag: "div",
|
|
15
|
+
getAttrs: (element) => {
|
|
16
|
+
if (typeof element === "string") {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (element.getAttribute("data-node-type") === this.name) {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return false;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
renderHTML({ HTMLAttributes }) {
|
|
31
|
+
const columnList = document.createElement("div");
|
|
32
|
+
columnList.className = "bn-block-column-list";
|
|
33
|
+
columnList.setAttribute("data-node-type", this.name);
|
|
34
|
+
for (const [attribute, value] of Object.entries(HTMLAttributes)) {
|
|
35
|
+
columnList.setAttribute(attribute, value as any); // TODO as any
|
|
36
|
+
}
|
|
37
|
+
columnList.style.display = "flex";
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
dom: columnList,
|
|
41
|
+
contentDOM: columnList,
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
});
|