在線代碼編輯器 Codemirror 的輕量級 React 組件

代碼編輯器 CodeMirror 的輕量級 React 組件 demo @uiw-react.github.io/react-codem…

特性:

? 自動根據 mode 配置加載 mode 文件。
? 快速簡單的配置 API。

安裝

npm install @uiw/react-codemirror --save
復制代碼

使用

import CodeMirror from '@uiw/react-codemirror';
import 'codemirror/keymap/sublime';
import 'codemirror/theme/eclipse.css';const code = 'const a = 0;';<CodeMirrorvalue={code}options={{keyMap: 'sublime',mode: 'jsx',}}
/>
復制代碼

需要 codemirror 資源,在指定某些語言模式和主題時經常會出現這種情況。 只需設置模式,語言資源就會自動延遲加載。

import CodeMirror from '@uiw/react-codemirror';
import 'codemirror/addon/display/autorefresh';
import 'codemirror/addon/comment/comment';
import 'codemirror/addon/edit/matchbrackets';
import 'codemirror/keymap/sublime';
import 'codemirror/theme/eclipse.css';const code = 'const a = 0;';<CodeMirrorvalue={code}options={{theme: 'eclipse',tabSize: 2,keyMap: 'sublime',mode: 'jsx',}}
/>
復制代碼

改變主題

import CodeMirror from '@uiw/react-codemirror';
import 'codemirror/addon/display/autorefresh';
import 'codemirror/addon/comment/comment';
import 'codemirror/addon/edit/matchbrackets';
import 'codemirror/keymap/sublime';
+ import 'codemirror/theme/monokai.css';const code = 'const a = 0;';<CodeMirrorvalue={code}options={{
+    theme: 'monokai',keyMap: 'sublime',mode: 'jsx',}}/>
復制代碼

設置參數

codemirror options

