Skip to content

Commit

Permalink
fix: title cell drag and type fix
Browse files Browse the repository at this point in the history
  • Loading branch information
golok727 committed Apr 26, 2024
1 parent ee2f2a8 commit a34ee09
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ShadowlessElement } from '@blocksuite/block-std';
import { assertEquals, assertExists } from '@blocksuite/global/utils';
import { DocCollection, type Text } from '@blocksuite/store';
import { DocCollection, Text, type Y } from '@blocksuite/store';
import type { ReactiveController } from 'lit';
import { css, html } from 'lit';
import { customElement } from 'lit/decorators.js';
Expand Down Expand Up @@ -769,20 +769,24 @@ function fillSelectionWithFocusCellData(
const curRowId = cellContainer?.rowId;

if (tRichText.is(focusCell.column.dataType)) {
const focusCellText = focusData as Text;
const delta = focusCellText.toDelta();
const curCellText = cellContainer.column.getValue(curRowId) as Text;
// title column gives Y.Text and text col gives Text
const focusCellText = focusData as Y.Text | Text;

const delta = focusCellText.toDelta();
const curCellText = cellContainer.column.getValue(curRowId);
if (curCellText) {
curCellText.clear();
curCellText.applyDelta(delta);
const text =
focusCell.column.type === 'title'
? new Text(curCellText as Y.Text)
: (curCellText as Text);

text.clear();
text.applyDelta(delta);
} else {
const newText = new DocCollection.Y.Text();
newText.applyDelta(delta);
cellContainer.column.setValue(curRowId, newText);
}

continue;
} else {
cellContainer.column.setValue(curRowId, focusData);
}
Expand Down

0 comments on commit a34ee09

Please sign in to comment.