• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript codemirror.on函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中codemirror.on函数的典型用法代码示例。如果您正苦于以下问题:TypeScript on函数的具体用法?TypeScript on怎么用?TypeScript on使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了on函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: showTooltipFor

 function showTooltipFor(e, content, node, state, cm) {
   var tooltip = showTooltip(e, content);
   function hide() {
     CodeMirror.off(node, "mouseout", hide);
     CodeMirror.off(node, "click", hide);
     node.className = node.className.replace(HOVER_CLASS, "");
     if (tooltip) {
       hideTooltip(tooltip);
       tooltip = null;
     }
     cm.removeKeyMap(state.keyMap);
   }
   var poll = setInterval(function() {
     if (tooltip)
       for ( var n = node;; n = n.parentNode) {
         if (n == document.body)
           return;
         if (!n) {
           hide();
           break;
         }
       }
     if (!tooltip)
       return clearInterval(poll);
   }, 400);
   CodeMirror.on(node, "mouseout", hide);
   CodeMirror.on(node, "click", hide);
   state.keyMap = {Esc: hide};
   cm.addKeyMap(state.keyMap);
   //BAS
   hidePreviousToolTip = hide;
 }
开发者ID:JeyKeu,项目名称:alm,代码行数:32,代码来源:text-hover.ts


示例2: constructor

 /**
  * Construct a new editor widget.
  */
 constructor(model: IDocumentModel, context: IDocumentContext) {
   super();
   this.addClass(EDITOR_CLASS);
   let editor = this.editor;
   editor.setOption('lineNumbers', true);
   let doc = editor.getDoc();
   doc.setValue(model.toString());
   this.title.text = context.path.split('/').pop();
   loadModeByFileName(editor, context.path);
   model.stateChanged.connect((m, args) => {
     if (args.name === 'dirty') {
       if (args.newValue) {
         this.title.className += ` ${DIRTY_CLASS}`;
       } else {
         this.title.className = this.title.className.replace(DIRTY_CLASS, '');
       }
     }
   });
   context.pathChanged.connect((c, path) => {
     loadModeByFileName(editor, path);
     this.title.text = path.split('/').pop();
   });
   model.contentChanged.connect(() => {
     let old = doc.getValue();
     let text = model.toString();
     if (old !== text) {
       doc.setValue(text);
     }
   });
   CodeMirror.on(doc, 'change', (instance, change) => {
     if (change.origin !== 'setValue') {
       model.fromString(instance.getValue());
     }
   });
 }
开发者ID:katiewhite360,项目名称:jupyterlab,代码行数:38,代码来源:widget.ts


示例3: createWidget

 /**
  * Create the widget from a path.
  */
 protected createWidget(path: string): CodeMirrorWidget {
   let widget = new CodeMirrorWidget();
   widget.addClass(EDITOR_CLASS);
   CodeMirror.on(widget.editor.getDoc(), 'change', () => {
     this.setDirty(path, true);
   });
   return widget;
 }
开发者ID:lduchesne,项目名称:jupyter-js-ui,代码行数:11,代码来源:default.ts


示例4: createWidget

 /**
  * Create the widget from an `IContentsModel`.
  */
 protected createWidget(model: IContentsModel): CodeMirrorWidget {
   let widget = new CodeMirrorWidget();
   widget.addClass(EDITOR_CLASS);
   CodeMirror.on(widget.editor.getDoc(), 'change', () => {
     this.setDirty(model.path);
   });
   return widget;
 }
开发者ID:blink1073,项目名称:jupyter-js-ui,代码行数:11,代码来源:default.ts


示例5: optionHandler

  function optionHandler(cm, val, old) {
    if (old && old != CodeMirror.Init) {
      CodeMirror.off(cm.getWrapperElement(), "mouseover",
          cm.state.textHover.onMouseOver);
      delete cm.state.textHover;
    }

    if (val) {
      var state = cm.state.textHover = new TextHoverState(cm, parseOptions(cm,
          val));
      CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
    }
  }
开发者ID:JeyKeu,项目名称:alm,代码行数:13,代码来源:text-hover.ts


示例6: constructor

 /**
  * Construct a new editor widget.
  */
 constructor(context: DocumentRegistry.Context) {
   super({
     extraKeys: {
       'Tab': 'indentMore',
       'Shift-Enter': () => { /* no-op */ }
     },
     indentUnit: 4,
     theme: DEFAULT_CODEMIRROR_THEME,
     lineNumbers: true,
     lineWrapping: true,
   });
   this.addClass(EDITOR_CLASS);
   this._context = context;
   let editor = this.editor;
   let model = context.model;
   let doc = editor.getDoc();
   // Prevent the initial loading from disk from being in the editor history.
   context.ready.then( () => {
     doc.setValue(model.toString());
     doc.clearHistory();
   });
   this.title.label = context.path.split('/').pop();
   loadModeByFileName(editor, context.path);
   model.stateChanged.connect((m, args) => {
     if (args.name === 'dirty') {
       if (args.newValue) {
         this.title.className += ` ${DIRTY_CLASS}`;
       } else {
         this.title.className = this.title.className.replace(DIRTY_CLASS, '');
       }
     }
   });
   context.pathChanged.connect((c, path) => {
     loadModeByFileName(editor, path);
     this.title.label = path.split('/').pop();
   });
   model.contentChanged.connect(() => {
     let old = doc.getValue();
     let text = model.toString();
     if (old !== text) {
       doc.setValue(text);
     }
   });
   CodeMirror.on(doc, 'change', (instance, change) => {
     if (change.origin !== 'setValue') {
       model.fromString(instance.getValue());
     }
   });
 }
