Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append the tooltip to the wrapper element #6135

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion addon/lint/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
var tt = document.createElement("div");
tt.className = "CodeMirror-lint-tooltip cm-s-" + cm.options.theme;
tt.appendChild(content.cloneNode(true));
document.body.appendChild(tt);
if(cm.options.lint.selfContain)
cm.getWrapperElement().appendChild(tt);
else
document.body.appendChild(tt);

function position(e) {
if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position);
Expand Down
4 changes: 3 additions & 1 deletion demo/lint.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ <h2>Linter Demo</h2>
lineNumbers: true,
mode: "javascript",
gutters: ["CodeMirror-lint-markers"],
lint: true
lint: {
selfContain: true
}
});

var editor_json = CodeMirror.fromTextArea(document.getElementById("code-json"), {
Expand Down
1 change: 1 addition & 0 deletions doc/manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -2911,6 +2911,7 @@ <h2 id="addons">Addons</h2>
will only be executed when the promise resolves.
By default, the linter will run (debounced) whenever the document is changed.
You can pass a <code>lintOnChange: false</code> option to disable that.
You can pass a <code>selfContain: true</code> option to render the tooltip inside the editor instance.
Depends on <code>addon/lint/lint.css</code>. A demo can be
found <a href="../demo/lint.html">here</a>.</dd>

Expand Down