UNPKG

@aomao/plugin-codeblock-vue

Version:
38 lines (37 loc) 1.65 kB
import CodeMirror, { EditorConfiguration, Editor } from 'codemirror'; import { EditorInterface, NodeInterface } from '@aomao/engine'; import { CodeBlockEditorInterface, Options } from './types'; declare class CodeBlockEditor implements CodeBlockEditorInterface { private editor; private options; private styleMap; codeMirror?: Editor; mode: string; container: NodeInterface; constructor(editor: EditorInterface, options: Options); renderTemplate(): string; getConfig(value: string, mode?: string): EditorConfiguration; getSyntax(mode: string): string; create(mode: string, value: string, options?: EditorConfiguration): CodeMirror.Editor; setAutoWrap(value: boolean): void; update(mode: string, code?: string): void; render(mode: string, value: string, options?: EditorConfiguration): void; save(): void; focus(): void; select(start?: boolean): void; toHtml(col: number, text: string, style?: string, tabSize?: number): string; /** * 代码来自 runmode addon * 支持行号需要考虑复制粘贴问题 * * runmode 本身不支持行号,见 https://github.com/codemirror/CodeMirror/issues/3364 * 可参考的解法 https://stackoverflow.com/questions/14237361/use-codemirror-for-standalone-syntax-highlighting-with-line-numbers * * ref: * - https://codemirror.net/doc/manual.html#addons * - https://codemirror.net/addon/runmode/runmode.js */ runMode(string: string, modespec: string, callback: any, options: any): void; destroy(): void; } export default CodeBlockEditor;