📄 bs_editor.class.js
字号:
paramObj['value'] = tempRange.htmlText;}var code = '<a';for (var i=0; i<propArr.length; i++) {if (!bs_isEmpty(paramObj[propArr[i]])) code += ' ' + propArr[i] + '="' + paramObj[propArr[i]] + '"';}code += '>' + paramObj['value'] + '</a>';tempRange.pasteHTML(code);tempRange.select();} else {for (var i=0; i<propArr.length; i++) {if (!bs_isEmpty(paramObj[propArr[i]])) tempElm.setAttribute(propArr[i], paramObj[propArr[i]]);}if (!bs_isEmpty(paramObj['value'])) tempElm.innerHTML = paramObj['value'];}} else {var r2 = expandSelectionToSimpleTag(tempRange, 'a');if (r2.text != tempRange.text) tempRange = r2;if (bs_isEmpty(paramObj.href)) {var code = '';} else {var code = '<a';for (var i=0; i<propArr.length; i++) {if (!bs_isEmpty(paramObj[propArr[i]])) code += ' ' + propArr[i] + '="' + paramObj[propArr[i]] + '"';}code += '>';}tempRange.text = code;tempRange.select();}}this.createImage = function(paramObj) {var propArr = new Array('src', 'alt', 'width', 'height', 'hspace', 'vspace', 'border', 'align', 'name', 'title', 'id', 'class', 'style');var tempRange = this.workingDoc.selection.createRange();if ((this.dataType == 'whtml') && !this._inHtmlMode) {if (this.workingDoc.selection.type == "Control") {} else {tempRange.execCommand('InsertImage', false, paramObj.src);var tempRange = this.workingDoc.selection.createRange();}tempElm = tempRange(0);if (tempElm != false) {for (var i=0; i<propArr.length; i++) {if (!bs_isEmpty(paramObj[propArr[i]])) tempElm.setAttribute(propArr[i], paramObj[propArr[i]]);}}} else {var r2 = expandSelectionToSimpleTag(tempRange, 'img');if (r2.text != tempRange.text) tempRange = r2;var code = '<img';for (var i=0; i<propArr.length; i++) {if (!bs_isEmpty(paramObj[propArr[i]])) code += ' ' + propArr[i] + '="' + paramObj[propArr[i]] + '"';}code += '>';tempRange.text = code;tempRange.select();}}this.setFgColor = function(hexCode) {this.workingDoc.execCommand('ForeColor', false, hexCode);}this.setFontOption = function(option, b) {var current = this.workingDoc.queryCommandValue(option);if (current && !b) {this.workingDoc.execCommand(option, false, false);} else if (!current && b) {this.workingDoc.execCommand(option, false, true);}}this.setFont = function(paramObj) {if (!bs_isEmpty(paramObj.fontFace)) this.workingDoc.execCommand('FontName', false, paramObj.fontFace);if (!bs_isEmpty(paramObj.fontSize)) this.workingDoc.execCommand('FontSize', false, paramObj.fontSize);this.setFontOption('Bold', (paramObj.fontStyle.indexOf('Bold') != -1));this.setFontOption('Italic', (paramObj.fontStyle.indexOf('Italic') != -1));this.setFontOption('Underline', paramObj.underline);this.setFontOption('StrikeThrough', paramObj.strikeThrough);this.setFontOption('SuperScript', paramObj.superScript);this.setFontOption('SubScript', paramObj.subScript);}this.callbackWindowHref = function() {var paramObj = new Object;var tempRange = this.workingDoc.selection.createRange();if ((this.dataType == 'html') || this._inHtmlMode) {var r2 = expandSelectionToSimpleTag(tempRange, 'a');if ((r2.text != tempRange.text) && !bs_isEmpty(r2.text)) {r2.select();paramObj = bs_parseSimpleTagProps(r2.text);paramObj['value'] = 'ggg';}} else {var tempElm = findWrappingElement('A', tempRange);if (tempElm != false) {paramObj.href = (!bs_isEmpty(tempElm.getAttribute('href'))) ? tempElm.getAttribute('href') : '';paramObj.target = (!bs_isEmpty(tempElm.getAttribute('target'))) ? tempElm.getAttribute('target') : '';paramObj.name = (!bs_isEmpty(tempElm.getAttribute('name'))) ? tempElm.getAttribute('name') : '';paramObj.title = (!bs_isEmpty(tempElm.getAttribute('title'))) ? tempElm.getAttribute('title') : '';paramObj.id = (!bs_isEmpty(tempElm.getAttribute('id'))) ? tempElm.getAttribute('id') : '';paramObj['class'] = (!bs_isEmpty(tempElm.getAttribute('class'))) ? tempElm.getAttribute('class') : '';paramObj.style = (!bs_isEmpty(tempElm.getAttribute('style'))) ? tempElm.getAttribute('style') : '';paramObj['value'] = tempElm.innerHTML;} else {if (typeof(tempRange.text) == 'undefined') {paramObj['value'] = tempRange.item(0).outerHTML;} else {paramObj['value'] = tempRange.text;}}}return paramObj;}this.callbackWindowImage = function() {var paramObj = new Object;var tempRange = this.workingDoc.selection.createRange();if (typeof(tempRange.text) == 'undefined') {var tempElm = tempRange(0);if (tempElm != false) {paramObj.src = (!bs_isEmpty(tempElm.getAttribute('src'))) ? tempElm.getAttribute('src') : '';paramObj.alt = (!bs_isEmpty(tempElm.getAttribute('alt'))) ? tempElm.getAttribute('alt') : '';paramObj.width = (!bs_isEmpty(tempElm.getAttribute('width'))) ? tempElm.getAttribute('width') : '';paramObj.height = (!bs_isEmpty(tempElm.getAttribute('height'))) ? tempElm.getAttribute('height') : '';paramObj.hspace = (!bs_isEmpty(tempElm.getAttribute('hspace'))) ? tempElm.getAttribute('hspace') : '';paramObj.vspace = (!bs_isEmpty(tempElm.getAttribute('vspace'))) ? tempElm.getAttribute('vspace') : '';paramObj.border = (!bs_isEmpty(tempElm.getAttribute('border'))) ? tempElm.getAttribute('border') : '';paramObj.align = (!bs_isEmpty(tempElm.getAttribute('align'))) ? tempElm.getAttribute('align') : '';paramObj.name = (!bs_isEmpty(tempElm.getAttribute('name'))) ? tempElm.getAttribute('name') : '';paramObj.title = (!bs_isEmpty(tempElm.getAttribute('title'))) ? tempElm.getAttribute('title') : '';paramObj.id = (!bs_isEmpty(tempElm.getAttribute('id'))) ? tempElm.getAttribute('id') : '';paramObj['class'] = (!bs_isEmpty(tempElm.getAttribute('class'))) ? tempElm.getAttribute('class') : '';paramObj.style = (!bs_isEmpty(tempElm.getAttribute('style'))) ? tempElm.getAttribute('style') : '';}} else {if ((this.dataType == 'html') || this._inHtmlMode) {var r2 = expandSelectionToSimpleTag(tempRange, 'img');if ((r2.text != tempRange.text) && !bs_isEmpty(r2.text)) {paramObj = bs_parseSimpleTagProps(r2.text);r2.select();}}}if (typeof(this.imageSelector[3]) != 'undefined') {paramObj.imageBrowser = this.imageSelector[3];}return paramObj;}this.callbackWindowColor = function() {var currentColor = this.workingDoc.queryCommandValue('ForeColor');currentColor = currentColor.toString(16);for (var i=6-currentColor.length; i>0; i--) {currentColor = '0' + '' + currentColor;}var paramObj = new Object;paramObj.color = currentColor;return paramObj;}this.callbackWindowFont = function() {var paramObj = new Object;paramObj.fontFace = this.workingDoc.queryCommandValue('FontName');var fontStyle = new Array;if (this.workingDoc.queryCommandValue('Bold')) fontStyle[fontStyle.length] = 'Bold';if (this.workingDoc.queryCommandValue('Italic')) fontStyle[fontStyle.length] = 'Italic';paramObj.fontStyle = fontStyle.join(' ');paramObj.fontSize = this.workingDoc.queryCommandValue('FontSize');paramObj.underline = this.workingDoc.queryCommandValue('Underline');paramObj.strikeThrough = this.workingDoc.queryCommandValue('StrikeThrough');paramObj.superScript = this.workingDoc.queryCommandValue('Superscript');paramObj.subScript = this.workingDoc.queryCommandValue('Subscript');try {if (this.lastSelection.text == '') {this.lastSelection.expand('word');}paramObj.previewText = this.lastSelection.text;} catch (e) {}return paramObj;}this.attachEvent = function(trigger, yourEvent) {if (typeof(this._attachedEvents) == 'undefined') {this._attachedEvents = new Array();}if (typeof(this._attachedEvents[trigger]) == 'undefined') {this._attachedEvents[trigger] = new Array(yourEvent);} else {this._attachedEvents[trigger][this._attachedEvents[trigger].length] = yourEvent;}}this.hasEventAttached = function(trigger) {return (this._attachedEvents && this._attachedEvents[trigger]);}this.fireEvent = function(trigger) {if (this._attachedEvents && this._attachedEvents[trigger]) {var e = this._attachedEvents[trigger];if ((typeof(e) == 'string') || (typeof(e) == 'function')) {e = new Array(e);}for (var i=0; i<e.length; i++) {if (typeof(e[i]) == 'function') {e[i](this);} else if (typeof(e[i]) == 'string') {eval(e[i]);}}}}this.toolbarButtonClicked = function(btnObj) {try {if (moz) {this.workingElm.contentWindow.focus();} else {this.workingElm.focus();}} catch (e) {}switch (btnObj.action) {case 'Bold':case 'Italic':case 'Underline':case 'Undo':case 'Redo':case 'Cut':case 'Copy':case 'Paste':case 'JustifyLeft':case 'JustifyCenter':case 'JustifyRight':case 'InsertOrderedList':case 'InsertUnorderedList':case 'Outdent':case 'Indent':case 'UnLink':try {this.workingDoc.execCommand(btnObj.action, false, null);} catch (e) {}break;case 'CreateLink':var url = this.hrefSelector[0] + '?objectName=' + this._objectName;url += '&callbackLoad=callbackWindowHref&callbackSave=createLink';if (moz) {window.open(url, "HrefSelector", "width=" + this.hrefSelector[1] + ",height=" + this.hrefSelector[2] + ",left=0,top=0,scrollbars=no,status=no,toolbar=no,resizable=no,location=no,hotkeys=no,dependent=yes");} else {var ret = window.showModalDialog(url, this.callbackWindowHref(), "dialogWidth:" + this.hrefSelector[1] + "px; dialogHeight:" + this.hrefSelector[2] + "px;");if (ret) this.createLink(ret);}break;case 'InsertImage':var url = this.imageSelector[0] + '?objectName=' + this._objectName;url += '&callbackLoad=callbackWindowImage&callbackSave=createImage';if (moz) {window.open(url, "ImageSelector", "width=" + this.imageSelector[1] + ",height=" + this.imageSelector[2] + ",left=0,top=0,scrollbars=no,status=no,toolbar=no,resizable=no,location=no,hotkeys=no,dependent=yes");} else {var ret = window.showModalDialog(url, this.callbackWindowImage(), "dialogWidth:" + this.imageSelector[1] + "px; dialogHeight:" + this.imageSelector[2] + "px;");if (ret) this.createImage(ret);}break;case 'ForeColor':var url = this.fgColorSelector[0] + '?objectName=' + this._objectName;url += '&callbackLoad=callbackWindowColor&callbackSave=setFgColor';if (moz) {window.open(url, "FgColorSelector", "width=" + this.fgColorSelector[1] + ",height=" + this.fgColorSelector[2] + ",left=0,top=0,scrollbars=no,status=no,toolbar=no,resizable=no,location=no,hotkeys=no,dependent=yes");} else {var ret = window.showModalDialog(url, this.callbackWindowColor(), "dialogWidth:" + this.fgColorSelector[1] + "px; dialogHeight:" + this.fgColorSelector[2] + "px;");if (ret) this.setFgColor(ret);}break;case 'Color':var url = this.fgColorSelector[0] + '?objectName=' + this._objectName;url += '&callbackLoad=false&callbackSave=insertString';if (moz) {window.open(url, "ColorSelector", "width=" + this.fgColorSelector[1] + ",height=" + this.fgColorSelector[2] + ",left=0,top=0,scrollbars=no,status=no,toolbar=no,resizable=no,location=no,hotkeys=no,dependent=yes");} else {var ret = window.showModalDialog(url, this.callbackWindowColor(), "dialogWidth:" + this.fgColorSelector[1] + "px; dialogHeight:" + this.fgColorSelector[2] + "px;");if (ret) this.insertString(ret);}break;case 'Font':this.lastSelection = this.workingDoc.selection.createRange();var url = this.fontSelector[0] + '?objectName=' + this._objectName;url += '&callbackLoad=callbackWindowFont&callbackSave=setFont';if (moz) {window.open(url, "fontSelector", "width=" + this.fontSelector[1] + ",height=" + this.fontSelector[2] + ",left=0,top=0,scrollbars=no,status=no,toolbar=no,resizable=no,location=no,hotkeys=no,dependent=yes");} else {var ret = window.showModalDialog(url, this.callbackWindowFont(), "dialogWidth:" + this.fontSelector[1] + "px; dialogHeight:" + this.fontSelector[2] + "px;");if (ret) this.setFont(ret);}break;case 'SpecialChars':
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -