<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>evolutionComposer jQuery Plugin</title><link>https://community.telligent.com/community/11/w/api-documentation/67141/evolutioncomposer-jquery-plugin</link><description /><dc:language>en-US</dc:language><generator>14.0.0.586 14</generator><item><title>evolutionComposer jQuery Plugin</title><link>https://community.telligent.com/community/11/w/api-documentation/67141/evolutioncomposer-jquery-plugin</link><pubDate>Tue, 25 Jun 2019 19:41:48 GMT</pubDate><guid isPermaLink="false">9681db2d-e301-4dd9-a400-ee0d14887528</guid><dc:creator>Ben Tiedt</dc:creator><comments>https://community.telligent.com/community/11/w/api-documentation/67141/evolutioncomposer-jquery-plugin#comments</comments><description>Current Revision posted to API Documentation by Ben Tiedt on 06/25/2019 19:41:48&lt;br /&gt;
&lt;hr class="generated-documentation-start" style="border-width:0;" /&gt;
&lt;h3&gt;&lt;a id="jQuery_fn_evolutionComposer" name="jQuery_fn_evolutionComposer"&gt;&lt;/a&gt;jQuery.fn.evolutionComposer&lt;/h3&gt;
&lt;p&gt;The composer is a jQuery plugin which enhances a &lt;code&gt;textarea&lt;/code&gt; element with a shell API, enabling plugins to add extra interactive functionality to the &lt;code&gt;textarea&lt;/code&gt; in a cooperative manner. Composer plugins define when they should be activated and released based on states of the &lt;code&gt;textarea&lt;/code&gt;, and can manipulate the &lt;code&gt;textarea&lt;/code&gt;&amp;#39;s, text, size, highlights, and ultimately its value as returned to the client code.&lt;/p&gt;
&lt;p&gt;Composer plugins enable [[hashtags Composer Plugin|hashtag]] and [[mentions Composer Plugin|@mention]] support on textareas via Evolution-provided plugins, though the composer is not limited to only these plugins.&lt;/p&gt;
&lt;p&gt;Each composer instance also implements auto-resizing against the textarea via the [[evolutionResize jQuery Plugin|evolutionResize plugin]].&lt;/p&gt;
&lt;h3&gt;&lt;a id="Usage" name="Usage"&gt;&lt;/a&gt;Usage&lt;/h3&gt;
&lt;p&gt;Initializes a composer plugin against a &lt;code&gt;textarea&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$(&amp;#39;textarea.myTextArea&amp;#39;).evolutionComposer(options)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Initialize a composer with [[hashtags Composer Plugin|hashtags]] and [[mentions Composer Plugin|@mentions]].&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$(&amp;#39;textarea.myTextArea&amp;#39;).evolutionComposer({
    plugins: ['hashtags', 'mentions']
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Retrieves the current value of the Composer. In the case of usage of hashtags or mentions, the value will include the proper tokens for tags and mentions.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;var value = $(&amp;#39;textarea.myTextArea&amp;#39;).evolutionCompser(&amp;#39;val&amp;#39;);
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;&lt;a id="Options" name="Options"&gt;&lt;/a&gt;Options&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;plugins&lt;/code&gt;: Array of Composer plugin objects or string names of Composer plugins&lt;/li&gt;
&lt;li&gt;&lt;code&gt;focus&lt;/code&gt;: when true, auto-focuses. &lt;em&gt;default&lt;/em&gt;: &lt;code&gt;false&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;contentTypeId&lt;/code&gt;: when set, identifies the type of content being edited&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All other options are passed to Composer plugins.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Methods" name="Methods"&gt;&lt;/a&gt;Methods&lt;/h3&gt;
&lt;h4&gt;&lt;a id="val" name="val"&gt;&lt;/a&gt;val&lt;/h4&gt;
&lt;p&gt;Gets or sets the current value of the composer.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This should be used instead of &lt;code&gt;$(&amp;#39;textarea&amp;#39;).val()&lt;/code&gt;, as each Composer plugin gets the opportunity to mutate the value before it is returned to the caller.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// get a value
var value = $(&amp;#39;textarea&amp;#39;).evolutionComposer(&amp;#39;val&amp;#39;);

// set a value
$(&amp;#39;textarea&amp;#39;).evolutionComposer(&amp;#39;val&amp;#39;, &amp;#39;new value&amp;#39;);
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;&lt;a id="onkeydown" name="onkeydown"&gt;&lt;/a&gt;onkeydown&lt;/h4&gt;
&lt;p&gt;Handles the keydown event within a Composer.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: This should be used instead of &lt;code&gt;$(&amp;#39;textarea).on(&amp;#39;keydown&amp;#39;, fn)&lt;/code&gt; as each Composer plugin gets the opportunity to conditionally interact and cancel this event.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$(&amp;#39;textarea&amp;#39;).evolutionComposer(&amp;#39;onkeydown&amp;#39;, function(e) {
    // handle event
});
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;&lt;a id="oninput" name="oninput"&gt;&lt;/a&gt;oninput&lt;/h4&gt;
&lt;p&gt;Handles the &lt;a href="https://developer.mozilla.org/en-US/docs/DOM/DOM_event_reference/input"&gt;input&lt;/a&gt; event within a Composer.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: This should be used instead of &lt;code&gt;$(&amp;#39;textarea).on(&amp;#39;input&amp;#39;, fn)&lt;/code&gt; as each Composer plugin gets the opportunity to conditionally interact and cancel this event. &lt;code&gt;Input&lt;/code&gt; is shimmed in older browsers which do not natively support the event.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$(&amp;#39;textarea&amp;#39;).evolutionComposer(&amp;#39;oninput&amp;#39;, function(e) {
    // handle event
});
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;&lt;a id="resize" name="resize"&gt;&lt;/a&gt;resize&lt;/h4&gt;
&lt;p&gt;Resizes a Composer.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: This should be used instead of applying width and height directly to the &lt;code&gt;textarea&lt;/code&gt; as each Composer plugin gets the opportunity to interact with this change.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;var newWidth = 300,
    newHeight = 200;
$(&amp;#39;textarea&amp;#39;).evolutionComposer(&amp;#39;resize&amp;#39;, newWidth, newHeight);
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;&lt;a id="Composer_Plugin_API_Methods" name="Composer_Plugin_API_Methods"&gt;&lt;/a&gt;Composer Plugin API Methods&lt;/h3&gt;
&lt;p&gt;Composer plugins are objects defined within &lt;code&gt;jQuery.fn.evolutionComposer.plugins&lt;/code&gt;. Composer plugins cooperate with each other, declaring when they should be active or inactive, and share in mutating the final state of the composer&amp;#39;s value. Built-in plugins include [[hashtags Composer Plugin|hashtags]] and [[mentions Composer Plugin|@mentions]].&lt;/p&gt;
&lt;h4&gt;&lt;a id="init" name="init"&gt;&lt;/a&gt;init&lt;/h4&gt;
&lt;p&gt;Called on each plugin passed to the Composer when the Composer is created.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;arguments&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;context&lt;/code&gt;: Composer plugin context&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;&lt;a id="onTransform" name="onTransform"&gt;&lt;/a&gt;onTransform&lt;/h4&gt;
&lt;p&gt;Called on each plugin passed to the Composer whenever the value of the Composer changes, either through user interaction or through &lt;code&gt;evolutionComposer(&lt;/code&gt;val&lt;code&gt;)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;arguments&lt;/em&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;context&lt;/code&gt;: Composer plugin context&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;&lt;a id="shouldActivate" name="shouldActivate"&gt;&lt;/a&gt;shouldActivate&lt;/h4&gt;
&lt;p&gt;When a plugin is not currently active, called on each plugin passed to the Composer on &lt;code&gt;input&lt;/code&gt; events until one returns &lt;code&gt;true&lt;/code&gt;. When a plugin returns &lt;code&gt;true&lt;/code&gt;, that plugin is considered active and is passed key events exclusively (blocking other plugins) until the plugin releases control back to the composer.&lt;/p&gt;
&lt;p&gt;An example usage of this technique is hashtag and @mention auto-complete selection mode, where typing &amp;#39;@&amp;#39; will trigger specific plugin-defined actions, UI, and event handlers to to run until a selection is made or cancelled.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;arguments&lt;/em&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;context&lt;/code&gt;: Composer plugin context&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;returns&lt;/em&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Boolean true or false&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;&lt;a id="onActivate" name="onActivate"&gt;&lt;/a&gt;onActivate&lt;/h4&gt;
&lt;p&gt;Called on a plugin when it transitions to the active state due to user interaction and the &lt;code&gt;shouldActivate&lt;/code&gt; method&lt;/p&gt;
&lt;p&gt;&lt;em&gt;arguments&lt;/em&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;context&lt;/code&gt;: Composer plugin context&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;&lt;a id="onDeactivate" name="onDeactivate"&gt;&lt;/a&gt;onDeactivate&lt;/h4&gt;
&lt;p&gt;Called on a plugin when it transitions to the inactive state due to the plugin releasing itself via the &lt;code&gt;context&lt;/code&gt;&amp;#39;s &lt;code&gt;release()&lt;/code&gt; method.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;arguments&lt;/em&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;context&lt;/code&gt;: Composer plugin context&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;&lt;a id="val" name="val"&gt;&lt;/a&gt;val&lt;/h4&gt;
&lt;p&gt;Allows a plugin passed to the Composer an opportunity to mutate the value of the decorated &lt;code&gt;textarea&lt;/code&gt; before it is returned to the caller of $(&amp;#39;textarea&amp;#39;).evolutionComposer(&amp;#39;val&amp;#39;). In this manner, a Composer plugin can track internal state that is not visible to the user but is available as tokens within the final value returned to the caller, such as hashtag or @mention tokens.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;arguments&lt;/em&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;val&lt;/code&gt;: Current raw value of the input&lt;/li&gt;
&lt;li&gt;&lt;code&gt;context&lt;/code&gt;: Composer plugin context&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;returns&lt;/em&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Transformed value, potentially modified by the plugin.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;&lt;a id="onkeydown" name="onkeydown"&gt;&lt;/a&gt;onkeydown&lt;/h4&gt;
&lt;p&gt;Handles &lt;code&gt;keydown&lt;/code&gt; events on the Composer&amp;#39;s &lt;code&gt;textarea&lt;/code&gt;, but &lt;em&gt;only when the plugin defining the handler is active&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;arguments&lt;/em&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;context&lt;/code&gt;: Composer plugin context&lt;/li&gt;
&lt;li&gt;&lt;code&gt;event&lt;/code&gt;: Event&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;&lt;a id="onkeypress" name="onkeypress"&gt;&lt;/a&gt;onkeypress&lt;/h4&gt;
&lt;p&gt;Handles &lt;code&gt;keypress&lt;/code&gt; events on the Composer&amp;#39;s &lt;code&gt;textarea&lt;/code&gt;, but &lt;em&gt;only when the plugin defining the handler is active&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;arguments&lt;/em&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;context&lt;/code&gt;: Composer plugin context&lt;/li&gt;
&lt;li&gt;&lt;code&gt;event&lt;/code&gt;: Event&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;&lt;a id="oninput" name="oninput"&gt;&lt;/a&gt;oninput&lt;/h4&gt;
&lt;p&gt;Handles &lt;code&gt;input&lt;/code&gt; events on the Composer&amp;#39;s &lt;code&gt;textarea&lt;/code&gt;, but &lt;em&gt;only when the plugin defining the handler is active&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;arguments&lt;/em&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;context&lt;/code&gt;: Composer plugin context&lt;/li&gt;
&lt;li&gt;&lt;code&gt;event&lt;/code&gt;: Event&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;&lt;a id="Composer_Plugin_API_Context" name="Composer_Plugin_API_Context"&gt;&lt;/a&gt;Composer Plugin API Context&lt;/h3&gt;
&lt;p&gt;Each method of the Composer Plugin API is passed the current Composer context. The context exposes data to the plugin as well as enables manipulation of the composer via methods on the context.&lt;/p&gt;
&lt;h4&gt;&lt;a id="settings" name="settings"&gt;&lt;/a&gt;settings&lt;/h4&gt;
&lt;p&gt;All options initially passed to Composer during its construction via &lt;code&gt;$(&amp;#39;textarea&amp;#39;).evolutionComposer(options)&lt;/code&gt;.&lt;/p&gt;
&lt;h4&gt;&lt;a id="input" name="input"&gt;&lt;/a&gt;input&lt;/h4&gt;
&lt;p&gt;The selected &lt;code&gt;textarea&lt;/code&gt; elements decorated by the Composer instance.&lt;/p&gt;
&lt;h4&gt;&lt;a id="data" name="data"&gt;&lt;/a&gt;data&lt;/h4&gt;
&lt;p&gt;Stores or retrieves contextual data against a plugin instance of the composer instance.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// store data
context.data(key, value);

// retrieve data
var value = context.data(key);
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;&lt;a id="val" name="val"&gt;&lt;/a&gt;val&lt;/h4&gt;
&lt;p&gt;Returns the current raw value of the composer, not processed by other plugins.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;var value = context.val()
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;&lt;a id="release" name="release"&gt;&lt;/a&gt;release&lt;/h4&gt;
&lt;p&gt;When active, &lt;code&gt;context.release()&lt;/code&gt; releases control back to the parent &lt;code&gt;evolutionComposer&lt;/code&gt; plugin. Only when a plugin is active does it receive &lt;code&gt;keypress&lt;/code&gt;, &lt;code&gt;keydown&lt;/code&gt;, and &lt;code&gt;input&lt;/code&gt; events.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;context.release();
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;&lt;a id="caretPosition" name="caretPosition"&gt;&lt;/a&gt;caretPosition&lt;/h4&gt;
&lt;p&gt;Returns the Composer&amp;#39;s current caret position index.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;var position = context.caretPosition();
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;&lt;a id="currentWord" name="currentWord"&gt;&lt;/a&gt;currentWord&lt;/h4&gt;
&lt;p&gt;Returns an object regarding the current word surrounding a caret position.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;var currentWord = context.currentWord();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Object contains the properties:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;value&lt;/code&gt;: word value&lt;/li&gt;
&lt;li&gt;&lt;code&gt;start&lt;/code&gt;: word start index&lt;/li&gt;
&lt;li&gt;&lt;code&gt;stop&lt;/code&gt;: word stop index&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;&lt;a id="replace" name="replace"&gt;&lt;/a&gt;replace&lt;/h4&gt;
&lt;p&gt;Replaces text on the input.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;parameters&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;start&lt;/code&gt;: index at which to begin replacement&lt;/li&gt;
&lt;li&gt;&lt;code&gt;stop&lt;/code&gt;: index at which to end replacement&lt;/li&gt;
&lt;li&gt;&lt;code&gt;newValue&lt;/code&gt;: new value to splice in&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;&lt;a id="clearHighlights" name="clearHighlights"&gt;&lt;/a&gt;clearHighlights&lt;/h4&gt;
&lt;p&gt;Clears any current highlights on the input.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;context.clearHighlights();
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;&lt;a id="addHighlight" name="addHighlight"&gt;&lt;/a&gt;addHighlight&lt;/h4&gt;
&lt;p&gt;Adds a highlight to the input. The highlight does not render immediately, but is instead tracked until &lt;code&gt;renderHighlights&lt;/code&gt; is called.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;context.addHighlight({ 5, 20, &amp;#39;myClassName&amp;#39; });
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;parameters&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;start&lt;/code&gt;: start index for the highlight&lt;/li&gt;
&lt;li&gt;&lt;code&gt;stop&lt;/code&gt;: stop index for the highlight&lt;/li&gt;
&lt;li&gt;&lt;code&gt;className&lt;/code&gt;: CSS class name to apply to the highlight&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;&lt;a id="renderHighlights" name="renderHighlights"&gt;&lt;/a&gt;renderHighlights&lt;/h4&gt;
&lt;p&gt;Renders all highlights queued up by calls to &lt;code&gt;addHighlight&lt;/code&gt;.&lt;/p&gt;
&lt;hr class="generated-documentation-end" style="border-width:0;" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item></channel></rss>