Editor.Protocol

Protocol module used in Editor.url and custom protocol.

Methods

Editor.Protocol.register (protocol, fn)

  • protocol string - Protocol name
  • fn function
    Register a protocol so that Editor.url can use it to convert an url to the filesystem path.The fn accept an url Object via url.parse.

Example:

  1. const Path = require('path');
  2. let _url2path = base => {
  3. return uri => {
  4. if ( uri.pathname ) {
  5. return Path.join( base, uri.host, uri.pathname );
  6. }
  7. return Path.join( base, uri.host );
  8. };
  9. };
  10. Editor.Protocol.register('editor-framework', _url2path(Editor.frameworkPath));