Office JavaScript API: highlighting text in a document - ms-word

I'm working on a side project using the Microsoft Office JavaScript APIs. I have been relying on the documentation to find my way around, but I've hit a wall trying to find something in the docs (perhaps it isn't there because it doesn't exist).
Recently I attempting to implement some functionality to highlight some text within a Word document. I don't want to modify the document, mind you; in other words I would rather not use something like ContentControl.insertHtml as that would change the actual content. What I want is to make the text temporarily highlighted (e.g., until the user clicks a "Cancel" button), much like what you see when you perform a search with Ctrl+F (and text matching your search is highlighted in yellow).
Is this possible using the Office JavaScript APIs?

Try getting a reference to the Range object and then setting Range.font.highlightcolor. Have a handler for the Cancel button click event that reverses the color change.

Here is a sample application that uses font.highlightcolor from the Office Javascript API. https://github.com/OfficeDev/Word-Add-in-JS-Redact/

Related

Can I tag text for meaning using TinyMCE or some other rich text editor?

I'm not sure what this functionality or feature is technically called. I just tried asking the chat on their homepage and they suggested I try asking here to see if anyone else has done this.
We're looking to allow users to highlight text and connect a tag to that text so that it can be categorized and found in a search later on, or used in analytics. For example, if the highlighted text says, "His leadership skills were average," the user should be able to highlight that text and be offered to tag it with pre-built tags, in this case perhaps "leadership" and "neutral". That way a separate user can search for those tags later. What would this functionality be called?

Is it possible to check for specific text to highlight on AEM site without using JavaScript?

Currently, I am building a feature in which author can decide which text to highlight throughout every single page of the site. In addition, when you hover over the highlighted text, the tooltip of the highlighted text will show the text's definition.
My idea is that the author will be given a component on a page. When the user open the component dialog, it will be given a multi-field to enter "text" and "definition" as a key-value pair. Since this data is not private, so I will render the data on a page, and use JavaScript to read data from the page and store in a dictionary. Each time you load a page, JavaScript will check for the text in dictionary and do the trick.
I am not sure if my idea is a good idea. I am concerned that the site will be very slow on mobile if I do it in JavaScript. Is there a better approach to do the trick in Java model or anywhere on server side?

How can I format text without changing document state in MSWord web add-in API?

I'm developing an add-in for MSWord using Microsoft web add-in API. I'd like to underline or highlight some given words, but only in the scope of that session. I don't want to change the document's state. In other words, I don't want to persist the new text formatting when the document is saved.
I know how to format text, but the document's state is changed. I have this code at the moment:
word_range.font.underline = Word.UnderlineType.wave;
I want to achieve a behavior similar to Grammarly plug-in, where the underline is only to point out something is wrong with those words, but again, without persisting the underlining.
I found a similar question (word - highlight search results without permanently changing document formatting), but it was asked a few years ago and the solution is not exactly what I'm looking for.
I'm afraid that there is no way to highlight that will automatically disappear if the user saves the document. The answer that you linked to, or this one is the best that can be done in Office.js right now. It is a good idea, however, so please suggest it at Office Developer Suggestion Box.

Detect hover in Microsoft Word Add-In

I'm trying to develop an Add-In for Microsoft Word. The basic idea being to load some key words into the document and then when the user hovers over one of the key words a box pops up to show more information, like on Wikipedia or Facebook.
Looking over the api reference I see that the popup box isn't possible, and that's okay I could just make it appear in the Add-In's panel.
I read about bindings, but it seems they can't detect a hover or even a click event? I thought about hacking something together with links but I don't think that would be very UI friendly.
The only thing I can think of to make it kind of possible is to have the user manually highlight the key word (sometimes the key word is more than one word), then have them click a "search" button in the Add-In's panel that would read the selected range and compare it against a database of words. It just seems very anti user compared to the original idea.
Does anyone know of a better way to achieve this?

Custom Ribbons - per DOTM

we have a possible customer, who would like to have a custom ribbon in ONE template, which makes it for him easier to design the text etc.
This stuff should work on Office 2007, 2010 and 2013.
Since this will go to thousands of people, the easiest solution for this would be, to implement Macros, which do the Design-Stuff.
It seems to be no problem (I tested only with 2013) to create a custom ribbon and connect it to macros, it seems even to be possible to define custom Icons.
The real problem causess the Ribbon itself. Since, if I activate my custom ribbon, it's activated for all documents, I have to anyhow create a macro, which makes it visible JUST for one template.
Is this even possible, or is there a possibility to define a Ribbon per dotm? I didnt find anything about that, but what I found makes me nervous about the 2007, 2010, 2013 thing...
Or is it easier to create an Addin, which is kindahow compatible with alle 3 Versions?
Use Visual Studio and start a Word Template project. You can use VB if macros are to your liking or C#.
Your future documents will have to have the template attached for the ribbon to show up, which in my experience has proven to be a pain.
Alternatively you can create an addon that handles document-open events and checks if the document looks like what you expect it to look like. Heuristics can be very tricky if you don't have very specific indicators (such as an attached template, schema or content tags)
Another suggestion, which would most likely be acceptable to users, is to write an addon that shows and hides its main ribbon tab but has a ribbon button to "activate" the document and when you click that button (on another tab) it attaches your template or assigns some other persistent indicator to the document. This addon would also check each document when opened for that indicator and automatically show the actual ribbon tab when the document is recognized.