@jupyterlab/codemirror 0.17.3 → 0.18.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/editor.d.ts CHANGED
@@ -183,6 +183,17 @@ export declare class CodeMirrorEditor implements CodeEditor.IEditor {
183
183
  * Passing an empty array resets a cursor position to the start of a document.
184
184
  */
185
185
  setSelections(selections: CodeEditor.IRange[]): void;
186
+ /**
187
+ * Get a list of tokens for the current editor text content.
188
+ */
189
+ getTokens(): CodeEditor.IToken[];
190
+ /**
191
+ * Get the token at a given editor position.
192
+ */
193
+ getTokenForPosition(position: CodeEditor.IPosition): CodeEditor.IToken;
194
+ /**
195
+ * Insert a new indented line at the current cursor position.
196
+ */
186
197
  newIndentedLine(): void;
187
198
  /**
188
199
  * Execute a codemirror command on the editor.
package/lib/editor.js CHANGED
@@ -420,6 +420,36 @@ class CodeMirrorEditor {
420
420
  const cmSelections = this._toCodeMirrorSelections(selections);
421
421
  this.doc.setSelections(cmSelections, 0);
422
422
  }
423
+ /**
424
+ * Get a list of tokens for the current editor text content.
425
+ */
426
+ getTokens() {
427
+ let tokens = [];
428
+ for (let i = 0; i < this.lineCount; ++i) {
429
+ const lineTokens = this.editor.getLineTokens(i).map(t => ({
430
+ offset: this.getOffsetAt({ column: t.start, line: i }),
431
+ value: t.string,
432
+ type: t.type || ''
433
+ }));
434
+ tokens = tokens.concat(lineTokens);
435
+ }
436
+ return tokens;
437
+ }
438
+ /**
439
+ * Get the token at a given editor position.
440
+ */
441
+ getTokenForPosition(position) {
442
+ const cursor = this._toCodeMirrorPosition(position);
443
+ const token = this.editor.getTokenAt(cursor);
444
+ return {
445
+ offset: this.getOffsetAt({ column: token.start, line: cursor.line }),
446
+ value: token.string,
447
+ type: token.type
448
+ };
449
+ }
450
+ /**
451
+ * Insert a new indented line at the current cursor position.
452
+ */
423
453
  newIndentedLine() {
424
454
  this.execCommand('newlineAndIndent');
425
455
  }
package/lib/editor.js.map CHANG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AAS,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,CAAC;gBAC3C,MAAM;YACR,KAAK,qBAAqB;gBACxB,MAAM,CAAC,SAAS,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;gBAC7C,MAAM;YACR,KAAK,UAAU;gBACb,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;gBAC5C,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;gBAChC,MAAM;YACR,KAAK,YAAY;gBACf,EAAE,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;gBAC5B,MAAM;YACR,KAAK,UAAU;gBACb,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;gBAChD,MAAM;YACR,KAAK,YAAY;gBACf,EAAE,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;gBACtD,MAAM;YACR;gBACE,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;gBAChC,MAAM;SACT;IACH,CAAC;IArDe,iBAAS,YAqDxB,CAAA;AACH,CAAC,EAhLS,OAAO,KAAP,OAAO,QAgLhB;AAED;;;GAGG;AACH,gBAAgB,CAAC,UAAU,CACzB,uBAAuB,EACvB,OAAO,CAAC,qBAAqB,CAC9B,CAAC;AAEF;;GAEG;AACH,gBAAgB,CAAC,UAAU,CACzB,uBAAuB,EACvB,OAAO,CAAC,qBAAqB,CAC9B,CAAC","sourcesContent":["// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n\nimport CodeMirror from 'codemirror';\n\nimport { JSONExt } from '@phosphor/coreutils';\n\nimport { ArrayExt } from '@phosphor/algorithm';\n\nimport { IDisposable, DisposableDelegate } from '@phosphor/disposable';\n\nimport { Signal } from '@phosphor/signaling';\n\nimport { showDialog } from '@jupyterlab/apputils';\n\nimport { CodeEditor } from '@jupyterlab/codeeditor';\n\nimport { UUID } from '@phosphor/coreutils';\n\nimport {\n IObservableMap,\n IObservableString,\n ICollaborator\n} from '@jupyterlab/observables';\n\nimport { Mode } from './mode';\n\nimport 'codemirror/addon/comment/comment.js';\nimport 'codemirror/addon/edit/matchbrackets.js';\nimport 'codemirror/addon/edit/closebrackets.js';\nimport 'codemirror/addon/scroll/scrollpastend.js';\nimport 'codemirror/addon/search/searchcursor';\nimport 'codemirror/addon/search/search';\nimport 'codemirror/keymap/emacs.js';\nimport 'codemirror/keymap/sublime.js';\nimport 'codemirror/keymap/vim.js';\n\n/**\n * The class name added to CodeMirrorWidget instances.\n */\nconst EDITOR_CLASS = 'jp-CodeMirrorEditor';\n\n/**\n * The class name added to read only cell editor widgets.\n */\nconst READ_ONLY_CLASS = 'jp-mod-readOnly';\n\n/**\n * The class name for the hover box for collaborator cursors.\n */\nconst COLLABORATOR_CURSOR_CLASS = 'jp-CollaboratorCursor';\n\n/**\n * The class name for the hover box for collaborator cursors.\n */\nconst COLLABORATOR_HOVER_CLASS = 'jp-CollaboratorCursor-hover';\n\n/**\n * The key code for the up arrow key.\n */\nconst UP_ARROW = 38;\n\n/**\n * The key code for the down arrow key.\n */\nconst DOWN_ARROW = 40;\n\n/**\n * The time that a collaborator name hover persists.\n */\nconst HOVER_TIMEOUT = 1000;\n\n/**\n * CodeMirror editor.\n */\nexport class CodeMirrorEditor implements CodeEditor.IEditor {\n /**\n * Construct a CodeMirror editor.\n */\n constructor(options: CodeMirrorEditor.IOptions) {\n let host = (this.host = options.host);\n host.classList.add(EDITOR_CLASS);\n host.classList.add('jp-Editor');\n host.addEventListener('focus', this, true);\n host.addEventListener('blur', this, true);\n host.addEventListener('scroll', this, true);\n\n this._uuid = options.uuid || UUID.uuid4();\n\n // Handle selection style.\n let style = options.selectionStyle || {};\n this._selectionStyle = {\n ...CodeEditor.defaultSelectionStyle,\n ...(style as CodeEditor.ISelectionStyle)\n };\n\n let model = (this._model = options.model);\n let config = options.config || {};\n let fullConfig = (this._config = {\n ...CodeMirrorEditor.defaultConfig,\n ...config\n });\n let editor = (this._editor = Private.createEditor(host, fullConfig));\n\n let doc = editor.getDoc();\n\n // Handle initial values for text, mimetype, and selections.\n doc.setValue(model.value.text);\n this.clearHistory();\n this._onMimeTypeChanged();\n this._onCursorActivity();\n this._timer = window.setInterval(() => {\n this._checkSync();\n }, 3000);\n\n // Connect to changes.\n model.value.changed.connect(this._onValueChanged, this);\n model.mimeTypeChanged.connect(this._onMimeTypeChanged, this);\n model.selections.changed.connect(this._onSelectionsChanged, this);\n\n CodeMirror.on(editor, 'keydown', (editor, event) => {\n let index = ArrayExt.findFirstIndex(this._keydownHandlers, handler => {\n if (handler(this, event) === true) {\n event.preventDefault();\n return true;\n }\n return false;\n });\n if (index === -1) {\n this.onKeydown(event);\n }\n });\n CodeMirror.on(editor, 'cursorActivity', () => this._onCursorActivity());\n CodeMirror.on(editor.getDoc(), 'beforeChange', (instance, change) => {\n this._beforeDocChanged(instance, change);\n });\n CodeMirror.on(editor.getDoc(), 'change', (instance, change) => {\n // Manually refresh after setValue to make sure editor is properly sized.\n if (change.origin === 'setValue' && this.hasFocus()) {\n this.refresh();\n }\n this._lastChange = change;\n });\n\n // Manually refresh on paste to make sure editor is properly sized.\n editor.getWrapperElement().addEventListener('paste', () => {\n if (this.hasFocus()) {\n this.refresh();\n }\n });\n }\n\n /**\n * A signal emitted when either the top or bottom edge is requested.\n */\n readonly edgeRequested = new Signal<this, CodeEditor.EdgeLocation>(this);\n\n /**\n * The DOM node that hosts the editor.\n */\n readonly host: HTMLElement;\n\n /**\n * The uuid of this editor;\n */\n get uuid(): string {\n return this._uuid;\n }\n set uuid(value: string) {\n this._uuid = value;\n }\n\n /**\n * The selection style of this editor.\n */\n get selectionStyle(): CodeEditor.ISelectionStyle {\n return this._selectionStyle;\n }\n set selectionStyle(value: CodeEditor.ISelectionStyle) {\n this._selectionStyle = value;\n }\n\n /**\n * Get the codemirror editor wrapped by the editor.\n */\n get editor(): CodeMirror.Editor {\n return this._editor;\n }\n\n /**\n * Get the codemirror doc wrapped by the widget.\n */\n get doc(): CodeMirror.Doc {\n return this._editor.getDoc();\n }\n\n /**\n * Get the number of lines in the editor.\n */\n get lineCount(): number {\n return this.doc.lineCount();\n }\n\n /**\n * Returns a model for this editor.\n */\n get model(): CodeEditor.IModel {\n return this._model;\n }\n\n /**\n * The height of a line in the editor in pixels.\n */\n get lineHeight(): number {\n return this._editor.defaultTextHeight();\n }\n\n /**\n * The widget of a character in the editor in pixels.\n */\n get charWidth(): number {\n return this._editor.defaultCharWidth();\n }\n\n /**\n * Tests whether the editor is disposed.\n */\n get isDisposed(): boolean {\n return this._isDisposed;\n }\n\n /**\n * Dispose of the resources held by the widget.\n */\n dispose(): void {\n if (this.isDisposed) {\n return;\n }\n this._isDisposed = true;\n this.host.removeEventListener('focus', this, true);\n this.host.removeEventListener('blur', this, true);\n this.host.removeEventListener('scroll', this, true);\n this._keydownHandlers.length = 0;\n window.clearInterval(this._timer);\n Signal.clearData(this);\n }\n\n /**\n * Get a config option for the editor.\n */\n getOption<K extends keyof CodeMirrorEditor.IConfig>(\n option: K\n ): CodeMirrorEditor.IConfig[K] {\n return this._config[option];\n }\n\n /**\n * Set a config option for the editor.\n */\n setOption<K extends keyof CodeMirrorEditor.IConfig>(\n option: K,\n value: CodeMirrorEditor.IConfig[K]\n ): void {\n // Don't bother setting the option if it is already the same.\n if (this._config[option] !== value) {\n this._config[option] = value;\n Private.setOption(this.editor, option, value, this._config);\n }\n }\n\n /**\n * Returns the content for the given line number.\n */\n getLine(line: number): string | undefined {\n return this.doc.getLine(line);\n }\n\n /**\n * Find an offset for the given position.\n */\n getOffsetAt(position: CodeEditor.IPosition): number {\n return this.doc.indexFromPos({\n ch: position.column,\n line: position.line\n });\n }\n\n /**\n * Find a position for the given offset.\n */\n getPositionAt(offset: number): CodeEditor.IPosition {\n const { ch, line } = this.doc.posFromIndex(offset);\n return { line, column: ch };\n }\n\n /**\n * Undo one edit (if any undo events are stored).\n */\n undo(): void {\n this.doc.undo();\n }\n\n /**\n * Redo one undone edit.\n */\n redo(): void {\n this.doc.redo();\n }\n\n /**\n * Clear the undo history.\n */\n clearHistory(): void {\n this.doc.clearHistory();\n }\n\n /**\n * Brings browser focus to this editor text.\n */\n focus(): void {\n this._editor.focus();\n }\n\n /**\n * Test whether the editor has keyboard focus.\n */\n hasFocus(): boolean {\n return this._editor.getWrapperElement().contains(document.activeElement);\n }\n\n /**\n * Explicitly blur the editor.\n */\n blur(): void {\n this._editor.getInputField().blur();\n }\n\n /**\n * Repaint editor.\n */\n refresh(): void {\n this._editor.refresh();\n this._needsRefresh = false;\n }\n\n /**\n * Refresh the editor if it is focused;\n * otherwise postpone refreshing till focusing.\n */\n resizeToFit(): void {\n if (this.hasFocus()) {\n this.refresh();\n } else {\n this._needsRefresh = true;\n }\n this._clearHover();\n }\n\n /**\n * Add a keydown handler to the editor.\n *\n * @param handler - A keydown handler.\n *\n * @returns A disposable that can be used to remove the handler.\n */\n addKeydownHandler(handler: CodeEditor.KeydownHandler): IDisposable {\n this._keydownHandlers.push(handler);\n return new DisposableDelegate(() => {\n ArrayExt.removeAllWhere(this._keydownHandlers, val => val === handler);\n });\n }\n\n /**\n * Set the size of the editor in pixels.\n */\n setSize(dimension: CodeEditor.IDimension | null): void {\n if (dimension) {\n this._editor.setSize(dimension.width, dimension.height);\n } else {\n this._editor.setSize(null, null);\n }\n this._needsRefresh = false;\n }\n\n /**\n * Reveal the given position in the editor.\n */\n revealPosition(position: CodeEditor.IPosition): void {\n const cmPosition = this._toCodeMirrorPosition(position);\n this._editor.scrollIntoView(cmPosition);\n }\n\n /**\n * Reveal the given selection in the editor.\n */\n revealSelection(selection: CodeEditor.IRange): void {\n const range = this._toCodeMirrorRange(selection);\n this._editor.scrollIntoView(range);\n }\n\n /**\n * Get the window coordinates given a cursor position.\n */\n getCoordinateForPosition(\n position: CodeEditor.IPosition\n ): CodeEditor.ICoordinate {\n const pos = this._toCodeMirrorPosition(position);\n const rect = this.editor.charCoords(pos, 'page');\n return rect as CodeEditor.ICoordinate;\n }\n\n /**\n * Get the cursor position given window coordinates.\n *\n * @param coordinate - The desired coordinate.\n *\n * @returns The position of the coordinates, or null if not\n * contained in the editor.\n */\n getPositionForCoordinate(\n coordinate: CodeEditor.ICoordinate\n ): CodeEditor.IPosition | null {\n return this._toPosition(this.editor.coordsChar(coordinate)) || null;\n }\n\n /**\n * Returns the primary position of the cursor, never `null`.\n */\n getCursorPosition(): CodeEditor.IPosition {\n const cursor = this.doc.getCursor();\n return this._toPosition(cursor);\n }\n\n /**\n * Set the primary position of the cursor.\n *\n * #### Notes\n * This will remove any secondary cursors.\n */\n setCursorPosition(position: CodeEditor.IPosition): void {\n const cursor = this._toCodeMirrorPosition(position);\n this.doc.setCursor(cursor);\n // If the editor does not have focus, this cursor change\n // will get screened out in _onCursorsChanged(). Make an\n // exception for this method.\n if (!this.editor.hasFocus()) {\n this.model.selections.set(this.uuid, this.getSelections());\n }\n }\n\n /**\n * Returns the primary selection, never `null`.\n */\n getSelection(): CodeEditor.ITextSelection {\n return this.getSelections()[0];\n }\n\n /**\n * Set the primary selection. This will remove any secondary cursors.\n */\n setSelection(selection: CodeEditor.IRange): void {\n this.setSelections([selection]);\n }\n\n /**\n * Gets the selections for all the cursors, never `null` or empty.\n */\n getSelections(): CodeEditor.ITextSelection[] {\n const selections = this.doc.listSelections();\n if (selections.length > 0) {\n return selections.map(selection => this._toSelection(selection));\n }\n const cursor = this.doc.getCursor();\n const selection = this._toSelection({ anchor: cursor, head: cursor });\n return [selection];\n }\n\n /**\n * Sets the selections for all the cursors, should not be empty.\n * Cursors will be removed or added, as necessary.\n * Passing an empty array resets a cursor position to the start of a document.\n */\n setSelections(selections: CodeEditor.IRange[]): void {\n const cmSelections = this._toCodeMirrorSelections(selections);\n this.doc.setSelections(cmSelections, 0);\n }\n\n newIndentedLine(): void {\n this.execCommand('newlineAndIndent');\n }\n\n /**\n * Execute a codemirror command on the editor.\n *\n * @param command - The name of the command to execute.\n */\n execCommand(command: string): void {\n this._editor.execCommand(command);\n }\n\n /**\n * Handle keydown events from the editor.\n */\n protected onKeydown(event: KeyboardEvent): boolean {\n let position = this.getCursorPosition();\n let { line, column } = position;\n\n if (line === 0 && column === 0 && event.keyCode === UP_ARROW) {\n if (!event.shiftKey) {\n this.edgeRequested.emit('top');\n }\n return false;\n }\n\n let lastLine = this.lineCount - 1;\n let lastCh = this.getLine(lastLine)!.length;\n if (\n line === lastLine &&\n column === lastCh &&\n event.keyCode === DOWN_ARROW\n ) {\n if (!event.shiftKey) {\n this.edgeRequested.emit('bottom');\n }\n return false;\n }\n return false;\n }\n\n /**\n * Converts selections to code mirror selections.\n */\n private _toCodeMirrorSelections(\n selections: CodeEditor.IRange[]\n ): CodeMirror.Selection[] {\n if (selections.length > 0) {\n return selections.map(selection =>\n this._toCodeMirrorSelection(selection)\n );\n }\n const position = { line: 0, ch: 0 };\n return [{ anchor: position, head: position }];\n }\n\n /**\n * Handles a mime type change.\n */\n private _onMimeTypeChanged(): void {\n const mime = this._model.mimeType;\n let editor = this._editor;\n Mode.ensure(mime).then(spec => {\n editor.setOption('mode', spec.mime);\n });\n let extraKeys = editor.getOption('extraKeys') || {};\n const isCode = mime !== 'text/plain' && mime !== 'text/x-ipythongfm';\n if (isCode) {\n extraKeys['Backspace'] = 'delSpaceToPrevTabStop';\n } else {\n delete extraKeys['Backspace'];\n }\n editor.setOption('extraKeys', extraKeys);\n }\n\n /**\n * Handles a selections change.\n */\n private _onSelectionsChanged(\n selections: IObservableMap<CodeEditor.ITextSelection[]>,\n args: IObservableMap.IChangedArgs<CodeEditor.ITextSelection[]>\n ): void {\n const uuid = args.key;\n if (uuid !== this.uuid) {\n this._cleanSelections(uuid);\n if (args.type !== 'remove' && args.newValue) {\n this._markSelections(uuid, args.newValue);\n }\n }\n }\n\n /**\n * Clean selections for the given uuid.\n */\n private _cleanSelections(uuid: string) {\n const markers = this.selectionMarkers[uuid];\n if (markers) {\n markers.forEach(marker => {\n marker.clear();\n });\n }\n delete this.selectionMarkers[uuid];\n }\n\n /**\n * Marks selections.\n */\n private _markSelections(\n uuid: string,\n selections: CodeEditor.ITextSelection[]\n ) {\n const markers: CodeMirror.TextMarker[] = [];\n\n // If we are marking selections corresponding to an active hover,\n // remove it.\n if (uuid === this._hoverId) {\n this._clearHover();\n }\n // If we can id the selection to a specific collaborator,\n // use that information.\n let collaborator: ICollaborator | undefined;\n if (this._model.modelDB.collaborators) {\n collaborator = this._model.modelDB.collaborators.get(uuid);\n }\n\n // Style each selection for the uuid.\n selections.forEach(selection => {\n // Only render selections if the start is not equal to the end.\n // In that case, we don't need to render the cursor.\n if (!JSONExt.deepEqual(selection.start, selection.end)) {\n const { anchor, head } = this._toCodeMirrorSelection(selection);\n let markerOptions: CodeMirror.TextMarkerOptions;\n if (collaborator) {\n markerOptions = this._toTextMarkerOptions({\n ...selection.style,\n color: collaborator.color\n });\n } else {\n markerOptions = this._toTextMarkerOptions(selection.style);\n }\n markers.push(this.doc.markText(anchor, head, markerOptions));\n } else if (collaborator) {\n let caret = this._getCaret(collaborator);\n markers.push(\n this.doc.setBookmark(this._toCodeMirrorPosition(selection.end), {\n widget: caret\n })\n );\n }\n });\n this.selectionMarkers[uuid] = markers;\n }\n\n /**\n * Handles a cursor activity event.\n */\n private _onCursorActivity(): void {\n // Only add selections if the editor has focus. This avoids unwanted\n // triggering of cursor activity due to collaborator actions.\n if (this._editor.hasFocus()) {\n const selections = this.getSelections();\n this.model.selections.set(this.uuid, selections);\n }\n }\n\n /**\n * Converts a code mirror selection to an editor selection.\n */\n private _toSelection(\n selection: CodeMirror.Selection\n ): CodeEditor.ITextSelection {\n return {\n uuid: this.uuid,\n start: this._toPosition(selection.anchor),\n end: this._toPosition(selection.head),\n style: this.selectionStyle\n };\n }\n\n /**\n * Converts the selection style to a text marker options.\n */\n private _toTextMarkerOptions(\n style: CodeEditor.ISelectionStyle\n ): CodeMirror.TextMarkerOptions {\n let r = parseInt(style.color.slice(1, 3), 16);\n let g = parseInt(style.color.slice(3, 5), 16);\n let b = parseInt(style.color.slice(5, 7), 16);\n let css = `background-color: rgba( ${r}, ${g}, ${b}, 0.15)`;\n return {\n className: style.className,\n title: style.displayName,\n css\n };\n }\n\n /**\n * Converts an editor selection to a code mirror selection.\n */\n private _toCodeMirrorSelection(\n selection: CodeEditor.IRange\n ): CodeMirror.Selection {\n // Selections only appear to render correctly if the anchor\n // is before the head in the document. That is, reverse selections\n // do not appear as intended.\n let forward: boolean =\n selection.start.line < selection.end.line ||\n (selection.start.line === selection.end.line &&\n selection.start.column <= selection.end.column);\n let anchor = forward ? selection.start : selection.end;\n let head = forward ? selection.end : selection.start;\n return {\n anchor: this._toCodeMirrorPosition(anchor),\n head: this._toCodeMirrorPosition(head)\n };\n }\n\n /**\n * Converts an editor selection to a code mirror selection.\n */\n private _toCodeMirrorRange(range: CodeEditor.IRange): CodeMirror.Range {\n return {\n from: this._toCodeMirrorPosition(range.start),\n to: this._toCodeMirrorPosition(range.end)\n };\n }\n\n /**\n * Convert a code mirror position to an editor position.\n */\n private _toPosition(position: CodeMirror.Position) {\n return {\n line: position.line,\n column: position.ch\n };\n }\n\n /**\n * Convert an editor position to a code mirror position.\n */\n private _toCodeMirrorPosition(position: CodeEditor.IPosition) {\n return {\n line: position.line,\n ch: position.column\n };\n }\n\n /**\n * Handle model value changes.\n */\n private _onValueChanged(\n value: IObservableString,\n args: IObservableString.IChangedArgs\n ): void {\n if (this._changeGuard) {\n return;\n }\n this._changeGuard = true;\n let doc = this.doc;\n switch (args.type) {\n case 'insert':\n let pos = doc.posFromIndex(args.start);\n doc.replaceRange(args.value, pos, pos);\n break;\n case 'remove':\n let from = doc.posFromIndex(args.start);\n let to = doc.posFromIndex(args.end);\n doc.replaceRange('', from, to);\n break;\n case 'set':\n doc.setValue(args.value);\n break;\n default:\n break;\n }\n this._changeGuard = false;\n }\n\n /**\n * Handles document changes.\n */\n private _beforeDocChanged(\n doc: CodeMirror.Doc,\n change: CodeMirror.EditorChange\n ) {\n if (this._changeGuard) {\n return;\n }\n this._changeGuard = true;\n let value = this._model.value;\n let start = doc.indexFromPos(change.from);\n let end = doc.indexFromPos(change.to);\n let inserted = change.text.join('\\n');\n\n if (end !== start) {\n value.remove(start, end);\n }\n if (inserted) {\n value.insert(start, inserted);\n }\n this._changeGuard = false;\n }\n\n /**\n * Handle the DOM events for the editor.\n *\n * @param event - The DOM event sent to the editor.\n *\n * #### Notes\n * This method implements the DOM `EventListener` interface and is\n * called in response to events on the editor's DOM node. It should\n * not be called directly by user code.\n */\n handleEvent(event: Event): void {\n switch (event.type) {\n case 'focus':\n this._evtFocus(event as FocusEvent);\n break;\n case 'blur':\n this._evtBlur(event as FocusEvent);\n break;\n case 'scroll':\n this._evtScroll();\n break;\n default:\n break;\n }\n }\n\n /**\n * Handle `focus` events for the editor.\n */\n private _evtFocus(event: FocusEvent): void {\n if (this._needsRefresh) {\n this.refresh();\n }\n this.host.classList.add('jp-mod-focused');\n\n // Update the selections on editor gaining focus because\n // the onCursorActivity function filters usual cursor events\n // based on the editor's focus.\n this._onCursorActivity();\n }\n\n /**\n * Handle `blur` events for the editor.\n */\n private _evtBlur(event: FocusEvent): void {\n this.host.classList.remove('jp-mod-focused');\n }\n\n /**\n * Handle `scroll` events for the editor.\n */\n private _evtScroll(): void {\n // Remove any active hover.\n this._clearHover();\n }\n\n /**\n * Clear the hover for a caret, due to things like\n * scrolling, resizing, deactivation, etc, where\n * the position is no longer valid.\n */\n private _clearHover(): void {\n if (this._caretHover) {\n window.clearTimeout(this._hoverTimeout);\n document.body.removeChild(this._caretHover);\n this._caretHover = null;\n }\n }\n\n /**\n * Construct a caret element representing the position\n * of a collaborator's cursor.\n */\n private _getCaret(collaborator: ICollaborator): HTMLElement {\n let name = collaborator ? collaborator.displayName : 'Anonymous';\n let color = collaborator ? collaborator.color : this._selectionStyle.color;\n let caret: HTMLElement = document.createElement('span');\n caret.className = COLLABORATOR_CURSOR_CLASS;\n caret.style.borderBottomColor = color;\n caret.onmouseenter = () => {\n this._clearHover();\n this._hoverId = collaborator.sessionId;\n let rect = caret.getBoundingClientRect();\n // Construct and place the hover box.\n let hover = document.createElement('div');\n hover.className = COLLABORATOR_HOVER_CLASS;\n hover.style.left = String(rect.left) + 'px';\n hover.style.top = String(rect.bottom) + 'px';\n hover.textContent = name;\n hover.style.backgroundColor = color;\n\n // If the user mouses over the hover, take over the timer.\n hover.onmouseenter = () => {\n window.clearTimeout(this._hoverTimeout);\n };\n hover.onmouseleave = () => {\n this._hoverTimeout = window.setTimeout(() => {\n this._clearHover();\n }, HOVER_TIMEOUT);\n };\n this._caretHover = hover;\n document.body.appendChild(hover);\n };\n caret.onmouseleave = () => {\n this._hoverTimeout = window.setTimeout(() => {\n this._clearHover();\n }, HOVER_TIMEOUT);\n };\n return caret;\n }\n\n /**\n * Check for an out of sync editor.\n */\n private _checkSync(): void {\n let change = this._lastChange;\n if (!change) {\n return;\n }\n this._lastChange = null;\n let editor = this._editor;\n let doc = editor.getDoc();\n if (doc.getValue() === this._model.value.text) {\n return;\n }\n\n showDialog({\n title: 'Code Editor out of Sync',\n body:\n 'Please open your browser JavaScript console for bug report instructions'\n });\n console.log(\n 'Please paste the following to https://github.com/jupyterlab/jupyterlab/issues/2951'\n );\n console.log(\n JSON.stringify({\n model: this._model.value.text,\n view: doc.getValue(),\n selections: this.getSelections(),\n cursor: this.getCursorPosition(),\n lineSep: editor.getOption('lineSeparator'),\n mode: editor.getOption('mode'),\n change\n })\n );\n }\n\n private _model: CodeEditor.IModel;\n private _editor: CodeMirror.Editor;\n protected selectionMarkers: {\n [key: string]: CodeMirror.TextMarker[] | undefined;\n } = {};\n private _caretHover: HTMLElement | null;\n private readonly _config: CodeMirrorEditor.IConfig;\n private _hoverTimeout: number;\n private _hoverId: string;\n private _keydownHandlers = new Array<CodeEditor.KeydownHandler>();\n private _changeGuard = false;\n private _selectionStyle: CodeEditor.ISelectionStyle;\n private _uuid = '';\n private _needsRefresh = false;\n private _isDisposed = false;\n private _lastChange: CodeMirror.EditorChange | null = null;\n private _timer = -1;\n}\n\n/**\n * The namespace for `CodeMirrorEditor` statics.\n */\nexport namespace CodeMirrorEditor {\n /**\n * The options used to initialize a code mirror editor.\n */\n export interface IOptions extends CodeEditor.IOptions {\n /**\n * The configuration options for the editor.\n */\n config?: Partial<IConfig>;\n }\n\n /**\n * The configuration options for a codemirror editor.\n */\n export interface IConfig extends CodeEditor.IConfig {\n /**\n * The mode to use.\n */\n mode?: string | Mode.IMode;\n\n /**\n * The theme to style the editor with.\n * You must make sure the CSS file defining the corresponding\n * .cm-s-[name] styles is loaded.\n */\n theme?: string;\n\n /**\n * Whether to use the context-sensitive indentation that the mode provides\n * (or just indent the same as the line before).\n */\n smartIndent?: boolean;\n\n /**\n * Configures whether the editor should re-indent the current line when a\n * character is typed that might change its proper indentation\n * (only works if the mode supports indentation).\n */\n electricChars?: boolean;\n\n /**\n * Configures the keymap to use. The default is \"default\", which is the\n * only keymap defined in codemirror.js itself.\n * Extra keymaps are found in the CodeMirror keymap directory.\n */\n keyMap?: string;\n\n /**\n * Can be used to specify extra keybindings for the editor, alongside the\n * ones defined by keyMap. Should be either null, or a valid keymap value.\n */\n extraKeys?: any;\n\n /**\n * Can be used to add extra gutters (beyond or instead of the line number\n * gutter).\n * Should be an array of CSS class names, each of which defines a width\n * (and optionally a background),\n * and which will be used to draw the background of the gutters.\n * May include the CodeMirror-linenumbers class, in order to explicitly\n * set the position of the line number gutter\n * (it will default to be to the right of all other gutters).\n * These class names are the keys passed to setGutterMarker.\n */\n gutters?: string[];\n\n /**\n * Determines whether the gutter scrolls along with the content\n * horizontally (false)\n * or whether it stays fixed during horizontal scrolling (true,\n * the default).\n */\n fixedGutter?: boolean;\n\n /**\n * Whether the cursor should be drawn when a selection is active.\n */\n showCursorWhenSelecting?: boolean;\n\n /**\n * When fixedGutter is on, and there is a horizontal scrollbar, by default\n * the gutter will be visible to the left of this scrollbar. If this\n * option is set to true, it will be covered by an element with class\n * CodeMirror-gutter-filler.\n */\n coverGutterNextToScrollbar?: boolean;\n\n /**\n * Controls whether drag-and-drop is enabled.\n */\n dragDrop?: boolean;\n\n /**\n * Explicitly set the line separator for the editor.\n * By default (value null), the document will be split on CRLFs as well as\n * lone CRs and LFs, and a single LF will be used as line separator in all\n * output (such as getValue). When a specific string is given, lines will\n * only be split on that string, and output will, by default, use that\n * same separator.\n */\n lineSeparator?: string | null;\n\n /**\n * Chooses a scrollbar implementation. The default is \"native\", showing\n * native scrollbars. The core library also provides the \"null\" style,\n * which completely hides the scrollbars. Addons can implement additional\n * scrollbar models.\n */\n scrollbarStyle?: string;\n\n /**\n * When enabled, which is the default, doing copy or cut when there is no\n * selection will copy or cut the whole lines that have cursors on them.\n */\n lineWiseCopyCut?: boolean;\n\n /**\n * Whether to scroll past the end of the buffer.\n */\n scrollPastEnd?: boolean;\n }\n\n /**\n * The default configuration options for an editor.\n */\n export let defaultConfig: IConfig = {\n ...CodeEditor.defaultConfig,\n mode: 'null',\n theme: 'jupyter',\n smartIndent: true,\n electricChars: true,\n keyMap: 'default',\n extraKeys: null,\n gutters: [],\n fixedGutter: true,\n showCursorWhenSelecting: false,\n coverGutterNextToScrollbar: false,\n dragDrop: true,\n lineSeparator: null,\n scrollbarStyle: 'native',\n lineWiseCopyCut: true,\n scrollPastEnd: false\n };\n\n /**\n * Add a command to CodeMirror.\n *\n * @param name - The name of the command to add.\n *\n * @param command - The command function.\n */\n export function addCommand(\n name: string,\n command: (cm: CodeMirror.Editor) => void\n ) {\n CodeMirror.commands[name] = command;\n }\n}\n\n/**\n * The namespace for module private data.\n */\nnamespace Private {\n export function createEditor(\n host: HTMLElement,\n config: CodeMirrorEditor.IConfig\n ): CodeMirror.Editor {\n let {\n autoClosingBrackets,\n fontFamily,\n fontSize,\n insertSpaces,\n lineHeight,\n lineWrap,\n wordWrapColumn,\n tabSize,\n readOnly,\n ...otherOptions\n } = config;\n let bareConfig = {\n autoCloseBrackets: autoClosingBrackets,\n indentUnit: tabSize,\n indentWithTabs: !insertSpaces,\n lineWrapping: lineWrap === 'off' ? false : true,\n readOnly,\n ...otherOptions\n };\n return CodeMirror(el => {\n if (fontFamily) {\n el.style.fontFamily = fontFamily;\n }\n if (fontSize) {\n el.style.fontSize = fontSize + 'px';\n }\n if (lineHeight) {\n el.style.lineHeight = lineHeight.toString();\n }\n if (readOnly) {\n el.classList.add(READ_ONLY_CLASS);\n }\n if (lineWrap === 'wordWrapColumn') {\n const lines = el.querySelector('.CodeMirror-lines') as HTMLDivElement;\n lines.style.width = `${wordWrapColumn}ch`;\n }\n if (lineWrap === 'bounded') {\n const lines = el.querySelector('.CodeMirror-lines') as HTMLDivElement;\n lines.style.maxWidth = `${wordWrapColumn}ch`;\n }\n host.appendChild(el);\n }, bareConfig);\n }\n\n /**\n * Indent or insert a tab as appropriate.\n */\n export function indentMoreOrinsertTab(cm: CodeMirror.Editor): void {\n let doc = cm.getDoc();\n let from = doc.getCursor('from');\n let to = doc.getCursor('to');\n let sel = !posEq(from, to);\n if (sel) {\n CodeMirror.commands['indentMore'](cm);\n return;\n }\n // Check for start of line.\n let line = doc.getLine(from.line);\n let before = line.slice(0, from.ch);\n if (/^\\s*$/.test(before)) {\n CodeMirror.commands['indentMore'](cm);\n } else {\n if (cm.getOption('indentWithTabs')) {\n CodeMirror.commands['insertTab'](cm);\n } else {\n CodeMirror.commands['insertSoftTab'](cm);\n }\n }\n }\n\n /**\n * Delete spaces to the previous tab stob in a codemirror editor.\n */\n export function delSpaceToPrevTabStop(cm: CodeMirror.Editor): void {\n let doc = cm.getDoc();\n let from = doc.getCursor('from');\n let to = doc.getCursor('to');\n let sel = !posEq(from, to);\n if (sel) {\n let ranges = doc.listSelections();\n for (let i = ranges.length - 1; i >= 0; i--) {\n let head = ranges[i].head;\n let anchor = ranges[i].anchor;\n doc.replaceRange(\n '',\n CodeMirror.Pos(head.line, head.ch),\n CodeMirror.Pos(anchor.line, anchor.ch)\n );\n }\n return;\n }\n let cur = doc.getCursor();\n let tabsize = cm.getOption('tabSize');\n let chToPrevTabStop = cur.ch - (Math.ceil(cur.ch / tabsize) - 1) * tabsize;\n from = { ch: cur.ch - chToPrevTabStop, line: cur.line };\n let select = doc.getRange(from, cur);\n if (select.match(/^\\ +$/) !== null) {\n doc.replaceRange('', from, cur);\n } else {\n CodeMirror.commands['delCharBefore'](cm);\n }\n }\n\n /**\n * Test whether two CodeMirror positions are equal.\n */\n export function posEq(\n a: CodeMirror.Position,\n b: CodeMirror.Position\n ): boolean {\n return a.line === b.line && a.ch === b.ch;\n }\n\n /**\n * Set a config option for the editor.\n */\n export function setOption<K extends keyof CodeMirrorEditor.IConfig>(\n editor: CodeMirror.Editor,\n option: K,\n value: CodeMirrorEditor.IConfig[K],\n config: CodeMirrorEditor.IConfig\n ): void {\n let el = editor.getWrapperElement();\n switch (option) {\n case 'lineWrap':\n const lineWrapping = value === 'off' ? false : true;\n const lines = el.querySelector('.CodeMirror-lines') as HTMLDivElement;\n const maxWidth =\n value === 'bounded' ? `${config.wordWrapColumn}ch` : null;\n const width =\n value === 'wordWrapColumn' ? `${config.wordWrapColumn}ch` : null;\n lines.style.maxWidth = maxWidth;\n lines.style.width = width;\n editor.setOption('lineWrapping', lineWrapping);\n break;\n case 'wordWrapColumn':\n const { lineWrap } = config;\n if (lineWrap === 'wordWrapColumn' || lineWrap === 'bounded') {\n const lines = el.querySelector('.CodeMirror-lines') as HTMLDivElement;\n const prop = lineWrap === 'wordWrapColumn' ? 'width' : 'maxWidth';\n lines.style[prop] = `${value}ch`;\n }\n break;\n case 'tabSize':\n editor.setOption('indentUnit', value);\n break;\n case 'insertSpaces':\n editor.setOption('indentWithTabs', !value);\n break;\n case 'autoClosingBrackets':\n editor.setOption('autoCloseBrackets', value);\n break;\n case 'readOnly':\n el.classList.toggle(READ_ONLY_CLASS, value);\n editor.setOption(option, value);\n break;\n case 'fontFamily':\n el.style.fontFamily = value;\n break;\n case 'fontSize':\n el.style.fontSize = value ? value + 'px' : null;\n break;\n case 'lineHeight':\n el.style.lineHeight = value ? value.toString() : null;\n break;\n default:\n editor.setOption(option, value);\n break;\n }\n }\n}\n\n/**\n * Add a CodeMirror command to delete until previous non blanking space\n * character or first multiple of tabsize tabstop.\n */\nCodeMirrorEditor.addCommand(\n 'delSpaceToPrevTabStop',\n Private.delSpaceToPrevTabStop\n);\n\n/**\n * Add a CodeMirror command to indent or insert a tab as appropriate.\n */\nCodeMirrorEditor.addCommand(\n 'indentMoreOrinsertTab',\n Private.indentMoreOrinsertTab\n);\n"]}
1
+ {"version":3,"file":"editor.js","sourceRoot":"","sources":["../../../../codemirror/src/editor.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,2DAA2D;;;;;;;;;;;;;;AAE3D,4DAAoC;AAEpC,mDAA8C;AAE9C,mDAA+C;AAE/C,qDAAuE;AAEvE,mDAA6C;AAE7C,mDAAkD;AAElD,uDAAoD;AAEpD,mDAA2C;AAQ3C,iCAA8B;AAE9B,+CAA6C;AAC7C,kDAAgD;AAChD,kDAAgD;AAChD,oDAAkD;AAClD,gDAA8C;AAC9C,0CAAwC;AACxC,sCAAoC;AACpC,wCAAsC;AACtC,oCAAkC;AAElC;;GAEG;AACH,MAAM,YAAY,GAAG,qBAAqB,CAAC;AAE3C;;GAEG;AACH,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAE1C;;GAEG;AACH,MAAM,yBAAyB,GAAG,uBAAuB,CAAC;AAE1D;;GAEG;AACH,MAAM,wBAAwB,GAAG,6BAA6B,CAAC;AAE/D;;GAEG;AACH,MAAM,QAAQ,GAAG,EAAE,CAAC;AAEpB;;GAEG;AACH,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB;;GAEG;AACH,MAAM,aAAa,GAAG,IAAI,CAAC;AAE3B;;GAEG;AACH;IACE;;OAEG;IAC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,UAAU,CACzB,uBAAuB,EACvB,OAAO,CAAC,qBAAqB,CAC9B,CAAC","sourcesContent":["// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n\nimport CodeMirror from 'codemirror';\n\nimport { JSONExt } from '@phosphor/coreutils';\n\nimport { ArrayExt } from '@phosphor/algorithm';\n\nimport { IDisposable, DisposableDelegate } from '@phosphor/disposable';\n\nimport { Signal } from '@phosphor/signaling';\n\nimport { showDialog } from '@jupyterlab/apputils';\n\nimport { CodeEditor } from '@jupyterlab/codeeditor';\n\nimport { UUID } from '@phosphor/coreutils';\n\nimport {\n IObservableMap,\n IObservableString,\n ICollaborator\n} from '@jupyterlab/observables';\n\nimport { Mode } from './mode';\n\nimport 'codemirror/addon/comment/comment.js';\nimport 'codemirror/addon/edit/matchbrackets.js';\nimport 'codemirror/addon/edit/closebrackets.js';\nimport 'codemirror/addon/scroll/scrollpastend.js';\nimport 'codemirror/addon/search/searchcursor';\nimport 'codemirror/addon/search/search';\nimport 'codemirror/keymap/emacs.js';\nimport 'codemirror/keymap/sublime.js';\nimport 'codemirror/keymap/vim.js';\n\n/**\n * The class name added to CodeMirrorWidget instances.\n */\nconst EDITOR_CLASS = 'jp-CodeMirrorEditor';\n\n/**\n * The class name added to read only cell editor widgets.\n */\nconst READ_ONLY_CLASS = 'jp-mod-readOnly';\n\n/**\n * The class name for the hover box for collaborator cursors.\n */\nconst COLLABORATOR_CURSOR_CLASS = 'jp-CollaboratorCursor';\n\n/**\n * The class name for the hover box for collaborator cursors.\n */\nconst COLLABORATOR_HOVER_CLASS = 'jp-CollaboratorCursor-hover';\n\n/**\n * The key code for the up arrow key.\n */\nconst UP_ARROW = 38;\n\n/**\n * The key code for the down arrow key.\n */\nconst DOWN_ARROW = 40;\n\n/**\n * The time that a collaborator name hover persists.\n */\nconst HOVER_TIMEOUT = 1000;\n\n/**\n * CodeMirror editor.\n */\nexport class CodeMirrorEditor implements CodeEditor.IEditor {\n /**\n * Construct a CodeMirror editor.\n */\n constructor(options: CodeMirrorEditor.IOptions) {\n let host = (this.host = options.host);\n host.classList.add(EDITOR_CLASS);\n host.classList.add('jp-Editor');\n host.addEventListener('focus', this, true);\n host.addEventListener('blur', this, true);\n host.addEventListener('scroll', this, true);\n\n this._uuid = options.uuid || UUID.uuid4();\n\n // Handle selection style.\n let style = options.selectionStyle || {};\n this._selectionStyle = {\n ...CodeEditor.defaultSelectionStyle,\n ...(style as CodeEditor.ISelectionStyle)\n };\n\n let model = (this._model = options.model);\n let config = options.config || {};\n let fullConfig = (this._config = {\n ...CodeMirrorEditor.defaultConfig,\n ...config\n });\n let editor = (this._editor = Private.createEditor(host, fullConfig));\n\n let doc = editor.getDoc();\n\n // Handle initial values for text, mimetype, and selections.\n doc.setValue(model.value.text);\n this.clearHistory();\n this._onMimeTypeChanged();\n this._onCursorActivity();\n this._timer = window.setInterval(() => {\n this._checkSync();\n }, 3000);\n\n // Connect to changes.\n model.value.changed.connect(this._onValueChanged, this);\n model.mimeTypeChanged.connect(this._onMimeTypeChanged, this);\n model.selections.changed.connect(this._onSelectionsChanged, this);\n\n CodeMirror.on(editor, 'keydown', (editor: CodeMirror.Editor, event) => {\n let index = ArrayExt.findFirstIndex(this._keydownHandlers, handler => {\n if (handler(this, event) === true) {\n event.preventDefault();\n return true;\n }\n return false;\n });\n if (index === -1) {\n this.onKeydown(event);\n }\n });\n CodeMirror.on(editor, 'cursorActivity', () => this._onCursorActivity());\n CodeMirror.on(editor.getDoc(), 'beforeChange', (instance, change) => {\n this._beforeDocChanged(instance, change);\n });\n CodeMirror.on(editor.getDoc(), 'change', (instance, change) => {\n // Manually refresh after setValue to make sure editor is properly sized.\n if (change.origin === 'setValue' && this.hasFocus()) {\n this.refresh();\n }\n this._lastChange = change;\n });\n\n // Manually refresh on paste to make sure editor is properly sized.\n editor.getWrapperElement().addEventListener('paste', () => {\n if (this.hasFocus()) {\n this.refresh();\n }\n });\n }\n\n /**\n * A signal emitted when either the top or bottom edge is requested.\n */\n readonly edgeRequested = new Signal<this, CodeEditor.EdgeLocation>(this);\n\n /**\n * The DOM node that hosts the editor.\n */\n readonly host: HTMLElement;\n\n /**\n * The uuid of this editor;\n */\n get uuid(): string {\n return this._uuid;\n }\n set uuid(value: string) {\n this._uuid = value;\n }\n\n /**\n * The selection style of this editor.\n */\n get selectionStyle(): CodeEditor.ISelectionStyle {\n return this._selectionStyle;\n }\n set selectionStyle(value: CodeEditor.ISelectionStyle) {\n this._selectionStyle = value;\n }\n\n /**\n * Get the codemirror editor wrapped by the editor.\n */\n get editor(): CodeMirror.Editor {\n return this._editor;\n }\n\n /**\n * Get the codemirror doc wrapped by the widget.\n */\n get doc(): CodeMirror.Doc {\n return this._editor.getDoc();\n }\n\n /**\n * Get the number of lines in the editor.\n */\n get lineCount(): number {\n return this.doc.lineCount();\n }\n\n /**\n * Returns a model for this editor.\n */\n get model(): CodeEditor.IModel {\n return this._model;\n }\n\n /**\n * The height of a line in the editor in pixels.\n */\n get lineHeight(): number {\n return this._editor.defaultTextHeight();\n }\n\n /**\n * The widget of a character in the editor in pixels.\n */\n get charWidth(): number {\n return this._editor.defaultCharWidth();\n }\n\n /**\n * Tests whether the editor is disposed.\n */\n get isDisposed(): boolean {\n return this._isDisposed;\n }\n\n /**\n * Dispose of the resources held by the widget.\n */\n dispose(): void {\n if (this.isDisposed) {\n return;\n }\n this._isDisposed = true;\n this.host.removeEventListener('focus', this, true);\n this.host.removeEventListener('blur', this, true);\n this.host.removeEventListener('scroll', this, true);\n this._keydownHandlers.length = 0;\n window.clearInterval(this._timer);\n Signal.clearData(this);\n }\n\n /**\n * Get a config option for the editor.\n */\n getOption<K extends keyof CodeMirrorEditor.IConfig>(\n option: K\n ): CodeMirrorEditor.IConfig[K] {\n return this._config[option];\n }\n\n /**\n * Set a config option for the editor.\n */\n setOption<K extends keyof CodeMirrorEditor.IConfig>(\n option: K,\n value: CodeMirrorEditor.IConfig[K]\n ): void {\n // Don't bother setting the option if it is already the same.\n if (this._config[option] !== value) {\n this._config[option] = value;\n Private.setOption(this.editor, option, value, this._config);\n }\n }\n\n /**\n * Returns the content for the given line number.\n */\n getLine(line: number): string | undefined {\n return this.doc.getLine(line);\n }\n\n /**\n * Find an offset for the given position.\n */\n getOffsetAt(position: CodeEditor.IPosition): number {\n return this.doc.indexFromPos({\n ch: position.column,\n line: position.line\n });\n }\n\n /**\n * Find a position for the given offset.\n */\n getPositionAt(offset: number): CodeEditor.IPosition {\n const { ch, line } = this.doc.posFromIndex(offset);\n return { line, column: ch };\n }\n\n /**\n * Undo one edit (if any undo events are stored).\n */\n undo(): void {\n this.doc.undo();\n }\n\n /**\n * Redo one undone edit.\n */\n redo(): void {\n this.doc.redo();\n }\n\n /**\n * Clear the undo history.\n */\n clearHistory(): void {\n this.doc.clearHistory();\n }\n\n /**\n * Brings browser focus to this editor text.\n */\n focus(): void {\n this._editor.focus();\n }\n\n /**\n * Test whether the editor has keyboard focus.\n */\n hasFocus(): boolean {\n return this._editor.getWrapperElement().contains(document.activeElement);\n }\n\n /**\n * Explicitly blur the editor.\n */\n blur(): void {\n this._editor.getInputField().blur();\n }\n\n /**\n * Repaint editor.\n */\n refresh(): void {\n this._editor.refresh();\n this._needsRefresh = false;\n }\n\n /**\n * Refresh the editor if it is focused;\n * otherwise postpone refreshing till focusing.\n */\n resizeToFit(): void {\n if (this.hasFocus()) {\n this.refresh();\n } else {\n this._needsRefresh = true;\n }\n this._clearHover();\n }\n\n /**\n * Add a keydown handler to the editor.\n *\n * @param handler - A keydown handler.\n *\n * @returns A disposable that can be used to remove the handler.\n */\n addKeydownHandler(handler: CodeEditor.KeydownHandler): IDisposable {\n this._keydownHandlers.push(handler);\n return new DisposableDelegate(() => {\n ArrayExt.removeAllWhere(this._keydownHandlers, val => val === handler);\n });\n }\n\n /**\n * Set the size of the editor in pixels.\n */\n setSize(dimension: CodeEditor.IDimension | null): void {\n if (dimension) {\n this._editor.setSize(dimension.width, dimension.height);\n } else {\n this._editor.setSize(null, null);\n }\n this._needsRefresh = false;\n }\n\n /**\n * Reveal the given position in the editor.\n */\n revealPosition(position: CodeEditor.IPosition): void {\n const cmPosition = this._toCodeMirrorPosition(position);\n this._editor.scrollIntoView(cmPosition);\n }\n\n /**\n * Reveal the given selection in the editor.\n */\n revealSelection(selection: CodeEditor.IRange): void {\n const range = this._toCodeMirrorRange(selection);\n this._editor.scrollIntoView(range);\n }\n\n /**\n * Get the window coordinates given a cursor position.\n */\n getCoordinateForPosition(\n position: CodeEditor.IPosition\n ): CodeEditor.ICoordinate {\n const pos = this._toCodeMirrorPosition(position);\n const rect = this.editor.charCoords(pos, 'page');\n return rect as CodeEditor.ICoordinate;\n }\n\n /**\n * Get the cursor position given window coordinates.\n *\n * @param coordinate - The desired coordinate.\n *\n * @returns The position of the coordinates, or null if not\n * contained in the editor.\n */\n getPositionForCoordinate(\n coordinate: CodeEditor.ICoordinate\n ): CodeEditor.IPosition | null {\n return this._toPosition(this.editor.coordsChar(coordinate)) || null;\n }\n\n /**\n * Returns the primary position of the cursor, never `null`.\n */\n getCursorPosition(): CodeEditor.IPosition {\n const cursor = this.doc.getCursor();\n return this._toPosition(cursor);\n }\n\n /**\n * Set the primary position of the cursor.\n *\n * #### Notes\n * This will remove any secondary cursors.\n */\n setCursorPosition(position: CodeEditor.IPosition): void {\n const cursor = this._toCodeMirrorPosition(position);\n this.doc.setCursor(cursor);\n // If the editor does not have focus, this cursor change\n // will get screened out in _onCursorsChanged(). Make an\n // exception for this method.\n if (!this.editor.hasFocus()) {\n this.model.selections.set(this.uuid, this.getSelections());\n }\n }\n\n /**\n * Returns the primary selection, never `null`.\n */\n getSelection(): CodeEditor.ITextSelection {\n return this.getSelections()[0];\n }\n\n /**\n * Set the primary selection. This will remove any secondary cursors.\n */\n setSelection(selection: CodeEditor.IRange): void {\n this.setSelections([selection]);\n }\n\n /**\n * Gets the selections for all the cursors, never `null` or empty.\n */\n getSelections(): CodeEditor.ITextSelection[] {\n const selections = this.doc.listSelections();\n if (selections.length > 0) {\n return selections.map(selection => this._toSelection(selection));\n }\n const cursor = this.doc.getCursor();\n const selection = this._toSelection({ anchor: cursor, head: cursor });\n return [selection];\n }\n\n /**\n * Sets the selections for all the cursors, should not be empty.\n * Cursors will be removed or added, as necessary.\n * Passing an empty array resets a cursor position to the start of a document.\n */\n setSelections(selections: CodeEditor.IRange[]): void {\n const cmSelections = this._toCodeMirrorSelections(selections);\n this.doc.setSelections(cmSelections, 0);\n }\n\n /**\n * Get a list of tokens for the current editor text content.\n */\n getTokens(): CodeEditor.IToken[] {\n let tokens: CodeEditor.IToken[] = [];\n for (let i = 0; i < this.lineCount; ++i) {\n const lineTokens = this.editor.getLineTokens(i).map(t => ({\n offset: this.getOffsetAt({ column: t.start, line: i }),\n value: t.string,\n type: t.type || ''\n }));\n tokens = tokens.concat(lineTokens);\n }\n return tokens;\n }\n\n /**\n * Get the token at a given editor position.\n */\n getTokenForPosition(position: CodeEditor.IPosition): CodeEditor.IToken {\n const cursor = this._toCodeMirrorPosition(position);\n const token = this.editor.getTokenAt(cursor);\n return {\n offset: this.getOffsetAt({ column: token.start, line: cursor.line }),\n value: token.string,\n type: token.type\n };\n }\n\n /**\n * Insert a new indented line at the current cursor position.\n */\n newIndentedLine(): void {\n this.execCommand('newlineAndIndent');\n }\n\n /**\n * Execute a codemirror command on the editor.\n *\n * @param command - The name of the command to execute.\n */\n execCommand(command: string): void {\n this._editor.execCommand(command);\n }\n\n /**\n * Handle keydown events from the editor.\n */\n protected onKeydown(event: KeyboardEvent): boolean {\n let position = this.getCursorPosition();\n let { line, column } = position;\n\n if (line === 0 && column === 0 && event.keyCode === UP_ARROW) {\n if (!event.shiftKey) {\n this.edgeRequested.emit('top');\n }\n return false;\n }\n\n let lastLine = this.lineCount - 1;\n let lastCh = this.getLine(lastLine)!.length;\n if (\n line === lastLine &&\n column === lastCh &&\n event.keyCode === DOWN_ARROW\n ) {\n if (!event.shiftKey) {\n this.edgeRequested.emit('bottom');\n }\n return false;\n }\n return false;\n }\n\n /**\n * Converts selections to code mirror selections.\n */\n private _toCodeMirrorSelections(\n selections: CodeEditor.IRange[]\n ): CodeMirror.Selection[] {\n if (selections.length > 0) {\n return selections.map(selection =>\n this._toCodeMirrorSelection(selection)\n );\n }\n const position = { line: 0, ch: 0 };\n return [{ anchor: position, head: position }];\n }\n\n /**\n * Handles a mime type change.\n */\n private _onMimeTypeChanged(): void {\n const mime = this._model.mimeType;\n let editor = this._editor;\n Mode.ensure(mime).then(spec => {\n editor.setOption('mode', spec.mime);\n });\n let extraKeys = editor.getOption('extraKeys') || {};\n const isCode = mime !== 'text/plain' && mime !== 'text/x-ipythongfm';\n if (isCode) {\n extraKeys['Backspace'] = 'delSpaceToPrevTabStop';\n } else {\n delete extraKeys['Backspace'];\n }\n editor.setOption('extraKeys', extraKeys);\n }\n\n /**\n * Handles a selections change.\n */\n private _onSelectionsChanged(\n selections: IObservableMap<CodeEditor.ITextSelection[]>,\n args: IObservableMap.IChangedArgs<CodeEditor.ITextSelection[]>\n ): void {\n const uuid = args.key;\n if (uuid !== this.uuid) {\n this._cleanSelections(uuid);\n if (args.type !== 'remove' && args.newValue) {\n this._markSelections(uuid, args.newValue);\n }\n }\n }\n\n /**\n * Clean selections for the given uuid.\n */\n private _cleanSelections(uuid: string) {\n const markers = this.selectionMarkers[uuid];\n if (markers) {\n markers.forEach(marker => {\n marker.clear();\n });\n }\n delete this.selectionMarkers[uuid];\n }\n\n /**\n * Marks selections.\n */\n private _markSelections(\n uuid: string,\n selections: CodeEditor.ITextSelection[]\n ) {\n const markers: CodeMirror.TextMarker[] = [];\n\n // If we are marking selections corresponding to an active hover,\n // remove it.\n if (uuid === this._hoverId) {\n this._clearHover();\n }\n // If we can id the selection to a specific collaborator,\n // use that information.\n let collaborator: ICollaborator | undefined;\n if (this._model.modelDB.collaborators) {\n collaborator = this._model.modelDB.collaborators.get(uuid);\n }\n\n // Style each selection for the uuid.\n selections.forEach(selection => {\n // Only render selections if the start is not equal to the end.\n // In that case, we don't need to render the cursor.\n if (!JSONExt.deepEqual(selection.start, selection.end)) {\n const { anchor, head } = this._toCodeMirrorSelection(selection);\n let markerOptions: CodeMirror.TextMarkerOptions;\n if (collaborator) {\n markerOptions = this._toTextMarkerOptions({\n ...selection.style,\n color: collaborator.color\n });\n } else {\n markerOptions = this._toTextMarkerOptions(selection.style);\n }\n markers.push(this.doc.markText(anchor, head, markerOptions));\n } else if (collaborator) {\n let caret = this._getCaret(collaborator);\n markers.push(\n this.doc.setBookmark(this._toCodeMirrorPosition(selection.end), {\n widget: caret\n })\n );\n }\n });\n this.selectionMarkers[uuid] = markers;\n }\n\n /**\n * Handles a cursor activity event.\n */\n private _onCursorActivity(): void {\n // Only add selections if the editor has focus. This avoids unwanted\n // triggering of cursor activity due to collaborator actions.\n if (this._editor.hasFocus()) {\n const selections = this.getSelections();\n this.model.selections.set(this.uuid, selections);\n }\n }\n\n /**\n * Converts a code mirror selection to an editor selection.\n */\n private _toSelection(\n selection: CodeMirror.Selection\n ): CodeEditor.ITextSelection {\n return {\n uuid: this.uuid,\n start: this._toPosition(selection.anchor),\n end: this._toPosition(selection.head),\n style: this.selectionStyle\n };\n }\n\n /**\n * Converts the selection style to a text marker options.\n */\n private _toTextMarkerOptions(\n style: CodeEditor.ISelectionStyle\n ): CodeMirror.TextMarkerOptions {\n let r = parseInt(style.color.slice(1, 3), 16);\n let g = parseInt(style.color.slice(3, 5), 16);\n let b = parseInt(style.color.slice(5, 7), 16);\n let css = `background-color: rgba( ${r}, ${g}, ${b}, 0.15)`;\n return {\n className: style.className,\n title: style.displayName,\n css\n };\n }\n\n /**\n * Converts an editor selection to a code mirror selection.\n */\n private _toCodeMirrorSelection(\n selection: CodeEditor.IRange\n ): CodeMirror.Selection {\n // Selections only appear to render correctly if the anchor\n // is before the head in the document. That is, reverse selections\n // do not appear as intended.\n let forward: boolean =\n selection.start.line < selection.end.line ||\n (selection.start.line === selection.end.line &&\n selection.start.column <= selection.end.column);\n let anchor = forward ? selection.start : selection.end;\n let head = forward ? selection.end : selection.start;\n return {\n anchor: this._toCodeMirrorPosition(anchor),\n head: this._toCodeMirrorPosition(head)\n };\n }\n\n /**\n * Converts an editor selection to a code mirror selection.\n */\n private _toCodeMirrorRange(range: CodeEditor.IRange): CodeMirror.Range {\n return {\n from: this._toCodeMirrorPosition(range.start),\n to: this._toCodeMirrorPosition(range.end)\n };\n }\n\n /**\n * Convert a code mirror position to an editor position.\n */\n private _toPosition(position: CodeMirror.Position) {\n return {\n line: position.line,\n column: position.ch\n };\n }\n\n /**\n * Convert an editor position to a code mirror position.\n */\n private _toCodeMirrorPosition(position: CodeEditor.IPosition) {\n return {\n line: position.line,\n ch: position.column\n };\n }\n\n /**\n * Handle model value changes.\n */\n private _onValueChanged(\n value: IObservableString,\n args: IObservableString.IChangedArgs\n ): void {\n if (this._changeGuard) {\n return;\n }\n this._changeGuard = true;\n let doc = this.doc;\n switch (args.type) {\n case 'insert':\n let pos = doc.posFromIndex(args.start);\n doc.replaceRange(args.value, pos, pos);\n break;\n case 'remove':\n let from = doc.posFromIndex(args.start);\n let to = doc.posFromIndex(args.end);\n doc.replaceRange('', from, to);\n break;\n case 'set':\n doc.setValue(args.value);\n break;\n default:\n break;\n }\n this._changeGuard = false;\n }\n\n /**\n * Handles document changes.\n */\n private _beforeDocChanged(\n doc: CodeMirror.Doc,\n change: CodeMirror.EditorChange\n ) {\n if (this._changeGuard) {\n return;\n }\n this._changeGuard = true;\n let value = this._model.value;\n let start = doc.indexFromPos(change.from);\n let end = doc.indexFromPos(change.to);\n let inserted = change.text.join('\\n');\n\n if (end !== start) {\n value.remove(start, end);\n }\n if (inserted) {\n value.insert(start, inserted);\n }\n this._changeGuard = false;\n }\n\n /**\n * Handle the DOM events for the editor.\n *\n * @param event - The DOM event sent to the editor.\n *\n * #### Notes\n * This method implements the DOM `EventListener` interface and is\n * called in response to events on the editor's DOM node. It should\n * not be called directly by user code.\n */\n handleEvent(event: Event): void {\n switch (event.type) {\n case 'focus':\n this._evtFocus(event as FocusEvent);\n break;\n case 'blur':\n this._evtBlur(event as FocusEvent);\n break;\n case 'scroll':\n this._evtScroll();\n break;\n default:\n break;\n }\n }\n\n /**\n * Handle `focus` events for the editor.\n */\n private _evtFocus(event: FocusEvent): void {\n if (this._needsRefresh) {\n this.refresh();\n }\n this.host.classList.add('jp-mod-focused');\n\n // Update the selections on editor gaining focus because\n // the onCursorActivity function filters usual cursor events\n // based on the editor's focus.\n this._onCursorActivity();\n }\n\n /**\n * Handle `blur` events for the editor.\n */\n private _evtBlur(event: FocusEvent): void {\n this.host.classList.remove('jp-mod-focused');\n }\n\n /**\n * Handle `scroll` events for the editor.\n */\n private _evtScroll(): void {\n // Remove any active hover.\n this._clearHover();\n }\n\n /**\n * Clear the hover for a caret, due to things like\n * scrolling, resizing, deactivation, etc, where\n * the position is no longer valid.\n */\n private _clearHover(): void {\n if (this._caretHover) {\n window.clearTimeout(this._hoverTimeout);\n document.body.removeChild(this._caretHover);\n this._caretHover = null;\n }\n }\n\n /**\n * Construct a caret element representing the position\n * of a collaborator's cursor.\n */\n private _getCaret(collaborator: ICollaborator): HTMLElement {\n let name = collaborator ? collaborator.displayName : 'Anonymous';\n let color = collaborator ? collaborator.color : this._selectionStyle.color;\n let caret: HTMLElement = document.createElement('span');\n caret.className = COLLABORATOR_CURSOR_CLASS;\n caret.style.borderBottomColor = color;\n caret.onmouseenter = () => {\n this._clearHover();\n this._hoverId = collaborator.sessionId;\n let rect = caret.getBoundingClientRect();\n // Construct and place the hover box.\n let hover = document.createElement('div');\n hover.className = COLLABORATOR_HOVER_CLASS;\n hover.style.left = String(rect.left) + 'px';\n hover.style.top = String(rect.bottom) + 'px';\n hover.textContent = name;\n hover.style.backgroundColor = color;\n\n // If the user mouses over the hover, take over the timer.\n hover.onmouseenter = () => {\n window.clearTimeout(this._hoverTimeout);\n };\n hover.onmouseleave = () => {\n this._hoverTimeout = window.setTimeout(() => {\n this._clearHover();\n }, HOVER_TIMEOUT);\n };\n this._caretHover = hover;\n document.body.appendChild(hover);\n };\n caret.onmouseleave = () => {\n this._hoverTimeout = window.setTimeout(() => {\n this._clearHover();\n }, HOVER_TIMEOUT);\n };\n return caret;\n }\n\n /**\n * Check for an out of sync editor.\n */\n private _checkSync(): void {\n let change = this._lastChange;\n if (!change) {\n return;\n }\n this._lastChange = null;\n let editor = this._editor;\n let doc = editor.getDoc();\n if (doc.getValue() === this._model.value.text) {\n return;\n }\n\n showDialog({\n title: 'Code Editor out of Sync',\n body:\n 'Please open your browser JavaScript console for bug report instructions'\n });\n console.log(\n 'Please paste the following to https://github.com/jupyterlab/jupyterlab/issues/2951'\n );\n console.log(\n JSON.stringify({\n model: this._model.value.text,\n view: doc.getValue(),\n selections: this.getSelections(),\n cursor: this.getCursorPosition(),\n lineSep: editor.getOption('lineSeparator'),\n mode: editor.getOption('mode'),\n change\n })\n );\n }\n\n private _model: CodeEditor.IModel;\n private _editor: CodeMirror.Editor;\n protected selectionMarkers: {\n [key: string]: CodeMirror.TextMarker[] | undefined;\n } = {};\n private _caretHover: HTMLElement | null;\n private readonly _config: CodeMirrorEditor.IConfig;\n private _hoverTimeout: number;\n private _hoverId: string;\n private _keydownHandlers = new Array<CodeEditor.KeydownHandler>();\n private _changeGuard = false;\n private _selectionStyle: CodeEditor.ISelectionStyle;\n private _uuid = '';\n private _needsRefresh = false;\n private _isDisposed = false;\n private _lastChange: CodeMirror.EditorChange | null = null;\n private _timer = -1;\n}\n\n/**\n * The namespace for `CodeMirrorEditor` statics.\n */\nexport namespace CodeMirrorEditor {\n /**\n * The options used to initialize a code mirror editor.\n */\n export interface IOptions extends CodeEditor.IOptions {\n /**\n * The configuration options for the editor.\n */\n config?: Partial<IConfig>;\n }\n\n /**\n * The configuration options for a codemirror editor.\n */\n export interface IConfig extends CodeEditor.IConfig {\n /**\n * The mode to use.\n */\n mode?: string | Mode.IMode;\n\n /**\n * The theme to style the editor with.\n * You must make sure the CSS file defining the corresponding\n * .cm-s-[name] styles is loaded.\n */\n theme?: string;\n\n /**\n * Whether to use the context-sensitive indentation that the mode provides\n * (or just indent the same as the line before).\n */\n smartIndent?: boolean;\n\n /**\n * Configures whether the editor should re-indent the current line when a\n * character is typed that might change its proper indentation\n * (only works if the mode supports indentation).\n */\n electricChars?: boolean;\n\n /**\n * Configures the keymap to use. The default is \"default\", which is the\n * only keymap defined in codemirror.js itself.\n * Extra keymaps are found in the CodeMirror keymap directory.\n */\n keyMap?: string;\n\n /**\n * Can be used to specify extra keybindings for the editor, alongside the\n * ones defined by keyMap. Should be either null, or a valid keymap value.\n */\n extraKeys?: any;\n\n /**\n * Can be used to add extra gutters (beyond or instead of the line number\n * gutter).\n * Should be an array of CSS class names, each of which defines a width\n * (and optionally a background),\n * and which will be used to draw the background of the gutters.\n * May include the CodeMirror-linenumbers class, in order to explicitly\n * set the position of the line number gutter\n * (it will default to be to the right of all other gutters).\n * These class names are the keys passed to setGutterMarker.\n */\n gutters?: string[];\n\n /**\n * Determines whether the gutter scrolls along with the content\n * horizontally (false)\n * or whether it stays fixed during horizontal scrolling (true,\n * the default).\n */\n fixedGutter?: boolean;\n\n /**\n * Whether the cursor should be drawn when a selection is active.\n */\n showCursorWhenSelecting?: boolean;\n\n /**\n * When fixedGutter is on, and there is a horizontal scrollbar, by default\n * the gutter will be visible to the left of this scrollbar. If this\n * option is set to true, it will be covered by an element with class\n * CodeMirror-gutter-filler.\n */\n coverGutterNextToScrollbar?: boolean;\n\n /**\n * Controls whether drag-and-drop is enabled.\n */\n dragDrop?: boolean;\n\n /**\n * Explicitly set the line separator for the editor.\n * By default (value null), the document will be split on CRLFs as well as\n * lone CRs and LFs, and a single LF will be used as line separator in all\n * output (such as getValue). When a specific string is given, lines will\n * only be split on that string, and output will, by default, use that\n * same separator.\n */\n lineSeparator?: string | null;\n\n /**\n * Chooses a scrollbar implementation. The default is \"native\", showing\n * native scrollbars. The core library also provides the \"null\" style,\n * which completely hides the scrollbars. Addons can implement additional\n * scrollbar models.\n */\n scrollbarStyle?: string;\n\n /**\n * When enabled, which is the default, doing copy or cut when there is no\n * selection will copy or cut the whole lines that have cursors on them.\n */\n lineWiseCopyCut?: boolean;\n\n /**\n * Whether to scroll past the end of the buffer.\n */\n scrollPastEnd?: boolean;\n }\n\n /**\n * The default configuration options for an editor.\n */\n export let defaultConfig: IConfig = {\n ...CodeEditor.defaultConfig,\n mode: 'null',\n theme: 'jupyter',\n smartIndent: true,\n electricChars: true,\n keyMap: 'default',\n extraKeys: null,\n gutters: [],\n fixedGutter: true,\n showCursorWhenSelecting: false,\n coverGutterNextToScrollbar: false,\n dragDrop: true,\n lineSeparator: null,\n scrollbarStyle: 'native',\n lineWiseCopyCut: true,\n scrollPastEnd: false\n };\n\n /**\n * Add a command to CodeMirror.\n *\n * @param name - The name of the command to add.\n *\n * @param command - The command function.\n */\n export function addCommand(\n name: string,\n command: (cm: CodeMirror.Editor) => void\n ) {\n CodeMirror.commands[name] = command;\n }\n}\n\n/**\n * The namespace for module private data.\n */\nnamespace Private {\n export function createEditor(\n host: HTMLElement,\n config: CodeMirrorEditor.IConfig\n ): CodeMirror.Editor {\n let {\n autoClosingBrackets,\n fontFamily,\n fontSize,\n insertSpaces,\n lineHeight,\n lineWrap,\n wordWrapColumn,\n tabSize,\n readOnly,\n ...otherOptions\n } = config;\n let bareConfig = {\n autoCloseBrackets: autoClosingBrackets,\n indentUnit: tabSize,\n indentWithTabs: !insertSpaces,\n lineWrapping: lineWrap === 'off' ? false : true,\n readOnly,\n ...otherOptions\n };\n return CodeMirror(el => {\n if (fontFamily) {\n el.style.fontFamily = fontFamily;\n }\n if (fontSize) {\n el.style.fontSize = fontSize + 'px';\n }\n if (lineHeight) {\n el.style.lineHeight = lineHeight.toString();\n }\n if (readOnly) {\n el.classList.add(READ_ONLY_CLASS);\n }\n if (lineWrap === 'wordWrapColumn') {\n const lines = el.querySelector('.CodeMirror-lines') as HTMLDivElement;\n lines.style.width = `${wordWrapColumn}ch`;\n }\n if (lineWrap === 'bounded') {\n const lines = el.querySelector('.CodeMirror-lines') as HTMLDivElement;\n lines.style.maxWidth = `${wordWrapColumn}ch`;\n }\n host.appendChild(el);\n }, bareConfig);\n }\n\n /**\n * Indent or insert a tab as appropriate.\n */\n export function indentMoreOrinsertTab(cm: CodeMirror.Editor): void {\n let doc = cm.getDoc();\n let from = doc.getCursor('from');\n let to = doc.getCursor('to');\n let sel = !posEq(from, to);\n if (sel) {\n CodeMirror.commands['indentMore'](cm);\n return;\n }\n // Check for start of line.\n let line = doc.getLine(from.line);\n let before = line.slice(0, from.ch);\n if (/^\\s*$/.test(before)) {\n CodeMirror.commands['indentMore'](cm);\n } else {\n if (cm.getOption('indentWithTabs')) {\n CodeMirror.commands['insertTab'](cm);\n } else {\n CodeMirror.commands['insertSoftTab'](cm);\n }\n }\n }\n\n /**\n * Delete spaces to the previous tab stob in a codemirror editor.\n */\n export function delSpaceToPrevTabStop(cm: CodeMirror.Editor): void {\n let doc = cm.getDoc();\n let from = doc.getCursor('from');\n let to = doc.getCursor('to');\n let sel = !posEq(from, to);\n if (sel) {\n let ranges = doc.listSelections();\n for (let i = ranges.length - 1; i >= 0; i--) {\n let head = ranges[i].head;\n let anchor = ranges[i].anchor;\n doc.replaceRange(\n '',\n CodeMirror.Pos(head.line, head.ch),\n CodeMirror.Pos(anchor.line, anchor.ch)\n );\n }\n return;\n }\n let cur = doc.getCursor();\n let tabsize = cm.getOption('tabSize');\n let chToPrevTabStop = cur.ch - (Math.ceil(cur.ch / tabsize) - 1) * tabsize;\n from = { ch: cur.ch - chToPrevTabStop, line: cur.line };\n let select = doc.getRange(from, cur);\n if (select.match(/^\\ +$/) !== null) {\n doc.replaceRange('', from, cur);\n } else {\n CodeMirror.commands['delCharBefore'](cm);\n }\n }\n\n /**\n * Test whether two CodeMirror positions are equal.\n */\n export function posEq(\n a: CodeMirror.Position,\n b: CodeMirror.Position\n ): boolean {\n return a.line === b.line && a.ch === b.ch;\n }\n\n /**\n * Set a config option for the editor.\n */\n export function setOption<K extends keyof CodeMirrorEditor.IConfig>(\n editor: CodeMirror.Editor,\n option: K,\n value: CodeMirrorEditor.IConfig[K],\n config: CodeMirrorEditor.IConfig\n ): void {\n let el = editor.getWrapperElement();\n switch (option) {\n case 'lineWrap':\n const lineWrapping = value === 'off' ? false : true;\n const lines = el.querySelector('.CodeMirror-lines') as HTMLDivElement;\n const maxWidth =\n value === 'bounded' ? `${config.wordWrapColumn}ch` : null;\n const width =\n value === 'wordWrapColumn' ? `${config.wordWrapColumn}ch` : null;\n lines.style.maxWidth = maxWidth;\n lines.style.width = width;\n editor.setOption('lineWrapping', lineWrapping);\n break;\n case 'wordWrapColumn':\n const { lineWrap } = config;\n if (lineWrap === 'wordWrapColumn' || lineWrap === 'bounded') {\n const lines = el.querySelector('.CodeMirror-lines') as HTMLDivElement;\n const prop = lineWrap === 'wordWrapColumn' ? 'width' : 'maxWidth';\n lines.style[prop] = `${value}ch`;\n }\n break;\n case 'tabSize':\n editor.setOption('indentUnit', value);\n break;\n case 'insertSpaces':\n editor.setOption('indentWithTabs', !value);\n break;\n case 'autoClosingBrackets':\n editor.setOption('autoCloseBrackets', value);\n break;\n case 'readOnly':\n el.classList.toggle(READ_ONLY_CLASS, value);\n editor.setOption(option, value);\n break;\n case 'fontFamily':\n el.style.fontFamily = value;\n break;\n case 'fontSize':\n el.style.fontSize = value ? value + 'px' : null;\n break;\n case 'lineHeight':\n el.style.lineHeight = value ? value.toString() : null;\n break;\n default:\n editor.setOption(option, value);\n break;\n }\n }\n}\n\n/**\n * Add a CodeMirror command to delete until previous non blanking space\n * character or first multiple of tabsize tabstop.\n */\nCodeMirrorEditor.addCommand(\n 'delSpaceToPrevTabStop',\n Private.delSpaceToPrevTabStop\n);\n\n/**\n * Add a CodeMirror command to indent or insert a tab as appropriate.\n */\nCodeMirrorEditor.addCommand(\n 'indentMoreOrinsertTab',\n Private.indentMoreOrinsertTab\n);\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyterlab/codemirror",
3
- "version": "0.17.3",
3
+ "version": "0.18.4",
4
4
  "description": "JupyterLab - CodeMirror Editor Provider",
5
5
  "homepage": "https://github.com/jupyterlab/jupyterlab",
6
6
  "bugs": {
@@ -30,10 +30,10 @@
30
30
  "watch": "tsc -w --listEmittedFiles"
31
31
  },
32
32
  "dependencies": {
33
- "@jupyterlab/apputils": "^0.17.2",
34
- "@jupyterlab/codeeditor": "^0.17.2",
35
- "@jupyterlab/coreutils": "^2.0.2",
36
- "@jupyterlab/observables": "^2.0.2",
33
+ "@jupyterlab/apputils": "^0.18.4",
34
+ "@jupyterlab/codeeditor": "^0.18.4",
35
+ "@jupyterlab/coreutils": "^2.1.4",
36
+ "@jupyterlab/observables": "^2.0.7",
37
37
  "@phosphor/algorithm": "^1.1.2",
38
38
  "@phosphor/coreutils": "^1.3.0",
39
39
  "@phosphor/disposable": "^1.1.2",