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

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?

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?

Does tinymce have an option, via menu, to insert form fields into it or just by editing the code?

Does anyone know of a ready-made plugin that allows adding input, textarea, select etc. on tinymce?
The tinymce.dom.Selection API (https://www.tiny.cloud/docs/api/tinymce.dom/tinymce.dom.selection/#select) allows you to select elements or set content in the TinyMCE editor. You can assign the API class to an action or an interaction element like a button or form, and any selected content will be replaced with the contents the API action passes in.
If that's not a good fit for what you need, is there an example of the type of adding input, a textarea, or a select you're looking for?
There are no official plugins that allow such interactive elements to be added. TinyMCE is a text editor that is built to create blog posts, articles, etc. By design, it is not a page builder. However, there may be some unofficial plugins on GitHub that may implement such features.
If you are going to insert forms and text areas that should not be edited or reconfigured afterward, you can use templates. They may come as any valid HTML. Thus, some fixed forms can be just saved as templates.
Another way is, of course, inserting HTML directly into the code.

Office JavaScript API: highlighting text in a document

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/

GWT Textfield with content assist kind of functionality

I am working on a project and I have a requirement to create one GWT Textfield. User should be able to put query in the text field. But this text field should have content assist (like Ecliplse) kind of functionality.
Example: "path" is one of the predefined object in the application with having certain attribute like "name","address". So now when user type "path.", it should show available attribute. This should work almost same way as in eclipse we get while put objectname it will give all available methods to call.
Example: User writes text "From path.name, path.attribute for object.attribute"
When user writes "from","for" it will not show any assistance but when user types "path." or "object." in above statement, it should show assist.
This is an interesting idea. You could try this with a suggest box widget.
GWT Suggest Box - http://gwt.googleusercontent.com/samples/Showcase/Showcase.html#!CwSuggestBox
GWTChosen Suggest Box - http://jdramaix.github.com/gwtchosen/
The above widget demos work with simple "contains" check on string. You would need to spend some serious logic on the regex matching if you want to pull of your idea.

How can I select a value matching my input from a TypeAhead control using WWW::Mechanize?

So ordinarily the element I want to pick from a list would be populated on a page and I'd just find it and pick it. But I'm dealing with a control that doesn't populate list elements until some input has been stuck into a text box, after which it gives me a list of recommendations.
For an example of the kind of list I'm talking about think of Facebook's "People, Places, and Things" search field.
I want to plug a string into this text box, select the same string from the list of recommendations, and submit the form. The issue I'm having right now is I can't seem to get Mechanize to even recognize the field is there. I examine a dump of $mech->find_all_inputs and it isn't listed. Is this kind of field just beyond Mechanize's jurisdiction?
This control's magic comes via Javascript, and (as you know) WWW::Mechanize don't work with Javascript.
But you can find (with Firefox's HTTPFox extension for example) what request your browser sends to the target site than you get "recommendations" and make the same request (I'm sure this is POST) from your WWW::Mechanize object.