Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | 5x 5x 16x 16x 16x 1x 1x 16x 1x 1x 16x 1x 1x 16x 1x 1x 16x 1x 1x 16x 5x 5x 16x 1x 16x 1x 16x 1x 16x 1x 1x 16x 1x 16x 1x 1x 16x 1x 1x | import { ActionDeltaUpdate, ActionTrigger, DocumentAction } from '../types/ActionTypes'; import { EditorAPI, Id } from '../types/CommonTypes'; import { getEditorResponseData } from '../utils/EditorResponseData'; /** * The ActionController is responsible for all Actions-related functionality. * Methods inside this controller can be called by `window.SDK.action.{method-name}` */ export class ActionController { /** * @ignore */ #editorAPI: EditorAPI; /** * @ignore */ constructor(editorAPI: EditorAPI) { this.#editorAPI = editorAPI; } /** * This method returns the list of all actions. * @returns list of all actions */ getAll = async () => { const res = await this.#editorAPI; return res.getActions().then((result) => getEditorResponseData<DocumentAction[]>(result)); }; /** * This method returns an action by the id * @param id the id of a specific action * @returns action details */ getById = async (id: Id) => { const res = await this.#editorAPI; return res.getActionById(id).then((result) => getEditorResponseData<DocumentAction>(result)); }; /** * This method creates a new action. * @returns the id of the newly created action. */ create = async () => { const res = await this.#editorAPI; return res.createAction().then((result) => getEditorResponseData<Id>(result)); }; /** * This method duplicates an existing action by the id * @param id the id of a specific action * @returns the id of the duplicated action. */ duplicate = async (id: Id) => { const res = await this.#editorAPI; return res.duplicateAction(id).then((result) => getEditorResponseData<Id>(result)); }; /** * This method removes the action by the id * @param id the id of a specific action * @returns */ remove = async (id: Id) => { const res = await this.#editorAPI; return res.removeAction(id).then((result) => getEditorResponseData<null>(result)); }; /** * This method updates an existing Action * @param id the id of a specific Action * @param update the delta update to apply to the Action * @returns */ update = async (id: Id, update: ActionDeltaUpdate) => { const res = await this.#editorAPI; return res.updateAction(id, JSON.stringify(update)).then((result) => getEditorResponseData<null>(result)); }; /** * @deprecated use the update method instead * * This method renames an action by the id and provided name * @param id the id of a specific action * @param name the new unique name for the action * @returns */ rename = async (id: Id, name: string) => { return this.update(id, { name: name }); }; /** * @deprecated use the update method instead * * This method updates the script the action uses by the id and provided script * @param id the id of a specific action * @param actionScript the JavaScript based action script * @returns */ updateScript = async (id: Id, actionScript: string) => { return this.update(id, { script: actionScript }); }; /** * @deprecated use the update method instead * * This method updates the triggers on which the action will react. * @param id the id of a specific action * @param triggers the triggers this action should react on. * @returns */ updateTriggers = async (id: Id, triggers: ActionTrigger[]) => { return this.update(id, { triggers: triggers }); }; /** * This method changes positions of actions * @param order the position of actions * @param ids the list of action IDs * @returns */ move = async (order: number, ids: string[]) => { const res = await this.#editorAPI; return res.moveActions(order, ids).then((result) => getEditorResponseData<null>(result)); }; /** * @deprecated use the update method instead * * This method stores the state of action type errors to the document * * Those errors states can be read back from the usual getters or the * `onActionsChanged` stream * @param id the id of a specific action * @param hasTypeErrors whether there is an action type error * @returns */ setTypeError = async (id: string, hasTypeErrors: boolean) => { return this.update(id, { hasTypeError: hasTypeErrors }); }; /** * This method disables the execution of Actions. * Note that any Action will be ignored and forgotten. * @returns */ disable = async () => { const res = await this.#editorAPI; return res.disableActions().then((result) => getEditorResponseData<null>(result)); }; /** * This method enables the execution of Actions. * Note this is enabled by default. * @returns */ enable = async () => { const res = await this.#editorAPI; return res.enableActions().then((result) => getEditorResponseData<null>(result)); }; } |