Giter Club home page Giter Club logo

Comments (10)

Soreine avatar Soreine commented on July 23, 2024

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.

tommoor avatar tommoor commented on July 23, 2024

from slate-edit-code.

Soreine avatar Soreine commented on July 23, 2024

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.

tommoor avatar tommoor commented on July 23, 2024

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.

tommoor avatar tommoor commented on July 23, 2024

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.

Soreine avatar Soreine commented on July 23, 2024

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

Code reference

from slate-edit-code.

tommoor avatar tommoor commented on July 23, 2024

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

image

from slate-edit-code.

Soreine avatar Soreine commented on July 23, 2024

from slate-edit-code.

Soreine avatar Soreine commented on July 23, 2024

It looks as if you used your old type for code blocks as the new type for code lines

from slate-edit-code.

tommoor avatar tommoor commented on July 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.