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 | 5x 5x 6x 6x 6x 1x 1x 1x 6x 1x 1x 6x 1x 1x | import { EditorAPI } from '../types/CommonTypes'; import { SelectedTextStyle, TextStyleUpdateType } from '../types/TextStyleTypes'; import { getEditorResponseData } from '../utils/EditorResponseData'; /** * The TextStyleController is responsible for all communication regarding text styles. * Methods inside this controller can be called by `window.SDK.textStyle.{method-name}` */ export class TextStyleController { /** * @ignore */ readonly #editorAPI: EditorAPI; /** * @ignore */ constructor(editorAPI: EditorAPI) { this.#editorAPI = editorAPI; } /** * This method updates a selected Text's style properties * @returns */ set = async (style: TextStyleUpdateType) => { const res = await this.#editorAPI; return res .selectedTextStyleDeltaUpdate(JSON.stringify(style)) .then((result) => getEditorResponseData<null>(result)); }; /** * This method removes a selected Text's style properties * If the text is selected, then the inline style properties will be removed * If the text is not selected and user tried to change any style property, the temporary style will be removed * if there is no text selection and there is no temporary style, the inline paragraph properties will be removed * @returns */ removeSelected = async () => { const res = await this.#editorAPI; return res.selectedTextStyleClean().then((result) => getEditorResponseData<null>(result)); }; /** * This method gets a selected Text's style properties * @returns */ getSelected = async () => { const res = await this.#editorAPI; return res.getSelectedTextStyle().then((result) => getEditorResponseData<SelectedTextStyle>(result)); }; } |