Skip to content

Commit

Permalink
fix: sentry-a9663f0a1ad445f9baa3b4b6340686ad (#7682)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saul-Mirone authored Jul 18, 2024
1 parent 9455996 commit 6647981
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { EditorHost } from '@blocksuite/block-std';
import type { Doc } from '@blocksuite/store';

import { assertExists } from '@blocksuite/global/utils';
import { type BlockModel, Text } from '@blocksuite/store';

import type { ListBlockModel } from '../../../list-block/index.js';
Expand Down Expand Up @@ -129,7 +128,7 @@ export function handleBlockEndEnter(
// bbb
const id = doc.addBlock(flavour, blockProps, parent, index + 1);
const newModel = doc.getBlockById(id);
assertExists(newModel);
if (!newModel) return;
doc.moveBlocks(model.children, newModel);

// 4. If the target block is a numbered list, update the prefix of next siblings
Expand Down Expand Up @@ -275,7 +274,7 @@ export function handleMultiBlockIndent(
const indentModels = models.slice(firstIndentIndex);
indentModels.forEach(model => {
const parent = doc.getParent(model);
assertExists(parent);
if (!parent) return;
// Only indent the model which parent is not in the `indentModels`
// When parent is in the `indentModels`, it means the parent has been indented
// And the model should be indented with its parent
Expand Down Expand Up @@ -372,8 +371,7 @@ export function handleMultiBlockOutdent(
for (let i = outdentModels.length - 1; i >= 0; i--) {
const model = outdentModels[i];
const parent = doc.getParent(model);
assertExists(parent);
if (!outdentModels.includes(parent)) {
if (parent && !outdentModels.includes(parent)) {
handleUnindent(editorHost, model);
}
}
Expand Down Expand Up @@ -401,8 +399,7 @@ export function handleRemoveAllIndentForMultiBlocks(
for (let i = models.length - 1; i >= 0; i--) {
const model = models[i];
const parent = doc.getParent(model);
assertExists(parent);
if (!matchFlavours(parent, ['affine:note'])) {
if (parent && !matchFlavours(parent, ['affine:note'])) {
handleRemoveAllIndent(editorHost, model);
}
}
Expand Down Expand Up @@ -585,7 +582,7 @@ function handleNoPreviousSibling(editorHost: EditorHost, model: ExtendedModel) {
const doc = model.doc;
const text = model.text;
const parent = doc.getParent(model);
assertExists(parent);
if (!parent) return false;
const titleElement = getDocTitleByEditorHost(
editorHost
) as HTMLTextAreaElement | null;
Expand Down Expand Up @@ -616,7 +613,7 @@ function handleNoPreviousSibling(editorHost: EditorHost, model: ExtendedModel) {
// Preserve at least one block to be able to focus on container click
if (doc.getNext(model) || model.children.length > 0) {
const parent = doc.getParent(model);
assertExists(parent);
if (!parent) return false;
doc.deleteBlock(model, {
bringChildrenTo: parent,
});
Expand Down Expand Up @@ -670,7 +667,7 @@ function handleParagraphDeleteActions(
editorHost,
previousSibling
);
assertExists(previousSiblingElement);
if (!previousSiblingElement) return false;
const selection = editorHost.selection.create('block', {
blockId: previousSiblingElement.blockId,
});
Expand Down Expand Up @@ -859,7 +856,7 @@ function handleParagraphBlockForwardDelete(
editorHost,
nextSibling
);
assertExists(nextSiblingComponent);
if (!nextSiblingComponent) return false;
editorHost.selection.setGroup('note', [
editorHost.selection.create('block', {
blockId: nextSiblingComponent.blockId,
Expand Down

1 comment on commit 6647981

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Size Report

Bundles

Entry Size Gzip Brotli
examples/basic 1.31 kB 743 B (-2 B) 633 B (-5 B)

Packages

Name Size Gzip Brotli
blocks 3.69 MB (+1.81 kB) 1.04 MB (+528 B) 811 kB (+1.14 kB)
editor 84 B 89 B 63 B
store 83 B 88 B 63 B
inline 84 B 88 B 63 B

Please sign in to comment.