Skip to content

Commit d0d27df

Browse files
committed
Merge branch 'refs/heads/main' into releases
# Conflicts: # package-lock.json # packages/server-util/package.json
2 parents 0e7f52f + 6011aa9 commit d0d27df

File tree

102 files changed

+981
-669
lines changed

Some content is hidden

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

102 files changed

+981
-669
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
retention-days: 30
7979

8080
- name: Upload webpack stats artifact (editor)
81-
uses: relative-ci/agent-upload-artifact-action@v1
81+
uses: relative-ci/agent-upload-artifact-action@v2
8282
with:
8383
webpackStatsFile: ./playground/dist/webpack-stats.json
8484
artifactName: relative-ci-artifacts-editor

docs/pages/docs/editor-api/manipulating-blocks.mdx

Lines changed: 1 addition & 1 deletion

docs/pages/docs/editor-basics/setup.mdx

Lines changed: 6 additions & 3 deletions

examples/01-basic/01-minimal/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import "@blocknote/core/fonts/inter.css";
2-
import { useCreateBlockNote } from "@blocknote/react";
32
import { BlockNoteView } from "@blocknote/mantine";
43
import "@blocknote/mantine/style.css";
4+
import { useCreateBlockNote } from "@blocknote/react";
55

66
export default function App() {
77
// Creates a new editor instance.

package-lock.json

Lines changed: 180 additions & 179 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@
3434
"postpublish": "rm -rf packages/core/README.md && rm -rf packages/react/README.md",
3535
"clean": "lerna run --stream clean"
3636
}
37-
}
37+
}

packages/core/package.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,26 @@
5555
},
5656
"dependencies": {
5757
"@emoji-mart/data": "^1.2.1",
58-
"@tiptap/core": "^2.5.0",
59-
"@tiptap/extension-bold": "^2.5.0",
60-
"@tiptap/extension-code": "^2.5.0",
61-
"@tiptap/extension-collaboration": "^2.5.0",
62-
"@tiptap/extension-collaboration-cursor": "^2.5.0",
63-
"@tiptap/extension-dropcursor": "^2.5.0",
64-
"@tiptap/extension-gapcursor": "^2.5.0",
65-
"@tiptap/extension-hard-break": "^2.5.0",
66-
"@tiptap/extension-history": "^2.5.0",
67-
"@tiptap/extension-horizontal-rule": "^2.5.0",
68-
"@tiptap/extension-italic": "^2.5.0",
69-
"@tiptap/extension-link": "^2.5.0",
70-
"@tiptap/extension-paragraph": "^2.5.0",
71-
"@tiptap/extension-strike": "^2.5.0",
72-
"@tiptap/extension-table-cell": "^2.5.0",
73-
"@tiptap/extension-table-header": "^2.5.0",
74-
"@tiptap/extension-table-row": "^2.5.0",
75-
"@tiptap/extension-text": "^2.5.0",
76-
"@tiptap/extension-underline": "^2.5.0",
77-
"@tiptap/pm": "^2.5.0",
58+
"@tiptap/core": "^2.7.1",
59+
"@tiptap/extension-bold": "^2.7.1",
60+
"@tiptap/extension-code": "^2.7.1",
61+
"@tiptap/extension-collaboration": "^2.7.1",
62+
"@tiptap/extension-collaboration-cursor": "^2.7.1",
63+
"@tiptap/extension-dropcursor": "^2.7.1",
64+
"@tiptap/extension-gapcursor": "^2.7.1",
65+
"@tiptap/extension-hard-break": "^2.7.1",
66+
"@tiptap/extension-history": "^2.7.1",
67+
"@tiptap/extension-horizontal-rule": "^2.7.1",
68+
"@tiptap/extension-italic": "^2.7.1",
69+
"@tiptap/extension-link": "^2.7.1",
70+
"@tiptap/extension-paragraph": "^2.7.1",
71+
"@tiptap/extension-strike": "^2.7.1",
72+
"@tiptap/extension-table-cell": "^2.7.1",
73+
"@tiptap/extension-table-header": "^2.7.1",
74+
"@tiptap/extension-table-row": "^2.7.1",
75+
"@tiptap/extension-text": "^2.7.1",
76+
"@tiptap/extension-underline": "^2.7.1",
77+
"@tiptap/pm": "^2.7.1",
7878
"emoji-mart": "^5.6.0",
7979
"hast-util-from-dom": "^4.2.0",
8080
"prosemirror-model": "^1.21.0",
@@ -92,7 +92,7 @@
9292
"remark-stringify": "^10.0.2",
9393
"unified": "^10.1.2",
9494
"uuid": "^8.3.2",
95-
"y-prosemirror": "1.2.9",
95+
"y-prosemirror": "1.2.12",
9696
"y-protocols": "^1.0.6",
9797
"yjs": "^13.6.15"
9898
},

