Skip to content

Commit 2e2cb06

Browse files
committed
Merge branch 'main' into plugin-system
2 parents 4644cb4 + f1d6e89 commit 2e2cb06

File tree

26 files changed

+406
-363
lines changed

26 files changed

+406
-363
lines changed

docs/package.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
"@ai-sdk/openai-compatible": "^1.0.22",
2323
"@aws-sdk/client-s3": "^3.609.0",
2424
"@aws-sdk/s3-request-presigner": "^3.609.0",
25-
"@blocknote/code-block": "latest",
26-
"@blocknote/server-util": "latest",
27-
"@blocknote/xl-ai": "latest",
28-
"@blocknote/xl-docx-exporter": "latest",
29-
"@blocknote/xl-email-exporter": "latest",
30-
"@blocknote/xl-multi-column": "latest",
31-
"@blocknote/xl-odt-exporter": "latest",
32-
"@blocknote/xl-pdf-exporter": "latest",
25+
"@blocknote/code-block": "workspace:*",
26+
"@blocknote/server-util": "workspace:*",
27+
"@blocknote/xl-ai": "workspace:*",
28+
"@blocknote/xl-docx-exporter": "workspace:*",
29+
"@blocknote/xl-email-exporter": "workspace:*",
30+
"@blocknote/xl-multi-column": "workspace:*",
31+
"@blocknote/xl-odt-exporter": "workspace:*",
32+
"@blocknote/xl-pdf-exporter": "workspace:*",
3333
"@emotion/react": "^11.11.4",
3434
"@emotion/styled": "^11.11.5",
3535
"@fumadocs/mdx-remote": "1.3.0",
@@ -79,12 +79,12 @@
7979
"clsx": "2.1.1",
8080
"docx": "^9.0.2",
8181
"framer-motion": "^11.18.2",
82-
"fumadocs-core": "^15.8.5",
83-
"fumadocs-docgen": "^2.1.0",
84-
"fumadocs-mdx": "^11.10.1",
85-
"fumadocs-twoslash": "^3.1.8",
86-
"fumadocs-typescript": "^4.0.11",
87-
"fumadocs-ui": "^15.8.5",
82+
"fumadocs-core": "15.5.4",
83+
"fumadocs-docgen": "2.0.1",
84+
"fumadocs-mdx": "11.6.9",
85+
"fumadocs-twoslash": "3.1.4",
86+
"fumadocs-typescript": "4.0.6",
87+
"fumadocs-ui": "15.5.4",
8888
"import-in-the-middle": "^1.15.0",
8989
"next": "15.5.1",
9090
"nodemailer": "^6.10.1",
@@ -107,15 +107,15 @@
107107
"zustand": "^5.0.3"
108108
},
109109
"devDependencies": {
110-
"@blocknote/ariakit": "workspace:^",
111-
"@blocknote/code-block": "workspace:^",
112-
"@blocknote/core": "workspace:^",
113-
"@blocknote/mantine": "workspace:^",
114-
"@blocknote/react": "workspace:^",
115-
"@blocknote/shadcn": "workspace:^",
116-
"@blocknote/xl-docx-exporter": "workspace:^",
117-
"@blocknote/xl-multi-column": "workspace:^",
118-
"@blocknote/xl-pdf-exporter": "workspace:^",
110+
"@blocknote/ariakit": "workspace:*",
111+
"@blocknote/code-block": "workspace:*",
112+
"@blocknote/core": "workspace:*",
113+
"@blocknote/mantine": "workspace:*",
114+
"@blocknote/react": "workspace:*",
115+
"@blocknote/shadcn": "workspace:*",
116+
"@blocknote/xl-docx-exporter": "workspace:*",
117+
"@blocknote/xl-multi-column": "workspace:*",
118+
"@blocknote/xl-pdf-exporter": "workspace:*",
119119
"@liveblocks/react": "^2.24.3",
120120
"@liveblocks/react-tiptap": "^2.24.3",
121121
"@liveblocks/react-ui": "^2.24.3",

packages/core/src/blocks/Code/block.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export const createCodeBlockSpec = createBlockSpec(
102102
const code = el.firstElementChild!;
103103

104104
return parser.parse(code, {
105+
preserveWhitespace: "full",
105106
topNode: schema.nodes["codeBlock"].create(),
106107
}).content;
107108
},

packages/core/src/editor/BlockNoteEditor.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,13 +814,26 @@ export class BlockNoteEditor<
814814
return !this._tiptapEditor.isInitialized;
815815
}
816816

817+
/**
818+
* Focus on the editor
819+
*/
817820
public focus() {
818821
if (this.headless) {
819822
return;
820823
}
821824
this.prosemirrorView.focus();
822825
}
823826

