Skip to content

Commit 6b36b97

Browse files
committed
Merge branch 'main' into new-releases
2 parents 2265d90 + bda6f30 commit 6b36b97

File tree

43 files changed

+871
-156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+871
-156
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages/*/types
77
examples/*/types
88
/.pnp
99
.pnp.js
10-
10+
tsconfig.tsbuildinfo
1111
# testing
1212
coverage
1313

examples/editor/tsconfig.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
"resolveJsonModule": true,
1515
"isolatedModules": true,
1616
"noEmit": true,
17-
"jsx": "react-jsx"
18-
// "paths": {
19-
// "@blocknote/core": ["../../packages/core/src"]
20-
// }
17+
"jsx": "react-jsx",
18+
"composite": true
2119
},
2220
"include": ["src"],
2321
"references": [
24-
{ "path": "./tsconfig.node.json" }
25-
// { "path": "../../packages/core/tsconfig.json" }
22+
{ "path": "./tsconfig.node.json" },
23+
{ "path": "../../packages/core/" },
24+
{ "path": "../../packages/react/" }
2625
]
2726
}

examples/vanilla/src/ui/blockSideMenuFactory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ export const blockSideMenuFactory: BlockSideMenuFactory<DefaultBlockSchema> = (
3737
container.style.display = "block";
3838
}
3939

40-
container.style.top = params.referenceRect.y + "px";
40+
container.style.top = staticParams.getReferenceRect()!.y + "px";
4141
container.style.left =
42-
params.referenceRect.x - container.offsetWidth + "px";
42+
staticParams.getReferenceRect()!.x - container.offsetWidth + "px";
4343
},
4444
hide: () => {
4545
container.style.display = "none";

examples/vanilla/src/ui/formattingToolbarFactory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ export const formattingToolbarFactory: FormattingToolbarFactory<
3838
"bold" in staticParams.editor.getActiveStyles()
3939
? "unset bold"
4040
: "set bold";
41-
container.style.top = params.referenceRect.y + "px";
42-
container.style.left = params.referenceRect.x + "px";
41+
container.style.top = staticParams.getReferenceRect()!.y + "px";
42+
container.style.left = staticParams.getReferenceRect()!.x + "px";
4343
},
4444
hide: () => {
4545
container.style.display = "none";

examples/vanilla/src/ui/hyperlinkToolbarFactory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export const hyperlinkToolbarFactory: HyperlinkToolbarFactory = (
4343
container.style.display = "block";
4444
}
4545

46-
container.style.top = params.referenceRect.y + "px";
47-
container.style.left = params.referenceRect.x + "px";
46+
container.style.top = staticParams.getReferenceRect()!.y + "px";
47+
container.style.left = staticParams.getReferenceRect()!.x + "px";
4848
},
4949
hide: () => {
5050
container.style.display = "none";

examples/vanilla/src/ui/slashMenuFactory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ export const slashMenuFactory: SuggestionsMenuFactory<
5353
container.style.display = "block";
5454
}
5555

56-
container.style.top = params.referenceRect.y + "px";
57-
container.style.left = params.referenceRect.x + "px";
56+
container.style.top = staticParams.getReferenceRect()!.y + "px";
57+
container.style.left = staticParams.getReferenceRect()!.x + "px";
5858
},
5959
hide: () => {
6060
container.style.display = "none";

examples/vanilla/tsconfig.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414
"resolveJsonModule": true,
1515
"isolatedModules": true,
1616
"noEmit": true,
17-
"jsx": "react-jsx"
17+
"jsx": "react-jsx",
18+
"composite": true
1819
// "paths": {
1920
// "@blocknote/core": ["../../packages/core/src"]
2021
// }
2122
},
2223
"include": ["src"],
2324
"references": [
24-
{ "path": "./tsconfig.node.json" }
25-
// { "path": "../../packages/core/tsconfig.json" }
25+
{ "path": "./tsconfig.node.json" },
26+
{ "path": "../../packages/core/" },
27+
{ "path": "../../packages/react/" }
2628
]
2729
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"scripts": {
1717
"start": "lerna run --stream --scope @blocknote/example-editor dev",
1818
"start:built": "npx serve examples/editor/dist",
19-
"test:updateSnaps": "docker run --rm -e RUN_IN_DOCKER=true --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.33.0-focal npx playwright test -u",
19+
"test:updateSnaps": "docker run --rm -e RUN_IN_DOCKER=true --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.35.1-focal npx playwright test -u",
2020
"build": "lerna run --stream build --concurrency 1",
2121
"build:site": "lerna run --stream docs:build --concurrency 1",
2222
"lint": "lerna run --stream lint",
@@ -29,7 +29,7 @@
2929
"prepublishOnly": "npm run build && cp README.md packages/core/README.md && cp README.md packages/react/README.md",
3030
"postpublish": "rm -rf packages/core/README.md && rm -rf packages/react/README.md",
3131
"test-ct": "playwright test -c playwright-ct.config.ts --headed",
32-
"test-ct:updateSnaps": "docker run --rm -e RUN_IN_DOCKER=true --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.33.0-focal npm install && playwright test -c playwright-ct.config.ts -u"
32+
"test-ct:updateSnaps": "docker run --rm -e RUN_IN_DOCKER=true --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.35.1-focal npm install && playwright test -c playwright-ct.config.ts -u"
3333
},
3434
"overrides": {
3535
"react": "18.2.0",

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"build-bundled": "tsc && vite build --config vite.config.bundled.ts && git checkout tmp-releases && rm -rf ../../release && mv ../../release-tmp ../../release",
4646
"preview": "vite preview",
4747
"lint": "eslint src --max-warnings 0",
48-
"test": "vitest",
48+
"test": "vitest --run",
4949
"test-watch": "vitest watch"
5050
},
5151
"dependencies": {

packages/core/src/BlockNoteEditor.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema> {
149149
public readonly _tiptapEditor: TiptapEditor & { contentComponent: any };
150150
public blockCache = new WeakMap<Node, Block<BSchema>>();
151151
public readonly schema: BSchema;
152+
private ready = false;
152153

153154
public get domElement() {
154155
return this._tiptapEditor.view.dom as HTMLDivElement;
@@ -204,11 +205,24 @@ export class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema> {
204205
newOptions.onEditorReady?.(this);
205206
newOptions.initialContent &&
206207
this.replaceBlocks(this.topLevelBlocks, newOptions.initialContent);
208+
this.ready = true;
207209
},
208210
onUpdate: () => {
211+
// This seems to be necessary due to a bug in TipTap:
212+
// https://github.com/ueberdosis/tiptap/issues/2583
213+
if (!this.ready) {
214+
return;
215+
}
216+
209217
newOptions.onEditorContentChange?.(this);
210218
},
211219
onSelectionUpdate: () => {
220+
// This seems to be necessary due to a bug in TipTap:
221+
// https://github.com/ueberdosis/tiptap/issues/2583
222+
if (!this.ready) {
223+
return;
224+
}
225+
212226
newOptions.onTextCursorPositionChange?.(this);
213227
},
214228
editable: options.editable === undefined ? true : options.editable,

0 commit comments

Comments
 (0)