Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(options: RawEditor.IOptions) {
super({
orientation: 'horizontal',
renderer: SplitPanel.defaultRenderer,
spacing: 1
});
const { commands, editorFactory, registry } = options;
this.registry = registry;
this._commands = commands;
// Create read-only defaults editor.
const defaults = (this._defaults = new CodeEditorWrapper({
model: new CodeEditor.Model(),
factory: editorFactory
}));
defaults.editor.model.value = '';
defaults.editor.model.mimeType = 'text/javascript';
defaults.editor.setOption('readOnly', true);
// Create read-write user settings editor.
const user = (this._user = new CodeEditorWrapper({
model: new CodeEditor.Model(),
factory: editorFactory,
config: { lineNumbers: true }
}));
user.addClass(USER_CLASS);
user.editor.model.mimeType = 'text/javascript';
constructor(value?: string, options?: Partial) {
if (options && options.readOnly) {
// Prevent readonly editor from trapping tabs
options.extraKeys = {Tab: false, 'Shift-Tab': false};
}
super({
model: new CodeEditor.Model({value}),
factory: function() {
let factory = new CodeMirrorEditorFactory(options);
return factory.newInlineEditor.bind(factory);
}()
});
this.staticLoaded = false;
EditorWidget.editors.push(this.cm);
}
it('should create a CodeEditor Model with an initial value', () => {
let other = new CodeEditor.Model({ value: 'Initial text here' });
expect(other).to.be.an.instanceof(CodeEditor.Model);
expect(other.value.text).to.equal('Initial text here');
other.dispose();
});
it('should be called upon an editor edge request', async () => {
const history = new TestHistory({ session });
expect(history.methods).to.not.contain('onEdgeRequest');
const host = document.createElement('div');
const model = new CodeEditor.Model();
const editor = new CodeMirrorEditor({ model, host });
history.editor = editor;
history.push('foo');
const promise = signalToPromise(editor.model.value.changed);
editor.edgeRequested.emit('top');
expect(history.methods).to.contain('onEdgeRequest');
await promise;
expect(editor.model.value.text).to.equal('foo');
});
});
it('should create a CodeEditor Model with an initial mimetype', () => {
let other = new CodeEditor.Model({
value: 'import this',
mimeType: 'text/x-python'
});
expect(other).to.be.an.instanceof(CodeEditor.Model);
expect(other.mimeType).to.equal('text/x-python');
expect(other.value.text).to.equal('import this');
other.dispose();
});
});
function createEditorWidget(): CodeEditorWrapper {
const model = new CodeEditor.Model();
const factory = (options: CodeEditor.IOptions) => {
return new CodeMirrorEditor(options);
};
return new CodeEditorWrapper({ factory, model });
}
function createEditorWidget(): CodeEditorWrapper {
let model = new CodeEditor.Model();
let factory = (options: CodeEditor.IOptions) => {
return new CodeMirrorEditor(options);
};
return new CodeEditorWrapper({ factory, model });
}
beforeEach(() => {
model = new CodeEditor.Model();
});
function createEditorWidget(): CodeEditorWrapper {
let model = new CodeEditor.Model();
let factory = (options: CodeEditor.IOptions) => {
return new CodeMirrorEditor(options);
};
return new CodeEditorWrapper({ factory, model });
}
constructor(
protected language = () => 'python',
protected path = () => 'dummy.py',
protected file_extension = () => 'py'
) {
const factoryService = new CodeMirrorEditorFactory();
this.connections = new Map();
this.host = document.createElement('div');
document.body.appendChild(this.host);
let model = new CodeEditor.Model();
this.ce_editor = factoryService.newDocumentEditor({
host: this.host,
model
});
this.virtual_editor = new VirtualFileEditor(
language,
file_extension,
path,
this.ce_editor.editor
);
}