From a78e21b524bb2973371dffd9e4334dfb81584db9 Mon Sep 17 00:00:00 2001 From: Steffen Becker Date: Wed, 12 Aug 2026 18:09:19 +0200 Subject: [PATCH] feat: paste options on the ribbon's Paste button The big split button already stacked, so the caret only needed a menu: paste, and paste without formatting. Both call the reader the context menu has always used. Word offers a third, Merge Formatting. The engine reads the clipboard as HTML or as text, so there is no third thing to offer. --- src/lib/components/ribbon/tabs/HomeTab.svelte | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/lib/components/ribbon/tabs/HomeTab.svelte b/src/lib/components/ribbon/tabs/HomeTab.svelte index b8ca06d..9e9e9bb 100644 --- a/src/lib/components/ribbon/tabs/HomeTab.svelte +++ b/src/lib/components/ribbon/tabs/HomeTab.svelte @@ -68,6 +68,11 @@ let paraShade = $derived(tick >= 0 && editor ? (uniformBlockAttr(editor.state, 'backgroundColor', null) || null) : null); let lineHeight = $derived(tick >= 0 && editor ? uniformBlockAttr(editor.state, 'lineHeight', '1') : '1'); + function paste(plainOnly: boolean) { + closeMenu(); + if (editor) void readClipboard(editor, plainOnly); + } + // Sub- and superscript are mutually exclusive, so each clears the other. const toggleSuper = () => editor?.chain().focus().unsetSubscript().toggleSuperscript().run(); const toggleSub = () => editor?.chain().focus().unsetSuperscript().toggleSubscript().run(); @@ -149,14 +154,31 @@ - editor && void readClipboard(editor, false)} - /> +
+ paste(false)} + onCaret={() => toggleMenu('paste')} + /> + {#if isMenuOpen('paste')} + + + {/if} +
editor && clipboardCommand(editor, 'cut')} /> editor && clipboardCommand(editor, 'copy')} />