/** string| The starting value of the editor. Can be a string, or a document object. */
value?: any;/** string|object. The mode to use. When not given, this will default to the first mode that was loaded.
It may be a string, which either simply names the mode or is a MIME type associated with the mode.
Alternatively, it may be an object containing configuration options for the mode,
with a name property that names the mode (for example {name: "javascript", json: true}). */
mode?: any;/** The theme to style the editor with. You must make sure the CSS file defining the corresponding .cm-s-[name] styles is loaded.
The default is "default". */
theme?: string;/** How many spaces a block (whatever that means in the edited language) should be indented. The default is 2. */
indentUnit?: number;/** Whether to use the context-sensitive indentation that the mode provides (or just indent the same as the line before). Defaults to true. */
smartIndent?: boolean;/** The width of a tab character. Defaults to 4. */
tabSize?: number;/** Whether, when indenting, the first N*tabSize spaces should be replaced by N tabs. Default is false. */
indentWithTabs?: boolean;/** Configures whether the editor should re-indent the current line when a character is typed
that might change its proper indentation (only works if the mode supports indentation). Default is true. */
electricChars?: boolean;/** Determines whether horizontal cursor movement through right-to-left (Arabic, Hebrew) text
is visual (pressing the left arrow moves the cursor left)
or logical (pressing the left arrow moves to the next lower index in the string, which is visually right in right-to-left text).
The default is false on Windows, and true on other platforms. */
rtlMoveVisually?: boolean;/** Configures the keymap to use. The default is "default", which is the only keymap defined in codemirror.js itself.
Extra keymaps are found in the keymap directory. See the section on keymaps for more information. */
keyMap?: string;/** Can be used to specify extra keybindings for the editor, alongside the ones defined by keyMap. Should be either null, or a valid keymap value. */
extraKeys?: any;/** Whether CodeMirror should scroll or wrap for long lines. Defaults to false (scroll). */
lineWrapping?: boolean;/** Whether to show line numbers to the left of the editor. */
lineNumbers?: boolean;/** At which number to start counting lines. Default is 1. */
firstLineNumber?: number;/** A function used to format line numbers. The function is passed the line number, and should return a string that will be shown in the gutter. */
lineNumberFormatter?: (line: number) => string;/** Can be used to add extra gutters (beyond or instead of the line number gutter).
Should be an array of CSS class names, each of which defines a width (and optionally a background),
and which will be used to draw the background of the gutters.
May include the CodeMirror-linenumbers class, in order to explicitly set the position of the line number gutter
(it will default to be to the right of all other gutters). These class names are the keys passed to setGutterMarker. */
gutters?: string[];/** Provides an option foldGutter, which can be used to create a gutter with markers indicating the blocks that can be folded. */
foldGutter?: boolean;/** Determines whether the gutter scrolls along with the content horizontally (false)
or whether it stays fixed during horizontal scrolling (true, the default). */
fixedGutter?: boolean;/*** Chooses a scrollbar implementation. The default is "native", showing native scrollbars. The core library also* provides the "null" style, which completely hides the scrollbars. Addons can implement additional scrollbar models.*/
scrollbarStyle?: string;/** boolean|string. This disables editing of the editor content by the user. If the special value "nocursor" is given (instead of simply true), focusing of the editor is also disallowed. */
readOnly?: any;/**Whether the cursor should be drawn when a selection is active. Defaults to false. */
showCursorWhenSelecting?: boolean;/** The maximum number of undo levels that the editor stores. Defaults to 40. */
undoDepth?: number;/** The period of inactivity (in milliseconds) that will cause a new history event to be started when typing or deleting. Defaults to 500. */
historyEventDelay?: number;/** The tab index to assign to the editor. If not given, no tab index will be assigned. */
tabindex?: number;/** Can be used to make CodeMirror focus itself on initialization. Defaults to off.
When fromTextArea is used, and no explicit value is given for this option, it will be set to true when either the source textarea is focused,
or it has an autofocus attribute and no other element is focused. */
autofocus?: boolean;/** Controls whether drag-and - drop is enabled. On by default. */
dragDrop?: boolean;/** When given , this will be called when the editor is handling a dragenter , dragover , or drop event.
It will be passed the editor instance and the event object as arguments.
The callback can choose to handle the event itself , in which case it should return true to indicate that CodeMirror should not do anything further. */
onDragEvent?: (instance: CodeMirror.Editor, event: Event) => boolean;/** This provides a rather low - level hook into CodeMirror's key handling.
If provided, this function will be called on every keydown, keyup, and keypress event that CodeMirror captures.
It will be passed two arguments, the editor instance and the key event.
This key event is pretty much the raw key event, except that a stop() method is always added to it.
You could feed it to, for example, jQuery.Event to further normalize it.
This function can inspect the key event, and handle it if it wants to.
It may return true to tell CodeMirror to ignore the event.
Be wary that, on some browsers, stopping a keydown does not stop the keypress from firing, whereas on others it does.
If you respond to an event, you should probably inspect its type property and only do something when it is keydown
(or keypress for actions that need character data). */
onKeyEvent?: (instance: CodeMirror.Editor, event: Event) => boolean;/** Half - period in milliseconds used for cursor blinking. The default blink rate is 530ms. */
cursorBlinkRate?: number;/** Determines the height of the cursor. Default is 1 , meaning it spans the whole height of the line.
For some fonts (and by some tastes) a smaller height (for example 0.85),
which causes the cursor to not reach all the way to the bottom of the line, looks better */
cursorHeight?: number;/** Highlighting is done by a pseudo background - thread that will work for workTime milliseconds,
and then use timeout to sleep for workDelay milliseconds.
The defaults are 200 and 300, you can change these options to make the highlighting more or less aggressive. */
workTime?: number;/** See workTime. */
workDelay?: number;/** Indicates how quickly CodeMirror should poll its input textarea for changes(when focused).
Most input is captured by events, but some things, like IME input on some browsers, don't generate events that allow CodeMirror to properly detect it.
Thus, it polls. Default is 100 milliseconds. */
pollInterval?: number/** By default, CodeMirror will combine adjacent tokens into a single span if they have the same class.
This will result in a simpler DOM tree, and thus perform better. With some kinds of styling(such as rounded corners),
this will change the way the document looks. You can set this option to false to disable this behavior. */
flattenSpans?: boolean;/** When highlighting long lines, in order to stay responsive, the editor will give up and simply style
the rest of the line as plain text when it reaches a certain position. The default is 10000.
You can set this to Infinity to turn off this behavior. */
maxHighlightLength?: number;/** Specifies the amount of lines that are rendered above and below the part of the document that's currently scrolled into view.
This affects the amount of updates needed when scrolling, and the amount of work that such an update does.
You should usually leave it at its default, 10. Can be set to Infinity to make sure the whole document is always rendered,
and thus the browser's text search works on it. This will have bad effects on performance of big documents. */
viewportMargin?: number;/** Optional lint configuration to be used in conjunction with CodeMirror's linter addon. */
lint?: boolean | LintOptions;/** Optional value to be used in conjunction with CodeMirror’s placeholder add-on. */
placeholder?: string;
復制代碼

