OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
_backup
/
tinymce
/
tinymce
/
src
/
core
/
main
/
ts
/
api
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/20/2020 05:44:43 AM
rwxr-xr-x
📄
AddOnManager.ts
9.83 KB
02/20/2020 05:41:54 AM
rw-r--r--
📄
Annotator.ts
3.54 KB
02/20/2020 05:41:53 AM
rw-r--r--
📄
Editor.ts
35.88 KB
02/20/2020 05:41:55 AM
rw-r--r--
📄
EditorCommands.ts
16.78 KB
02/20/2020 05:41:55 AM
rw-r--r--
📄
EditorManager.ts
22 KB
02/20/2020 05:41:56 AM
rw-r--r--
📄
EditorObservable.ts
5.88 KB
02/20/2020 05:41:56 AM
rw-r--r--
📄
EditorUpload.ts
8.24 KB
02/20/2020 05:41:57 AM
rw-r--r--
📄
Env.ts
5.05 KB
02/20/2020 05:41:57 AM
rw-r--r--
📄
EventTypes.ts
3.4 KB
02/20/2020 05:41:58 AM
rw-r--r--
📄
Events.ts
1.17 KB
02/20/2020 05:41:58 AM
rw-r--r--
📄
FocusManager.ts
1.37 KB
02/20/2020 05:41:59 AM
rw-r--r--
📄
Formatter.ts
7.65 KB
02/20/2020 05:41:59 AM
rw-r--r--
📄
IconManager.ts
992 bytes
02/20/2020 05:42:00 AM
rw-r--r--
📄
Main.ts
786 bytes
02/20/2020 05:42:01 AM
rw-r--r--
📄
NotificationManager.ts
5.03 KB
02/20/2020 05:42:02 AM
rw-r--r--
📄
PluginManager.ts
493 bytes
02/20/2020 05:42:04 AM
rw-r--r--
📄
Settings.ts
5.44 KB
02/20/2020 05:42:04 AM
rw-r--r--
📄
SettingsTypes.ts
6.75 KB
02/20/2020 05:42:05 AM
rw-r--r--
📄
Shortcuts.ts
6.68 KB
02/20/2020 05:42:05 AM
rw-r--r--
📄
ThemeManager.ts
1016 bytes
02/20/2020 05:42:06 AM
rw-r--r--
📄
Tinymce.ts
7.54 KB
02/20/2020 05:42:06 AM
rw-r--r--
📄
UndoManager.ts
11.93 KB
02/20/2020 05:42:09 AM
rw-r--r--
📄
WindowManager.ts
7.1 KB
02/20/2020 05:42:09 AM
rw-r--r--
📁
dom
-
02/20/2020 06:46:12 AM
rwxr-xr-x
📁
file
-
02/20/2020 06:11:56 AM
rwxr-xr-x
📁
fmt
-
02/20/2020 06:11:59 AM
rwxr-xr-x
📁
geom
-
02/20/2020 06:12:03 AM
rwxr-xr-x
📁
html
-
02/20/2020 06:12:08 AM
rwxr-xr-x
📁
ui
-
02/20/2020 06:12:12 AM
rwxr-xr-x
📁
util
-
02/20/2020 06:12:21 AM
rwxr-xr-x
Editing: Formatter.ts
Close
/** * Copyright (c) Tiny Technologies, Inc. All rights reserved. * Licensed under the LGPL or a commercial license. * For LGPL see License.txt in the project root for license information. * For commercial licenses see https://www.tiny.cloud/ */ import { Node } from '@ephox/dom-globals'; import { Cell, Fun } from '@ephox/katamari'; import ApplyFormat from '../fmt/ApplyFormat'; import * as CaretFormat from '../fmt/CaretFormat'; import * as FormatChanged from '../fmt/FormatChanged'; import { FormatRegistry } from '../fmt/FormatRegistry'; import MatchFormat from '../fmt/MatchFormat'; import Preview from '../fmt/Preview'; import RemoveFormat from '../fmt/RemoveFormat'; import ToggleFormat from '../fmt/ToggleFormat'; import FormatShortcuts from '../keyboard/FormatShortcuts'; import { Format, FormatVars } from './fmt/Format'; import Editor from './Editor'; /** * Text formatter engine class. This class is used to apply formats like bold, italic, font size * etc to the current selection or specific nodes. This engine was built to replace the browser's * default formatting logic for execCommand due to its inconsistent and buggy behavior. * * @class tinymce.Formatter * @example * tinymce.activeEditor.formatter.register('mycustomformat', { * inline: 'span', * styles: {color: '#ff0000'} * }); * * tinymce.activeEditor.formatter.apply('mycustomformat'); */ // TODO: Figure out why we need a range like object, instead of an actual range (see ExpandRange.ts) interface RangeLikeObject { startContainer: Node; startOffset: number; endContainer: Node; endOffset: number; } interface Formatter extends FormatRegistry { apply (name: string, vars?: FormatVars, node?: Node | RangeLikeObject): void; remove (name: string, vars?: FormatVars, node?: Node | RangeLikeObject, similar?: boolean): void; toggle (name: string, vars?: FormatVars, node?: Node): void; match (name: string, vars?: FormatVars, node?: Node): boolean; matchAll (names: string[], vars?: FormatVars): Format[]; matchNode (node: Node, name: string, vars?: FormatVars, similar?: boolean): boolean; canApply (name: string): boolean; formatChanged (names: string, callback: FormatChanged.FormatChangeCallback, similar?: boolean): { unbind: () => void }; getCssText (format: string | Format): string; } const Formatter = function (editor: Editor): Formatter { const formats = FormatRegistry(editor); const formatChangeState = Cell(null); FormatShortcuts.setup(editor); CaretFormat.setup(editor); return { /** * Returns the format by name or all formats if no name is specified. * * @method get * @param {String} name Optional name to retrieve by. * @return {Array/Object} Array/Object with all registered formats or a specific format. */ get: formats.get, /** * Returns true or false if a format is registered for the specified name. * * @method has * @param {String} name Format name to check if a format exists. * @return {boolean} True/False if a format for the specified name exists. */ has: formats.has, /** * Registers a specific format by name. * * @method register * @param {Object/String} name Name of the format for example "bold". * @param {Object/Array} format Optional format object or array of format variants * can only be omitted if the first arg is an object. */ register: formats.register, /** * Unregister a specific format by name. * * @method unregister * @param {String} name Name of the format for example "bold". */ unregister: formats.unregister, /** * Applies the specified format to the current selection or specified node. * * @method apply * @param {String} name Name of format to apply. * @param {Object} vars Optional list of variables to replace within format before applying it. * @param {Node} node Optional node to apply the format to defaults to current selection. */ apply: Fun.curry(ApplyFormat.applyFormat, editor), /** * Removes the specified format from the current selection or specified node. * * @method remove * @param {String} name Name of format to remove. * @param {Object} vars Optional list of variables to replace within format before removing it. * @param {Node/Range} node Optional node or DOM range to remove the format from defaults to current selection. */ remove: Fun.curry(RemoveFormat.remove, editor), /** * Toggles the specified format on/off. * * @method toggle * @param {String} name Name of format to apply/remove. * @param {Object} vars Optional list of variables to replace within format before applying/removing it. * @param {Node} node Optional node to apply the format to or remove from. Defaults to current selection. */ toggle: Fun.curry(ToggleFormat.toggle, editor, formats), /** * Matches the current selection or specified node against the specified format name. * * @method match * @param {String} name Name of format to match. * @param {Object} vars Optional list of variables to replace before checking it. * @param {Node} node Optional node to check. * @return {boolean} true/false if the specified selection/node matches the format. */ match: Fun.curry(MatchFormat.match, editor), /** * Matches the current selection against the array of formats and returns a new array with matching formats. * * @method matchAll * @param {Array} names Name of format to match. * @param {Object} vars Optional list of variables to replace before checking it. * @return {Array} Array with matched formats. */ matchAll: Fun.curry(MatchFormat.matchAll, editor), /** * Return true/false if the specified node has the specified format. * * @method matchNode * @param {Node} node Node to check the format on. * @param {String} name Format name to check. * @param {Object} vars Optional list of variables to replace before checking it. * @param {Boolean} similar Match format that has similar properties. * @return {Object} Returns the format object it matches or undefined if it doesn't match. */ matchNode: Fun.curry(MatchFormat.matchNode, editor), /** * Returns true/false if the specified format can be applied to the current selection or not. It * will currently only check the state for selector formats, it returns true on all other format types. * * @method canApply * @param {String} name Name of format to check. * @return {boolean} true/false if the specified format can be applied to the current selection/node. */ canApply: Fun.curry(MatchFormat.canApply, editor), /** * Executes the specified callback when the current selection matches the formats or not. * * @method formatChanged * @param {String} formats Comma separated list of formats to check for. * @param {function} callback Callback with state and args when the format is changed/toggled on/off. * @param {Boolean} similar True/false state if the match should handle similar or exact formats. */ formatChanged: Fun.curry(FormatChanged.formatChanged, editor, formatChangeState), /** * Returns a preview css text for the specified format. * * @method getCssText * @param {String/Object} format Format to generate preview css text for. * @return {String} Css text for the specified format. * @example * var cssText1 = editor.formatter.getCssText('bold'); * var cssText2 = editor.formatter.getCssText({inline: 'b'}); */ getCssText: Fun.curry(Preview.getCssText, editor) }; }; export default Formatter;