Coder Social home page Coder Social logo

Comments (9)

arteevraina avatar arteevraina commented on June 12, 2024 1

I would like to work on this too.

from web-components.

irmerk avatar irmerk commented on June 12, 2024 1

This will likely be solved in withLists/insertBreak which handles essentially the functionality of pressing ENTER, or in RichTextEditor/onKeyDown where you can place a check for SHIFT+ENTER and make that create a new paragraph block.

from web-components.

arteevraina avatar arteevraina commented on June 12, 2024 1

@irmerk Still working on it. I will be sending a PR soon.

from web-components.

arteevraina avatar arteevraina commented on June 12, 2024

@irmerk As described in the issue SHIFT + Enter is used to create a new paragraph. By pressing even only Enter inside the variable we can create a new paragraph. Can you confirm it?

from web-components.

irmerk avatar irmerk commented on June 12, 2024

Just ENTER doesn't add a new paragraph. Only SHIFT + ENTER

from web-components.

arteevraina avatar arteevraina commented on June 12, 2024

@irmerk I am not exactly able to trace from where it is coming. Can you please guide me a bit?

from web-components.

irmerk avatar irmerk commented on June 12, 2024

@arteevraina any update on this?

from web-components.

arteevraina avatar arteevraina commented on June 12, 2024

@irmerk withLists/insertBreak is in markdown-editor repo. Could not find any reference for it in cicero-ui. Could you guide me a little bit more please?

from web-components.

irmerk avatar irmerk commented on June 12, 2024

Ah yes! Definitely. So I was wrong and it would actually be in withVariables, so yeah not in markdown-editor, sorry!

The way these withSomething functions are working is they're taking the Slate editor and manipulating the functions on it. So each withSomething wrapping the editor can dictate it's own version of editor.insertBreak and then they will all be called during runtime.

In withVariables, we will need to do something similar to what was done in markdown-editor's withLists, extracting insertBreak from editor and manipulating it.

const withVariables = (editor) => {
  const { insertBreak, insertText, isInline } = editor;

  editor.insertBreak = () => {
  // Some logic similar-ish to what is in withLists/insertBreak
  insertBreak();
  };

  editor.insertText = (text) => {...};

  editor.isInline = element => {...};
  return editor;
};

There's a chance this might not be the right approach? Another suggestion is similar, but with normalizeNode:

const withVariables = (editor) => {
  const { insertText, isInline, normalizeNode } = editor;

  editor.normalizeNode = ([node, path]) => {
    // Maybe some logic to prevent multiple paragraphs in a variable?
    return normalizeNode([node, path])
  };

  editor.insertText = (text) => {...};

  editor.isInline = element => {...};
  return editor;
};

I'd search through Slate docs, especially their examples for more reference.

from web-components.

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.