Code Monkey home page Code Monkey logo

Comments (4)

chilijung avatar chilijung commented on May 25, 2024 2

@Slapbox

  1. Cool, look for trailing space before and after I think is a better solution! As you said, we have problem to Ctrl + Z in the current implementation, I think I'll change the matching pattern to [space]*bold*[space] and transform to bold mark, and so does italic and bold italic.

  2. Yes, custom block/mark tags are the thing I'll work on next because some packages are related to packages from https://github.com/Canner/slate-editor-icons , might take time to achieve it.

from canner-slate-editor.

chilijung avatar chilijung commented on May 25, 2024 2

@Slapbox

  1. Support ***boldItalics***
  2. Apply changes when inserting space after markdown syntax
  3. Make Ctrl + Z work properly
  4. Customize types.

All these problems above are solved in the latest version v0.2.0, give it a try!

from canner-slate-editor.

chilijung avatar chilijung commented on May 25, 2024

Hi, @Slapbox thanks for your compliments.

Support for custom block/mark tags

What do you mean by custom block/mark tags, any examples?

Support for * for italics - I know first-hand this is a pain due to the edge case of handling triple asterisks for italics+bold

I've added *<text>* for italics before, but it won't work, because you will never get the bold mark. Whenever you type **<text>* will convert to *<italic>, in order to make both works, I decide to use different symbols. Maybe you could think of some better solution for that?

from canner-slate-editor.

Slapbox avatar Slapbox commented on May 25, 2024

For making ***boldItalics*** work in my implementation what I did was wait until space was pressed after the italics to do conversion into richtext. I personally found this to be a more natural feeling way of doing the conversion besides the fact that is allows for triple asterisks. The downside is, it leads to more to maintain.

A pleasant side effect of this method is that using Ctrl+Z to undo prevents the markdown pattern from immediately being reapplied and instead leaves the user with their markdown as it was written. A not so pleasant side effect is that it's possible to have orphaned markdown tags in the document, for example if someone types the following but never presses Space, instead of being bold, the text will just have the asterisks around it.

This is a sentence and **this part is bold**

Another edge case is if someone puts punctuation or text directly after the asterisk.

`This is a sentence and this part is bold.


Regarding block/mark tags, it's an issue only when using the editor as a plugin and not standalone.

Here's an example from https://github.com/Canner/slate-md-editor/blob/master/src/match/codeBlock.js

const codePlugin = PluginEditCode({
  onlyIn: node => node.type === 'code_block'
})

In my implementation the tag for code blocks is codeBlock, as opposed to code_block. It would be great to be able to set names for the tags for integration with existing editor implementations.

The example is actually more apt than I thought, as it's the code to do exactly that for the slate-edit-code plugin.

from canner-slate-editor.

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.