Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not get Autoreplace to work #39

Open
FrancisVila opened this issue Feb 1, 2019 · 1 comment
Open

Could not get Autoreplace to work #39

FrancisVila opened this issue Feb 1, 2019 · 1 comment

Comments

@FrancisVila
Copy link

FrancisVila commented Feb 1, 2019

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>
    )
  }
@arnaudambro
Copy link

I don't know why it's not working but VSCode warning has nothing to do with this.
If I paraphrase VSCode warning, I'd say :

Hey you user ! There is no types and no TypeScript in this project... yet. Which is fine, but maybe the author of the library put the types outside slate-auto-replace, like in @types/slate-auto-replace ? You can try to installed @types/slate-auto-replace if you want

which you did, but @types/slate-auto-replace does not exist, that's why you got a 404.

This being said, it doesn't tell you why it's not working. Sorry !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants