Add Clear Formatting action to editor context menu

This commit is contained in:
Yuri Karamian
2026-08-08 23:53:27 +02:00
parent 32ef51161d
commit b0555fe648
2 changed files with 91 additions and 0 deletions
+10
View File
@@ -52,6 +52,7 @@
import { calloutGroup, calloutIcon, calloutLabel, CALLOUT_MENU, transformCalloutBlockquotes, serializeCallout } from '$lib/editor/callouts';
import { wrapTextareaSelection } from '$lib/editor/source/selectionPairs';
import { convertListNode, type MixedListName } from '$lib/editor/mixedLists';
import { clearFormatting } from '$lib/editor/clearFormatting';
import { serializeInlineMarkdown } from '$lib/editor/markdown';
import { relativePath } from '$lib/utils/paths';
import GraphView from './GraphView.svelte';
@@ -5079,6 +5080,11 @@
closeTextContextMenu();
}
function ctxClearFormatting() {
if (editor) clearFormatting(editor);
closeTextContextMenu();
}
function ctxCode() {
editor?.chain().focus().toggleCode().run();
closeTextContextMenu();
@@ -7201,6 +7207,10 @@
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 013 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>
Highlight
</button>
<button onclick={ctxClearFormatting}>
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg>
Clear Formatting
</button>
<div class="text-ctx-sep"></div>
<button onclick={ctxLink}>
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71"/></svg>