Monaco editor: how to recompute and redraw semantic highlighting data? - syntax-highlighting

I have implemented semantic highlighting on Monaco (using registerDocumentSemanticTokensProvider). My semantic highlighting depends on some out-of-editor information (say, a data model with valid property names, against which I check how to highlight tokens). Such information can change over time, e.g., because the user adds a new property to the data model, maybe even as the result of a code action in the editor. So, whenever the data model changes, I'd like to update the editor to show the new information. However, Monaco only updates the semantic highlighting when the document is changed. Is there a way to force it to reapply highlighting even when no editing operation occurred?

It turns out that by simply re-setting the model's value, semantic highlighting gets refreshed:
model.setValue(model.getValue());
As far as I know, this is not documented anywhere. Tested on Monaco 0.24.0.

Related

VSTO Outlook: Apply a color to the cells of a custom View column

I am trying to add a new column (it is of type text only) to the inbox folder view and I am wondering if it is possible to apply a custom different color to each cell (foreground and background). I have had a look at the view's XML definition which in fact is an XML file. In the columns I have added I have typed the attributes background-color and color within the style tag but it seems it is not working. It seems that it can be achieved by using conditional formatting as the ones already defined for unread messages, etc. but I don't want to apply the color to the entire row, only to some cells of the column. I haven't tried yet using conditional formatting, I don't know if it is possible programmatically, but I would like to avoid this approach. So how can I apply a color to each cell of the column independently?
Try to make such changes manually in Outlook. That is how you can do that - do the required changes manually (if possible) and then you may observe the result in XML. If it is not possible you will not find any way for doing that manually.
The best what you could do is to use a conditional formatting for the view, see Conditional formatting by Field Criteria with VBA (e.g. From address contains) for more information.

Event for Markup drawing

What is the name of event when we start drawing the markup(circle, arrow, rectangle etc.) on the shape when in edit mode? And can we change the markup type in this event?
Problem is: When we are in edit mode and have selected specific shape and color to draw the markup, and in between if we select any markup, the drawing tool takes up that shape and color for the next markup to be drawn ignoring the markup type and color we selected earlier. Is this the normal behavior. Why does the drawing tool take up the configuration of the last selected markup and overrides the type we define through - new Autodesk.Viewing.Extensions.Markups.Core.EditModeCloud(markupExt);
Thanks!
That's an interesting question. I believe the current behavior of markups is as-designed because one would typically only select a markup if they wanted to move it around, scale it, etc. That's why in the current implementation, selecting a markup automatically enters its edit mode.
At the same time I understand your view where if I already activate a specific edit mode, it seems strange that that edit mode would change after simply selecting another markup.
Let me bring this up with the engineering team, and in the meantime, I'd suggest using the Autodesk.Viewing.Extensions.Markups.Core.EVENT_EDITMODE_CHANGED event to detect a change to the edit mode, and if needed, reset the mode to the one you want.

Do I need to use aria-label on elements that have visible labels which are read by screen reader?

