📄 sync.richtextarea.js
字号:
if (features.image) { insertMenu.addItem(new Extras.OptionModel("insertimage", this._msg["Menu.InsertImage"], this._icons.image)); } if (features.hyperlink) { insertMenu.addItem(new Extras.OptionModel("inserthyperlink", this._msg["Menu.InsertHyperlink"], this._icons.hyperlink)); } insertMenu.addItem(new Extras.SeparatorModel()); if (features.table) { insertMenu.addItem(new Extras.OptionModel("inserttable", this._msg["Menu.InsertTable"], this._icons.table)); } menu.addItem(insertMenu); } if (features.bold || features.italic || features.underline || features.strikeThrough || features.subscript || features.paragraphStyle || features.alignment || features.indent || features.foreground || features.background) { var formatMenu = new Extras.MenuModel(null, this._msg["Menu.Format"], null); if (features.bold || features.italic || features.underline || features.strikeThrough || features.subscript) { } if (features.paragraphStyle) { formatMenu.addItem(new Extras.MenuModel(null, this._msg["Menu.ParagraphStyle"], this._icons.paragraphStyle, [ new Extras.OptionModel("/formatblock/<p>", this._msg["Menu.Normal"], this._icons.styleNormal), new Extras.OptionModel("/formatblock/<pre>", this._msg["Menu.Preformatted"], this._icons.stylePreformatted), new Extras.OptionModel("/formatblock/<h1>", this._msg["Menu.Heading1"], this._icons.styleH1), new Extras.OptionModel("/formatblock/<h2>", this._msg["Menu.Heading2"], this._icons.styleH2), new Extras.OptionModel("/formatblock/<h3>", this._msg["Menu.Heading3"], this._icons.styleH3), new Extras.OptionModel("/formatblock/<h4>", this._msg["Menu.Heading4"], this._icons.styleH4), new Extras.OptionModel("/formatblock/<h5>", this._msg["Menu.Heading5"], this._icons.styleH5), new Extras.OptionModel("/formatblock/<h6>", this._msg["Menu.Heading6"], this._icons.styleH6) ])); } if (features.bold || features.italic || features.underline || features.strikeThrough || features.subscript) { var textMenu = new Extras.MenuModel(null, this._msg["Menu.TextStyle"], this._icons.textStyle); textMenu.addItem(new Extras.OptionModel("/removeformat", this._msg["Menu.PlainText"], this._icons.plainText)); textMenu.addItem(new Extras.SeparatorModel()); if (features.bold) { textMenu.addItem(new Extras.OptionModel("/bold", this._msg["Menu.Bold"], this._icons.bold)); } if (features.italic) { textMenu.addItem(new Extras.OptionModel("/italic", this._msg["Menu.Italic"], this._icons.italic)); } if (features.underline) { textMenu.addItem(new Extras.OptionModel("/underline", this._msg["Menu.Underline"], this._icons.underline)); } if (features.strikethrough) { textMenu.addItem(new Extras.OptionModel("/strikethrough", this._msg["Menu.Strikethrough"], this._icons.strikethrough)); } textMenu.addItem(new Extras.SeparatorModel()); if (features.subscript) { textMenu.addItem(new Extras.OptionModel("/superscript", this._msg["Menu.Superscript"], this._icons.superscript)); textMenu.addItem(new Extras.OptionModel("/subscript", this._msg["Menu.Subscript"], this._icons.subscript)); } formatMenu.addItem(textMenu); } if (features.alignment) { formatMenu.addItem(new Extras.MenuModel(null, this._msg["Menu.Alignment"], this._icons.alignment, [ new Extras.OptionModel("/justifyleft", this._msg["Menu.Left"], this._icons.alignmentLeft), new Extras.OptionModel("/justifycenter", this._msg["Menu.Center"], this._icons.alignmentCenter), new Extras.OptionModel("/justifyright", this._msg["Menu.Right"], this._icons.alignmentRight), new Extras.OptionModel("/justifyfull", this._msg["Menu.Justified"], this._icons.alignmentJustify) ])); } formatMenu.addItem(new Extras.SeparatorModel()); if (features.indent) { formatMenu.addItem(new Extras.OptionModel("/indent", this._msg["Menu.Indent"], this._icons.indent)); formatMenu.addItem(new Extras.OptionModel("/outdent", this._msg["Menu.Outdent"], this._icons.outdent)); } formatMenu.addItem(new Extras.SeparatorModel()); if (features.foreground || features.background) { if (features.foreground) { formatMenu.addItem(new Extras.OptionModel("foreground", this._msg["Menu.SetForeground"], this._icons.foreground)); } if (features.background) { formatMenu.addItem(new Extras.OptionModel("background", this._msg["Menu.SetBackground"], this._icons.background)); } } menu.addItem(formatMenu); } return menu; }, /** * Creates main menu bar component. * * @return the main menu bar * @type Extras.MenuBarPane */ _createMenu: function() { return new Extras.MenuBarPane({ styleName: this.component.render("menuStyleName"), model: this._createMainMenuBarModel(), events: { action: Core.method(this, this._processMenuAction) } }); }, /** * Creates tool bar component. * * @return the toolbar * @type Echo.Component */ _createToolbar: function() { var row, button; var features = this.component.render("features", Extras.Sync.RichTextArea.defaultFeatures); var controlsRow; var panel = new Echo.Panel({ styleName: this.component.render("toolbarPanelStyleName"), layoutData: { overflow: Echo.SplitPane.OVERFLOW_HIDDEN }, insets: 2, children: [ controlsRow = new Echo.Row({ styleName: this.component.render("toolbarRowStyleName"), cellSpacing: 10 }) ] }); // Style Dropdown. if (features.paragraphStyle) { var actionListener = Core.method(this, function(e) { var style = this._styleSelect.get("selectedId"); this._richTextInput.peer.execCommand("formatblock", "<" + style + ">"); }); this._styleSelect = new Echo.SelectField({ items: [ { id: "p", text: this._msg["Menu.Normal"] }, { id: "pre", text: this._msg["Menu.Preformatted"] }, { id: "h1", text: this._msg["Menu.Heading1"] }, { id: "h2", text: this._msg["Menu.Heading2"] }, { id: "h3", text: this._msg["Menu.Heading3"] }, { id: "h4", text: this._msg["Menu.Heading4"] }, { id: "h5", text: this._msg["Menu.Heading5"] }, { id: "h6", text: this._msg["Menu.Heading6"] } ], events: { action: actionListener } }); controlsRow.add(this._styleSelect); } // Undo/Redo Tools if (features.undo) { controlsRow.add(new Echo.Row({ children: [ this._createToolbarButton("<<<", this._icons.undo, this._msg["Menu.Undo"], this._processCommand, "undo"), this._createToolbarButton(">>>", this._icons.redo, this._msg["Menu.Redo"], this._processCommand, "redo") ] })); } // Font Bold/Italic/Underline Tools if (features.bold || features.italic || features.underline) { row = new Echo.Row(); if (features.bold) { button = this._createToolbarButton("B", this._icons.bold, this._msg["Menu.Bold"], this._processCommand, "bold"); button.set("toggle", true); row.add(button); } if (features.italic) { button = this._createToolbarButton("I", this._icons.italic, this._msg["Menu.Italic"], this._processCommand, "italic"); button.set("toggle", true); row.add(button); } if (features.underline) { button = this._createToolbarButton("U", this._icons.underline, this._msg["Menu.Underline"], this._processCommand, "underline"); button.set("toggle", true); row.add(button); } controlsRow.add(row); } //Super/Subscript Tools if (features.subscript) { controlsRow.add(new Echo.Row({ children: [ this._createToolbarButton("^", this._icons.superscript, this._msg["Menu.Superscript"], this._processCommand, "superscript"), this._createToolbarButton("v", this._icons.subscript,this._msg["Menu.Subscript"], this._processCommand, "subscript") ] })); } // Alignment Tools if (features.alignment) { controlsRow.add(new Echo.Row({ children: [ this._createToolbarButton("<-", this._icons.alignmentLeft, this._msg["Menu.Left"], this._processCommand, "justifyleft"), this._createToolbarButton("-|-", this._icons.alignmentCenter, this._msg["Menu.Center"], this._processCommand, "justifycenter"), this._createToolbarButton("->", this._icons.alignmentRight, this._msg["Menu.Right"], this._processCommand, "justifyright"), this._createToolbarButton("||", this._icons.alignmentJustify, this._msg["Menu.Justified"], this._processCommand, "justifyfull") ] })); } // Color Tools if (features.foreground || features.background) { row = new Echo.Row(); if (features.foreground) { row.add(this._createToolbarButton("FG", this._icons.foreground, this._msg["Menu.SetForeground"], this.processSetForeground, "foreground")); } if (features.background) { row.add(this._createToolbarButton("BG", this._icons.background, this._msg["Menu.SetBackground"], this.processSetBackground, "background")); } controlsRow.add(row); } // Insert Tools if (features.list || features.horizontalRule || features.image || features.hyperlink || features.table) { row = new Echo.Row(); if (features.list) { row.add(this._createToolbarButton("Bulleted List", this._icons.bulletedList, this._msg["Menu.BulletedList"], this._processCommand, "insertunorderedlist")); row.add(this._createToolbarButton("Numbered List", this._icons.numberedList, this._msg["Menu.NumberedList"], this._processCommand, "insertorderedlist")); } if (features.horizontalRule) { row.add(this._createToolbarButton("Horizontal Rule", this._icons.horizontalRule, this._msg["Menu.InsertHorizontalRule"], this._processCommand, "inserthorizontalrule")); } if (features.image) { row.add(this._createToolbarButton("Image", this._icons.image, this._msg["Menu.InsertImage"], this.processInsertImage)); } if (features.hyperlink) { row.add(this._createToolbarButton("Hyperlink", this._icons.hyperlink, this._msg["Menu.InsertHyperlink"], this.processInsertHyperlink)); } if (features.table) { row.add(this._createToolbarButton("Table", this._icons.table, this._msg["Menu.InsertTable"], this.processInsertTable)); } controlsRow.add(row); } return panel; }, _createToolbarButton: function(text, icon, toolTipText, eventMethod, actionCommand) { var button = new Extras.Sync.RichTextArea.ToolbarButton({ actionCommand: actionCommand, styleName: this.component.render("toolbarButtonStyleName"), text: icon ? null : text, icon: icon, toolTipText: toolTipText }); if (eventMethod) { button.addListener("action", Core.method(this, eventMethod)); } this._toolbarButtons[actionCommand] = button; return button; }, execCommand: function(commandName, value) { this._richTextInput.peer.execCommand(commandName, value); }, focusDocument: function() { this._richTextInput.peer.focusDocument(); }, getDomainElement: function() { return this._mainDiv; }, _getDefaultIcon: function(name) { return this.client.getResourceUrl("Extras", "image/richtext/" + name + ".gif"); }, /** * Returns default icon set map object. * @type Object */ _getDefaultIcons: function() { var iconNames = [ "alignmentCenter", "alignmentJustify", "alignmentLeft", "alignmentRight", "background", "bold", "bulletedList", "cancel", "copy", "cut", "foreground", "horizontalRule", "hyperlink", "image", "ident", "italic", "numberedList", "ok", "outdent", "paste", "redo", "subscript", "superscript", "table", "underline", "undo" ]; var defaultIcons = { }; for (var i = 0; i < iconNames.length; ++i) { var iconResource = iconNames[i].charAt(0).toUpperCase() + iconNames[i].substring(1); defaultIcons[iconNames[i]] = this.client.getResourceUrl("Extras", "image/richtext/" + iconResource + ".gif"); } return defaultIcons; }, insertHtml: function(html) { this._richTextInput.peer._insertHtml(html); }, insertImage: function(url) { this.insertHtml("<img src=\"" + url + "\">"); }, insertTable: function(columns, rows) { var rowHtml = "", i; for (i = 0; i < columns; ++i) { rowHtml += "<td></td>";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -