Updates image size of context rule of stylesheet model
@param  {TextEditor}  editor
@param  {SyntaxModel} model
@return {Promise}
963280
function updateImageSizeCSS(editor, model) {
	const pos = editor.getCursorBufferPosition();
	const property = getImageCSSNode(editor, model, pos);
	const urlToken = findUrlToken(property, pos);
	const src = urlToken && getImageSrcCSS(urlToken);

	if (!src) {
		return Promise.reject(new Error('No valid image source'));
	}

	locateFile(editor, src)
	.then(getImageSize)
	.then(size => {
		// since this action is asynchronous, we have to ensure that editor wasn’t
		// changed and user didn’t moved caret outside <img> node
		if (getImageCSSNode(editor, model, pos) === property) {
			updateCSSNode(editor, property, size.width, size.height);
		}
	})
	.catch(err => console.warn('Error while updating image size:', err));
}
863486
function saveLineFolds(editor) {
        var saveFolds = prefs.getSetting("saveFoldStates");
        if (!editor || !saveFolds) {
            return;
        }
        var folds = editor._codeMirror._lineFolds || {};
        var path = editor.document.file.fullPath;
        if (Object.keys(folds).length) {
            prefs.setFolds(path, folds);
        } else {
            prefs.setFolds(path, undefined);
        }
    }
236590
function(base, dialogOpts, file) {
				$(base).height(base.editor.fm.getUI().height() - 100);
			}
622147
function () {
      priv.editProxy.height(priv.editProxy.parent().innerHeight() - 4);
      priv.editProxy.val(datamap.getText(priv.selStart, priv.selEnd));
      setTimeout(editproxy.focus, 1);
      priv.editorDestroyer = self.view.applyCellTypeMethod('editor', self.view.getCellAtCoords(priv.selStart), priv.selStart, priv.editProxy);
    }
124652
function updateImageSizeHTML(editor) {
		var offset = editor.getCaretPos();

		// find tag from current caret position
		var info = editorUtils.outputInfo(editor);
		var xmlElem = xmlEditTree.parseFromPosition(info.content, offset, true);
		if (xmlElem && (xmlElem.name() || '').toLowerCase() == 'img') {
			getImageSizeForSource(editor, xmlElem.value('src'), function(size) {
				if (size) {
					var compoundData = xmlElem.range(true);
					xmlElem.value('width', size.width);
					xmlElem.value('height', size.height, xmlElem.indexOf('width') + 1);

					actionUtils.compoundUpdate(editor, utils.extend(compoundData, {
						data: xmlElem.toString(),
						caret: offset
					}));
				}
			});
		}
	}
1142545
function Editor(el, model) {
  EditorInterface.call(this);
  this.el_ = el;

  _.assign(this.el_.style, constants.editorStyle, {
    padding: '0',
    overflowY: 'hidden'
  });

  this.ta_ = document.createElement('textarea');
  _.assign(this.ta_.style, constants.baseStyle, {
    display: 'block',
    margin: '0',
    border: '0',
    padding: constants.editorStyle.padding,
    width: '100%',
    height: '100%',
    font: constants.editorStyle.font,
    lineHeight: '1.2',
    outline: 'none',
    resize: 'none'
  });
  this.el_.appendChild(this.ta_);

  // Register input handlers. Use 'input' event to catch text mutations, and
  // various other events to catch selection mutations.
  this.ta_.addEventListener('input', this.handleInput_.bind(this));

  var handler = this.updateSelection_.bind(this);
  this.ta_.addEventListener('input', handler);
  this.ta_.addEventListener('keydown', handler);
  this.ta_.addEventListener('mousedown', handler);
  this.ta_.addEventListener('mousemove', handler);
  this.ta_.addEventListener('select', handler);
  window.addEventListener('blur', this.blur.bind(this));

  this.reset(model);
}
753815
function setFontSize(fontSize) {
        if (currFontSize === fontSize) {
            return;
        }

        _removeDynamicFontSize();
        if (fontSize) {
            _addDynamicFontSize(fontSize);
        }

        // Update scroll metrics in viewed editors
        _.forEach(MainViewManager.getPaneIdList(), function (paneId) {
            var currentPath = MainViewManager.getCurrentlyViewedPath(paneId),
                doc = currentPath && DocumentManager.getOpenDocumentForPath(currentPath);
            if (doc && doc._masterEditor) {
                _updateScroll(doc._masterEditor, fontSize);
            }
        });

        exports.trigger("fontSizeChange", fontSize, currFontSize);
        currFontSize = fontSize;
        prefs.set("fontSize", fontSize);
    }