Editor

/** Tells you whether the editor currently has focus. */
hasFocus(): boolean;/** Used to find the target position for horizontal cursor motion.start is a { line , ch } object,
amount an integer(may be negative), and unit one of the string "char", "column", or "word".
Will return a position that is produced by moving amount times the distance specified by unit.
When visually is true , motion in right - to - left text will be visual rather than logical.
When the motion was clipped by hitting the end or start of the document, the returned value will have a hitSide property set to true. */
findPosH(start: CodeMirror.Position, amount: number, unit: string, visually: boolean): { line: number; ch: number; hitSide?: boolean; };/** Similar to findPosH , but used for vertical motion.unit may be "line" or "page".
The other arguments and the returned value have the same interpretation as they have in findPosH. */
findPosV(start: CodeMirror.Position, amount: number, unit: string): { line: number; ch: number; hitSide?: boolean; };/** Returns the start and end of the 'word' (the stretch of letters, whitespace, or punctuation) at the given position. */
findWordAt(pos: CodeMirror.Position): CodeMirror.Range;/** Change the configuration of the editor. option should the name of an option, and value should be a valid value for that option. */
setOption(option: string, value: any): void;/** Retrieves the current value of the given option for this editor instance. */
getOption(option: string): any;/** Attach an additional keymap to the editor.
This is mostly useful for add - ons that need to register some key handlers without trampling on the extraKeys option.
Maps added in this way have a higher precedence than the extraKeys and keyMap options, and between them,
the maps added earlier have a lower precedence than those added later, unless the bottom argument was passed,
in which case they end up below other keymaps added with this method. */
addKeyMap(map: any, bottom?: boolean): void;/** Disable a keymap added with addKeyMap.Either pass in the keymap object itself , or a string,
which will be compared against the name property of the active keymaps. */
removeKeyMap(map: any): void;/** Enable a highlighting overlay.This is a stateless mini - mode that can be used to add extra highlighting.
For example, the search add - on uses it to highlight the term that's currently being searched.
mode can be a mode spec or a mode object (an object with a token method). The options parameter is optional. If given, it should be an object.
Currently, only the opaque option is recognized. This defaults to off, but can be given to allow the overlay styling, when not null,
to override the styling of the base mode entirely, instead of the two being applied together. */
addOverlay(mode: any, options?: any): void;/** Pass this the exact argument passed for the mode parameter to addOverlay to remove an overlay again. */
removeOverlay(mode: any): void;/** Retrieve the currently active document from an editor. */
getDoc(): CodeMirror.Doc;/** Attach a new document to the editor. Returns the old document, which is now no longer associated with an editor. */
swapDoc(doc: CodeMirror.Doc): CodeMirror.Doc;/** Get the content of the current editor document. You can pass it an optional argument to specify the string to be used to separate lines (defaults to "\n"). */
getValue(seperator?: string): string;/** Set the content of the current editor document. */
setValue(content: string): void;/** Sets the gutter marker for the given gutter (identified by its CSS class, see the gutters option) to the given value.
Value can be either null, to clear the marker, or a DOM element, to set it. The DOM element will be shown in the specified gutter next to the specified line. */
setGutterMarker(line: any, gutterID: string, value: HTMLElement | null): CodeMirror.LineHandle;/** Remove all gutter markers in the gutter with the given ID. */
clearGutter(gutterID: string): void;/** Set a CSS class name for the given line.line can be a number or a line handle.
where determines to which element this class should be applied, can can be one of "text" (the text element, which lies in front of the selection),
"background"(a background element that will be behind the selection),
or "wrap" (the wrapper node that wraps all of the line's elements, including gutter elements).
class should be the name of the class to apply. */
addLineClass(line: any, where: string, _class_: string): CodeMirror.LineHandle;/** Remove a CSS class from a line.line can be a line handle or number.
where should be one of "text", "background", or "wrap"(see addLineClass).
class can be left off to remove all classes for the specified node, or be a string to remove only a specific class. */
removeLineClass(line: any, where: string, class_?: string): CodeMirror.LineHandle;/** Compute the line at the given pixel height. mode is the relative element
to use to compute this line, it may be "window", "page" (the default), or "local" */
lineAtHeight(height: number, mode?: CoordsMode): number;/** Computes the height of the top of a line, in the coordinate system specified by mode, it may be "window",
"page" (the default), or "local". When a line below the bottom of the document is specified, the returned value
is the bottom of the last line in the document. By default, the position of the actual text is returned.
If includeWidgets is true and the line has line widgets, the position above the first line widget is returned. */
heightAtLine(line: any, mode?: CoordsMode, includeWidgets?: boolean): number;/** Returns the line number, text content, and marker status of the given line, which can be either a number or a line handle. */
lineInfo(line: any): {line: any;handle: any;text: string;/** Object mapping gutter IDs to marker elements. */gutterMarkers: any;textClass: string;bgClass: string;wrapClass: string;/** Array of line widgets attached to this line. */widgets: any;
};/** Puts node, which should be an absolutely positioned DOM node, into the editor, positioned right below the given { line , ch } position.
When scrollIntoView is true, the editor will ensure that the entire node is visible (if possible).
To remove the widget again, simply use DOM methods (move it somewhere else, or call removeChild on its parent). */
addWidget(pos: CodeMirror.Position, node: HTMLElement, scrollIntoView: boolean): void;/** 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?: {/** Whether the widget should cover the gutter. */coverGutter: boolean;/** Whether the widget should stay fixed in the face of horizontal scrolling. */noHScroll: boolean;/** Causes the widget to be placed above instead of below the text of the line. */above: boolean;/** When true, will cause the widget to be rendered even if the line it is associated with is hidden. */showIfHidden: boolean;
}): CodeMirror.LineWidget;/** Programatically set the size of the editor (overriding the applicable CSS rules).
width and height height can be either numbers(interpreted as pixels) or CSS units ("100%", for example).
You can pass null for either of them to indicate that that dimension should not be changed. */
setSize(width: any, height: any): void;/** Scroll the editor to a given(pixel) position.Both arguments may be left as null or undefined to have no effect. */
scrollTo(x?: number | null, y?: number | null): void;/** Get an { left , top , width , height , clientWidth , clientHeight } object that represents the current scroll position, the size of the scrollable area,
and the size of the visible area(minus scrollbars). */
getScrollInfo(): CodeMirror.ScrollInfo;/** Scrolls the given element into view. pos is a { line , ch } position, referring to a given character, null, to refer to the cursor.
The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */
scrollIntoView(pos: CodeMirror.Position | null, margin?: number): void;/** Scrolls the given element into view. pos is a { left , top , right , bottom } object, in editor-local coordinates.
The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */
scrollIntoView(pos: { left: number; top: number; right: number; bottom: number; }, margin: number): void;/** Scrolls the given element into view. pos is a { line, ch } object, in editor-local coordinates.
The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */
scrollIntoView(pos: { line: number, ch: number }, margin?: number): void;/** Scrolls the given element into view. pos is a { from, to } object, in editor-local coordinates.
The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */
scrollIntoView(pos: { from: CodeMirror.Position, to: CodeMirror.Position }, margin: number): void;/** Returns an { left , top , bottom } object containing the coordinates of the cursor position.
If mode is "local", they will be relative to the top-left corner of the editable document.
If it is "page" or not given, they are relative to the top-left corner of the page.
where is a boolean indicating whether you want the start(true) or the end(false) of the selection. */
cursorCoords(where: boolean, mode?: CoordsMode): { left: number; top: number; bottom: number; };/** Returns an { left , top , bottom } object containing the coordinates of the cursor position.
If mode is "local", they will be relative to the top-left corner of the editable document.
If it is "page" or not given, they are relative to the top-left corner of the page.
where specifies the precise position at which you want to measure. */
cursorCoords(where: CodeMirror.Position, mode?: CoordsMode): { left: number; top: number; bottom: number; };/** Returns the position and dimensions of an arbitrary character. pos should be a { line , ch } object.
If mode is "local", they will be relative to the top-left corner of the editable document.
If it is "page" or not given, they are relative to the top-left corner of the page.
This differs from cursorCoords in that it'll give the size of the whole character,
rather than just the position that the cursor would have when it would sit at that position. */
charCoords(pos: CodeMirror.Position, mode?: CoordsMode): { left: number; right: number; top: number; bottom: number; };/** Given an { left , top } object , returns the { line , ch } position that corresponds to it.
The optional mode parameter determines relative to what the coordinates are interpreted.
It may be "window", "page" (the default), or "local". */
coordsChar(object: { left: number; top: number; }, mode?: CoordsMode): CodeMirror.Position;/** Returns the line height of the default font for the editor. */
defaultTextHeight(): number;/** Returns the pixel width of an 'x' in the default font for the editor.
(Note that for non - monospace fonts , this is mostly useless, and even for monospace fonts, non - ascii characters might have a different width). */
defaultCharWidth(): number;/** Returns a { from , to } object indicating the start (inclusive) and end (exclusive) of the currently rendered part of the document.
In big documents, when most content is scrolled out of view, CodeMirror will only render the visible part, and a margin around it.
See also the viewportChange event. */
getViewport(): { from: number; to: number };/** If your code does something to change the size of the editor element (window resizes are already listened for), or unhides it,
you should probably follow up by calling this method to ensure CodeMirror is still looking as intended. */
refresh(): void;/** Retrieves information about the token the current mode found before the given position (a {line, ch} object). */
getTokenAt(pos: CodeMirror.Position, precise?: boolean): Token;/** This is a (much) cheaper version of getTokenAt useful for when you just need the type of the token at a given position, 
and no other information. Will return null for unstyled tokens, and a string, potentially containing multiple 
space-separated style names, otherwise. */
getTokenTypeAt(pos: CodeMirror.Position): string;/** This is similar to getTokenAt, but collects all tokens for a given line into an array. */
getLineTokens(line: number, precise?: boolean): Token[];/** Returns the mode's parser state, if any, at the end of the given line number.
If no line number is given, the state at the end of the document is returned.
This can be useful for storing parsing errors in the state, or getting other kinds of contextual information for a line. */
getStateAfter(line?: number): any;/** CodeMirror internally buffers changes and only updates its DOM structure after it has finished performing some operation.
If you need to perform a lot of operations on a CodeMirror instance, you can call this method with a function argument.
It will call the function, buffering up all changes, and only doing the expensive update after the function returns.
This can be a lot faster. The return value from this method will be the return value of your function. */
operation<T>(fn: ()=> T): T;/** Adjust the indentation of the given line.
The second argument (which defaults to "smart") may be one of:
"prev" Base indentation on the indentation of the previous line.
"smart" Use the mode's smart indentation if available, behave like "prev" otherwise.
"add" Increase the indentation of the line by one indent unit.
"subtract" Reduce the indentation of the line. */
indentLine(line: number, dir?: string): void;/** Tells you whether the editor's content can be edited by the user. */
isReadOnly(): boolean;/** Runs the command with the given name on the editor. */
execCommand(name: string): void;/** Give the editor focus. */
focus(): void;/** Returns the hidden textarea used to read input. */
getInputField(): HTMLTextAreaElement;/** Returns the DOM node that represents the editor, and controls its size. Remove this from your tree to delete an editor instance. */
getWrapperElement(): HTMLElement;/** Returns the DOM node that is responsible for the scrolling of the editor. */
getScrollerElement(): HTMLElement;/** Fetches the DOM node that contains the editor gutters. */
getGutterElement(): HTMLElement;/** Events are registered with the on method (and removed with the off method).
These are the events that fire on the instance object. The name of the event is followed by the arguments that will be passed to the handler.
The instance argument always refers to the editor instance. */
on(eventName: string, handler: (instance: CodeMirror.Editor) => void ): void;
off(eventName: string, handler: (instance: CodeMirror.Editor) => void ): void;/** Fires every time the content of the editor is changed. */
on(eventName: 'change', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeLinkedList) => void ): void;
off(eventName: 'change', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeLinkedList) => void ): void;/** Like the "change" event, but batched per operation, passing an* array containing all the changes that happened in the operation.* This event is fired after the operation finished, and display* changes it makes will trigger a new operation. */
on(eventName: 'changes', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeLinkedList[]) => void ): void;
off(eventName: 'changes', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeLinkedList[]) => void ): void;/** This event is fired before a change is applied, and its handler may choose to modify or cancel the change.
The changeObj never has a next property, since this is fired for each individual change, and not batched per operation.
Note: you may not do anything from a "beforeChange" handler that would cause changes to the document or its visualization.
Doing so will, since this handler is called directly from the bowels of the CodeMirror implementation,
probably cause the editor to become corrupted. */
on(eventName: 'beforeChange', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeCancellable) => void ): void;
off(eventName: 'beforeChange', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeCancellable) => void ): void;/** Will be fired when the cursor or selection moves, or any change is made to the editor content. */
on(eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void ): void;
off(eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void ): void;/** This event is fired before the selection is moved. Its handler may modify the resulting selection head and anchor.
Handlers for this event have the same restriction as "beforeChange" handlers � they should not do anything to directly update the state of the editor. */
on(eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, selection: { head: CodeMirror.Position; anchor: CodeMirror.Position; }) => void ): void;
off(eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, selection: { head: CodeMirror.Position; anchor: CodeMirror.Position; }) => void ): void;/** Fires whenever the view port of the editor changes (due to scrolling, editing, or any other factor).
The from and to arguments give the new start and end of the viewport. */
on(eventName: 'viewportChange', handler: (instance: CodeMirror.Editor, from: number, to: number) => void ): void;
off(eventName: 'viewportChange', handler: (instance: CodeMirror.Editor, from: number, to: number) => void ): void;/** Fires when the editor gutter (the line-number area) is clicked. Will pass the editor instance as first argument,
the (zero-based) number of the line that was clicked as second argument, the CSS class of the gutter that was clicked as third argument,
and the raw mousedown event object as fourth argument. */
on(eventName: 'gutterClick', handler: (instance: CodeMirror.Editor, line: number, gutter: string, clickEvent: Event) => void ): void;
off(eventName: 'gutterClick', handler: (instance: CodeMirror.Editor, line: number, gutter: string, clickEvent: Event) => void ): void;/** Fires whenever the editor is focused. */
on(eventName: 'focus', handler: (instance: CodeMirror.Editor) => void ): void;
off(eventName: 'focus', handler: (instance: CodeMirror.Editor) => void ): void;/** Fires whenever the editor is unfocused. */
on(eventName: 'blur', handler: (instance: CodeMirror.Editor) => void ): void;
off(eventName: 'blur', handler: (instance: CodeMirror.Editor) => void ): void;/** Fires when the editor is scrolled. */
on(eventName: 'scroll', handler: (instance: CodeMirror.Editor) => void ): void;
off(eventName: 'scroll', handler: (instance: CodeMirror.Editor) => void ): void;/** Will be fired whenever CodeMirror updates its DOM display. */
on(eventName: 'update', handler: (instance: CodeMirror.Editor) => void ): void;
off(eventName: 'update', handler: (instance: CodeMirror.Editor) => void ): void;/** Fired whenever a line is (re-)rendered to the DOM. Fired right after the DOM element is built, before it is added to the document.
The handler may mess with the style of the resulting element, or add event handlers, but should not try to change the state of the editor. */
on(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: CodeMirror.LineHandle, element: HTMLElement) => void ): void;
off(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: CodeMirror.LineHandle, element: HTMLElement) => void ): void;/** Fires when one of the DOM events fires. */
on(eventName: DOMEvent, handler: (instance: CodeMirror.Editor, event: Event) => void ): void;
off(eventName: DOMEvent, handler: (instance: CodeMirror.Editor, event: Event) => void ): void;/** Expose the state object, so that the Editor.state.completionActive property is reachable*/
state: any;
復制代碼

