diff --git a/src/editor-mode/annotations/menuInvokerAnnot.ts b/src/editor-mode/annotations/menuInvokerAnnot.ts deleted file mode 100644 index f25a91d..0000000 --- a/src/editor-mode/annotations/menuInvokerAnnot.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { Annotation } from "@codemirror/state"; -import { TagMenuSpec } from "src/types"; - -export let menuInvokerAnnot = Annotation.define(); \ No newline at end of file diff --git a/src/editor-mode/view-plugin/EditorPlugin.ts b/src/editor-mode/view-plugin/EditorPlugin.ts index 3c8cfea..38d9901 100644 --- a/src/editor-mode/view-plugin/EditorPlugin.ts +++ b/src/editor-mode/view-plugin/EditorPlugin.ts @@ -3,17 +3,16 @@ import { DecorationBuilder } from "src/editor-mode/decorator/builder"; import { builderField } from "src/editor-mode/state-fields"; import { pluginFacet } from "src/editor-mode/facets"; import ExtendedMarkdownSyntax from "main"; -import { menuInvokerAnnot } from "src/editor-mode/annotations"; -import { IndexCache, TagMenuSpec } from "src/types"; -import { ColorMenu } from "src/editor-mode/ui-components"; -import { Format } from "src/enums"; +import { IndexCache } from "src/types"; export class EditorPlugin implements PluginValue { builder: DecorationBuilder; mainPlugin: ExtendedMarkdownSyntax; root: DocumentOrShadowRoot; - indexCache: Record<"colorMenuItem", IndexCache> = { - colorMenuItem: { number: 0 } + indexCache: Record<"colorMenuItem" | "spanTagMenuItem" | "divTagMenuItem", IndexCache> = { + colorMenuItem: { number: 0 }, + spanTagMenuItem: { number: 0 }, + divTagMenuItem: { number: 0 } } constructor(view: EditorView) { let state = view.state; @@ -27,13 +26,6 @@ export class EditorPlugin implements PluginValue { this.onRootChanged(update.view.root); } this.builder.onViewUpdate(update); - let colorMenuSpec: undefined | TagMenuSpec; - update.transactions.find(tr => colorMenuSpec = tr.annotation(menuInvokerAnnot)); - if (colorMenuSpec && colorMenuSpec.type == Format.HIGHLIGHT && !colorMenuSpec.accessed) { - let showAtPos = update.state.selection.main.to; - colorMenuSpec.accessed = true; - this.invokeColorMenu(colorMenuSpec, update.view, showAtPos); - } } destroy(): void { this.mainPlugin.colorsHandler.abandon(this.root); @@ -46,8 +38,4 @@ export class EditorPlugin implements PluginValue { this.mainPlugin.opacityHandler.adopt(newRoot); this.root = newRoot; } - invokeColorMenu(spec: TagMenuSpec, view: EditorView, showAtPos?: number) { - let menu = ColorMenu.create(view, spec.openRange, spec.tagRange, spec.closeRange, spec.moveCursorAfterTag, this.indexCache.colorMenuItem); - menu.showMenu(showAtPos); - } } \ No newline at end of file