1154523
function CaptionEditor(view) {
    var self = this;
    var attached = false;

    // text input for node edits.
    var $editor = $("<textarea/>", {
      id : "caption-editor",
      "class" : "node-text-behaviour"
    }).bind("keydown", "esc", function() {
      self.stop();
    }).bind("keydown", "return", function() {
      commitText();
    }).mousedown(function(e) {
      // avoid premature canceling
      e.stopPropagation();
    }).blur(function() {
      commitText();
    }).bind(
        "input",
        function() {
          var metrics = textMetrics.getTextMetrics(self.node,
              view.zoomFactor, $editor.val());
          $editor.css(metrics);
          alignBranches();
        });

    function commitText() {
      if (attached && self.commit) {
        self.commit(self.node, $editor.val());
      }
    }

    function alignBranches() {
      // slightly defer execution for better performance on slow
      // browsers
      setTimeout(function() {
        view.redrawNodeConnectors(self.node);
      }, 1);
    }

    /**
     * Attaches the textarea to the node and temporarily removes the
     * original node caption.
     * 
     * @param {mindmaps.Node} node
     * @param {jQuery} $cancelArea
     */
    this.edit = function(node, $cancelArea) {
      if (attached) {
        return;
      }
      this.node = node;
      attached = true;

      // TODO put text into span and hide()
      this.$text = $getNodeCaption(node);
      this.$cancelArea = $cancelArea;

      this.text = this.$text.text();

      this.$text.css({
        width : "auto",
        height : "auto"
      }).empty().addClass("edit");

      // jquery ui prevents blur() event from happening when dragging a
      // draggable. need this
      // workaround to detect click on other draggable
      $cancelArea.bind("mousedown.editNodeCaption", function(e) {
        commitText();
      });

      var metrics = textMetrics.getTextMetrics(self.node,
          view.zoomFactor, this.text);
      $editor.attr({
        value : this.text
      }).css(metrics).appendTo(this.$text).select();

    };

    /**
     * Removes the editor from the node and restores its old text value.
     */
    this.stop = function() {
      if (attached) {
        attached = false;
        this.$text.removeClass("edit");
        $editor.detach();
        this.$cancelArea.unbind("mousedown.editNodeCaption");
        view.setNodeText(this.node, this.text);

        alignBranches();
      }
    };
  }
1359042
function Change(model, offset, text, previousText, type) {
		this.model = model;
		this.offset = offset;
		this.text = text;
		this.previousText = previousText;
		this.type = type;
	}
1124870
function makeChangeSingleDocInEditor(cm, change, spans) {
  let doc = cm.doc, display = cm.display, from = change.from, to = change.to

  let recomputeMaxLength = false, checkWidthStart = from.line
  if (!cm.options.lineWrapping) {
    checkWidthStart = lineNo(visualLine(getLine(doc, from.line)))
    doc.iter(checkWidthStart, to.line + 1, line => {
      if (line == display.maxLine) {
        recomputeMaxLength = true
        return true
      }
    })
  }

  if (doc.sel.contains(change.from, change.to) > -1)
    signalCursorActivity(cm)

  updateDoc(doc, change, spans, estimateHeight(cm))

  if (!cm.options.lineWrapping) {
    doc.iter(checkWidthStart, from.line + change.text.length, line => {
      let len = lineLength(line)
      if (len > display.maxLineLength) {
        display.maxLine = line
        display.maxLineLength = len
        display.maxLineChanged = true
        recomputeMaxLength = false
      }
    })
    if (recomputeMaxLength) cm.curOp.updateMaxLine = true
  }

  retreatFrontier(doc, from.line)
  startWorker(cm, 400)

  let lendiff = change.text.length - (to.line - from.line) - 1
  // Remember that these lines changed, for updating the display
  if (change.full)
    regChange(cm)
  else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
    regLineChange(cm, from.line, "text")
  else
    regChange(cm, from.line, to.line + 1, lendiff)

  let changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change")
  if (changeHandler || changesHandler) {
    let obj = {
      from: from, to: to,
      text: change.text,
      removed: change.removed,
      origin: change.origin
    }
    if (changeHandler) signalLater(cm, "change", cm, obj)
    if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj)
  }
  cm.display.selForContextMenu = null
}
580209
private void updateStyleForElement(RendererState state, SvgElementBase obj)
   {
      boolean  isRootSVG = (obj.parent == null);
      state.style.resetNonInheritingProperties(isRootSVG);

      // Apply the styles defined by style attributes on the element
      if (obj.baseStyle != null)
         updateStyle(state, obj.baseStyle);

      // Apply the styles from any CSS files or <style> elements
      if (document.hasCSSRules())
      {
         for (CSSParser.Rule rule: document.getCSSRules())
         {
            if (CSSParser.ruleMatch(this.ruleMatchContext, rule.selector, obj)) {
               updateStyle(state, rule.style);
            }
         }
      }

      // Apply the styles defined by the 'style' attribute. They have the highest precedence.
      if (obj.style != null)
         updateStyle(state, obj.style);
   }
539191
function getImageSizeForSource(editor, src, callback) {
		var fileContent;
		if (src) {
			// check if it is data:url
			if (/^data:/.test(src)) {
				fileContent = base64.decode( src.replace(/^data\:.+?;.+?,/, '') );
				return callback(actionUtils.getImageSize(fileContent));
			}

			var filePath = editor.getFilePath();
			file.locateFile(filePath, src, function(absPath) {
				if (absPath === null) {
					throw "Can't find " + src + ' file';
				}

				file.read(absPath, function(err, content) {
					if (err) {
						throw 'Unable to read ' + absPath + ': ' + err;
					}

					content = String(content);
					callback(actionUtils.getImageSize(content));
				});
			});
		}
	}
1505
def setModelData(self, editor, model, index):
        
        value = editor.currentText()
        model.setData(index, wrapVariant(value))
1232961
function( editor )
	{
		// Set config related properties.

		var skin = editor.config.skin.split( ',' ),
			skinName = skin[ 0 ],
			skinPath = CKEDITOR.getUrl( skin[ 1 ] || (
				'_source/' +	// @Packager.RemoveLine
				'skins/' + skinName + '/' ) );

		/**
		 * The name of the skin used by this editor instance. The skin name can
		 * be set through the <code>{@link CKEDITOR.config.skin}</code> setting.
		 * @name CKEDITOR.editor.prototype.skinName
		 * @type String
		 * @example
		 * alert( editor.skinName );  // E.g. "kama"
		 */
		editor.skinName = skinName;

		/**
		 * The full URL of the skin directory.
		 * @name CKEDITOR.editor.prototype.skinPath
		 * @type String
		 * @example
		 * alert( editor.skinPath );  // E.g. "http://example.com/ckeditor/skins/kama/"
		 */
		editor.skinPath = skinPath;

		/**
		 * The CSS class name used for skin identification purposes.
		 * @name CKEDITOR.editor.prototype.skinClass
		 * @type String
		 * @example
		 * alert( editor.skinClass );  // E.g. "cke_skin_kama"
		 */
		editor.skinClass = 'cke_skin_' + skinName;

		/**
		 * The <a href="http://en.wikipedia.org/wiki/Tabbing_navigation">tabbing
		 * navigation</a> order that has been calculated for this editor
		 * instance. This can be set by the <code>{@link CKEDITOR.config.tabIndex}</code>
		 * setting or taken from the <code>tabindex</code> attribute of the
		 * <code>{@link #element}</code> associated with the editor.
		 * @name CKEDITOR.editor.prototype.tabIndex
		 * @type Number
		 * @default 0 (zero)
		 * @example
		 * alert( editor.tabIndex );  // E.g. "0"
		 */
		editor.tabIndex = editor.config.tabIndex || editor.element.getAttribute( 'tabindex' ) || 0;

		/**
		 * Indicates the read-only state of this editor. This is a read-only property.
		 * @name CKEDITOR.editor.prototype.readOnly
		 * @type Boolean
		 * @since 3.6
		 * @see CKEDITOR.editor#setReadOnly
		 */
		editor.readOnly = !!( editor.config.readOnly || editor.element.getAttribute( 'disabled' ) );

		// Fire the "configLoaded" event.
		editor.fireOnce( 'configLoaded' );

		// Load language file.
		loadSkin( editor );
	}