Events

codemirror events

License

Licensed under the MIT License.

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/451131.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/451131.shtml
英文地址,請注明出處:http://en.pswp.cn/news/451131.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

「機械」4大傳動方式優劣對比:機械、電氣、氣壓、液壓

傳動方式有很多種。目前應用比較多的四大類傳動方式&#xff08;機械、電氣、液壓和氣壓&#xff09;中&#xff0c;沒有一種動力傳動是十全十美的。今天跟大家分享4種傳動方式的優劣對比。 一. 機械傳動 1. 齒輪傳動 齒輪傳動是機械傳動中應用最廣的一種傳動形式。它的傳動比較…

一次性獲取多個oracle序列的值,實現關聯表多數據的批量insert

前些天發現了一個巨牛的人工智能學習網站&#xff0c;通俗易懂&#xff0c;風趣幽默&#xff0c;忍不住分享一下給大家。點擊跳轉到教程。 業務 要求批量導入不小于10W條數據到 user 表&#xff0c;但是user表在 insert 每條數據的同時要 insert 一條對應數據到 customer表…

開始使用C++11的9個理由

如果你的代碼工作正常并且表現良好&#xff0c;你可能會想知道為什么還要使用C 11。當然了&#xff0c;使用用最新的技術感覺很好&#xff0c;但是事實上它是否值得呢&#xff1f; 在我看來&#xff0c;答案毫無疑問是肯定的。我在下面給出了9個理由&#xff0c;它們分為兩類&a…

