當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript codemirror.CodeMirrorEditorFactory類代碼示例

本文整理匯總了TypeScript中@jupyterlab/codemirror.CodeMirrorEditorFactory的典型用法代碼示例。如果您正苦於以下問題:TypeScript CodeMirrorEditorFactory類的具體用法?TypeScript CodeMirrorEditorFactory怎麽用?TypeScript CodeMirrorEditorFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CodeMirrorEditorFactory類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

 it('should create a new editor with given options', () => {
   let factory = new CodeMirrorEditorFactory(options);
   let editor = factory.newDocumentEditor({host, model}) as CodeMirrorEditor;
   expect(editor).to.be.a(CodeMirrorEditor);
   for (let key in Object.keys(options)) {
     let option = key as keyof CodeMirrorEditor.IConfig;
     expect(editor.getOption(option)).to.equal(options[option]);
   }
   editor.dispose();
 });
開發者ID:7125messi,項目名稱:jupyterlab,代碼行數:10,代碼來源:factory.spec.ts

示例2: it

 it('should create a new editor with given options', () => {
   let factory = new CodeMirrorEditorFactory(options);
   let editor = factory.newDocumentEditor({host, model});
   expect(editor).to.be.a(CodeMirrorEditor);
   let inner = (editor as CodeMirrorEditor).editor;
   for (let key of Object.keys(options)) {
     expect(inner.getOption(key)).to.equal((options as any)[key]);
   }
   editor.dispose();
 });
開發者ID:charnpreetsingh185,項目名稱:jupyterlab,代碼行數:10,代碼來源:factory.spec.ts

示例3: describe

describe('editorwidget', () => {

  let factoryService = new CodeMirrorEditorFactory();
  let modelFactory = new TextModelFactory();
  let mimeTypeService = new CodeMirrorMimeTypeService();
  let context: DocumentRegistry.CodeContext;
  let manager: ServiceManager.IManager;

  before((done) => {
    manager = new ServiceManager();
    manager.ready.then(done, done);
  });

  describe('EditorWidget', () => {

    let widget: EditorWidget;

    beforeEach(() => {
      let path = utils.uuid() + '.py';
      context = new Context({ manager, factory: modelFactory, path });
      widget = new EditorWidget({
        factory: options => factoryService.newDocumentEditor(options),
        mimeTypeService,
        context
      });
    });

    afterEach(() => {
      widget.dispose();
    });

    describe('#constructor()', () => {

      it('should create an editor widget', () => {
        expect(widget).to.be.an(EditorWidget);
      });

      it('should update the editor text when the model changes', (done) => {
        context.save().catch(done);
        context.ready.then(() => {
          widget.context.model.fromString('foo');
          expect(widget.editor.model.value.text).to.be('foo');
        }).then(done, done);
      });

      it('should set the mime type for the path', () => {
        expect(widget.editor.model.mimeType).to.be('text/x-python');
      });

      it('should update the mime type when the path changes', (done) => {
        context.pathChanged.connect((sender, args) => {
          expect(widget.editor.model.mimeType).to.be('text/x-julia');
          done();
        });
        context.save().then(() => {
          return manager.contents.rename(context.path, utils.uuid() + '.jl');
        }).catch(done);
      });

      it('should set the title for the path', () => {
        expect(widget.title.label).to.be(context.path);
      });

      it('should add the dirty class when the model is dirty', (done) => {
        context.save().catch(done);
        context.ready.then(() => {
          context.model.fromString('bar');
          expect(widget.title.className).to.contain('jp-mod-dirty');
        }).then(done, done);
      });

      it('should update the title when the path changes', (done) => {
        let path = utils.uuid() + '.jl';
        context.pathChanged.connect((sender, args) => {
          expect(widget.title.label).to.be(path);
          done();
        });
        context.save().then(() => {
          return manager.contents.rename(context.path, path);
        }).catch(done);
      });

    });

    describe('#context', () => {

      it('should be the context used by the widget', () => {
        expect(widget.context).to.be(context);
      });

    });

  });

  describe('EditorWidgetFactory', () => {

    let widgetFactory = new EditorWidgetFactory({
      editorServices: {
        factoryService,
        mimeTypeService
//.........這裏部分代碼省略.........
開發者ID:faricacarroll,項目名稱:jupyterlab,代碼行數:101,代碼來源:widget.spec.ts

示例4: it

 it('should create a new editor', () => {
   const factory = new CodeMirrorEditorFactory();
   const editor = factory.newDocumentEditor({ host, model });
   expect(editor).to.be.an.instanceof(CodeMirrorEditor);
   editor.dispose();
 });
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:6,代碼來源:factory.spec.ts

示例5:

 factory: options => factoryService.newDocumentEditor(options),
開發者ID:faricacarroll,項目名稱:jupyterlab,代碼行數:1,代碼來源:widget.spec.ts


注:本文中的@jupyterlab/codemirror.CodeMirrorEditorFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。