本文整理匯總了TypeScript中codemirror.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript codemirror.default方法的具體用法?TypeScript codemirror.default怎麽用?TypeScript codemirror.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類codemirror
的用法示例。
在下文中一共展示了codemirror.default方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: require
}).then(kernel => {
// Create a codemirror instance
let code = require('../widget_code.json').join("\n");
let inputarea = document.getElementsByClassName("inputarea")[0] as HTMLElement;
let editor = CodeMirror(inputarea, {
value: code,
mode: "python",
tabSize: 4,
showCursorWhenSelecting: true,
viewportMargin: Infinity,
readOnly: true
});
// Create the widget area and widget manager
let widgetarea = document.getElementsByClassName("widgetarea")[0] as HTMLElement;
let manager = new WidgetManager(kernel, widgetarea);
// Run backend code to create the widgets. You could also create the
// widgets in the frontend, like the other widget examples demonstrate.
let request = kernel.requestExecute({ code: code });
request.onIOPub = (msg) => {
// If we have a display message, display the widget.
console.log(msg);
}
});
示例2: initialize
initialize(): void {
this._editor = CodeMirror(this.editorHostEl, this.getEditorOptions());
this.changeEventListener = () => {
this.onValueChanged();
};
this.keyDownEventListener = (_, event: KeyboardEvent) => {
this.onKeyDown(event);
};
this.focusEventListener = () => {
this.handleFocus(true);
this.emitEvent(new NoteSnippetEditorFocusedEvent(this._ref));
};
this.blurEventListener = () => {
this.handleFocus(false);
this.emitEvent(new NoteSnippetEditorBlurredEvent(this._ref));
};
this._editor.on('change', this.changeEventListener);
this._editor.on('keydown', this.keyDownEventListener);
this._editor.on('focus', this.focusEventListener);
this._editor.on('blur', this.blurEventListener);
this._afterInitialized.next();
}
示例3: init
init(pane: HTMLElement, edit: CodeMirror.Editor, options: CodeMirror.MergeView.MergeViewEditorConfiguration) {
this.edit = edit;
(this.edit.state.diffViews || (this.edit.state.diffViews = [])).push(this);
let orig = this.model.remote;
this.orig = CodeMirror(pane, copyObj({value: orig}, copyObj(options)));
this.orig.state.diffViews = [this];
this.chunks = this.model.getChunks();
this.dealigned = false;
this.showDifferences = options.showDifferences !== false;
this.forceUpdate = this.registerUpdate();
this.setScrollLock(true, false);
this.registerScroll();
}
示例4: require
}).then(kernel => {
// Create a codemirror instance
let code = require('../widget_code.json').join('\n');
let inputarea = document.getElementsByClassName('inputarea')[0] as HTMLElement;
let editor = CodeMirror(inputarea, {
value: code,
mode: 'python',
tabSize: 4,
showCursorWhenSelecting: true,
viewportMargin: Infinity,
readOnly: true
});
// Create the widget area and widget manager
let widgetarea = document.getElementsByClassName('widgetarea')[0] as HTMLElement;
let manager = new WidgetManager(kernel, widgetarea);
// Run backend code to create the widgets. You could also create the
// widgets in the frontend, like the other widget examples demonstrate.
let execution = kernel.requestExecute({ code: code });
execution.onIOPub = (msg) => {
// If we have a display message, display the widget.
if (KernelMessage.isDisplayDataMsg(msg)) {
let widgetData: any = msg.content.data['application/vnd.jupyter.widget-view+json'];
if (widgetData !== undefined && widgetData.version_major === 2) {
let model = manager.get_model(widgetData.model_id);
if (model !== undefined) {
model.then(model => {
manager.display_model(msg, model);
});
}
}
}
};
});
示例5: constructor
constructor(node: Node, options: MergeViewEditorConfiguration) {
this.options = options;
var remote = options.remote;
var local = options.local;
var merged = null; //options.merged;
var wrap = []
var left: DiffView = this.left = null;
var right: DiffView = this.right = null;
var merge: DiffView = this.merge = null
this.base = null;
var self = this;
this.diffViews = [];
this.aligners = [];
options.value = (options.remote.base !== null ?
options.remote.base : options.remote.remote);
options.lineNumbers = options.lineNumbers !== false;
/**
* Different cases possible:
* - Local and merged supplied: Merge:
* - Always use left, right and merge panes
* - Use base if `showBase` not set to false
* - Only remote supplied: Diff:
* - No change: Use ony base editor
* - Entire content added/deleted: Use only base editor,
* but with different classes
* - Partial changes: Use base + right editor
* */
var hasMerge = local !== null && merged !== null;
if (hasMerge) {
console.assert(remote.base == local.base);
left = this.left = new DiffView(local, 'left', this.alignChunks);
this.diffViews.push(left);
//wrap.push(left.buildGap());
var leftPane = elt('div', null, 'CodeMirror-merge-pane');
wrap.push(leftPane);
let showBase = options.showBase !== false;
if (showBase) {
var basePane = elt('div', null, 'CodeMirror-merge-pane');
wrap.push(basePane);
}
right = this.right = new DiffView(remote, 'right', this.alignChunks);
this.diffViews.push(right);
//wrap.push(right.buildGap());
var rightPane = elt('div', null, 'CodeMirror-merge-pane');
wrap.push(rightPane);
rightPane.className += ' CodeMirror-merge-pane-rightmost';
wrap.push(elt('div', null, null, 'height: 0; clear: both;'));
/*merge = this.merge = new DiffView(merged, 'merge', this.alignChunks);
var mergePane = elt('div', null, 'CodeMirror-merge-pane');
wrap.push(mergePane);*/
var panes = 3 + (showBase ? 1 : 0);
} else {
// Base always used
var basePane = elt('div', null, 'CodeMirror-merge-pane');
wrap.push(basePane);
if (remote.unchanged || remote.added || remote.deleted) {
if (remote.unchanged) {
basePane.className += ' CodeMirror-merge-pane-unchanged';
} else if (remote.added) {
basePane.className += ' CodeMirror-merge-pane-added';
} else if (remote.deleted) {
basePane.className += ' CodeMirror-merge-pane-deleted';
}
var panes = 1;
} else {
right = this.right = new DiffView(remote, 'right', this.alignChunks.bind(this));
this.diffViews.push(right);
var rightPane = elt('div', null, 'CodeMirror-merge-pane');
wrap.push(right.buildGap());
wrap.push(rightPane);
rightPane.className += ' CodeMirror-merge-pane-rightmost';
var panes = 2;
}
wrap.push(elt('div', null, null, 'height: 0; clear: both;'));
}
var wrapElt = this.wrap = node.appendChild(elt('div', wrap, 'CodeMirror-merge CodeMirror-merge-' + panes + 'pane'));
if (basePane !== undefined) {
this.base = CodeMirror(basePane, copyObj(options));
}
if (left) left.init(leftPane, this.base,
copyObj({readOnly: true}, copyObj(options)) as CodeMirror.MergeView.MergeViewEditorConfiguration);
if (right) right.init(rightPane, this.base,
copyObj({readOnly: true}, copyObj(options)) as CodeMirror.MergeView.MergeViewEditorConfiguration);
//if (merge) right.init(mergePane, this.base, copyObj({readOnly: false}, copyObj(options)));
if (options.collapseIdentical) {
this.base.operation(function() {
collapseIdenticalStretches(self, options.collapseIdentical);
});
}
//.........這裏部分代碼省略.........