MySQL批量update數據(更新的數據值不同)

(一)純mysql: ?UPDATE my_table SETstatus CASE idWHEN 1 THEN 3WHEN 2 THEN 4WHEN 3 THEN 5END,title CASE idWHEN 1 THEN New Title 1WHEN 2 THEN New Title 2WHEN 3 THEN New Title 3END WHERE id IN (1,2,3) (二)mybatis寫法 1:foreach <update id"batchUpd…

webpack+vue-cli 中proxyTable配置接口地址代理

在項目開發的時候&#xff0c;接口聯調的時候一般都是同域名下&#xff0c;且不存在跨域的情況下進行接口聯調&#xff0c;但是當我們現在使用vue-cli進行項目打包的時候&#xff0c;我們在本地啟動服務器后&#xff0c;比如本地開發服務下是 http://localhost:8080 這樣的訪問…

AMQP 協議介紹

RabbitMQ 是遵從AMQP 協議的&#xff0c; 換句話說&#xff0c; RabbitMQ 就是AMQP 協議的Erlang 的實現(當然RabbitMQ 還支持STOMP2 、MQTT3 等協議) 0 AMQP 的模型架構和RabbitMQ 的模型架構是一樣的&#xff0c;生產者將消息發送給交換器&#xff0c;交換器和隊列綁定。當生…

