-
Notifications
You must be signed in to change notification settings - Fork 0
API
If you would like to get to know to the angularjs adapter, come here.
Main object is called texty. It has one init
function that creates new Texty prototype and one object of functions called utils
.
Returns the element that is used as the main texty node.
name
is the className that will be applied. options
are the same as the rangy options extended by
-
removeClass
: Boolean. If true, the class will be removed from the output.
var editor = texty.init(document.getElementById('editor'));
editor.addApplier('bold', {
elementTagName: 'strong',
removeClass: true
});
<strong>example</strong>
<strong class="bold">example</strong>
<strong>example</strong>
Returns an object of function to control the applier with the given name. The functions are the following:
-
toggle()
: Toogles the applier. -
apply()
: Applies the applier. -
remove()
: Removes the applier. -
is()
: Returns a Boolean if the applier is applied.
Do a redo if called.
Returns a Boolean if redo can be done.
Do a undo if called.
Returns a Boolean if undo can be done.
Adds the callback
that is called whenever modifications can be made to the selection or to the editor. (No parameter is given to the function)
Removes the callback
.
Parses the input
. Adds class to non-span applier. See addApplier.
Returns the output. Classes are removed if needed. (See addApplier.) The unused attributes are removed.
Sets the tag name of the block node. tagName
must be uppercase and texty.utils.blockTagNames
must contain it.
Increases indent on block node by increasing text-indent by 20px.
Decreases indent on block node by decreasing text-indent by 20px.
Sets the align of the block element. Type should be one of left
, center
, right
, justify
.
Removes formatting on the selection.
Inserts the text
in paragraphs. If the text
is string, it will be split on every \n
. If the text
is an array of string, then each will become one paragraph.
Inserts link or replaces selected text to a link. (See Known issues) If no text
is given and there's no selection then Link will be the text of the new A
tag.
Return the newly created A
element.
Collapses selection and inserts image with the given src
.
Returns the newly created IMG
element.
Indicates if the selection is on an image.
The node of the selected image. If no image is selected then undefined.
Indicates if the selection is on an image.
The node of the selected link. If no link is selected then undefined.
Indicates the alignment of the selected block elements. If cannot be determined (e.g. no selection or more types of alignment) then value is undefined.
An array of the name of the active appliers.
An object where the key is the name of the appliers and public functions of the applier are the value.