packages/core/src/api/exporters/copyExtension.ts

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async function selectedFragmentToHTML<
2424
}> {
2525
const selectedFragment = view.state.selection.content().content;
2626

27-
const internalHTMLSerializer = await createInternalHTMLSerializer(
27+
const internalHTMLSerializer = createInternalHTMLSerializer(
2828
view.state.schema,
2929
editor
3030
);
@@ -48,6 +48,46 @@ async function selectedFragmentToHTML<
4848
return { internalHTML, externalHTML, plainText };
4949
}
5050

51+
const copyToClipboard = <
52+
BSchema extends BlockSchema,
53+
I extends InlineContentSchema,
54+
S extends StyleSchema
55+
>(
56+
editor: BlockNoteEditor<BSchema, I, S>,
57+
view: EditorView,
58+
event: ClipboardEvent
59+
) => {
60+
// Stops the default browser copy behaviour.
61+
event.preventDefault();
62+
event.clipboardData!.clearData();
63+
64+
// Checks if a `blockContent` node is being copied and expands
65+
// the selection to the parent `blockContainer` node. This is
66+
// for the use-case in which only a block without content is
67+
// selected, e.g. an image block.
68+
if (
69+
"node" in view.state.selection &&
70+
(view.state.selection.node as Node).type.spec.group === "blockContent"
71+
) {
72+
editor.dispatch(
73+
editor._tiptapEditor.state.tr.setSelection(
74+
new NodeSelection(view.state.doc.resolve(view.state.selection.from - 1))
75+
)
76+
);
77+
}
78+
79+
(async () => {
80+
const { internalHTML, externalHTML, plainText } =
81+
await selectedFragmentToHTML(view, editor);
82+
83+
// TODO: Writing to other MIME types not working in Safari for
84+
// some reason.
85+
event.clipboardData!.setData("blocknote/html", internalHTML);
86+
event.clipboardData!.setData("text/html", externalHTML);
87+
event.clipboardData!.setData("text/plain", plainText);
88+
})();
89+
};
90+
5191
export const createCopyToClipboardExtension = <
5292
BSchema extends BlockSchema,
5393
I extends InlineContentSchema,
@@ -63,38 +103,13 @@ export const createCopyToClipboardExtension = <
63103
props: {
64104
handleDOMEvents: {
65105
copy(view, event) {
66-
// Stops the default browser copy behaviour.
67-
event.preventDefault();
68-
event.clipboardData!.clearData();
69-
70-
// Checks if a `blockContent` node is being copied and expands
71-
// the selection to the parent `blockContainer` node. This is
72-
// for the use-case in which only a block without content is
73-
// selected, e.g. an image block.
74-
if (
75-
"node" in view.state.selection &&
76-
(view.state.selection.node as Node).type.spec.group ===
77-
"blockContent"
78-
) {
79-
editor.dispatch(
80-
editor._tiptapEditor.state.tr.setSelection(
81-
new NodeSelection(
82-
view.state.doc.resolve(view.state.selection.from - 1)
83-
)
84-
)
85-
);
86-
}
87-
88-
(async () => {
89-
const { internalHTML, externalHTML, plainText } =
90-
await selectedFragmentToHTML(view, editor);
91-
92-
// TODO: Writing to other MIME types not working in Safari for
93-
// some reason.
94-
event.clipboardData!.setData("blocknote/html", internalHTML);
95-
event.clipboardData!.setData("text/html", externalHTML);
96-
event.clipboardData!.setData("text/plain", plainText);
97-
})();
106+
copyToClipboard(editor, view, event);
107+
// Prevent default PM handler to be called
108+
return true;
109+
},
110+
cut(view, event) {
111+
copyToClipboard(editor, view, event);
112+
view.dispatch(view.state.tr.deleteSelection());
98113
// Prevent default PM handler to be called
99114
return true;
100115
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<h2 class="bn-inline-content"><strong><u>Heading </u></strong><em><s>2</s></em></h2><p class="bn-inline-content">Paragraph</p><ul><li><p class="bn-inline-content"></p></li></ul>
1+
<h2 data-text-color="yellow" data-background-color="blue" data-text-alignment="right" data-level="2"><strong><u>Heading </u></strong><em><s>2</s></em></h2><p data-background-color="red">Paragraph</p><ul><li><p class="bn-inline-content"></p></li></ul>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<p class="custom-paragraph">Hello World</p>
1+
<p class="custom-paragraph" data-text-color="orange" data-background-color="pink" data-text-alignment="center">Hello World</p>

0 commit comments

Comments
 (0)