Skip to content

Commit 2f40815

Browse files
committed
Merge branch 'default-blocks' into parse-export-fixes
2 parents 338262b + cd788ad commit 2f40815

File tree

36 files changed

+263
-263
lines changed

36 files changed

+263
-263
lines changed

docs/app/(home)/hero/DemoEditor.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ import {
1616
getMultiColumnSlashMenuItems,
1717
locales as multiColumnLocales,
1818
multiColumnDropCursor,
19-
ColumnListBlock,
20-
ColumnBlock,
19+
withMultiColumn,
2120
} from "@blocknote/xl-multi-column";
2221
import "@blocknote/mantine/style.css";
2322
import { useTheme } from "next-themes";
@@ -91,12 +90,7 @@ export default function DemoEditor() {
9190
...locales.en,
9291
multi_column: multiColumnLocales.en,
9392
},
94-
schema: BlockNoteSchema.create().extend({
95-
blockSpecs: {
96-
column: ColumnBlock,
97-
columnList: ColumnListBlock,
98-
},
99-
}),
93+
schema: withMultiColumn(BlockNoteSchema.create()),
10094
dropCursor: multiColumnDropCursor,
10195
collaboration: {
10296
provider,

docs/content/docs/features/custom-schemas/custom-inline-content.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ type CustomInlineContentConfig = {
5151
type: string;
5252
content: "styled" | "none";
5353
readonly propSchema: PropSchema;
54-
draggable?: boolean;
5554
};
5655
```
5756

@@ -100,14 +99,15 @@ If you do not want the prop to have a default value, you can define it as an obj
10099
mentioned._
101100
</Callout>
102101

103-
`draggable?:` Whether the inline content should be draggable.
104-
105102
### Inline Content Implementation (`ReactCustomInlineContentImplementation`)
106103

107104
The Inline Content Implementation defines how the inline content should be rendered to HTML.
108105

109106
```typescript
110107
type ReactCustomInlineContentImplementation = {
108+
meta?: {
109+
draggable?: boolean;
110+
};
111111
render: React.FC<{
112112
inlineContent: InlineContent;
113113
contentRef?: (node: HTMLElement | null) => void;
@@ -124,6 +124,8 @@ type ReactCustomInlineContentImplementation = {
124124

125125
- `draggable:` Specifies whether the inline content can be dragged within the editor. If set to `true`, the inline content will be draggable. Defaults to `false` if not specified. If this is true, you should add `data-drag-handle` to the DOM element that should function as the drag handle.
126126

127+
`meta?.draggable?:` Whether the inline content should be draggable.
128+
127129
<Callout type="info">
128130
_Note that since inline content is, by definition, inline, your component
129131
should also return an HTML inline element._

examples/01-basic/03-multi-column/src/App.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,17 @@ import {
1313
useCreateBlockNote,
1414
} from "@blocknote/react";
1515
import {
16-
ColumnBlock,
17-
ColumnListBlock,
1816
getMultiColumnSlashMenuItems,
1917
multiColumnDropCursor,
2018
locales as multiColumnLocales,
19+
withMultiColumn,
2120
} from "@blocknote/xl-multi-column";
2221
import { useMemo } from "react";
2322
export default function App() {
2423
// Creates a new editor instance.
2524
const editor = useCreateBlockNote({
2625
// Adds column and column list blocks to the schema.
27-
schema: BlockNoteSchema.create().extend({
28-
blockSpecs: {
29-
column: ColumnBlock,
30-
columnList: ColumnListBlock,
31-
},
32-
}),
26+
schema: withMultiColumn(BlockNoteSchema.create()),
3327
// The default drop cursor only shows up above and below blocks - we replace
3428
// it with the multi-column one that also shows up on the sides of blocks.
3529
dropCursor: multiColumnDropCursor,

examples/05-interoperability/05-converting-blocks-to-pdf/src/App.tsx

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {
22
BlockNoteSchema,
33
combineByGroup,
4-
createPageBreakBlockSpec,
54
filterSuggestionItems,
5+
withPageBreak,
66
} from "@blocknote/core";
7-
import * as locales from "@blocknote/core/locales";
87
import "@blocknote/core/fonts/inter.css";
8+
import * as locales from "@blocknote/core/locales";
99
import { BlockNoteView } from "@blocknote/mantine";
1010
import "@blocknote/mantine/style.css";
1111
import {
@@ -14,17 +14,16 @@ import {
1414
getPageBreakReactSlashMenuItems,
1515
useCreateBlockNote,
1616
} from "@blocknote/react";
17-
import {
18-
PDFExporter,
19-
pdfDefaultSchemaMappings,
20-
} from "@blocknote/xl-pdf-exporter";
2117
import {
2218
getMultiColumnSlashMenuItems,
2319
multiColumnDropCursor,
2420
locales as multiColumnLocales,
25-
ColumnListBlock,
26-
ColumnBlock,
21+
withMultiColumn,
2722
} from "@blocknote/xl-multi-column";
23+
import {
24+
PDFExporter,
25+
pdfDefaultSchemaMappings,
26+
} from "@blocknote/xl-pdf-exporter";
2827
import { PDFViewer } from "@react-pdf/renderer";
2928
import { useEffect, useMemo, useReducer, useState } from "react";
3029

@@ -37,13 +36,7 @@ export default function App() {
3736

3837
// Creates a new editor instance with some initial content.
3938
const editor = useCreateBlockNote({
40-
schema: BlockNoteSchema.create().extend({
41-
blockSpecs: {
42-
pageBreak: createPageBreakBlockSpec(),
43-
column: ColumnBlock,
44-
columnList: ColumnListBlock,
45-
},
46-
}),
39+
schema: withPageBreak(withMultiColumn(BlockNoteSchema.create())),
4740
dropCursor: multiColumnDropCursor,
4841
dictionary: {
4942
...locales.en,

examples/05-interoperability/06-converting-blocks-to-docx/src/App.tsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {
22
BlockNoteSchema,
33
combineByGroup,
4-
createPageBreakBlockSpec,
54
filterSuggestionItems,
5+
withPageBreak,
66
} from "@blocknote/core";
7-
import * as locales from "@blocknote/core/locales";
87
import "@blocknote/core/fonts/inter.css";
8+
import * as locales from "@blocknote/core/locales";
99
import { BlockNoteView } from "@blocknote/mantine";
1010
import "@blocknote/mantine/style.css";
1111
import {
@@ -22,8 +22,7 @@ import {
2222
getMultiColumnSlashMenuItems,
2323
multiColumnDropCursor,
2424
locales as multiColumnLocales,
25-
ColumnListBlock,
26-
ColumnBlock,
25+
withMultiColumn,
2726
} from "@blocknote/xl-multi-column";
2827
import { useMemo } from "react";
2928

@@ -32,13 +31,7 @@ import "./styles.css";
3231
export default function App() {
3332
// Creates a new editor instance with some initial content.
3433
const editor = useCreateBlockNote({
35-
schema: BlockNoteSchema.create().extend({
36-
blockSpecs: {
37-
pageBreak: createPageBreakBlockSpec(),
38-
column: ColumnBlock,
39-
columnList: ColumnListBlock,
40-
},
41-
}),
34+
schema: withPageBreak(withMultiColumn(BlockNoteSchema.create())),
4235
dropCursor: multiColumnDropCursor,
4336
dictionary: {
4437
...locales.en,

examples/05-interoperability/08-converting-blocks-to-react-email/src/App.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import {
33
COLORS_DARK_MODE_DEFAULT,
44
COLORS_DEFAULT,
55
combineByGroup,
6-
createPageBreakBlockSpec,
76
filterSuggestionItems,
7+
withPageBreak,
88
} from "@blocknote/core";
99
import "@blocknote/core/fonts/inter.css";
1010
import { BlockNoteView } from "@blocknote/mantine";
@@ -30,11 +30,7 @@ export default function App() {
3030

3131
// Creates a new editor instance with some initial content.
3232
const editor = useCreateBlockNote({
33-
schema: BlockNoteSchema.create().extend({
34-
blockSpecs: {
35-
pageBreak: createPageBreakBlockSpec(),
36-
},
37-
}),
33+
schema: withPageBreak(BlockNoteSchema.create()),
3834
tables: {
3935
splitCells: true,
4036
cellBackgroundColor: true,

examples/06-custom-schema/draggable-inline-content/src/App.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ const draggableButton = createReactInlineContentSpec(
1515
default: "",
1616
},
1717
},
18-
draggable: true,
19-
content: "none"
18+
content: "none",
2019
},
2120
{
21+
meta: {
22+
draggable: true,
23+
},
2224
render: (props) => {
2325
return (
2426
<span
@@ -30,12 +32,13 @@ const draggableButton = createReactInlineContentSpec(
3032
borderRadius: "4px",
3133
cursor: "move",
3234
}}
33-
data-drag-handle>
35+
data-drag-handle
36+
>
3437
<span>{props.inlineContent.props.title}</span>
3538
</span>
3639
);
3740
},
38-
}
41+
},
3942
);
4043

4144
const schema = BlockNoteSchema.create({

packages/core/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@
5757
"import": "./dist/comments.js",
5858
"require": "./dist/comments.cjs"
5959
},
60+
"./blocks": {
61+
"types": "./types/src/blocks/index.d.ts",
62+
"import": "./dist/blocks.js",
63+
"require": "./dist/blocks.cjs"
64+
},
6065
"./locales": {
6166
"types": "./types/src/i18n/index.d.ts",
6267
"import": "./dist/locales.js",

packages/core/src/api/exporters/html/util/serializeBlocksExternalHTML.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,12 @@ function serializeBlock<
222222
if (fragment.lastChild?.nodeName !== listType) {
223223
const list = doc.createElement(listType);
224224

225-
if (listType === "OL" && props?.start && props?.start !== 1) {
225+
if (
226+
listType === "OL" &&
227+
"start" in props &&
228+
props.start &&
229+
props?.start !== 1
230+
) {
226231
list.setAttribute("start", props.start + "");
227232
}
228233
fragment.append(list);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export interface AudioOptions {
1818
icon?: string;
1919
}
2020

21+
export type AudioBlockConfig = ReturnType<typeof createAudioBlockConfig>;
22+
2123
export const createAudioBlockConfig = createBlockConfig(
2224
(_ctx: AudioOptions) =>
2325
({

0 commit comments

Comments
 (0)