Home

# Class goog.editor.plugins.BasicTextFormatter

Functions to style text (e.g. underline, make bold, etc.)

extends goog.editor.Plugin

Instance Method Summary
| `applyBgColorManually_(string bgColor)` Applies a background color to a selection when the browser can't do the job. NOTE(nicksantos): If you think this is hacky, you should try applying background color in Opera. It made me cry.
| `applyExecCommandGeckoFixes_(string command)` Apply pre-execCommand fixes for Gecko.
| `applyExecCommandIEFixes_(string command) ⇒ ?Array` Apply pre-execCommand fixes for IE.
| `applyExecCommandSafariFixes_(string command) ⇒ (Element|null|undefined)` Apply pre-execCommand fixes for Safari.
| `applySubscriptSuperscriptWorkarounds_(?goog.editor.plugins.BasicTextFormatter.COMMAND command)` Makes sure that superscript is removed before applying subscript, and vice versa. Fixes {@link http://buganizer/issue?id=1173491} .

`beforeInsertListGecko_() ⇒ boolean`

Work around a Gecko bug that causes inserted lists to forget the current font. This affects WebKit in the same way and Opera in a slightly different way, but this workaround only works in Gecko. WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=19653 Mozilla bug: https://bugzilla.mozilla.org/show_bug.cgi?id=439966 Opera bug: https://bugs.opera.com/show_bug.cgi?id=340392 TODO: work around this issue in WebKit and Opera as well.

| `cleanUpSafariHeadings_()` Fix a ridiculous Safari bug: the first letters of new headings somehow retain their original font size and weight if multiple lines are selected during the execCommand that turns them into headings. The solution is to strip these styles which are normally stripped when making things headings anyway.
| `convertBreaksToDivs_() ⇒ boolean` Convert BRs in the selection to divs. This is only intended to be used in IE and Opera.
| `createLink_(?goog.dom.AbstractRange range, string url, string= opt_target) ⇒ ?goog.editor.Link` Create a link out of the current selection. If nothing is selected, insert a new link. Otherwise, enclose the selection in a link.
| `execCommandHelper_(string command, (boolean|null|number|string=) opt_value, boolean= opt_preserveDir, boolean= opt_styleWithCss)` Perform an execCommand on the active document.
| `execCommandInternal(?goog.editor.plugins.BasicTextFormatter.COMMAND command, (boolean|null|number|string|undefined) var_args) ⇒ (Object|null|undefined)` Execute a user-initiated command.
| `fixIELists_()` Changing an OL to a UL (or the other way around) will fail if the list has a type attribute (such as "UL type=disc" becoming "OL type=disc", which is visually identical). Most browsers will remove the type attribute automatically, but IE doesn't. This does it manually.
| `fixSafariLists_()` Prevent Safari from making each list item be "1" when converting from unordered to ordered lists. (see https://bugs.webkit.org/show_bug.cgi?id=19539 )
| `focusField_()` Focuses on the field.
| `getDocument_() ⇒ ?Document`
| `getRange_() ⇒ ?goog.dom.AbstractRange`
| `invalidateInlineCss_()` Workaround for Opera bug CORE-23903. Opera sometimes fails to invalidate serialized CSS or innerHTML for the DOM after certain execCommands when styleWithCSS is on. Toggling an inline style on the elements fixes it.
| `isJustification_(string command) ⇒ boolean` Returns true if the current justification matches the justification command for the entire selection.
| `isNodeInState_(string nodeName) ⇒ boolean` Returns true if a selection contained in the node should set the appropriate toolbar state for the given nodeName, e.g. if the node is contained in a strong element and nodeName is "strong", then it will return true.
| `isSupportedCommand(string command) ⇒ boolean` Whether the string corresponds to a command this plugin handles.
| `justify_(string command)` Justify the text in the selection.
| `queryCommandHelper_(boolean isGetQueryCommandState, (Document|Range|TextRange|null) queryObject, string command, boolean= opt_styleWithCss) ⇒ (boolean|null|string)` Helper function to perform queryCommand(Value|State).
| `queryCommandStateInternal_((Document|Range|TextRange|null) queryObject, string command, boolean= opt_styleWithCss) ⇒ boolean` Wrapper for browser's queryCommandState.
| `queryCommandValue(string command) ⇒ (boolean|null|string)` Gets the command value.
| `queryCommandValueInternal_((Document|Range|TextRange|null) queryObject, string command, boolean= opt_styleWithCss) ⇒ (boolean|null|string)` Wrapper for browser's queryCommandValue.
| `removeFontSizeFromStyleAttrs_()` Removes inline font-size styles from elements fully contained in the selection, so the font tags produced by execCommand work properly. See {@bug 1286408}.
| `toggleLink_(string= opt_target) ⇒ ?goog.editor.Link` Toggle link for the current selection: If selection contains a link, unlink it, return null. Otherwise, make selection into a link, return the link.

Static Method Summary
| `convertContainerToTextAlign_(?Node node)` Converts the block element containing the given node to use CSS text-align instead of the align property.
| `convertParagraphToDiv_(?Node paragraph, boolean= opt_convertBrs)` Convert the given paragraph to being a div. This clobbers the passed-in node! This is only intended to be used in IE and Opera.
| `convertToRealExecCommand_((goog.editor.plugins.BasicTextFormatter.COMMAND|null|string) command) ⇒ string` If this is a goog.editor.plugins.BasicTextFormatter.COMMAND, convert it to something that we can pass into execCommand, queryCommandState, etc. TODO(user): Consider doing away with the + and converter completely.
| `getNodeJustification_(?Element element) ⇒ string` Determines the justification for a given block-level element.
| `getSelectionBlockState_(?goog.dom.AbstractRange range) ⇒ ?string` Get the toolbar state for the block-level elements in the given range.