开发者ID:danielballan,项目名称:jupyterlab,代码行数:52,代码来源:widget.ts


示例7: constructor

 /**
  * Construct a new editor widget.
  */
 constructor(context: IDocumentContext<IDocumentModel>) {
   super();
   this.layout = new PanelLayout();
   this.addClass(EDITOR_CLASS);
   var codeMirror = new CodeMirrorWidget();
   var layout = this.layout as PanelLayout;
   let editor = codeMirror.editor;
   let model = context.model;
   this.createMenu(layout);
   layout.addChild(codeMirror);
   editor.setOption('lineNumbers', true);
   editor.setOption('theme', "material");
   let doc = editor.getDoc();
   doc.setValue(model.toString());
   this.title.text = context.path.split('/').pop();
   loadModeByFileName(editor, context.path);
   model.stateChanged.connect((m, args) => {
     if (args.name === 'dirty') {
       if (args.newValue) {
         this.title.className += ` ${DIRTY_CLASS}`;
       } else {
         this.title.className = this.title.className.replace(DIRTY_CLASS, '');
       }
     }
   });
   context.pathChanged.connect((c, path) => {
     loadModeByFileName(editor, path);
     this.title.text = path.split('/').pop();
   });
   model.contentChanged.connect(() => {
     let old = doc.getValue();
     let text = model.toString();
     if (old !== text) {
       doc.setValue(text);
     }
   });
   CodeMirror.on(doc, 'change', (instance, change) => {
     if (change.origin !== 'setValue') {
       model.fromString(instance.getValue());
     }
   });
 }
开发者ID:rnetro,项目名称:editor_changes,代码行数:45,代码来源:widget.ts


示例8: showTooltip

  function showTooltip(e, content) {
    var tt = document.createElement("div");
    tt.className = "CodeMirror-hover-tooltip";
    if (typeof content == "string") {
      content = document.createTextNode(content);
    }
    tt.appendChild(content);
    document.body.appendChild(tt);

    function position(e) {
      if (!tt.parentNode)
        return CodeMirror.off(document, "mousemove", position);
      tt.style.top = Math.max(0, e.clientY - tt.offsetHeight - 5) + "px";
      tt.style.left = (e.clientX + 5) + "px";
    }
    CodeMirror.on(document, "mousemove", position);
    position(e);
    if (tt.style.opacity != null)
      tt.style.opacity = "1";
    return tt;
  }
开发者ID:JeyKeu,项目名称:alm,代码行数:21,代码来源:text-hover.ts


示例9: collapseSingle

function collapseSingle(cm: CodeMirror.Editor, from: number, to: number): {mark: CodeMirror.TextMarker, clear: () => void} {
  cm.addLineClass(from, 'wrap', 'CodeMirror-merge-collapsed-line');
  var widget = document.createElement('span');
  widget.className = 'CodeMirror-merge-collapsed-widget';
  widget.title = 'Identical text collapsed. Click to expand.';
  var mark = cm.getDoc().markText(
    Pos(from, 0), Pos(to - 1),
    {
      inclusiveLeft: true,
      inclusiveRight: true,
      replacedWith: widget,
      clearOnEnter: true
    }
  );
  function clear() {
    mark.clear();
    cm.removeLineClass(from, 'wrap', 'CodeMirror-merge-collapsed-line');
  }
  CodeMirror.on(widget, 'click', clear);
  return {mark: mark, clear: clear};
}
开发者ID:gahjelle,项目名称:nbdime,代码行数:21,代码来源:mergeview.ts


示例10: buildGap

  buildGap(): HTMLElement {
    var lock = this.lockButton = elt('div', null, 'CodeMirror-merge-scrolllock');
    lock.title = 'Toggle locked scrolling';
    var lockWrap = elt('div', [lock], 'CodeMirror-merge-scrolllock-wrap');
    var self: DiffView = this;
    CodeMirror.on(lock, 'click', function() { self.setScrollLock(!self.lockScroll); });
    var gapElts = [lockWrap];
    /*if (this.mv.options.revertButtons !== false) {
        this.copyButtons = elt('div', null, 'CodeMirror-merge-copybuttons-' + this.type);
        CodeMirror.on(this.copyButtons, 'click', function(e) {
            var node = e.target || e.srcElement;
            if (!node.chunk) return;
            if (node.className == 'CodeMirror-merge-copy-reverse') {
                copyChunk(this, this.orig, this.edit, node.chunk);
                return;
            }
            copyChunk(this, this.edit, this.orig, node.chunk);
        });
        gapElts.unshift(this.copyButtons);
    }*/

    return this.gap = elt('div', gapElts, 'CodeMirror-merge-gap');
  }
开发者ID:gahjelle,项目名称:nbdime,代码行数:23,代码来源:mergeview.ts



注:本文中的codemirror.on函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript codemirror.Doc类代码示例发布时间:2022-05-24
下一篇:
TypeScript codemirror.off函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap