Created
September 10, 2025 12:15
-
-
Save jonathanmaron/ca8e46c74a24fefee77f6b18a1fd7d3e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Global variables | |
let copiedFormat = null; | |
let styleCounter = 1; | |
let customStyles = {}; | |
// Promise wrappers for TX Text Control API | |
const get = (method) => | |
new Promise((resolve, reject) => | |
TXTextControl.selection[method](v => resolve(v), e => reject(e)) | |
); | |
const set = (method, val) => | |
new Promise((resolve, reject) => | |
TXTextControl.selection[method](val, () => resolve(), e => reject(e)) | |
); | |
const getLength = () => | |
new Promise((resolve, reject) => | |
TXTextControl.selection.getLength(v => resolve(v), e => reject(e)) | |
); | |
const selectWord = () => | |
new Promise((resolve, reject) => | |
TXTextControl.selectWord(() => resolve(), e => reject(e)) | |
); | |
// Utility function to check if selected text has uniform formatting | |
function isCommonValueSelectedAsync(selection, attr) { | |
return new Promise((resolve, reject) => { | |
selection.isCommonSelectionValueSelected( | |
attr, | |
(result) => { | |
resolve(result); // true/false | |
}, | |
reject | |
); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment