Comments (2)
Interesting, but hydrating such a rendering into a working editor would be a whole different problem. Being able to do this would be cool, but, I think, too much extra complexity to be justified by that coolness. So yeah, this is probably out of scope.
from dev.
The hydration problem can be avoided by clearing out and re-building the DOM once the JS loads, like this (which is how the demo does it):
const editorDiv = document.querySelector('#editor');
editorDiv.innerHTML = '';
editorDiv.appendChild(view.dom);
It's not as fancy as React hydration by a long shot, but it works. For my use case I think this is perfectly acceptable as a hydration solution.
I just had another idea. As an alternative to populating global
(which doesn't feel quite right anyway) and detecting the Node environment, what if you could pass in document
as an optional argument to the EditorView
constructor? Something like this:
const dom = new JSDOM(html);
const document = dom.window.document;
new EditorView(state, document);
If document
is passed in, it can be assumed to be from JSDOM, and its presence can be used as the trigger to avoid executing code that's not necessary for just constructing the DOM.
Food for thought!
from dev.
Related Issues (20)
- Support custom commit characters in autocomplete HOT 8
- [autcomplete] need more information about changes to the document HOT 15
- how to use @codemirror/merge to compare 3 files HOT 1
- iOS autocorrect causes duplicate line break HOT 1
- iOS: Unable to paste links copied by share > copy HOT 2
- How to Maintain dispatch effect HOT 2
- Unified Merge View Bug HOT 2
- Safari tab navigation issue in `search-panel` HOT 1
- Line wrapping + line numbers not resizing to print media HOT 3
- Getting scrolling (e.g. on typing) to work in virtualized lists HOT 5
- Error: [commonjs--resolver] Missing "./" specifier in "xyz" package HOT 3
- Entering "ああ" in Markdown headings unexpectedly adds another "あ" on Chrome HOT 6
- Cursor gets stuck when typing at the end of a line on an Android device HOT 11
- Typo on "Try CodeMirror" page HOT 1
- Initial view doesn't start from the first line when the document has long wrapped lines HOT 1
- PostgreSQL dialect: Anonymous block code not color-coded properly HOT 1
- Title symbol followed by typing exhibits abnormal cursor position HOT 1
- Python language parser does not properly indent else clause in for and while loops HOT 1
- Typescript / JSX syntax highlighting breaks in certain documents with templated strings HOT 1
- CodeMirror 6 spends ~50 ms per frame 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 dev.