Hi!
I am iterating through the syntaxTree and set for every codeblock an attribute codeblockId
. But I also want to retrieve it? Is that even possible? I know that EditorView.dom
returns the DOM but how do I find the current “line” in it?
syntaxTree(view.state).iterate({ from: codeblock.from, to: codeblock.to,
enter(node) {
const line = view.state.doc.lineAt(node.from);
const lineText = view.state.sliceDoc(line.from, line.to);
const lang = searchString(lineText, "```");
// chek if line has attribute codeblockId??
if (node.type.name === "HyperMD-codeblock_HyperMD-codeblock-bg" ) {
decorations.push(Decoration.line({attributes: {class: lineClass, "codeblockId": randomString}}).range(node.from));
lineNumber++;
}
},
});
Thanks!