Comments (10)
I can't reproduce this on the online demo https://gitbookio.github.io/slate-edit-code/
The online demo is using slate^0.29.0
I tried using slate^0.30.0
locally, without luck.
Do you have the list of the plugins you are using and their version ?
from slate-edit-code.
from slate-edit-code.
Hmm I tried to make a bundle out of the plugin, but my browserify skills are not great. The best you have is this repo example.
You can run it locally:
git clone https://github.com/GitbookIO/slate-edit-code/
cd slate-edit-code
yarn
yarn run start
The source of the example is in ./example/main.js
There is no live-reload. So if you change something, you should restart yarn run start
from slate-edit-code.
Ah yes, the online demo works but my local works also when creating multiple blocks in an existing editor. The problem seems to be when creating the code blocks from an existing slate value (ie deserializing)… I'm not running any other plugins for the purposes of debugging this.
from slate-edit-code.
This seems to have been related to the fact that my slate state didn't include code-lines, I don't know why but as soon as I added them multiple code blocks started working.
Have you considered having the exported schema automatically create the code-line blocks?
from slate-edit-code.
The current schema automatically wraps into code-lines
the texts found inside code-blocks
. But any node that is not a raw text will just be removed, without even trying to convert it. I'm not sure how I would convert any block to a code-line
from slate-edit-code.
Ah, the mystery deepens! I've been poking around in the validation code and removed the onlyText
validation. Just removing that validation step (and leaving the other three) shows a code block nested in a code block… which explains why it's getting filtered out and removed.
Now to figure out which validationRule is causing the nesting
from slate-edit-code.
from slate-edit-code.
It looks as if you used your old type for code blocks as the new type for code lines
from slate-edit-code.
Nope, nothing like that. I can reproduce one part of this problem in the example code in the repo – you said above that:
The current schema automatically wraps into code-lines the texts found inside code-blocks. But any node that is not a raw text will just be removed
However, change the example code here to the following and the code lines are not created…
<code_block>
{`
// Some JavaScript
function hello() {
console.log('Hello World')
}
`}
</code_block>
from slate-edit-code.
Related Issues (20)
- How to insert code blocks? HOT 5
- Add quotes/double quotes when selection is expanded and quote keys are pressed. HOT 1
- Schema normalization has an infinite loop
- Edition doesn't mean editing HOT 1
- Prism highlighting does not update all lines when changing syntax HOT 1
- Support toggle of multiple blocks to code block
- Update to reflect changes in Slate v0.22.0 HOT 2
- Attempting to paste over multiple lines of code results in error HOT 7
- Allow custom indent
- Ctrl+Enter no longer exits codeblock on Windows HOT 2
- Select All with Ctrl+A no longer limits bounds to the codeblock HOT 2
- All code ending up in a single line block HOT 3
- Add line numbers HOT 1
- Accepting data in toggle & wrap functions
- How exactly does one use the getIndent option? HOT 7
- Don't work in slate 0.37 HOT 8
- How to do syntax highlighting? HOT 2
- Possible error when pasting something that is not text
- Shift + Tab to reduce indent
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 slate-edit-code.