-
Notifications
You must be signed in to change notification settings - Fork 1.1k
textAngularManager Module
The textAngularManager is a module that is used to setup, retrieve and modify textAngular instances and can be used outside of textAngular itself. If you wanted to create your own toolbar that hooks in, here's the place to do it.
-
registerEditor: function(name, scope, targetToolbars)
Register an editor and the toolbars that it is affected by or linked to.
name: A string name that must be unique.
scope: The scope to initialise the editor on.
targetToolbars: An array of strings that are the names of toolbars that have or will be added to textAngularManager viaregisterToolbar
RETURNS: An object with the following signature:
{
disable: function(), // disable all linked toolbars
enable: function(), // enable all linked toolbars
focus: function(), // this should be called when the editor is focussed
unfocus: function(), // this should be called when the editor becomes unfocussed
updateSelectedStyles: function(selectedElement), // update the active state of all buttons on linked toolbars
sendKeyCommand: function(event), // this searches through the tools on linked toolbars and applies the action of the tool if one is found with a matching keyCode
triggerElementSelect: function(event, element), // search through the taTools to see if a match for the tag selected is present, if there is, see if the tool is on a registered toolbar and not disabled, if so apply the elementSelect action.
}
-
retrieveEditor: function(name)
Retrieves the editor object of the named editor.
name: A string of the editors name.
RETURNS: An object with the following signature:
{
scope: Object, // the scope that the toolbar was registered with
toolbars: Array, // the array of toolbar names that was passed to the register function
_registerToolbar: function(toolbarScope), // registers a toolbar to act on the editor by passing the scope of the toolbar
editorFunctions: Object // the same object that is returned from `registerEditor`
}
-
unregisterEditor: function(name)
Removes an named editor from the manager.
name: A string of the editors name.
RETURNS: Null -
registerToolbar: function(scope)
Registers a toolbar such that it can be linked to editors.
scope: The scope of the editor, this needs to have aname
key on it that is unique amongst toolbars.
RETURNS: null -
retrieveToolbar: function(name)
Retrieve toolbar by name, largely used by testing suites only name: A string of the toolbars name.
RETURNS: The scope of the toolbar as passed intoregisterToolbar
-
retrieveToolbarsViaEditor: function(name)
Retrieve toolbars by editor name, largely used by testing suites only
name: A string of the editors name.
RETURNS: An array of toolbar scopes as passed intoregisterToolbar
that have been linked to the named editor -
unregisterToolbar: function(name)
Removes an named toolbar from the manager.
name: A string of the toolbars name.
RETURNS: Null
The following functions rely on the updateToolDisplay
and addTool
functions that should be defined on all toolbars.
-
updateToolsDisplay: function(newTaTools) Pass a partial object of the taTools, this allows us to update the tools on the fly, will not change the defaults.
newTaTools: An Object with the same setup as the taTool object in passed to the taRegisterTool textAngularSetup. For Example adding the html tool:taRegisterTool("html", {iconclass: 'fa fa-code' ...});
would be equivalent toupdateToolsDisplay({"html": {iconclass: 'fa fa-code' ...}});
RETURNS: null -
resetToolsDisplay: function()
This function resets all toolbars to their default tool definitions
RETURNS: null -
updateToolDisplay: function(toolKey, _newTool)
Update a tool on all toolbars
toolKey: A string that is the name the tool was originally registered with
_newTool: An object that represents the new values of the tool -
resetToolDisplay: function(toolKey)
Resets a tool to the default/starting state on all toolbars
toolKey: A string that is the name the tool was originally registered with -
updateToolbarToolDisplay: function(toolbarKey, toolKey, _newTool)
Update a tool on a specific toolbar
toolbarKey: The name of the targeted toolbar
toolKey: A string that is the name the tool was originally registered with
_newTool: An object that represents the new values of the tool -
resetToolbarToolDisplay: function(toolbarKey, toolKey) Reset a tool on a specific toolbar to it's default starting value
toolbarKey: The name of the targeted toolbar
toolKey: A string that is the name the tool was originally registered with -
removeTool: function(toolKey)
Removes a tool from all toolbars and it's definition
toolKey: A string that is the name the tool was originally registered with -
addTool: function(toolKey, toolDefinition, group, index)
This will add the passed tool definition to all toolbars.
toolKey: A string that is the name the tool was originally registered with
toolDefinition: An object that represents the new values of the tool
group: The button group in the default toolbar that the tool should be added to, Default Last group in toolbar
index: The index in the group that the tool should be inserted, Default Appends to the group. -
addToolToToolbar: function(toolKey, toolDefinition, toolbarKey, group, index)
Adds a Tool as inaddTool
function but only to one toolbar not all.
toolKey: A string that is the name the tool was originally registered with
toolDefinition: An object that represents the new values of the tool
toolbarKey: The name of the targeted toolbar
group: The button group in the default toolbar that the tool should be added to, Default Last group in toolbar
index: The index in the group that the tool should be inserted, Default Appends to the group. -
refreshEditor: function(name)
This is used when externally the html of an editor has been changed and textAngular needs to be notified to update the model. This will call a $digest if not already happening.
name: A string of the editors name.