visual-space / visual-editor

Rich text editor for Flutter based on Delta format (Quill fork)
MIT License
290 stars 46 forks source link

Blocks - Collapsable, Styled, Color Code, Sub & Super #99

Open adrian-moisa opened 2 years ago

adrian-moisa commented 2 years ago

VE Blocks - Collapsable text #99

VE Blocks - Styled blocks #40

This features aims to provide the ability to render custom boxes for paragraphs including custom icons. this is usually done in books to highlight certain information types. This could also be done with custom embeds, however this solution is sub par since we cannot easily copy paste the info box content or part of it and retain stylings.

image

VE Blocks - Code block color coding #18

The current implementation of code blocks in Flutter Quill is rather rudimentar. Not much effort was put into this feature so far. We want to develop this feature to render interactive coding tutorials in Visual Space.

Color coding could be done by borrowing the tokens from another open source code editor and applying styling to the lines of text in the renderer without changing the deltas. There are some code editors from where we can borrow the list of tokens. So far I haven't researched a lot the topic. But I imagine a simple and naive implementation would search for language tokens and would apply color coding over them.

Currently the delta format can apply styling over code snippets. The idea itself is rather goofy. Except the benefit of being able to render markers, highlights and attachments using the same logic I'm seeing few reasons why we would allow full formatting in the code. For example now it is possible to add inline code snippet in a code block. Which makes no sense.

image

At the moment we would be happy with a basic code editor that provides color highlighting. But in the future we plan to add some more basic code editing features such as: syntax error highlighter or jump to token. This is by far not an easy job and I'm not even sure how far we want to go with the inline code or if this could be better done in a custom embed. I'm still thinking if the user interactions make sense.

For example I don't know for sure if selecting part of text and part of a code block should be possible. It's almost like being able to select part of text and part of an image and copy pasting them somewhere else.

Edit

@kthecoder has suggested the possibility of using Microsoft's LSP Protocol to implement autocomplete features. I believe this is somewhat beyond what a text text editor should be doing. Using a library for code editing could be a smarter move, since it's someone else's problem. Someone who specialises in code editing. However at the moment these code editors are mostly abandoned and far from complete. Ex: code_editor

Edit 2

Looks like the authors of this super popular extension for Google Docs are happy with this setup. It appears they don't have access from Google to run automatic color coding at runtime. So therefore they apply styles over the existing text via a wizard that has to be manually triggered. This is insane. No way we are doing this.

image

Edit 3 - Some questions to consider

Based on the questions listed above we can conclude we want to have Visual Editor in charge of rendering code blocks. We will disable rich text formatting on the code snippets and leave only code related features (highlights, markers, etc)

VE Blocks - Web, Cursor pointer on link hover #20

recognizer: isLink && canLaunchLinks ? _getRecognizer(node) : null,
mouseCursor: isLink && canLaunchLinks ? SystemMouseCursors.click : null,

More info https://github.com/flutter/flutter/issues/81159 https://stackoverflow.com/questions/43583411/how-to-create-a-hyperlink-in-flutter-widget

VE Blocks - Unselecting the checkbox does not work

VE Blocks - Headings don't override the size of text #14

This feature was developed in Quill right before the fork. it was purely tested so a lot of quality issues snuck in. Including this one. We can't override the size of sized text with headings. this is standard behaviour in other editors. The last to change the text (font size or heading) has priority in controlling the line height. As you can see the line height changes but not the font size.

For example I checked Google Docs and they have the behaviour as described above. Although in some circumstances even their implementation is rather unreliable. For example if a heading has mixed sizes of text they all scale together until they cant. So if you have a line of text with small fonts and then super large fonts, their implementation wont override the font size. I'm not sure at all if this behaviour even makes sense. I'm eager to hear your thoughts.

https://user-images.githubusercontent.com/11160141/169512392-47e7b2d0-81bd-4bcb-92c4-263c40ac97f8.mov

VE Blocks - Subscript, Superscript #97