diff options
| author | Tyler Schicke <tyler_schicke@brown.edu> | 2019-03-17 21:34:30 -0400 | 
|---|---|---|
| committer | Tyler Schicke <tyler_schicke@brown.edu> | 2019-03-17 21:34:30 -0400 | 
| commit | 36a8067ff4e8d081c8336b016fd9f586b40f65f6 (patch) | |
| tree | 7cd4a1278a55962fa8f1eff172762cab9eeb18dc /src/client/util/RichTextRules.ts | |
| parent | 54048114bca3a01a6d287112d975edd00a4e398a (diff) | |
| parent | 8433cc2b1c4d838930c3812d140678011b06e728 (diff) | |
Merge branch 'master' of github-tsch-brown:browngraphicslab/Dash-Web into DocContents
Diffstat (limited to 'src/client/util/RichTextRules.ts')
| -rw-r--r-- | src/client/util/RichTextRules.ts | 43 | 
1 files changed, 43 insertions, 0 deletions
diff --git a/src/client/util/RichTextRules.ts b/src/client/util/RichTextRules.ts new file mode 100644 index 000000000..3b8396510 --- /dev/null +++ b/src/client/util/RichTextRules.ts @@ -0,0 +1,43 @@ +import { +    inputRules, +    wrappingInputRule, +    textblockTypeInputRule, +    smartQuotes, +    emDash, +    ellipsis +} from "prosemirror-inputrules"; +import { Schema, NodeSpec, MarkSpec, DOMOutputSpecArray, NodeType } from "prosemirror-model"; + +import { schema } from "./RichTextSchema"; + +export const inpRules = { +    rules: [ +        ...smartQuotes, +        ellipsis, +        emDash, + +        // > blockquote +        wrappingInputRule(/^\s*>\s$/, schema.nodes.blockquote), + +        // 1. ordered list +        wrappingInputRule( +            /^(\d+)\.\s$/, +            schema.nodes.ordered_list, +            match => ({ order: +match[1] }), +            (match, node) => node.childCount + node.attrs.order === +match[1] +        ), + +        // * bullet list +        wrappingInputRule(/^\s*([-+*])\s$/, schema.nodes.bullet_list), + +        // ``` code block +        textblockTypeInputRule(/^```$/, schema.nodes.code_block), + +        // # heading +        textblockTypeInputRule( +            new RegExp("^(#{1,6})\\s$"), +            schema.nodes.heading, +            match => ({ level: match[1].length }) +        ) +    ] +};  | 
