User:Mooeypoo/VisualEditor LanguageInspector Notes

Jump to navigation Jump to search

This will be my destination for random thoughts, plans and general ramblings about the LanguageInspector. Go here for the actual GSoC project updates.

Structure plan[edit]

  • ve/ce/annotations
    • ve.ce.LanguageAnnotation
  • ve/dm/annotations
  • ve/ui/inspectors
    • ve.ui.LanguageInspector
  • ve/ui/tools
    • ve.uiLanguageButtonTool
  • ve/ui/widget
    • ve.ui.LanguageWidget (ULS?)

Current Problems[edit]

The core of the Language Inspector was taken mostly from the Link inspector. However, there are a couple of unexpected behaviors related to the fragment and annotation that is produced by the fragment in ve.ui.LanguageInspector that I am trying to handle and are baffling. Any help would be really appreciated here!

Bafflement #1: Potential Conflict with textStyle/span[edit]

See the following screenshot:

Mooeypoo VeUiLanguageInspector AnnotationProblem.png

I've added console.log outputs to the Inspector and to the LanguageInspector to see what the inspector produces as an annotation and what the LanguageInspector *reads* as an annotation. The output you see is when I loaded the Language Inspector over a text that was already wrapped with <span lang='de' dir='ltr'>text text</span>

The weird thing here is that it calls the constructor three times; twice it doesn't recognize the fact this is a language inspector (but rather thinks it's a textStyle/span annotation) and once it does recognize it (the third reading time). However, it seems to send the annotation to the language inspector before the third time, which makes the annotation blank.

The Problem[edit]

I think the LanguageAnnotation may collide with the textStyle/span annotation. I need to find a way to differentiate between the textStyle/span annotation and the Language annotation despite the fact both use <span> as their base. This might be done with regular expressions, but I'm not sure where to add the test for that.

Bafflement #2: Inconsistent Annotation Reading Behavior[edit]

If you can, try this: - Load VE with my prototype - Mark some random text (multiple words prefered) and pick the "Language Annotation" button. It loads, ignore the text inside it (or change to 'he' or 'en' if you want), and close it (apply) - Move the marker anywhere else in the text - Put the marker back in the middle of the words you just selected - The language annotation works! The little button appears (just like the link!) and if you click the popup icon, you'll see the proper Fragment selection! woo! - Further test: Mark the same text also as a link (internal or external, doesn't matter) - now again go over it with the marker, and you can see that *both* icons -- link and language -- pop up for you. PERFECT behavior!

Why doesn't it work on the previously-set tags if I manually insert them as wikitext?

The only visible difference I could see was the fact my manually inserted spans had no class='ce-ve-LanguageInspector' attached to them. I added the class to my span manually -- and the language inspector *still* doesn't recognize the full span for the fragment.

A related issue with this is also intriguing. If I now try to save my newly implemented language span (the one that is recognized,) I get an error in my console: "Error: Attempting to convert unknown data element type span"