827+
/**
828+
* Blur the editor
829+
*/
830+
public blur() {
831+
if (this.headless) {
832+
return;
833+
}
834+
this.prosemirrorView.dom.blur();
835+
}
836+
824837
// TODO move to extension
825838
public onUploadStart(callback: (blockId?: string) => void) {
826839
this.onUploadStartCallbacks.push(callback);

packages/core/src/extensions/BackgroundColor/BackgroundColorMark.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.

packages/core/src/extensions/SideMenu/SideMenuPlugin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,8 @@ export const SideMenuProsemirrorPlugin = createExtension((editor) => {
727727
if (view) {
728728
view.isDragOrigin = false;
729729
}
730+
731+
editor.blur();
730732
},
731733

732734
/**

packages/core/src/extensions/TextColor/TextColorMark.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

packages/core/src/schema/inlineContent/createSpec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ export type CustomInlineContentImplementation<
8181
contentDOM?: HTMLElement;
8282
}
8383
| undefined;
84+
85+
runsBefore?: string[];
8486
};
8587

8688
export function getInlineContentParseRules<C extends CustomInlineContentConfig>(
@@ -220,6 +222,7 @@ export function createInlineContentSpec<
220222
node,
221223
inlineContentConfig.propSchema,
222224
{
225+
...inlineContentImplementation,
223226
toExternalHTML: inlineContentImplementation.toExternalHTML,
224227
render(inlineContent, updateInlineContent, editor) {
225228
const output = inlineContentImplementation.render(

packages/core/src/schema/inlineContent/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export type InlineContentImplementation<T extends InlineContentConfig> =
4343
ignoreMutation?: (mutation: ViewMutationRecord) => boolean;
4444
destroy?: () => void;
4545
};
46+
runsBefore?: string[];
4647
};
4748

4849
export type InlineContentSchemaWithInlineContent<

packages/core/src/schema/schema.ts

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,13 @@ export class CustomBlockNoteSchema<
8181

8282
private init() {
8383
const getPriority = sortByDependencies(
84-
Object.entries(this.opts.blockSpecs).map(([key, val]) => ({
84+
Object.entries({
85+
...this.opts.blockSpecs,
86+
...this.opts.inlineContentSpecs,
87+
...this.opts.styleSpecs,
88+
}).map(([key, val]) => ({
8589
key: key,
86-
runsBefore: val.implementation.runsBefore,
90+
runsBefore: val.implementation?.runsBefore ?? [],
8791
})),
8892
);
8993

@@ -105,19 +109,58 @@ export class CustomBlockNoteSchema<
105109
: never;
106110
};
107111

112+
const inlineContentSpecs = Object.fromEntries(
113+
Object.entries(this.opts.inlineContentSpecs).map(
114+
([key, inlineContentSpec]) => {
115+
// Case for text and links.
116+
if (typeof inlineContentSpec.config !== "object") {
117+
return [key, inlineContentSpec];
118+
}
119+
120+
return [
121+
key,
122+
{
123+
...inlineContentSpec,
124+
implementation: {
125+
...inlineContentSpec.implementation,
126+
node: inlineContentSpec.implementation?.node.extend({
127+
priority: getPriority(key),
128+
}),
129+
},
130+
},
131+
];
132+
},
133+
),
134+
) as InlineContentSpecs;
135+
136+
const styleSpecs = Object.fromEntries(
137+
Object.entries(this.opts.styleSpecs).map(([key, styleSpec]) => [
138+
key,
139+
{
140+
...styleSpec,
141+
implementation: {
142+
...styleSpec.implementation,
143+
mark: styleSpec.implementation?.mark.extend({
144+
priority: getPriority(key),
145+
}),
146+
},
147+
},
148+
]),
149+
) as StyleSpecs;
150+
108151
return {
109152
blockSpecs,
110153
blockSchema: Object.fromEntries(
111154
Object.entries(blockSpecs).map(([key, blockDef]) => {
112155
return [key, blockDef.config];
113156
}),
114157
) as any,
115-
inlineContentSpecs: removeUndefined(this.opts.inlineContentSpecs),
116-
styleSpecs: removeUndefined(this.opts.styleSpecs),
158+
inlineContentSpecs: removeUndefined(inlineContentSpecs),
159+
styleSpecs: removeUndefined(styleSpecs),
117160
inlineContentSchema: getInlineContentSchemaFromSpecs(
118-
this.opts.inlineContentSpecs,
161+
inlineContentSpecs,
119162
) as any,
120-
styleSchema: getStyleSchemaFromSpecs(this.opts.styleSpecs) as any,
163+
styleSchema: getStyleSchemaFromSpecs(styleSpecs) as any,
121164
};
122165
}
123166

packages/core/src/schema/styles/createSpec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export type CustomStyleImplementation<T extends StyleConfig> = {
2222
parse?: (
2323
element: HTMLElement,
2424
) => (T["propSchema"] extends "boolean" ? true : string) | undefined;
25+
runsBefore?: string[];
2526
};
2627

2728
export function getStyleParseRules<T extends StyleConfig>(
@@ -46,6 +47,10 @@ export function getStyleParseRules<T extends StyleConfig>(
4647
if (customParseFunction) {
4748
rules.push({
4849
tag: "*",
50+
// By default, styles can overlap each other, so the rules should not
51+
// completely consume the element they parse (which can have multiple
52+
// styles).
53+
consuming: false,
4954
getAttrs(node: string | HTMLElement) {
5055
if (typeof node === "string") {
5156
return false;
@@ -107,6 +112,7 @@ export function createStyleSpec<const T extends StyleConfig>(
107112
});
108113

109114
return createInternalStyleSpec(styleConfig, {
115+
...styleImplementation,
110116
mark,
111117
render: (value) => {
112118
const renderResult = styleImplementation.render(value as any);

0 commit comments

Comments
 (0)