Add data to line element #4057
Answered
by
raphaelbastide
raphaelbastide
asked this question in
Q&A
-
What would be the best way to add data to a line element? Here is what I want to achieve: add a <div style="top:338px;height:26px;" class="view-line" data-id="11" data-line="3">
<span>
<span class="mtk1"> </span><span class="mtk3">- id: 11</span>
</span>
</div> So far, my code only adds a class. editor.getModel().onDidChangeContent(function (event) {
const model = editor.getModel();
const lines = model.getLinesContent();
lines.forEach((lineContent,lineNumber) => {
const range = new monaco.Range(lineNumber + 1, 1, lineNumber + 1, 1);
editor.createDecorationsCollection([{
range: range,
options: {
isWholeLine: true,
className: "line-test",
}
},
]);
});
}); |
Beta Was this translation helpful? Give feedback.
Answered by
raphaelbastide
Jul 19, 2023
Replies: 2 comments 1 reply
-
I doubt this is possible without forking the monaco-editor (vscode). |
Beta Was this translation helpful? Give feedback.
1 reply
-
For the record I ended up hacking classNames to store my data. Imperfect but works. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
hediet
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For the record I ended up hacking classNames to store my data. Imperfect but works.