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

📄 richtexteditor.js

📁 javascript 很酷的类库
💻 JS
📖 第 1 页 / 共 2 页
字号:
/*
 * Isomorphic SmartClient
 * Version 6.5 (2008-04-30)
 * Copyright(c) 1998-2007 Isomorphic Software, Inc. All rights reserved.
 * "SmartClient" is a trademark of Isomorphic Software, Inc.
 *
 * licensing@smartclient.com
 *
 * http://smartclient.com/license
 */
 //>	@class RichTextEditor//  // RichTextEditing component.  Provides a rich-text editing area along with UI for executing// rich-text commands on the text.<br>// The HTML generated from this component may vary by browser, and, as with any HTML // value created on the client, we recommend values be sanitized on the server before // storing and displaying to other users.<br>// Note: This component has limited support on the Safari browser.////// @treeLocation Client Reference/Foundation// @visibility external// @example RichTextEditor//<isc.ClassFactory.defineClass("RichTextEditor", "VLayout");isc.RichTextEditor.addProperties({    // Edit Area config    editAreaConstructor : "RichTextCanvas",    //> @attr RichTextEditor.editAreaBackgroundColor (string : "white" : IR)    // Background color for the edit area.    //<    editAreaBackgroundColor : "white",    //>@attr    RichTextEditor.editAreaBackgroundClassName (string : null : IR)    // Edit Area can have a custom class applied.    //<    editAreaClassName : "normal",        //>@attr    RichTextEditor.value   (string : "" : IRW)    //  Initial value for the edit area.    Use <code>getValue()</code> and     // <code>setValue()</code> to update at runtime.    // @visibility external    //<    value : "",        // General toolbar config        // Toolbar will be an HLayout    toolbarConstructor : "HLayout",        toolbarHeight : 24, // should be less but figure this out later!    toolbarBackgroundColor : "#CCCCCC",        toolbarSeparatorSrc : "[SKIN]/RichTextEditor/separator.png",            // Default width for control buttons    controlButtonWidth : 20,        //>@attr RichTextEditor.defaultControlConstructor  (class : isc.Button : [IRA])    //  By default our 'controls' will be of this specified class. Override for specific     //  controls by either implementing a '[controlName]_autoMaker' function which returns the    //  control, or by specifying '[controlName]Constructor' as a pointer to an appropriate     //  isc class.    //<    defaultControlConstructor : isc.Button,    //>@attr RichTextEditor.controlGroups  (array : ["fontControls", "formatControls", "styleControls", "colorControls"] : [IRA])    //  An array of control group names (strings) specifying which groups of controls should     //  be included in the editor toolbar.<br>    //  For each control group name, this[controlGroupName] should be defined as an array of     //  +link{type:ControlName}s, allowing the controlGroup to be customized.    //     // @visibility external    // @example RichTextEditor    //<    controlGroups : [        "fontControls", "formatControls", "styleControls", "colorControls"        // ,"editControls"  // Don't show the edit controls by default as they're disabled                            // on Moz and Safari.    ],	//>	@type	ControlName    //  <code>ControlNames</code> are strings used to specify which UI controls should appear    //  in the editor toolbar.<br>    // @value "boldSelection"  A button to make the current selection bold.    // @value "italicSelection"  A button to make the current selection italic.    // @value "underlineSelection" A button to make the current selection underlined.    // @value "fontSelector" A select item allowing the user to change the font of the current    //                     text selection.    // @value "fontSizeSelector" A select item allowing the user to change the font     //                      size of the current text selection.    // @value "alignLeft" A button to left-align the selected text.    // @value "alignRight" A button to right-align the selected text.    // @value "alignCenter" A button to center the selected text    // @value "justify" A button to justify the selected line of text.    // @value "color" A color-picker allowing the user to set the text color    // @value "backgroundColor" A color picker allowing the user to set the text background     // color    // @visibility external    //<    // In addition to the standard ControlNames, custom controls can be added.    // To add a custom control simply add a new control name (string) to a controlGroup.    // By default the control will show up as a button with width specified by     // <code>richTextCanvas.controlButtonWidth</code>.<br>    // Properties for each control will be picked up from <code>this.[ControlName]Defaults</code>     // and <code>this.[ControlName]Properties</code>.<br>    // If no click handler is specified in these property blocks, click will call     // <code>fireAction()</code> on this editor, passing in the ControlName as an action to fire.<br>    //        //  Note - for custom click-handling purposes, default control buttons are created with    //  a 'creator' property which points back to the richTextEditor that created them.<br>    //  For completely custom controls to be included in the toolbar, define a method named    //  [ControlName]_autoMaker on the RichTextEditor instance. This method should return a    //  widget instance, which will then be added to the toolbar in the appropriate position.    // Style Control Config --------------------------------------            //>@attr    RichTextEditor.styleControls   (array : ["boldSelection", "italicSelection", "underlineSelection"] : [IRA])    //  Default text styling control group. Consists of an array of     //  +link{type:ControlName}s. To display this group of controls for some RichTextEditor,    //  include <code>"styleControls"</code> in the +link{RichTextEditor.controlGroups} array    // @visibility external    //<    styleControls : [        "boldSelection", "italicSelection", "underlineSelection"    ],        // Properties to apply to the style controls.    // These are picked up based on their name.    //  NOTE: on a per-instance basis we also pick up this.boldSelectionProperties, etc.    boldSelectionDefaults : {title:"<b>B</b>", prompt:"Make selection bold"},    italicSelectionDefaults : {title:"<i>I</i>", prompt:"Make selection italic"},    underlineSelectionDefaults : {title:"<u>U</u>", prompt:"Make selection underlined"},    // Font Control Config --------------------------------------        //>@attr    RichTextEditor.fontControls (array : ["fontSelector", "fontSizeSelector"] : [IRA])    //  Default font control group. Consists of an array of     //  +link{type:ControlName}s. To display this group of controls for some RichTextEditor,    //  include <code>"fontControls"</code> in the +link{RichTextEditor.controlGroups} array    // @visibility external    //<            fontControls : [        "fontSelector", "fontSizeSelector"    ],        // Specify the constructor function for the two dynamic form type items        fontSelectorConstructor : isc.DynamicForm,    fontSizeSelectorConstructor : isc.DynamicForm,        //>@attr    RichTextEditor.fontNames   (object : {} : [IRA])    //  ValueMap of css fontName properties to font name titles to display in the font selector     //  if <code>"fontSelector"</code> is included in +link{RichTextEditor.controlGroups}     //  for this editor.    //  Default value for this attribute:<br>    // <code> {    // &nbsp;&nbsp;"arial,helvetica,sans-serif":"Arial",    // &nbsp;&nbsp;'courier new,courier,monospace':"Courier New",	// &nbsp;&nbsp;'georgia,times new roman,times,serif':"Georgia",	// &nbsp;&nbsp;'tahoma,arial,helvetica,sans-serif':"Tahoma",	// &nbsp;&nbsp;'times new roman,times,serif':"Times New Roman",    // &nbsp;&nbsp;'verdana,arial,helvetica,sans-serif':"Verdana",    // &nbsp;&nbsp;"impact":"Impact"}</code>    // @visibility external    //<    //  The default <code>createFontSelector()</code> method will apply this valueMap to the    //  select item created as the <code>fontSelector</code> control.    //<    fontNames:{		"arial,helvetica,sans-serif":"Arial",		'courier new,courier,monospace':"Courier New",		'georgia,times new roman,times,serif':"Georgia",		'tahoma,arial,helvetica,sans-serif':"Tahoma",		'times new roman,times,serif':"Times New Roman",		'verdana,arial,helvetica,sans-serif':"Verdana",		"impact":"Impact"	},        //>@attr    RichTextEditor.fontSizes   (object : {} : [IRA])    //  ValueMap of css font size property values to font size titles to display in the font size    //  selector if <code>"fontSizeSelector"</code> is included in     //  +link{RichTextEditor.controlGroups}.    //  Default value for this attribute:<br>    // <code>{    // &nbsp;&nbsp;"1":"1 (8 pt)",    // &nbsp;&nbsp;"2":"2 (10 pt)",    // &nbsp;&nbsp;"3":"3 (12 pt)",    // &nbsp;&nbsp;"4":"4 (14 pt)",    // &nbsp;&nbsp;"5":"5 (18 pt)",    // &nbsp;&nbsp;"6":"6 (24 pt)",    // &nbsp;&nbsp;"7":"7 (36 pt)"}</code>    // @visibility external    //<    //  The default <code>createFontSizeSelector()</code> method will apply this valueMap to the    //  select item created as the <code>fontSizeSelector</code> control.    fontSizes : {		"1":"1 (8 pt)",		"2":"2 (10 pt)",		"3":"3 (12 pt)",		"4":"4 (14 pt)",		"5":"5 (18 pt)",		"6":"6 (24 pt)",		"7":"7 (36 pt)"    },        // Edit Control Config --------------------------------------    // (Note: edit controls are hidden by default, as cut, copy, paste are disabled for     //  security reasons in Moz by default, and paste appears to never be supported in Safari).        //>@attr    RichTextEditor.editControls   (array : [...] : [IRA])    //  Edit control group. Consists of an array of +link{type:ControlName}s.    //<    // Leave this @visibility internal until for now.    editControls : [        "copySelection", "cutSelection", "pasteSelection"    ],        // Defaults for the cut/copy/paste buttons    copySelectionDefaults : { icon:"[SKIN]/RichTextEditor/copy.png", prompt:"Copy Selection" },    cutSelectionDefaults : { icon:"[SKIN]/RichTextEditor/cut.png", prompt:"Cut Selection"},    pasteSelectionDefaults : {icon:"[SKIN]/RichTextEditor/paste.png", prompt:"Paste"},        // Format Control Config --------------------------------------    //>@attr    RichTextEditor.formatControls   (array : ["alignLeft", "alignRight", "alignCenter", "justify"] : [IRA])    //  Default text formatting control group. Consists of an array of     //  +link{type:ControlName}s. To display this group of controls for some RichTextEditor,    //  include <code>"formatControls"</code> in the +link{RichTextEditor.controlGroups} array    // @visibility external    //<    formatControls : [        "alignLeft", "alignRight", "alignCenter", "justify"        // Disable indent/outdent for now, since they're not supported by Safari.//        ,"indentSelection", "outdentSelection"    ],        // Note: click is overridden on the various "justify..." controls as they are going to    // call 'justifySelection(...)' passing in a parameter to specify the desired justification.    alignLeftDefaults : { icon:"[SKIN]/RichTextEditor/text_align_left.png",                          prompt:"Left align selection",                          click:"this.creator.fireAction('justifySelection', 'left');"      },    alignCenterDefaults : { icon:"[SKIN]/RichTextEditor/text_align_center.png",                            prompt:"Center selection",                            click:"this.creator.fireAction('justifySelection', 'center');"    },    alignRightDefaults : { icon:"[SKIN]/RichTextEditor/text_align_right.png",                           prompt:"Right align selection",                           click:"this.creator.fireAction('justifySelection', 'right');"    },    justifyDefaults : { icon:"[SKIN]/RichTextEditor/text_align_justified.png",                        prompt:"Full justify selection",                        click:"this.creator.fireAction('justifySelection', 'full');"    },    // Indent / Outdent - not included by default as not supported on Safari    indentSelectionDefaults : { icon:"[SKIN]/RichTextEditor/indent.png",  prompt:"Indent selection"},    outdentSelectionDefaults : { icon:"[SKIN]/RichTextEditor/outdent.png", prompt:"Decrease selection indent"},        // Color Control Config --------------------------------------        //>@attr    RichTextEditor.colorControls (array : ["color", "backgroundColor"] : [IRA])    //  Control group for modifying text color / background color.     //  Consists of an array of +link{type:ControlName}s.    //  To display this group of controls for some RichTextEditor,    //  include <code>"formatControls"</code> in the +link{RichTextEditor.controlGroups} array    // @visibility external    colorControls : [        "color", "backgroundColor"    ],        // color / background color defaults override click handling to prompt the user for a    // color and apply it to the selection.    colorDefaults : { icon:"[SKIN]/RichTextEditor/text_color.gif",                       prompt:"Set selection color",                      click:"this.creator.chooseTextColor()"    },                        backgroundColorDefaults : { icon:"[SKIN]/RichTextEditor/background_color.gif",                                 prompt:"Set selection background color",                                click:"this.creator.chooseBackgroundColor()"     },        // For tabbing / focussing purposes, this editor should pass straight through to the    // editArea    canFocus:true,    _useFocusProxy:false,    _useNativeTabIndex:false    });isc.RichTextEditor.addClassProperties({    // Whenever the edit area changes we want to be notified too.    // Avoid recreating the notification function (fired in the scope of the edit area)    _canvasContentsChanged : function (oldValue, newValue) {        this.creator._valueChanged(oldValue, newValue);    }});//!>Deferred

⌨️ 快捷键说明

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