Working with SFDT is hard and the JS API from SF provides us only the basics to do that.
Here we have compiled a group of utils so that we can easily do some more advanced things.
There are two groups of functions:
- Operations on SFDT objects directly, eg: toggleBookmark
- Batched calls to the document editor API, eg: hasBookmark
Eg:
import toggleBookmark from 'sfdt-utils/toggleBookmark'
/**
* @param {String} -
*/
bookmarkAction()
/**
* @param {String} -
*/
bookmarkHighlight()
/**
* @param {String} -
*/
getCurrentSelection()
/**
* @param {String} -
*/
getSFDTjson()
/**
* @param {String} -
*/
getSFDTstring()
/**
* @param {String} name - Bookmark name
* @param {Object} documentEditor - Instance of the SF document editor
*
* @returns {Boolean} - True if the bookmark exists in the editor
*/
hasBookmark('my-bookmark-name', documentEditor)
/**
* @param {Object} SFDT - The SF SFDT JSON object
* @param {String} bookmarkName - Bookmark to toggle on or off
* @param {Boolean} toggleOn - True to show bookmark content, false to hide it
*
* @returns {Object} updatedSFDT
*/
const updatedSFDT = toggleBookmark(SFDT, 'my-bookmark-name', true)
/**
* @param {String} name - name of bookmark
* @param {String} content - new content
* @param {String} documentEditor - live documentEditor object
*/
updateBookmarkContent('my-bookmark-name', 'new content!', documentEditor)
$ yarn test
$ yarn fmt