CodeMirror documentation differs from types for addLineWidget (#30529)

This commit is contained in:
Wylie Conlon 2018-11-15 16:04:48 -05:00 committed by Pranav Senthilnathan
parent 615629e8f9
commit cff4ff4231
2 changed files with 14 additions and 0 deletions

View File

@ -670,6 +670,11 @@ declare namespace CodeMirror {
/** Returns an array containing all marked ranges in the document. */
getAllMarks(): CodeMirror.TextMarker[];
/** Adds a line widget, an element shown below a line, spanning the whole of the editor's width, and moving the lines below it downwards.
line should be either an integer or a line handle, and node should be a DOM node, which will be displayed below the given line.
options, when given, should be an object that configures the behavior of the widget.
Note that the widget node will become a descendant of nodes with CodeMirror-specific CSS classes, and those classes might in some cases affect it. */
addLineWidget(line: any, node: HTMLElement, options?: CodeMirror.LineWidgetOptions): CodeMirror.LineWidget;
/** Gets the mode object for the editor. Note that this is distinct from getOption("mode"), which gives you the mode specification,
rather than the resolved, instantiated mode object. */

View File

@ -91,3 +91,12 @@ CodeMirror.registerHelper("lint", "javascript", {});
myCodeMirror.isReadOnly();
myCodeMirror.execCommand('selectAll');
let htmlElement1 = document.createElement('div');
let htmlElement2 = document.createElement('div');
let widget1 = myCodeMirror.addLineWidget(1, htmlElement1, {});
let widget2 = doc.addLineWidget(1, htmlElement2, {});
widget1.clear();
widget2.clear();
htmlElement1.remove();
htmlElement2.remove();