mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
fix(editor): use nullable inline editor root element (#9320)
Fixes `sentry-7906c03b79a54ede819c56cc15ad9889`
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* eslint-disable no-useless-escape */
|
||||
/* oxlint-disable no-useless-escape */
|
||||
import type { BlockComponent, ExtensionType } from '@blocksuite/block-std';
|
||||
import {
|
||||
KEYBOARD_ALLOW_DEFAULT,
|
||||
@@ -450,6 +450,7 @@ export const LatexExtension = InlineMarkdownExtension({
|
||||
|
||||
undoManager.stopCapturing();
|
||||
|
||||
if (!inlineEditor.rootElement) return KEYBOARD_ALLOW_DEFAULT;
|
||||
const blockComponent =
|
||||
inlineEditor.rootElement.closest<BlockComponent>('[data-block-id]');
|
||||
if (!blockComponent) return KEYBOARD_ALLOW_DEFAULT;
|
||||
|
||||
@@ -103,7 +103,8 @@ export class AffineLink extends ShadowlessElement {
|
||||
// Please also note that when readonly mode active,
|
||||
// this workaround is not necessary and links work normally.
|
||||
get block() {
|
||||
const block = this.inlineEditor?.rootElement.closest<BlockComponent>(
|
||||
if (!this.inlineEditor?.rootElement) return null;
|
||||
const block = this.inlineEditor.rootElement.closest<BlockComponent>(
|
||||
`[${BLOCK_ID_ATTR}]`
|
||||
);
|
||||
return block;
|
||||
|
||||
@@ -148,7 +148,8 @@ export class AffineReference extends WithDisposable(ShadowlessElement) {
|
||||
}
|
||||
|
||||
get block() {
|
||||
const block = this.inlineEditor?.rootElement.closest<BlockComponent>(
|
||||
if (!this.inlineEditor?.rootElement) return null;
|
||||
const block = this.inlineEditor.rootElement.closest<BlockComponent>(
|
||||
`[${BLOCK_ID_ATTR}]`
|
||||
);
|
||||
return block;
|
||||
|
||||
@@ -138,7 +138,7 @@ export class ReferencePopup extends WithDisposable(LitElement) {
|
||||
}
|
||||
|
||||
get block() {
|
||||
const block = this.inlineEditor.rootElement.closest<BlockComponent>(
|
||||
const block = this.inlineEditor.rootElement?.closest<BlockComponent>(
|
||||
`[${BLOCK_ID_ATTR}]`
|
||||
);
|
||||
assertExists(block);
|
||||
|
||||
Reference in New Issue
Block a user