My company is trying to become WCAG compliant. One of the things we need to do is add aria-label to interactive elements. My question is do I need to add an aria-label to an element which already has a label which is read by a screen reader.
So basically i definitely need a "close" aria-label here:
<button>x</button>
But in some cases I have a placeholder for example, which is read by the screen reader. Do I need to add an aria-label anyway just in case? The aria-label would be the same as the placeholder.
#mikkel has good advice regarding the first rule of ARIA use.
Regarding your specific question on the placeholder attribute, relying on the placeholder as your label would fail several WCAG checkpoints.
Placeholder text is typically light gray and when displayed on a white background often fails 1.4.3 Contrast Minimum
The placeholder text disappears when you start typing so now the "label" has disappeared and would fail 3.3.2 Labels or Instructions
The placeholder attribute is not specifically referenced in the accessible name calculation (https://www.w3.org/TR/accname-1.1/#step2) although it might be considered in step 2D as "an attribute that defines a text alternative". It's not clear if placeholder is a "text alternative". Personally, I don't think it is. If not, then you would fail 4.1.2 Name, Role, Value
If you look at the spec for placeholder, it has a big disclaimer about not using it as a label.
Warning: Use of the placeholder attribute as a replacement for a label can reduce the accessibility and usability of the control for a range of users including older users and users with cognitive, mobility, fine motor skill or vision impairments. While the hint given by the control’s label is shown at all times, the short hint given in the placeholder attribute is only shown before the user enters a value. Furthermore, placeholder text may be mistaken for a pre-filled value, and as commonly implemented the default color of the placeholder text provides insufficient contrast and the lack of a separate visible label reduces the size of the hit region available for setting focus on the control.
So, all that being said, yes, you should have some kind of visible label associated with your input field even if you are using the placeholder attribute.
Short answer, no.
Long answer, it depends on the situation.
But important – first rule of aria:
If you can use a native HTML element or attribute with the semantics and behavior you require already built in, instead of re-purposing an element and adding an ARIA role, state or property to make it accessible, then do so.
When in doubt, choose native HTML.
https://www.w3.org/TR/using-aria/#rule1
If you have a visible label, then you should connect the label text and the input field via the label-element.
If the input field does not have a visible label, the aria-label is one technique that can add the label semantically.
In your example of the button, you should use an aria-label, as the "X" doesn’t give the user any information. Of course, most users can guess what an "x" dos, but the user should not have to guess.
And here am talking of users who use assistive technology.
I would recement that you get a professional to test your site, for legal reasons but mostly for your users.
I'm a web developer, but have used the last 10 years on web accessibility. So far, it’s the hardest field of web development I hav had to learn and I'm still learning. 😊

Magnolia 5.5.6 Stories App Custom CKEditor Panel

The Magnolia-Team wrote (DevelopingCustomBlocks) that the RichTextFieldDefinition is not available for Blocks.
I would love to use content-editor in the future instead of pages. Is it possible to extent the editor panel
with (custom) plugins for the ckeditor (that I created to use with the RichTextField)? If yes could you give me a hint on how to accomplish that?
It is possible, and you can even use the standard RichTextField.
However before you start extending it, please make sure you understand idea behind new editor, it's working, structure of data it stores and how is that data manipulated later in order to not dig for yourself hole that would be hard to escape with custom extensions.
Whole editor is meant to be fluent for editing and very simple to manipulate offering maximum of freedom. Editor works with concept of blocks. Each hit of enter produces new block of type text. There's other types of blocks offered OOTB by Magnolia. Each different type of block is stored separately and it's rendering can be controlled by template. E.g. each text block becomes paragraph or div in html, depending on your choice. For other blocks, they might produce other types of elements. And this is where you need to become careful. If you extend CK editor, or start using default/old RichTextField, you will suddenly end up with block that already contains html, thus making it unpredictable what the output might look like after such block is processed by your template and whether resulting html is valid or well formatted. The less of html you get "baked in" in each block, the easier templating becomes later.
As for adding extra plugins to the text block, you can modify config.js of the editor, as for adding RichTextField you can just create block that will provide this field. However, keep in mind that with first you run into risk of introducing potentially dangerous html and with the second it's same risk of baking in dangerous html and on top breaking editor experience as RTF will not support same keyboard shortcuts available for other blocks.

How does modifying text highlighting work?

We are all familiar with text highlighting. You hover over any "text" in any application on your Windows OS, your cursor changes into an I-Beam, and you can click and drag across the text to Highlight it. This highlighted text can be copied to the clipboard for later use.
Some applications modify the default highlighting behavior by changing color, opacity, or even shape. Some applications allow for column selection (e.g. Visual Studio "alt-click-drag" creates box like highlighting)
I have scoured the depths of the internet, but I can't seem to find a solid source of information that would explain how one would modify the behavior of text highlighting.
How would I implement column/block text selection, and modifying the appearance of the highlighted text in a compiled application.
Since applications can do this in various custom ways, there is no single solution to change how all of them style text selections.
Many will rely on the current color scheme (using GetSysColor) to determine the highlight colors. So you could modify the scheme and maybe affect the colors used for many applications.
To do this programmatically, you would use SetSysColors to change the COLOR_HIGHLIGHT and COLOR_HIGHLIGHTTEXT values.
Other applications might rely on the current theme (using GetThemeColor). To affect those you'd have to select a different theme that has the colors (and perhaps other styling choices) that you want.
A lot of apps use their own hard-coded color schemes, so you won't be able to programmatically at all.
I'm not sure what you mean with the web application part of your question. A web application is some HTML, JS and CSS that make the browser interact with your system. Any custom selection (coloring) logic that the web application provides, has to be implemented by the browser.
Also you have to realize that "(text) selection" is an rather virtual principle. An application can just render a colored shape (like a blue rectangle) and copy something to the clipboard when it receives a WM_COPY message.
Windows provides in basic substring selection functionality for (rich) edit controls (i.e. start and end position), but for something custom like column selection, custom code is required.
Read more about this in Making a rectangular selection in a RichTextBox with Alt-Left-Mouse sweep?.

Resources