Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues if richtext Text node is shown in two editor cells. #769

Open
malueck opened this issue Feb 13, 2024 · 4 comments
Open

Issues if richtext Text node is shown in two editor cells. #769

malueck opened this issue Feb 13, 2024 · 4 comments

Comments

@malueck
Copy link

malueck commented Feb 13, 2024

If a richtext Text node is shown in two cells, all sorts of problems appear.
A simple case to reproduce is in a collection with just the Text nodes:

[/
   %Text%
   %Text%
/]
  • Pressing Enter in the first editor will insert a newline, but the caret does not advance to the new line. The second editor does not have this problem.
  • Deleting a newline with either Delete or Backspace in the first editor will work, but then jump the caret to the corresponding position in the second editor. When inserting, there is no problem and the caret will stay in the correct editor.
  • Selecting words (by any means, mouse/shift+arrows...) is not possible in the first editor. The selection and focus will always jump to the second editor.

Found in MPS-richtext 2022.2.

@alexanderpann
Copy link
Collaborator

alexanderpann commented Feb 13, 2024

I've tested it with a simple editor with two text nodes as in the example and I can't reproduce those issues.

For me, it sounds like you are using the query list language and are showing the same node multiple times in the same editor. Then it is a known limitation that can only be influenced but not fixed by the duplicates safe property. The reason why it happens in those cases is that in some situations, the big cell (= top-most cell) of a node is queried from the editor component instead of direct usages of the correct editor cell. It always finds the cell for the second node and not the first one, that's why all the actions are working for the second text node.

If you are sure that it is a problem in the richtext language, you have to provide me with a sample project, so I can check it out.

@malueck
Copy link
Author

malueck commented Feb 14, 2024

mps_example

Querylist is not involved in this problem. A made a small example.

Version info:
MPS 2022.2.2
Build #MPS-222.4554.1547, built on December 13, 2023
Runtime version: 17.0.6+7-b469.82 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

The plugin "MPS Richtext Editor Component" is from the Marketplace i.e. in the "Downloaded" section of installed plugins and enabled.

I disabled all plugins except the dependencies of MPS Richtext and created a dummy concept. You can see the editor in the screenshot.
It has two cells for the same Text child and two cells for a multiline property.

  • Adding a newline in the first Text does not advance the cursor downwards.
  • Pressing space in the first Text likewise inserts a space, but does not advance the cursor to the right.
  • In the second Text, everything works.
  • New issue: Editing the multiline property at the bottom and adding a newline with Shift-Enter does not work and instead inserts an abstract IWord into the Text child which then shows up as a red node.

Observations:

  • When removing the cells for Text, the multiline property cells work as expected, even when there are two. It is again possible to insert newlines with Shift-Enter, even in both cells. The cursor always advances as expected.
  • When re-adding the Text child - even only in one cell - makes the multiline property again unusable.
  • The same even happens when there is only one Text child cell and one multiline property cell.

@malueck
Copy link
Author

malueck commented Feb 14, 2024

Example project as a zip file.

Project2.zip

Concept definition:

concept Dummy extends BaseConcept                                                                                                                                                
              implements <none>                                                                                                                                                  
                                                                                                                                                                                 
    instance can be root: true 
alias: <no alias> 
short description: <no short description> 
 
properties: 
str : string  
 
children: 
Text : Text[1] 
 
references: 
<< ... >>

Editor:


<default> editor for concept Dummy
    node cell layout:             
         [/                       
         % Text %                 
         % Text %                 
         <constant>               
         { str }\n                
         { str }\n                
         /]                       
                                  
    inspected cell layout:        
        <choose cell model>       
                                  

@alexanderpann
Copy link
Collaborator

I just checked the implementation. To summarize in case we want to fix this:

  • We can fix the bug with the new line not working with the text present. It has nothing to do with the text, it happens when another collection is in the editor. We need to insert a dummy role for EditorCell_Word to satisfy ChildrenCollectionFinder#isMultipleCollectionCell.
  • The other issue is the same as in the querylist language. You show the same node multiple times and then EditorComponent#findNodeCell finds the second cell instead of the first one. There are 14 usages of this method. I am not sure if this is fixable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants