Code Monkey home page Code Monkey logo

slate-plugins's Introduction

This repository contains a few of my Slate plugins in a single monorepo to keep them easier to develop.


Plugins

Note: this is not an "official" set of plugins, just ones that I've happened to need and have made. If you have an idea for a plugin, don't pull request it here, you should keep them in your own repos. (Feel free to use this monorepo as a template for your own!)


Demo

Check out the live demo of each of the plugins!


Contributing!

All contributions are super welcome! Check out the Contributing instructions for more info!

These plugins are MIT-licensed.

slate-plugins's People

Contributors

aunswjx avatar diegocouto avatar erquhart avatar gabri3l avatar ianstormtaylor avatar jemmyw avatar justinweiss avatar mklabs avatar mr-remington avatar oyeanuj avatar samypesse avatar soreine avatar wells avatar yurkaninryan 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

slate-plugins's Issues

slate-soft-break: insert soft break on paste

I'm looking into implementing it. Let me know if this feature is aligned with what this plugin is supposed to bring to slate and let me know if you have idea on how it should be implemented.

Do you want to request a feature or report a bug?

feature

What's the current behavior?

When pasting text into the editor, the \n character splits the current block in two.

What's the suggested behavior?

Add an option in slate-soft-break to interpret \n in pasted text as soft breaks.
I'm not sure it should do this on all block type or if the option should restrict to a specific block type.

Produces a Slate error on image paste

Do you want to request a feature or report a bug?

bug

What's the current behavior?

I clone this repo locally, install dependencies, run it and open the page in my Chrome browser, select "Drop/Paste images" tab, paste an image from clipboard, and see the error in the browser's console:
image
The worst thing comes that when in my project i use Nextjs with server-side rendering - this error crashes the page completely.

What's the expected behavior?

There is no error:)

Consider using ESLint rule: default-case

Do you want to request a feature or report a bug?

Feature (DevOps)

What's the current behavior?

Switch statements do not require a default case

What's the expected behavior?

If the past when returning undefined moved through the plugin stack this would definitely be overkill, but it might be worth considering now.

If we require a default case, it would probably help with ensuring that we are always returning next() where needed - This might be worth implementing in Slate itself as well with the recent changes.

https://eslint.org/docs/rules/default-case

Auto Replace and Collapse on Escape not working in example page.

Do you want to request a feature or report a bug?

