Skip to content

Instantly share code, notes, and snippets.

@dmitrizzle
Created May 29, 2017 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmitrizzle/7e30f29692c2f677861ca724be0f4b13 to your computer and use it in GitHub Desktop.
Save dmitrizzle/7e30f29692c2f677861ca724be0f4b13 to your computer and use it in GitHub Desktop.
Plugin config for Slate using "slate-auto-replace"
export const plugins = [
AutoReplace({
trigger: "*",
before: /(\*)(.*)/,
ignoreIn: "heading",
transform: (transform, e, data, matches) => {
return transform
.addMark({ type: "bold" })
.insertText(matches.before[2])
.removeMark({ type: "bold" })
}
}),
AutoReplace({
trigger: "_",
before: /(_)(.*)/,
ignoreIn: ["heading", "quote"],
transform: (transform, e, data, matches) => {
return transform
.addMark({ type: "italic" })
.insertText(matches.before[2])
.removeMark({ type: "italic" })
}
}),
]
/*
Unfortunately, these aren't very good. They can not mix because the text is being re-inserted as plaintext.
Plus it messes with how stuff is being typed in, for example ** is no longer possible to type.
/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment