📄 zpeditor-core.js
字号:
break; case "selectall": var tooltip = this.getMessage('selectAllTooltip'); var button = this.createButton("selectall", tooltip, function() { self.execCommand("selectall"); self.focus(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'SelectAll'; span.appendChild(button); break; case "bold": var button = this.createButton("bold", "Bold", function() { self.execCommand("bold", false, null); self.saveContentToField(); // Focus editor self.focus(); // Store an undo step self.undo.saveUndo(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'Bold'; span.appendChild(button); break; case "italic": var button = this.createButton("italic", "Italic", function() { self.execCommand("italic", false, null); self.saveContentToField(); // Focus editor self.focus(); // Store an undo step self.undo.saveUndo(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'Italic'; span.appendChild(button); break; case "underline": var tooltip = this.getMessage('underlineTooltip'); var button = this.createButton("underline", tooltip, function() { self.execCommand("underline", false, null); self.saveContentToField(); // Focus editor self.focus(); // Store an undo step self.undo.saveUndo(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'Underline'; span.appendChild(button); break; case "justifyleft": var tooltip = this.getMessage('justifyLeftTooltip'); var button = this.createButton("justifyleft", tooltip, function() { self.execCommand("justifyleft", false, null); self.saveContentToField(); // Focus editor self.focus(); // Store an undo step self.undo.saveUndo(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'JustifyLeft'; span.appendChild(button); break; case "justifycenter": var tooltip = this.getMessage('justifyCenterTooltip'); var button = this.createButton("justifycenter", tooltip, function() { self.execCommand("justifycenter", false, null); self.saveContentToField(); // Focus editor self.focus(); // Store an undo step self.undo.saveUndo(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'JustifyCenter'; span.appendChild(button); break; case "justifyright": var tooltip = this.getMessage('justifyRightTooltip'); var button = this.createButton("justifyright", tooltip, function() { self.execCommand("justifyright", false, null); self.saveContentToField(); // Focus editor self.focus(); // Store an undo step self.undo.saveUndo(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'JustifyRight'; span.appendChild(button); break; case "justifyfull": var tooltip = this.getMessage('justifyFullTooltip'); var button = this.createButton("justifyfull", tooltip, function() { self.execCommand("justifyfull", false, null); self.saveContentToField(); // Focus editor self.focus(); // Store an undo step self.undo.saveUndo(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'JustifyFull'; span.appendChild(button); break; case "insertorderedlist": var tooltip = this.getMessage('orderedListTooltip'); var button = this.createButton("orderedlist", tooltip, function() { self.execCommand("insertorderedlist", false, null); self.saveContentToField(); // Focus editor self.focus(); // Store an undo step self.undo.saveUndo(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'InsertOrderedList'; span.appendChild(button); break; case "insertunorderedlist": var tooltip = this.getMessage('unorderedListTooltip'); var button = this.createButton("unorderedlist", tooltip, function() { self.execCommand("insertunorderedlist", false, null); self.saveContentToField(); // Focus editor self.focus(); // Store an undo step self.undo.saveUndo(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'InsertUnorderedList'; span.appendChild(button); break; case "copy": var tooltip = this.getMessage('copyTooltip'); var button = this.createButton("copy", tooltip, function() { self.execCommand("copy", false, null); self.saveContentToField(); // Focus editor self.focus(); }); button.id = 'zpEditor' + this.id + 'Copy'; span.appendChild(button); break; case "cut": var tooltip = this.getMessage('cutTooltip'); var button = this.createButton("cut", tooltip, function() { self.execCommand("cut", false, null); self.saveContentToField(); // Focus editor self.focus(); // Store an undo step self.undo.saveUndo(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'Cut'; span.appendChild(button); break; case "paste": var tooltip = this.getMessage('pasteTooltip'); var button = this.createButton("paste", tooltip, function() { self.execCommand("paste", false, null); self.saveContentToField(); // Focus editor self.focus(); // Store an undo step self.undo.saveUndo(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'Paste'; span.appendChild(button); break; case "outdent": var tooltip = this.getMessage('outdentTooltip'); var button = this.createButton("outdent", tooltip, function() { self.execCommand("outdent", false, null); self.saveContentToField(); // Focus editor self.focus(); // Store an undo step self.undo.saveUndo(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'Outdent'; span.appendChild(button); break; case "indent": var tooltip = this.getMessage('indentTooltip'); var button = this.createButton("indent", tooltip, function() { self.execCommand("indent", false, null); self.saveContentToField(); // Focus editor self.focus(); // Store an undo step self.undo.saveUndo(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'Indent'; span.appendChild(button); break; case "undo": var tooltip = this.getMessage('undoTooltip'); var button = this.createButton("undo", tooltip, function() { // Restore to previous undo step self.undo.undo(); self.saveContentToField(); // Focus editor self.focus(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'Undo'; span.appendChild(button); break; case "redo": var tooltip = this.getMessage('redoTooltip'); var button = this.createButton("redo", tooltip, function() { // Restore to next redo step self.undo.redo(); self.saveContentToField(); // Focus editor self.focus(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'Redo'; span.appendChild(button); break; case "about": var tooltip = this.getMessage('aboutTooltip'); var button = this.createButton("about", tooltip, null, function() { var aboutText = self.getMessage('aboutText'); alert(aboutText); }, "?"); button.id = 'zpEditor' + this.id + 'About'; span.appendChild(button); break; case "fetch": var tooltip = this.getMessage('fetchTooltip'); var button = this.createButton("fetch", tooltip, function() { // Store an undo step self.undo.saveUndo(); self.fetch(); // Store an undo step self.undo.saveUndo(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'Fetch'; span.appendChild(button); break; case "save": var tooltip = this.getMessage('saveTooltip'); var button = this.createButton("save", tooltip, function() { // Store an undo step self.undo.saveUndo(); self.save(); // Update toolbar icon states self.updateToolbar(); }); button.id = 'zpEditor' + this.id + 'Save'; span.appendChild(button); break; case "browser": var tooltip = this.getMessage('browserTooltip'); var button = this.createButton("browser", tooltip, null, function() { var attributes = "status=1, width=" + self.config.externalBrowserWidth + ", height=" + self.config.externalBrowserHeight + ", resizable=yes"; var win = window.open("", "previewWindow", attributes); win.document.body.innerHTML = self.getHTML(); }); button.id = 'zpEditor' + this.id + 'Browser'; span.appendChild(button); break; case "switcher": var tooltip = this.getMessage('htmlTooltip'); var htmlButton = this.createButton("html", tooltip, null, function() { if (self.mode == "WYSIWYG") { self.switchToHTML(); var button = this; setTimeout(function() { htmlButton.style.display = 'none'; htmlButton.zpEditorWYSIWYGButton.style.display = 'block'; }, 10); // Focus html editor self.focusHtml(); } }); tooltip = this.getMessage('wysiwygTooltip'); var wysiwygButton = this.createButton("wysiwyg", tooltip, null, function() { if (self.mode == "HTML") { self.switchToWYSIWYG(); setTimeout(function() { wysiwygButton.style.display = 'none'; wysiwygButton.zpEditorHTMLButton.style.display = 'block'; }, 10); // Focus editor self.focus(); } }); htmlButton.id = 'zpEditor' + this.id + 'Html'; wysiwygButton.id = 'zpEditor' + this.id + 'Wysiwyg'; htmlButton.zpEditorWYSIWYGButton = wysiwygButton; wysiwygButton.zpEditorHTMLButton = htmlButton; wysiwygButton.style.display = 'none'; htmlButton.className += " switch"; wysiwygButton.className += " switch"; span.appendChild(htmlButton); span.appendChild(wysiwygButton); break; case "newpanel": if (span.childNodes.length == 0) { // if last created panel is empty - do not add new panel continue; } span = document.createElement("span"); span.className = "toolbarPanel" td.appendChild(span); break; case "newrow": if (td.childNodes.length == 1 && span.childNodes.length == 0) { // if last created row is empty - do not add new row continue; } tr = document.createElement("tr"); tbody.appendChild(tr); td = document.createElement("td"); tr.appendChild(td); span = document.createElement("span"); span.className = "toolbarPanel"; td.appendChild(span); break; default: Zapatec.Log({description: this.getMessage('unknownToolbarElementError', element)}) } }}/** * Creates a color drop-down button * @private * @param {boolean} isForeground If true a foreground color button will be created, * otherwise a background color button will be created */Zapatec.MinimalEditor.prototype.createColorButton = function(isForeground) { var colorButton = []; var self = this; // Generate color accessors and button id, name, class, tooltip var getter, setter, command, id, strClass, tooltip; if (isForeground) { getter = function() { return self.config.foreColor; }; setter = function(color) { self.config.foreColor = color; }; command = "forecolor"; strClass = "forecolor"; tooltip = this.getMessage('fontColorTooltip'); id = 'zpEditor' + this.id + 'ForeColor'; } else { getter = function() { return self.config.backColor; }; setter = function(color) { self.config.backColor = color; }; if (Zapatec.is_ie || Zapatec.is_khtml) { command = "backcolor"; } else { command = "hilitecolor"; } strClass = "backcolor"; tooltip = this.getMessage('bgColorTooltip'); id = 'zpEditor' + this.id + 'BackColor'; } var setColor = function(color) { // Change button icon color colorButton[0].colorDiv.style.background = color; // Store selected foreground color setter(color); if (Zapatec.is_khtml) { self.restoreSelection(); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -