GithubHelp home page GithubHelp logo

ianstormtaylor / slate Goto Github PK

View Code? Open in Web Editor NEW
29.0K 302.0 3.2K 22.87 MB

A completely customizable framework for building rich text editors. (Currently in beta.)

Home Page: http://slatejs.org

License: MIT License

JavaScript 2.80% TypeScript 97.08% CSS 0.12%
editor browser react rich-text framework slate javascript text-editor

slate's People

Contributors

12joan avatar alberthilb avatar bitphinix avatar bryanph avatar cameracker avatar clauderic avatar conorcussell avatar dependabot[bot] avatar dmarkow avatar dougreeder avatar dundercover avatar dylans avatar ericedem avatar github-actions[bot] avatar ianstormtaylor avatar isubasti avatar jameshfisher avatar justinweiss avatar oyeanuj avatar samypesse avatar schneidmaster avatar skogsmaskin avatar smilinbrian avatar soreine avatar thespyder avatar thesunny avatar tobiasandersen avatar ulion avatar zbeyens avatar zhujinxuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slate's Issues

allow for transforms that don't create a new save snapshot

Needed for collaborative editing among other things, but could also be useful for plugins.

It would be useful for plugins that want to "normalize" the document in different ways. For example ensuring that it always ends in an empty paragraph. Right now the undo stack will get contaminated otherwise.

normalize selections to text nodes

Right now some behavior assumes that startKey and endKey are always text nodes and some doesn't. But going forward, I think it's best to normalize a selection once it's applied to a document, so that it always points to text nodes. This will mimic the current onSelect behavior of the contenteditable attribute, and it will also allow for easier "wrap/unwrap" handling.

cleanup node.normalize() calls

Fairly sure right now that we're doing too much work. Would be better instead to remove all of the calls, and maybe just keep a list in ./transforms of which transforms actually require normalizing afterwards, since it would be few.

atomic nodes?

Haven't dug into this yet, but seems like there might be something helpful to do for the concept of "atomic" nodes that should be deleted/selected all at once.

move from `OrderedMap` to `List/Set` for `nodes`

I haven't looked at this closely, but I feel like there are places where .map() is returning odd ordered maps with the previous type of blocks keys, eg:

nodes.map((node) => {
  return node.nodes.first()
})

Right now the code just happens not to use those keys afterwards, but seems better to fix the issue. Either that, or be sure to call .toList() for each of those...

add ability for Record.create to initialize raw Javascript values

Getting tedious always writing things like:

const data = new Map(obj)
const block = Block.create({ type, data })
const blocks = Block.createMap([ block ])

When it could just be:

const blocks = Block.createMap([{ type, data: obj }])

Without that much magic going on.

consider adding `.parent` property to nodes

Would need to be kept in sync with .normalize(), but we're already doing that as it is for text nodes. Might reduce a lot of the parent = ... reaching up the tree logic that needs to happen.

void nodes?

It would be useful to solve this in core, just like in the DOM where img or input tags can be "void" to have no children. Right now it's hard to do this since the selection state gets wonky quickly when trying to add void / non-content-editable pieces to the editor, like an image.

differentiate between "type" and "kind"

Before doing #10, we need to differentiate between type and kind. In the new model, kind will be the type of model, whereas type will be a user-specifiable field that applies to block and inline nodes.

So we'd end up with four kinds of nodes:

  • document
  • block
  • inline
  • text

decorators are slow

Right now, the API for decorators feel nice in that it just maps directly to marks that get added to ranges of text. But the current implementation is very slow, such that it causes noticeable lag used. Fairly sure there's a way to speed it up, and that it's not inherent to the way the API works, just needs to be investigated before they will be fast.

refactor transforms

they should be separate from state, and have an .apply() method or similar, so that it's clear where save boundaries are for undo/redo

fix node normalizeKey helper

Right now the helper in normalizeKey is causing extra work since it prefers the string key which then has to be looked up again. Would be better to flip it, to prefer to node so that it doesn't have to keep looking it up again.

get rid of `<Text>` component?

I haven't looked into this too deeply, but we might be able to get away with just having Leaf and not need the extra <span> from each text.

cleanup range.normalize() calls

Similar to #25, we're calling selection.normalize() in lots of places right now, when it would be better to figure out exactly where it needs to be called to save cycles.

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.