1349833
function(e) {
      var t = this,
          isEditMode = $('.nm-pv').hasClass('edit-mode'),
          thisZIndex = 0,
          persist = true,
          viewport = t.$('.nm-cv-viewport'),
          css = _.clone(t.model.get('css')),
          parsedCss = $.parseStyleString(css['.nm-cv-viewport'] || ''),
          origSize = {
            height: viewport.height(),
            width: viewport.width()
          },
          newSize = _.extend({},origSize),
          downPos = {
            top: e.pageY,
            left: e.pageX
          };

      // Bring component to the top unless [SHIFT] is pressed
      if (e.shiftKey) {
        // Bring window to top
        thisZIndex = t.raiseToTop(true);
      }

      function drag(e) {
        newSize.height = Math.max(origSize.height + e.pageY - downPos.top, 0);
        newSize.width = Math.max(origSize.width + e.pageX - downPos.left, 0);

        // Snap to grid unless [SHIFT] is pressed
        if (!e.shiftKey) {
          newSize.height = newSize.height - newSize.height % DRAG_GRID_SNAP;
          newSize.width = newSize.width - newSize.width % DRAG_GRID_SNAP;
        }
        t.view.trigger('resize');
        viewport.css(newSize);
      }

      function drop(e) {
        $(document).unbind("mousemove", drag).unbind("mouseup", drop);

        // Set new height/width into the model if it's changed
        if (persist && (newSize.height !== origSize.height || newSize.width !== origSize.width)) {
          parsedCss.height = newSize.height + 'px';
          parsedCss.width = newSize.width + 'px';
          if (thisZIndex) {
            parsedCss['z-index'] = thisZIndex;
          }
          css['.nm-cv-viewport'] = $.makeStyleString(parsedCss);
          t.model.set({css: css});
          viewport.css({height:'',width:''});
          t.view.trigger('resize');
        }
        // Re-center the screen
        UI.pageView.centerPage();
      }

      $(document).bind("mousemove", drag).bind("mouseup", drop);
      e.preventDefault();
      e.stopPropagation();
    }
220761
function(editor, syntax, profile) {
			var info = editorUtils.outputInfo(editor, syntax, profile);
			if (!~cssSyntaxes.indexOf(info.syntax)) {
				return false;
			}
			
			// let's see if we are expanding gradient definition
			var caret = editor.getCaretPos();
			var content = info.content;
			var gradients = this.gradientsFromCSSProperty(content, caret);
			if (gradients) {
				if (!isValidCaretPosition(gradients, caret, info.syntax)) {
					return false;
				}

				var cssProperty = gradients.property;
				var cssRule = cssProperty.parent;
				var ruleStart = cssRule.options.offset || 0;
				var ruleEnd = ruleStart + cssRule.toString().length;
				
				// Handle special case:
				// user wrote gradient definition between existing CSS 
				// properties and did not finished it with semicolon.
				// In this case, we have semicolon right after gradient 
				// definition and re-parse rule again
				if (/[\n\r]/.test(cssProperty.value())) {
					// insert semicolon at the end of gradient definition
					var insertPos = cssProperty.valueRange(true).start + utils.last(gradients.gradients).matchedPart.end;
					content = utils.replaceSubstring(content, ';', insertPos);
					
					var _gradients = this.gradientsFromCSSProperty(content, caret);
					if (_gradients) {
						gradients = _gradients;
						cssProperty = gradients.property;
						cssRule = cssProperty.parent;
					}
				}
				
				// make sure current property has terminating semicolon
				cssProperty.end(';');
				
				// resolve CSS property name
				var resolvedName = resolvePropertyName(cssProperty.name(), syntax);
				if (resolvedName) {
					cssProperty.name(resolvedName);
				}
				
				pasteGradient(cssProperty, gradients.gradients);
				editor.replaceContent(cssRule.toString(), ruleStart, ruleEnd, true);
				return true;
			}
			
			return this.expandGradientOutsideValue(editor, syntax);
		}
166314
function( editor ) {
			CKEDITOR.dialog.add( 'templates', CKEDITOR.getUrl( this.path + 'dialogs/templates.js' ) );

			editor.addCommand( 'templates', new CKEDITOR.dialogCommand( 'templates' ) );

			editor.ui.addButton && editor.ui.addButton( 'Templates', {
				label: editor.lang.templates.button,
				command: 'templates',
				toolbar: 'doctools,10'
			} );
		}