| Conditions | 2 |
| Total Lines | 10 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { inputRules, InputRule } from 'prosemirror-inputrules'; |
||
| 10 | export function smileyRule() { |
||
| 11 | return new InputRule(SmileyConf.getRegex(), ((state, match) => { |
||
| 12 | const { tr } = state; |
||
| 13 | const syntax = match[1]; |
||
| 14 | const icon = SmileyConf.getSmileys()[syntax]; |
||
| 15 | |||
| 16 | tr.setSelection(TextSelection.create(tr.doc, tr.selection.from, tr.selection.from - syntax.length + 1)); |
||
| 17 | return tr.replaceSelectionWith(state.schema.nodes.smiley.create({ icon, syntax })); |
||
| 18 | })); |
||
| 19 | } |
||
| 20 | |||
| 34 |