diff --git a/web/cm_plugins/editor_paste.ts b/web/cm_plugins/editor_paste.ts index 09cb2684..0bd15fd9 100644 --- a/web/cm_plugins/editor_paste.ts +++ b/web/cm_plugins/editor_paste.ts @@ -73,10 +73,23 @@ export const pasteLinkExtension = ViewPlugin.fromClass( ); export function attachmentExtension(editor: Editor) { + let shiftDown = false; return EditorView.domEventHandlers({ dragover: (event) => { event.preventDefault(); }, + keydown: (event) => { + if (event.key === "Shift") { + shiftDown = true; + } + return false; + }, + keyup: (event) => { + if (event.key === "Shift") { + shiftDown = false; + } + return false; + }, drop: (event: DragEvent) => { // TODO: This doesn't take into account the target cursor position, // it just drops the attachment wherever the cursor was last. @@ -93,12 +106,12 @@ export function attachmentExtension(editor: Editor) { paste: (event: ClipboardEvent) => { const payload = [...event.clipboardData!.items]; const richText = event.clipboardData?.getData("text/html"); - if (richText) { + // Only do rich text paste if shift is NOT down + if (richText && !shiftDown) { const markdown = striptHtmlComments(turndownService.turndown(richText)) .trim(); const view = editor.editorView!; const selection = view.state.selection.main; - console.log("Rich text", markdown); view.dispatch({ changes: [ { diff --git a/website/CHANGELOG.md b/website/CHANGELOG.md index f600bd38..d17bef11 100644 --- a/website/CHANGELOG.md +++ b/website/CHANGELOG.md @@ -6,6 +6,7 @@ release. ## 0.2.1 * New `Plugs: Add` command +* When holding `Shift` while pasting, rich test paste will be disabled. ## 0.2.0 * The editor is now in "live preview" mode where a lot of markdown is hidden unless the cursor is present. This will take some getting used to, but results in a much more distraction free look.