Comments (8)
highlighting code in wysiwyg is easy.
hard part is managing highlighting tags while contenteditable manipulate that.
for now I have no option to make it pretty.
leave what you think if someone has an option.
from tui.editor.
Same question, why the preview area can highlight the code? Does it re-render markdown?
from tui.editor.
It would also be nice to have the syntax coloring in the editable part of the Markdown mode (as in https://laobubu.net/HyperMD/#README.md or https://stackedit.io/app# ) ...
@kyuwoo-choi : Is it possible you could mix the modes in the case of code blocks, so that a WYSIWYG code block is actually just the same mode as in the above?
from tui.editor.
First, I explain the editor implementation. The Markdown editor, the WYSIWYG editor, and the Preview use the different dependency modules to input data highlighting. It also provides different highlighting methods depending on the usability.
1. Preview (or with Markdown editor)
This is using the renderer of markdown-it and highlight.js. This works as expected of everyone. After editing in the editor, import the markdown data and highlight it.
2. Markdown editor
This is using CodeMirror. I checked that CodeMirror is highlighting the code block. So I think it's a bug and I'll check if it can be solved. This seems to be related to the question below.
It would also be nice to have the syntax coloring in the editable part of the Markdown mode (as in https://laobubu.net/HyperMD/#README.md or https://stackedit.io/app# ) ...
3. WYSIWYG editor
This is using Squire. First of all, the WYSIWYG editor cannot check the code language with syntax like Markdown. That's why the WYSIWYG editor uses the UI to select code languages and provide highlighting previews. Different languages have different highlighting methods, and there is no way to handle this in the editor.
I know why you think this is like a bug. Perhaps you can edit the code block in the editor, so it's as if highlighting should be automatic. And it's strange that highlighting doesn't work after editing through the editing layer. I think it should be handled considering usability and the code block in the editor seems to be in read mode. That way all the issues will be resolved. 🤔
from tui.editor.
Yes, no. 2 in your list was my issue. I see per CodeMirror's GFM demo that it:
Optionally depends on other modes for properly highlighted code blocks.
And since on https://codemirror.net/doc/manual.html#config , it says:
This will initialize the editor with a piece of code already in it, and explicitly tell it to use the JavaScript mode (which is useful when multiple modes are loaded).
...I think (and seem to recall it working this way) that it will make them available as long as you:
- Include the other mode scripts (e.g., JavaScript, HTML, JSON, and CSS) (and maybe stylesheets, though the CodeMirror demo doesn't seem to need these); the source of the gfm demo includes modes for xml, javascript, css, htmlmixed, clike (in addition to gfm and markdown) ; it also includes
addon/mode/overlay.js
andmeta.js
which appear may be needed for such mixed languages. - Ensure you have defined
mode: {name: "gfm"}
ormode: "gtm"
(so that if you load other sources in the above step, CodeMirror will know which one to use as the main) - Do not set
fencedCodeBlockHighlighting
tofalse
(the default istrue
) mentioned on the Markdown page. (This is not mentioned on the GFM page but since GFM inherits the options from Markdown ("Gfm mode supports these options (apart those from base Markdown mode)"), it may apply if you are using it.)
from tui.editor.
As far as no. 3 in your list, I'm not sure I understood you fully, but to try to reply:
First of all, the WYSIWYG editor cannot check the code language with syntax like Markdown. That's why the WYSIWYG editor uses the UI to select code languages and provide highlighting previews. Different languages have different highlighting methods, and there is no way to handle this in the editor.
Since the editor even shows it is aware of what language is in use (by hovering on the block, it shows on the top right), it should be possible to change the language mode here. It is definitely technically possible, as the demo links I gave earlier can do it, and these are partly WYSIWYG.
I think it should be handled considering usability and the code block in the editor seems to be in read mode.
If you mean that you think that reading mode should be distinct from the preview mode, and therefore not have highlighting, I can kind of understand this logic, but I don't really have the same personal preference, because:
- As per my comment at #171 (comment) , it would be useful to be able to have the Markdown part of the Editor with the Preview turned off, either by toggle and/or optionally as the default.
- I would hope the syntax highlighting could be made optional for those who prefer to be able to see clearly what they are typing, esp. in a log code block, without needing to look back and forth with the preview.
from tui.editor.
This issue has been automatically marked as inactive because there hasn’t been much going on it lately. It is going to be closed after 7 days. Thanks!
from tui.editor.
This issue will be closed due to inactivity. Thanks for your contribution!
from tui.editor.
Related Issues (20)
- Syntax highlighter does not escape XML-entities when language is unknown or unspecified
- Add URL validation for image upload by URL input HOT 1
- 에디터 가운데 정렬 문의
- Drag & Drop and Paste of Images renders as Base64 without addImageBlobHook in Firefox HOT 1
- Optionally Support rendered inline math using $$.
- Numbered List Issues
- Make base64 encoded images collapsible
- Select in a cell cause error : Uncaught TypeError: Class constructor Selection cannot be invoked without 'new'
- Any fork of this project? HOT 1
- Inserted Image via URL does not show/load on WYSIWYG only editor
- WYSIWYG mode no character escaping
- Support React@18
- enhance the initial table redring
- customHTMLRenderer behavior in Markdown vs WYSIWYG mode
- 표 내부 텍스트 영역 선택 시, 전체 인식 이슈
- getHTML() Method in Toast-UI/Editor Returns Unexpected Value When Editor is Empty
- Multiline XML opening tag is not escaped
- 에디터에서 사진 드래그 앤 드랍 막기.
- Specific HTML input breaks WYSIWYG usability
- Does Toast-UI Editor supports dark theme? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tui.editor.