Friday, 15 March 2013

expand abbreviation with javascript in Codemirror/emmet -


For I'am codemirror and my project Expanding the EMMT summarizes great works in the codemirror editor when interactively done (CTRL + E) I have to make a further step further by extending the summaries within the javascript code.

  & lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Meta charset = "UTF-8" & gt; & Lt; Link rel = "stylesheet" type = "text / css" href = "codemirror / lib / codemirror.css" & gt; & Lt; Link rel = "stylesheet" type = "text / css" href = "codemirror / lib / codemirror.css" & gt; & Lt; Script type = "text / javascript" src = "codemirror / lib / codemirror.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "codemirror / lib / codemirror.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "codemirror / mode / xml / xml.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "codemirror / mode / javascript / javascript.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "codemirror / mode / css / css.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "codemir / mode / htmlmixed / htmlmixed.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "resource / emmet.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div id = "editorcontainer" & gt; & Lt; / Div & gt; & Lt; Script type = "text / javascript" & gt; Var Test = {}; Test. Editor = null; Test.init = function () {Test.editor = CodeMirror (document.getElementById ('editorContainer'), {autofocus: true, lineNumbers: true, mode: "text / html", profile: 'xhtml', / * ammt Defines the output profile *); EmmetCodeMirror (Test.editor); Test.ol (); } Test.ol = function () {Test.editor.getDoc (). ReplaceSelection ('ol'; li * 3 ',' end '); Test.editor.focus (); EmmetCodeMirror.emmet.run ('wide_abet', test. Editor); }; Test.init (); & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

By calling test.ol () ol> Li * 3 is inserted, but its following execution

  emmetCodeMirror.emmet.run ('extension_base', test. Editor);  

result in a typeError: editor.getProfileName is not a function emmet.js: 41541

Can someone tell me that I What am I doing,

Thank you very much!

>

You CodeMirror editor example Emmet.run () instead of EmmetEditor . Anyway, the ultimate solution is only for the registered AMP command, for example

  Test.editor.execCommand ('emmet.expand_abence')  

No comments:

Post a Comment