|
| 1 | +// import applyFormatMarkdown from "./applyFormatMarkdown" |
| 2 | +import applyFormat from "./applyFormat" |
| 3 | +import deleteLTR from "./deleteLTR" |
| 4 | +import deleteRTL from "./deleteRTL" |
| 5 | +import history from "./history" |
| 6 | +import insertText from "./insertText" |
| 7 | + |
| 8 | +// Returns a keydown type for a keydown event. |
| 9 | +function keyDownTypeFor(e) { |
| 10 | + switch (true) { |
| 11 | + |
| 12 | + case applyFormat.plaintext(e): |
| 13 | + return "apply-format-plaintext" |
| 14 | + case applyFormat.em(e): |
| 15 | + return "apply-format-em" |
| 16 | + case applyFormat.strong(e): |
| 17 | + return "apply-format-strong" |
| 18 | + case applyFormat.code(e): |
| 19 | + return "apply-format-code" |
| 20 | + case applyFormat.strike(e): |
| 21 | + return "apply-format-strike" |
| 22 | + case applyFormat.a(e): |
| 23 | + return "apply-format-a" |
| 24 | + |
| 25 | + // case applyFormatMarkdown.em(e): |
| 26 | + // return "apply-format-markdown-em" |
| 27 | + // case applyFormatMarkdown.strong(e): |
| 28 | + // return "apply-format-markdown-strong" |
| 29 | + // case applyFormatMarkdown.code(e): |
| 30 | + // return "apply-format-markdown-code" |
| 31 | + // case applyFormatMarkdown.strike(e): |
| 32 | + // return "apply-format-markdown-strike" |
| 33 | + // case applyFormatMarkdown.a(e): |
| 34 | + // return "apply-format-markdown-a" |
| 35 | + |
| 36 | + case insertText.insertText(e): |
| 37 | + return "insert-text" |
| 38 | + case insertText.insertTab(e): |
| 39 | + return "insert-tab" |
| 40 | + case insertText.insertSoftParagraph(e): |
| 41 | + return "insert-soft-paragraph" |
| 42 | + case insertText.insertHardParagraph(e): |
| 43 | + return "insert-hard-paragraph" |
| 44 | + |
| 45 | + case deleteRTL.line(e): // Takes precedence |
| 46 | + return "delete-rtl-line" |
| 47 | + case deleteRTL.word(e): // Takes precedence |
| 48 | + return "delete-rtl-word" |
| 49 | + case deleteRTL.rune(e): |
| 50 | + return "delete-rtl-rune" |
| 51 | + |
| 52 | + case deleteLTR.word(e): // Takes precedence |
| 53 | + return "delete-ltr-word" |
| 54 | + case deleteLTR.rune(e): |
| 55 | + return "delete-ltr-rune" |
| 56 | + |
| 57 | + case history.undo(e): |
| 58 | + return "undo" |
| 59 | + case history.redo(e): |
| 60 | + return "redo" |
| 61 | + |
| 62 | + default: |
| 63 | + // No-op |
| 64 | + break |
| 65 | + } |
| 66 | + return "" |
| 67 | +} |
| 68 | + |
| 69 | +export default keyDownTypeFor |
0 commit comments