-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
I am trying to apply formatting to a document that already exists. I am trying to highlight text within the document, and I would like to preserve formatting around the changes I make.
For example, highlight yellow all occurrences of "test" in the paragraph "This is a test. This is only a test"
In this example the paragraph is in one run to start, but will be in four runs after highlighting ["This is a ", 'test", ". This is only a ", "test"].
It is not immediately obvious how to accomplish this goal. There are no utility functions that I can find for copying the formatting of a run, or for splitting a run into multiple runs, or for adding a run to an arbitrary location in the paragraph. I am considering either constructing a whole new document paragraph by paragraph (grossly inefficient) or manually implementing run.split(start, end) and paragraph.addRunAt(n) functions.
Is there a better way that I'm just missing? If I make the functions I described would they be useful to add to the package?