* Module Preparation * Registers Shortcuts CMD+A and CMD+C * to select all and copy them
()
| 146 | * to select all and copy them |
| 147 | */ |
| 148 | public prepare(): void { |
| 149 | this.selection = new SelectionUtils(); |
| 150 | |
| 151 | /** |
| 152 | * CMD/CTRL+A selection shortcut |
| 153 | */ |
| 154 | Shortcuts.add({ |
| 155 | name: 'CMD+A', |
| 156 | handler: (event) => { |
| 157 | const { BlockManager, ReadOnly } = this.Editor; |
| 158 | |
| 159 | /** |
| 160 | * We use Editor's Block selection on CMD+A ShortCut instead of Browsers |
| 161 | */ |
| 162 | if (ReadOnly.isEnabled) { |
| 163 | event.preventDefault(); |
| 164 | this.selectAllBlocks(); |
| 165 | |
| 166 | return; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * When one page consist of two or more EditorJS instances |
| 171 | * Shortcut module tries to handle all events. |
| 172 | * Thats why Editor's selection works inside the target Editor, but |
| 173 | * for others error occurs because nothing to select. |
| 174 | * |
| 175 | * Prevent such actions if focus is not inside the Editor |
| 176 | */ |
| 177 | if (!BlockManager.currentBlock) { |
| 178 | return; |
| 179 | } |
| 180 | |
| 181 | this.handleCommandA(event); |
| 182 | }, |
| 183 | on: this.Editor.UI.nodes.redactor, |
| 184 | }); |
| 185 | } |
| 186 | |
| 187 | /** |
| 188 | * Toggle read-only state |
nothing calls this directly
no test coverage detected