diff --git a/plugs/core/navigate.ts b/plugs/core/navigate.ts index a3632b59..644419e7 100644 --- a/plugs/core/navigate.ts +++ b/plugs/core/navigate.ts @@ -46,9 +46,8 @@ async function actionClickOrActionEnter( await editor.openUrl(url); break; } - case "CommandLink": { - const command = mdTree.children![1].text!; - console.log("Got command link", command); + case "CommandLinkName": { + const command = mdTree.children![0].text!; await system.invokeCommand(command); break; } diff --git a/web/clean_mode.ts b/web/clean_mode.ts deleted file mode 100644 index 8d2d7847..00000000 --- a/web/clean_mode.ts +++ /dev/null @@ -1,635 +0,0 @@ -import { - ChangeSpec, - Decoration, - DecorationSet, - EditorState, - EditorView, - foldedRanges, - NodeType, - SyntaxNodeRef, - syntaxTree, - ViewPlugin, - ViewUpdate, - WidgetType, -} from "./deps.ts"; - -function getLinkAnchor(view: EditorView) { - const widgets: any[] = []; - - for (const { from, to } of view.visibleRanges) { - syntaxTree(view.state).iterate({ - from, - to, - enter: ({ type, from, to, node }) => { - if (type.name !== "URL") return; - const parent = node.parent; - const blackListedParents = ["Image"]; - if (parent && !blackListedParents.includes(parent.name)) { - const marks = parent.getChildren("LinkMark"); - const ranges = view.state.selection.ranges; - const cursorOverlaps = ranges.some(({ from, to }) => - checkRangeOverlap([from, to], [parent.from, parent.to]) - ); - if (!cursorOverlaps) { - widgets.push( - ...marks.map(({ from, to }) => - invisibleDecoration.range(from, to) - ), - invisibleDecoration.range(from, to), - ); - } - } - }, - }); - } - - return Decoration.set(widgets, true); -} - -export const goToLinkPlugin = ViewPlugin.fromClass( - class { - decorations: DecorationSet = Decoration.none; - constructor(view: EditorView) { - this.decorations = getLinkAnchor(view); - } - update(update: ViewUpdate) { - if ( - update.docChanged || - update.viewportChanged || - update.selectionSet - ) { - this.decorations = getLinkAnchor(update.view); - } - } - }, - { decorations: (v) => v.decorations }, -); - -class StartDirectiveWidget extends WidgetType { - constructor() { - super(); - } - toDOM(): HTMLElement { - const queryEl = document.createElement("div"); - queryEl.textContent = "start"; - queryEl.className = "sb-directive-start"; - console.log("Got dom", queryEl); - return queryEl; - } -} - -function getDirectives(view: EditorView) { - const widgets: any[] = []; - - for (const { from, to } of view.visibleRanges) { - syntaxTree(view.state).iterate({ - from, - to, - enter: ({ type, from, to }) => { - if (type.name !== "CommentBlock") { - return; - } - const text = view.state.sliceDoc(from, to); - if (/