Bug. (on the examples website https://slate-plugins.netlify.com/#/slate-auto-replace)

What's the current behavior?

  • Auto Replace
    • E.g. typing "(c)" removes the entire "(c)" sequence when the last ")" is inserted, and replaces it with an empty string "".
  • Collapse on escape
    • When selecting some text, then hitting escape. The text is deselected, and nothing else happens.

What's the expected behavior?

  • Auto Replace
    • The "(c)" string should be replaced with "©" when the last ")" is inserted.
  • Collapse on escape
    • I actually have no idea.

Update: May 11, 2019
It seems that "Collapse on escape" is working as expected.

Outdated dependencies

Do you want to request a feature or report a bug?

dependencies need some maintenance

What's the current behavior?

screen shot 2018-03-30 at 3 52 07 pm

What's the expected behavior?

screen shot 2018-03-30 at 3 57 25 pm

--Would you like me to go through the dependencies and update them for all packages?

Update for slate 0.27.0+

Some of the plugins are still using the data.* properties. We're going to have to fix those up to remove the deprecations

Could not get Autoreplace to work

This module's objective fits exactly what I'm trying to do, but I can't get it to work! it does not produce any errors, but when I type (c) in the editor nothing happens.

I installed it with
npm install --save slate-auto-replace

VScode give me a warning on the import
import AutoReplace from 'slate-auto-replace'
the suggestion goes like this:

Could not find a declaration file for module 'slate-auto-replace'. 'c:/react/hoveringmenu/node_modules/slate-auto-replace/lib/slate-auto-replace.js' implicitly has an 'any' type.
Try npm install @types/slate-auto-replace if it exists or add a new declaration (.d.ts) file containing declare module 'slate-auto-replace';

npm install @types/slate-auto-replace gives an error. 404 Not Found: @types/slate-auto-replace@latest

Here's the code of my app;

import AutoReplace from 'slate-auto-replace'

const  plugins = [
  AutoReplace({
    trigger: ')',
    before: /(\(c)$/i,
// i also tried without the before
    change: transform => transform.insertText('©')
  }),
]

  render() {
    return (
      <div>
        <Editor
          placeholder="Enter some text..."
          value={this.state.value}
          onChange={this.onChange}
          renderEditor={this.renderEditor}
          renderMark={this.renderMark}
          onKeyDown={this.onKeyDown}
          plugins={plugins}
        />
      </div>
    )
  }

AutoSave plugin

Do you want to request a feature or report a bug?

Feature

What's the current behavior?

What's the expected behavior?

Any plans to make an auto save plugin? If not, could you help me with how to implement one. I need to autosave every time there is a 3 sec delay after last onChange. Currently I have tried doing this functionality with lodash.throttle, but I am not sure if that is the correct way of implementing autosave.

There seems to be a plugin out there -> https://github.com/komcal/slate-auto-save , but since it is not officially supported, I don't know how safe it is to use that.
Thanks in advance 🙂

slate-soft-break: Newline inserted just after a mark misplace the cursor

Do you want to request a feature or report a bug?

A bug

What's the current behavior?

When pressing Enter, the cursor stays on the same line when a leaf with a mark is just before the cursor.

OS:

Darwin xyz.local 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64

Browser Identification:

Firefox
65.0.1
20190211233335 release
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:65.0) Gecko/20100101 Firefox/65.0
Darwin 17.7.0

Live example
gif recording

What's the expected behavior?

The cursor is expected to be on the newline

Auto-Replace Add Mark Bug.

Do you want to request a feature or report a bug?

Bug.

What's the current behavior?

No Marks are being rendered with autoreplace. Text is showing up but not with BOLD mark. No marks are rendered at all.

If you type BEFORE the text manually, the text is bold.

What's the expected behavior?

Marks should render.

const plugins = [
            AutoReplace({
                trigger: '*',
                before: /(\*{1}(.+?))$/,
                change: (change, e, matches) => {
                    var match = [...matches.before].pop()

                    return change
                        .addMark('bold')
                        .insertText(match)

                }
            }),

        ]

Doing this should insert BOLD text. That's not the current behavior. Anyone else experiencing this ?

Wrong handler onInsertText in slate-drop-or-paste-images

What's the current behavior?

Wrong handler onInsertText in slate-drop-or-paste-images

In code we have call:

  asyncApplyChange(c, editor, file)

But the method accepts only such variables:

  function asyncApplyChange(change, file) {
    const { editor } = change

    return Promise.resolve(insertImage(change, file)).then(() => {
      editor.onChange(change)
    })
  }

So we need to remove editor from arguments, because we have it in change

Link in bullet list continues in the next list item

Here is a gif of the issue from slate-plugins example pages
link in bullet list

Steps:

  1. Open example https://slate-plugins-next.netlify.app/?path=/story/examples-playground--plugins
  2. type - followed by space to create a bullet
  3. type a link inside
  4. press return create a second bullet

What's the current behavior?

the second bullet is part of the link which is not desired

What's the expected behavior?

when you press enter to go on the next line the link should close and should not be part of the second bullet item

System

Chome, macOS latest version slate and slate-plugins

include a renderNode function in PasteLinkify plugin?

What do you think about including a basic renderNode function for the PasteLinkify plugin? something like this:

renderNode = props => {
    const { node, attributes, children } = props;
    switch (node.type) {
      case 'link':
        return (
          <a {...attributes} href={node.data.get('url')}>
            {children}
          </a>
        );
      default:
        return null;
    }
  };

may not be a one size fits all, but i think it's generally sufficient

slate-drop-or-paste-images: Error is thrown if file has no extension

Do you want to request a feature or report a bug?

Bug 🐛

What's the current behavior?

  • Create a file with no extension
  • Drag and drop into editor
  • A JS error is thrown: Uncaught TypeError: Cannot read property 'includes' of undefined

What's the expected behavior?

  • The plugin accounts for this type of file

Are these scheduled for merging or...

I appreciate the progress being made on the main repo. Still, quite a lot seems to be in plugins (cmd + z, is that a plugin? working indentions and wrapping?) and hidden away in private repos or third party modules like udecode's plugins (great extension, but also quite heavy performance wise).

Plate nowadays. What are the plans on this in the future? Is this gonna stay something Slate will leave to the ecosystem or integrate in the library?

Over all this time I scraped my own "slate plugins / snippets" repo together. Not really sure that is really good for onboarding new devs though.

Mad props, Slate is quality.

slate-auto-replace logs deprecation message with slate 0.44

bug: slate-auto-replace logs deprecation message with slate 0.44

As of Slate 0.43 the `editor.call(fn)` method has been deprecated, please use `editor.command(fn)` instead.
newFn @ client.js:1769
index @ tiny-warning.esm.js:8
call @ slate.es.js:11599
call @ slate-react.es.js:4388
onKeyDown @ slate-auto-replace.es.js:59

Auto-replace Example Broken

Looks like the auto replace example is borked. Tried to track down the issues myself to no avail 😞. Seems that change is not being passed in as an argument to the plugin for one reason or another. Looks like it's being passed in taking a peak at slate-react's source but I'm also super new to the slate architecture so could be something obvious going wrong elsewhere.

/cc @ianstormtaylor

slate-drop-or-paste-image breaks default drag&drop

Do you want to request a feature or report a bug?

Bug

What's the current behavior?

1

uncaught TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'.
    at Image.load (build.prod.js:582)
    at Image.componentDidMount (build.prod.js:571)
    at CallbackQueue.notifyAll (build.prod.js:17008)
    at ReactReconcileTransaction.close (build.prod.js:26887)
    at ReactReconcileTransaction.closeAll (build.prod.js:29742)
    at ReactReconcileTransaction.perform (build.prod.js:29689)
    at ReactUpdatesFlushTransaction.perform (build.prod.js:29676)
    at ReactUpdatesFlushTransaction.perform (build.prod.js:27796)
    at Object.flushBatchedUpdates (build.prod.js:27879)
    at ReactDefaultBatchingStrategyTransaction.closeAll (build.prod.js:29742)

What's the expected behavior?

drag and drop should work by default.

Question regarding Undo History with Slate-Auto-Replace

It seems that Slate-Auto-Replace removes each capture group in a separate operation, which means if a user tries to undo it, they actually have to undo each operation one at a time. Is there a reasonably easy way to undo all the changes with a single undo?

Thanks for a millionth time Ian.

mime-db dependency is huge!

Do you want to request a feature or report a bug?

bug, of sorts

What's the current behavior?

slate-drop-or-paste-images depends on mime-types to run this function:

  function onInsertFiles(event, change, editor, transfer) {
    const { target, files } = transfer

    for (const file of files) {
      if (extensions) {
        const ext = mime.extension(file.type)
        if (!extensions.includes(ext)) continue
      }

      if (target) {
        change.select(target)
      }

      asyncApplyChange(change, editor, file)
    }

    return true
  }

Which, as I understands check for allowed file types when the user attempts to insert one. That tool in turn depends on mime-db, which in production costs 144KB (before GZip).

What's the expected behavior?

I don't think filetype check function should cost as much as the entire Slate library from within a plugin. Perhaps there's a way to hardcode allowed types instead or use another dependency?

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.