Created
May 29, 2017 14:59
-
-
Save dmitrizzle/7e30f29692c2f677861ca724be0f4b13 to your computer and use it in GitHub Desktop.
Plugin config for Slate using "slate-auto-replace"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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