關聯表多數據的批量insert (批量導入,測試19W條數據用時46秒)

前些天發現了一個巨牛的人工智能學習網站&#xff0c;通俗易懂&#xff0c;風趣幽默&#xff0c;忍不住分享一下給大家。點擊跳轉到教程。 一、業務需求 &#xff1a;作多個批量導入 &#xff0c;根據業務不同&#xff0c;每條數據導入前作各種驗證&#xff0c; 導入后提示驗證…

Java已死?九百萬程序員說不

Java沒死&#xff0c;事實上它擁有足夠的能量讓你的應用跑起來。那些對Java吹毛求疵人頻繁地聚焦在一些小眾問題上&#xff0c;總是和其他技術或者語言做些不公平的對比&#xff0c;這些語言并沒有像Java一樣得到廣泛應用及長遠的歷史。 現在的小孩都能學Java&#xff0c;它在…

Linux SSH遠程管理故障如何排查?

SSH遠程管理故障排查方案&#xff1a;1、檢測兩個機器是否暢通兩個機器之間是否暢通&#xff0c;查看物理鏈路是否有問題(網線網卡、IP是否正確)第1步&#xff1a;物理鏈路是否暢通&#xff0c;比喻為“高速公路是否暢通”ping 排查客戶端到服務端的線路問題&#xff0c;ping是…

CSS中position的absolute和relative用法

static: HTML元素的默認定位方式absolute: 將對象從文檔流中拖出&#xff0c;使用left&#xff0c;right&#xff0c;top&#xff0c;bottom等屬性進行絕對定位。而其層疊通過z-index屬性定義。絕對定位的元素的位置相對于最近的已定位父元素&#xff0c;如果元素沒有已定位的父…

Spring HttpMessageNotReadableException異常

&#xff08;一&#xff09;現象 我們在進行服務間的rpc調用時&#xff0c;可能會遇到org.springframework.http.converter.HttpMessageNotReadableException異常。 其具體報錯如下&#xff1a; {"timestamp": 1456043810789,"status": 400,"error…

解決 -- java 調用webservice 服務端收到參數為null

前些天發現了一個巨牛的人工智能學習網站&#xff0c;通俗易懂&#xff0c;風趣幽默&#xff0c;忍不住分享一下給大家。點擊跳轉到教程。 我的客戶端和服務端都寫的很簡單&#xff0c;只是調用服務的時候&#xff0c; 服務端得不到參數&#xff0c;后來發現只改一個地方就可…

fastJson性能測試

測試裝備&#xff1a; mac pro 6核12線程 測試代碼&#xff1a; &#xff08;1&#xff09;序列化對象&#xff1a; import lombok.Data;Data public class User {int id;String name;int age;String address; } &#xff08;2&#xff09;序列化邏輯&#xff1a; import…

避免流量高峰期CDN問題的10個方法

在視頻流媒體中&#xff0c;因平臺火爆而出現問題是件好事。至少&#xff0c;這比根本沒有觀眾要好。\\也許你正在使用世界級的CDN&#xff0c;但是&#xff0c;在大型賽事期間&#xff0c;當CDN的服務器和對等點流量變得飽和的時候&#xff0c;一些用戶還是無法享受到流暢的體…

Android應用進入爆發期 手機游戲仍是市場重心

近日&#xff0c;91無線發布了《91無線移動應用發展趨勢報告&#xff08;Android版&#xff09;》。報告顯示&#xff0c;2012年&#xff0c;無論Android移動應用用戶下載還是開發者研發均呈爆發態勢&#xff0c;手機游戲仍是市場重心所在。同時&#xff0c;Android移動應用下載…

MQTT Client軟件-MQTTBox

最近發現了一個連接mqtt broker的軟件&#xff1a;MQTTBox。GitHub地址&#xff1a;https://github.com/workswithweb/MQTTBox 官網網站的介紹為&#xff1a;使用MQTTBox增強你的物聯網流程 MQTT客戶端特性 支持TCP、TLS、Web Sockets和安全的Web Sockets連接MQTT服務器支持各種…

fastJson toJSONString注意點

fastJosn是阿里爸爸推出一款高性能序列化工具&#xff0c;號稱最快的json序列化工具。不過好像也就那樣&#xff0c;在量比較大的時候優勢才會明顯。單次序列化時間還是會達到幾十毫秒的級別。 Fastjson is a Java library that can be used to convert Java Objects into the…

WebService中文件傳輸

前些天發現了一個巨牛的人工智能學習網站&#xff0c;通俗易懂&#xff0c;風趣幽默&#xff0c;忍不住分享一下給大家。點擊跳轉到教程。 WebService處理傳遞普通的信息&#xff0c;還可以傳輸文件&#xff0c;下面介紹WebService是怎么完成文件傳輸的。 1、 首先編寫服務器端…

Django框架-Form組件

一、DjangoForm組件介紹 我們之前在html頁面中利用form表單向后端提交數據時&#xff0c;都會寫一些獲取用戶輸入的標簽并且用form標簽把它們包起來。 與此同時我們在好多場景下都需要對用戶的輸入做校驗&#xff0c;比如驗證用戶是否輸入&#xff0c;輸入的長度和格式等是否正…