From cff4ff4231dacbc7217ca5f8ffe8db3c0bfaee22 Mon Sep 17 00:00:00 2001 From: Wylie Conlon Date: Thu, 15 Nov 2018 16:04:48 -0500 Subject: [PATCH] CodeMirror documentation differs from types for addLineWidget (#30529) --- types/codemirror/index.d.ts | 5 +++++ types/codemirror/test/index.ts | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/types/codemirror/index.d.ts b/types/codemirror/index.d.ts index 86e9067b3e..cdc3c4cd7c 100644 --- a/types/codemirror/index.d.ts +++ b/types/codemirror/index.d.ts @@ -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. */ diff --git a/types/codemirror/test/index.ts b/types/codemirror/test/index.ts index bd2aefac88..851e891e8f 100644 --- a/types/codemirror/test/index.ts +++ b/types/codemirror/test/index.ts @@ -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();