Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: move vscode specific clipboard code to plugin

thecodrr56b80b3089f2
diff --git a/apps/web/package.json b/apps/web/package.json
index 7ee4611f4..86a358f3c 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -29,6 +29,7 @@
"file-saver": "^2.0.5",
"framer-motion": "^4.1.17",
"hash-wasm": "^4.9.0",
+ "highlight.js": "^11.5.0",
"hotkeys-js": "^3.8.3",
"immer": "^9.0.6",
"just-debounce-it": "^3.0.1",
diff --git a/apps/web/src/components/editor/tinymce.js b/apps/web/src/components/editor/tinymce.js
index eef678510..bcddd83c1 100644
--- a/apps/web/src/components/editor/tinymce.js
+++ b/apps/web/src/components/editor/tinymce.js
@@ -296,7 +296,6 @@ function TinyMCE(props) {
* @param {ClipboardEvent} e
*/
async function onPaste(e) {
- if (handlePasteFromVSCode(e)) return;
if (e.clipboardData?.items?.length) {
for (let item of e.clipboardData.items) {
const file = item.getAsFile();
@@ -307,30 +306,6 @@ function TinyMCE(props) {
}
}
- /**
- *
- * @param {ClipboardEvent} e
- */
- function handlePasteFromVSCode(e) {
- let vscodeEditorData =
- e.clipboardData.getData("vscode-editor-data");
- if (!!vscodeEditorData?.trim()) {
- const { mode } = JSON.parse(vscodeEditorData);
- if (mode) {
- e.preventDefault();
-
- const code = e.clipboardData.getData("text/plain");
- editor.execCommand("mceInsertCodeblock", false, {
- code,
- language: mode,
- });
-
- return true;
- }
- }
- return false;
- }
-
editor.on("ScrollIntoView", onScrollIntoView);
editor.on("tap", onTap);
editor.on(changeEvents, onEditorChange);
@@ -349,9 +324,11 @@ function TinyMCE(props) {
browser_spellcheck: true,
inline: true,
fixed_toolbar_container: "#editorToolbar",
- paste_postprocess: function (_, args) {
+ paste_postprocess: async function (_, args) {
const { node } = args;
- processPastedContent(node);
+ const editor = tinymceRef.current.editor || args.target;
+ if (!editor || !editor.dom) return;
+ processPastedContent(editor, node);
},
invalid_styles: {
span: "--progress",