(event)
| 253 | } |
| 254 | |
| 255 | handleEvent(event) { |
| 256 | if (event.type == "diagnostic") { |
| 257 | this.view.dispatch(setDiagnostics(this.view.state, event.diagnostics)); |
| 258 | } else if (event.type == "focusout") { |
| 259 | codeFromUrl.set(event.target.code); |
| 260 | codeFromLocal.set(event.target.code); |
| 261 | } else if (event.type == "viewer-highlight") { |
| 262 | createHighlightEffect(this.view, event); |
| 263 | } else if (event.type == "mouseover") { |
| 264 | const pos = this.view.posAtCoords(event); |
| 265 | const tree = syntaxTree(this.view.state); |
| 266 | let cursor = tree.cursorAt(pos); |
| 267 | this.dispatchEvent( |
| 268 | new EditorHighlight({ start: cursor.from, end: cursor.to }), |
| 269 | ); |
| 270 | } else if (event.type == "click" || event.type === "focusin") { |
| 271 | codeFromUrl.set(this.code); |
| 272 | codeFromLocal.set(this.code); |
| 273 | const tree = syntaxTree(this.view.state); |
| 274 | let cursor; |
| 275 | if (event.x && event.y) { |
| 276 | const pos = this.view.posAtCoords(event); |
| 277 | cursor = tree.cursorAt(pos); |
| 278 | } else { |
| 279 | cursor = tree.cursorAt(this.view.state.selection.anchor); |
| 280 | } |
| 281 | this.dispatchEvent( |
| 282 | new EditorFocus({ start: cursor.from, end: cursor.to }), |
| 283 | ); |
| 284 | } else if (event.type == "load-code") { |
| 285 | this.view.dispatch( |
| 286 | this.view.state.update({ |
| 287 | changes: { |
| 288 | from: 0, |
| 289 | to: this.view.state.doc.length, |
| 290 | insert: event.sourcetext, |
| 291 | }, |
| 292 | }), |
| 293 | ); |
| 294 | this.dispatchEvent(new EditorChangeEvent(event.sourcetext)); |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | class MetricEvent extends Event { |
no test coverage detected