| 44 | |
| 45 | class PostFindMode extends SuppressPrintable { |
| 46 | constructor() { |
| 47 | const element = document.activeElement; |
| 48 | super({ |
| 49 | name: "post-find", |
| 50 | // PostFindMode shares a singleton with focusInput; each displaces the other. |
| 51 | singleton: "post-find-mode/focus-input", |
| 52 | exitOnBlur: element, |
| 53 | exitOnClick: true, |
| 54 | // Always truthy, so always continues bubbling. |
| 55 | keydown(event) { |
| 56 | return InsertMode.suppressEvent(event); |
| 57 | }, |
| 58 | keypress(event) { |
| 59 | return InsertMode.suppressEvent(event); |
| 60 | }, |
| 61 | keyup(event) { |
| 62 | return InsertMode.suppressEvent(event); |
| 63 | }, |
| 64 | }); |
| 65 | |
| 66 | // If the very-next keydown is Escape, then exit immediately, thereby passing subsequent keys to |
| 67 | // the underlying insert-mode instance. |
| 68 | this.push({ |
| 69 | _name: `mode-${this.id}/handle-escape`, |
| 70 | keydown: (event) => { |
| 71 | if (KeyboardUtils.isEscape(event)) { |
| 72 | this.exit(); |
| 73 | return this.suppressEvent; |
| 74 | } else { |
| 75 | handlerStack.remove(); |
| 76 | return this.continueBubbling; |
| 77 | } |
| 78 | }, |
| 79 | }); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | class FindMode extends Mode { |