⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 editor2.js

📁 初学者
💻 JS
📖 第 1 页 / 共 2 页
字号:
	} else {		if (this.shareToolbar) {			dojo.deprecated("Editor2:shareToolbar is deprecated in favor of toolbarGroup", "0.5");			this.toolbarGroup = "defaultDojoToolbarGroup";		}		if (this.toolbarGroup) {			if (dojo.widget.Editor2ToolbarGroups[this.toolbarGroup]) {				this.toolbarWidget = dojo.widget.Editor2ToolbarGroups[this.toolbarGroup];			}		}		if (!this.toolbarWidget) {			var tbOpts = {shareGroup:this.toolbarGroup, parent:this};			tbOpts.templateString = dojo.uri.cache.get(this.toolbarTemplatePath);			if (this.toolbarTemplateCssPath) {				tbOpts.templateCssPath = this.toolbarTemplateCssPath;				tbOpts.templateCssString = dojo.uri.cache.get(this.toolbarTemplateCssPath);			}			if (this.toolbarPlaceHolder) {				this.toolbarWidget = dojo.widget.createWidget("Editor2Toolbar", tbOpts, dojo.byId(this.toolbarPlaceHolder), "after");			} else {				this.toolbarWidget = dojo.widget.createWidget("Editor2Toolbar", tbOpts, this.domNode.firstChild, "before");			}			if (this.toolbarGroup) {				dojo.widget.Editor2ToolbarGroups[this.toolbarGroup] = this.toolbarWidget;			}			dojo.event.connect(this, "close", this.toolbarWidget, "hide");			this.toolbarLoaded();		}	}	dojo.event.topic.registerPublisher("Editor2.clobberFocus", this, "clobberFocus");	dojo.event.topic.subscribe("Editor2.clobberFocus", this, "setBlur");	dojo.event.topic.publish("dojo.widget.Editor2::onLoad", this);}, toolbarLoaded:function () {}, registerLoadedPlugin:function (obj) {	if (!this.loadedPlugins) {		this.loadedPlugins = [];	}	this.loadedPlugins.push(obj);}, unregisterLoadedPlugin:function (obj) {	for (var i in this.loadedPlugins) {		if (this.loadedPlugins[i] === obj) {			delete this.loadedPlugins[i];			return;		}	}	dojo.debug("dojo.widget.Editor2.unregisterLoadedPlugin: unknow plugin object: " + obj);}, execCommand:function (command, argument) {	switch (command.toLowerCase()) {	  case "htmltoggle":		this.toggleHtmlEditing();		break;	  default:		dojo.widget.Editor2.superclass.execCommand.apply(this, arguments);	}}, queryCommandEnabled:function (command, argument) {	switch (command.toLowerCase()) {	  case "htmltoggle":		return true;	  default:		if (this._inSourceMode) {			return false;		}		return dojo.widget.Editor2.superclass.queryCommandEnabled.apply(this, arguments);	}}, queryCommandState:function (command, argument) {	switch (command.toLowerCase()) {	  case "htmltoggle":		return this._inSourceMode;	  default:		return dojo.widget.Editor2.superclass.queryCommandState.apply(this, arguments);	}}, onClick:function (e) {	dojo.widget.Editor2.superclass.onClick.call(this, e);	if (dojo.widget.PopupManager) {		if (!e) {			e = this.window.event;		}		dojo.widget.PopupManager.onClick(e);	}}, clobberFocus:function () {}, toggleHtmlEditing:function () {	if (this === dojo.widget.Editor2Manager.getCurrentInstance()) {		if (!this._inSourceMode) {			var html = this.getEditorContent();			this._inSourceMode = true;			if (!this._htmlEditNode) {				this._htmlEditNode = dojo.doc().createElement("textarea");				dojo.html.insertAfter(this._htmlEditNode, this.editorObject);			}			this._htmlEditNode.style.display = "";			this._htmlEditNode.style.width = "100%";			this._htmlEditNode.style.height = dojo.html.getBorderBox(this.editNode).height + "px";			this._htmlEditNode.value = html;			with (this.editorObject.style) {				position = "absolute";				left = "-2000px";				top = "-2000px";			}		} else {			this._inSourceMode = false;			this._htmlEditNode.blur();			with (this.editorObject.style) {				position = "";				left = "";				top = "";			}			var html = this._htmlEditNode.value;			dojo.lang.setTimeout(this, "replaceEditorContent", 1, html);			this._htmlEditNode.style.display = "none";			this.focus();		}		this.onDisplayChanged(null, true);	}}, setFocus:function () {	if (dojo.widget.Editor2Manager.getCurrentInstance() === this) {		return;	}	this.clobberFocus();	dojo.widget.Editor2Manager.setCurrentInstance(this);}, setBlur:function () {}, saveSelection:function () {	this._bookmark = null;	this._bookmark = dojo.withGlobal(this.window, dojo.html.selection.getBookmark);}, restoreSelection:function () {	if (this._bookmark) {		this.focus();		dojo.withGlobal(this.window, "moveToBookmark", dojo.html.selection, [this._bookmark]);		this._bookmark = null;	} else {		dojo.debug("restoreSelection: no saved selection is found!");	}}, _updateToolbarLastRan:null, _updateToolbarTimer:null, _updateToolbarFrequency:500, updateToolbar:function (force) {	if ((!this.isLoaded) || (!this.toolbarWidget)) {		return;	}	var diff = new Date() - this._updateToolbarLastRan;	if ((!force) && (this._updateToolbarLastRan) && ((diff < this._updateToolbarFrequency))) {		clearTimeout(this._updateToolbarTimer);		var _this = this;		this._updateToolbarTimer = setTimeout(function () {			_this.updateToolbar();		}, this._updateToolbarFrequency / 2);		return;	} else {		this._updateToolbarLastRan = new Date();	}	if (dojo.widget.Editor2Manager.getCurrentInstance() !== this) {		return;	}	this.toolbarWidget.update();}, destroy:function (finalize) {	this._htmlEditNode = null;	dojo.event.disconnect(this, "close", this.toolbarWidget, "hide");	if (!finalize) {		this.toolbarWidget.destroy();	}	dojo.widget.Editor2.superclass.destroy.call(this);}, _lastStateTimestamp:0, onDisplayChanged:function (e, forceUpdate) {	this._lastStateTimestamp = (new Date()).getTime();	dojo.widget.Editor2.superclass.onDisplayChanged.call(this, e);	this.updateToolbar(forceUpdate);}, onLoad:function () {	try {		dojo.widget.Editor2.superclass.onLoad.call(this);	}	catch (e) {		dojo.debug(e);	}	this.editorOnLoad();}, onFocus:function () {	dojo.widget.Editor2.superclass.onFocus.call(this);	this.setFocus();}, getEditorContent:function () {	if (this._inSourceMode) {		return this._htmlEditNode.value;	}	return dojo.widget.Editor2.superclass.getEditorContent.call(this);}, replaceEditorContent:function (html) {	if (this._inSourceMode) {		this._htmlEditNode.value = html;		return;	}	dojo.widget.Editor2.superclass.replaceEditorContent.apply(this, arguments);}, getCommand:function (name) {	if (this._loadedCommands[name]) {		return this._loadedCommands[name];	}	var cmd = dojo.widget.Editor2Manager.getCommand(this, name);	this._loadedCommands[name] = cmd;	return cmd;}, shortcuts:[["bold"], ["italic"], ["underline"], ["selectall", "a"], ["insertunorderedlist", "\\"]], setupDefaultShortcuts:function () {	var exec = function (cmd) {		return function () {			cmd.execute();		};	};	var self = this;	dojo.lang.forEach(this.shortcuts, function (item) {		var cmd = self.getCommand(item[0]);		if (cmd) {			self.addKeyHandler(item[1] ? item[1] : item[0].charAt(0), item[2] == undefined ? self.KEY_CTRL : item[2], exec(cmd));		}	});}});

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -