I'm trying to develop word add-in which allows to modify word content. One of the requirement is to select some text and mark it:
I want to somehow persist that data within the document, so that:
So far I tried to persist that data by first, getting data as HTML, and add attributes to tags, but that didn't work. Also tried to add some hidden div, but it was only available during word app lifetime. Recently, found this link: https://github.com/OfficeDev/Excel-Add-in-JavaScript-PersistCustomSettings , but still it allows to persist data in scope of "browser", so, I assume that on other machine it won't work.
What are my possibilities? Maybe I shouldn't store it within a document, but if not, where?
Developing it using office-js - it should work for both Word 2013 and Word 2016 (so I don't have an access to Word 2016 specific API).
Check out https://learn.microsoft.com/en-us/javascript/api/office/office.settings
The Office JS Settings object allows you to save custom data that persists with the document. It is pretty straight-forward to use. Getting settings is synchronous - saving settings is async. The biggest thing is that you have to remember to call Office.settings.saveAsync() after you have made your changes using Office.settings.set() in order to actually save the changes to the document.