Skip to content

Commit

Permalink
fix(database): group as Database cannot keep inbound link (#6564)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzj3720 committed Mar 25, 2024
1 parent 8607e5d commit 54c4024
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,13 @@ export class RichTextCell extends BaseCellRenderer<Y.Text> {
}

get inlineManager() {
assertExists(this.service);
return this.service.inlineManager;
return this.service?.inlineManager;
}
get attributesSchema() {
return this.inlineManager.getSchema();
return this.inlineManager?.getSchema();
}
get attributeRenderer() {
return this.inlineManager.getRenderer();
return this.inlineManager?.getRenderer();
}

@query('rich-text')
Expand Down Expand Up @@ -153,7 +152,8 @@ export class RichTextCell extends BaseCellRenderer<Y.Text> {
.inlineEventSource=${this.topContenteditableElement}
.attributesSchema=${this.attributesSchema}
.attributeRenderer=${this.attributeRenderer}
.markdownShortcutHandler=${this.inlineManager.markdownShortcutHandler}
.embedChecker=${this.inlineManager?.embedChecker}
.markdownShortcutHandler=${this.inlineManager?.markdownShortcutHandler}
.readonly=${true}
class="affine-database-rich-text inline-editor"
></rich-text>`;
Expand Down Expand Up @@ -198,14 +198,13 @@ export class RichTextCellEditing extends BaseCellRenderer<Text> {
}

get inlineManager() {
assertExists(this.service);
return this.service.inlineManager;
return this.service?.inlineManager;
}
get attributesSchema() {
return this.inlineManager.getSchema();
return this.inlineManager?.getSchema();
}
get attributeRenderer() {
return this.inlineManager.getRenderer();
return this.inlineManager?.getRenderer();
}

@query('rich-text')
Expand Down Expand Up @@ -340,7 +339,8 @@ export class RichTextCellEditing extends BaseCellRenderer<Text> {
.inlineEventSource=${this.topContenteditableElement}
.attributesSchema=${this.attributesSchema}
.attributeRenderer=${this.attributeRenderer}
.markdownShortcutHandler=${this.inlineManager.markdownShortcutHandler}
.embedChecker=${this.inlineManager?.embedChecker}
.markdownShortcutHandler=${this.inlineManager?.markdownShortcutHandler}
class="affine-database-rich-text inline-editor"
></rich-text>`;
}
Expand Down
23 changes: 21 additions & 2 deletions packages/blocks/src/database-block/common/header-area/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,20 @@ abstract class BaseTextCell extends BaseCellRenderer<unknown> {
static override styles = styles;
@property({ attribute: false })
showIcon = false;
get service() {
const database = this.closest<DatabaseBlockComponent>('affine-database');
return database?.service;
}

get inlineManager() {
return this.service?.inlineManager;
}
get attributesSchema() {
return this.inlineManager?.getSchema();
}
get attributeRenderer() {
return this.inlineManager?.getRenderer();
}
get topContenteditableElement() {
const databaseBlock =
this.closest<DatabaseBlockComponent>('affine-database');
Expand Down Expand Up @@ -150,11 +163,14 @@ export class HeaderAreaTextCell extends BaseTextCell {
const yText = this.getYText(
this.titleColumn.getValue(this.rowId) as Y.Text | string | undefined
);

return html`${this.renderIcon()}
<rich-text
.yText=${yText}
.inlineEventSource=${this.topContenteditableElement}
.attributesSchema=${this.attributesSchema}
.attributeRenderer=${this.attributeRenderer}
.embedChecker=${this.inlineManager?.embedChecker}
.markdownShortcutHandler=${this.inlineManager?.markdownShortcutHandler}
.readonly=${true}
class="data-view-header-area-rich-text"
></rich-text>`;
Expand Down Expand Up @@ -191,11 +207,14 @@ export class HeaderAreaTextCellEditing extends BaseTextCell {
const yText = this.getYText(
this.titleColumn.getValue(this.rowId) as Y.Text | string | undefined
);

return html`${this.renderIcon()}
<rich-text
.yText=${yText}
.inlineEventSource=${this.topContenteditableElement}
.attributesSchema=${this.attributesSchema}
.attributeRenderer=${this.attributeRenderer}
.embedChecker=${this.inlineManager?.embedChecker}
.markdownShortcutHandler=${this.inlineManager?.markdownShortcutHandler}
.readonly=${this.readonly}
class="data-view-header-area-rich-text"
></rich-text>`;
Expand Down

0 comments on commit 54c4024

Please sign in to comment.