Some checks failed
Build & Test / Analyze (javascript, affine) (push) Failing after 4s
Build & Test / Analyze (typescript, affine) (push) Failing after 3s
Build & Test / Rust test filter (push) Failing after 4s
Build & Test / Check yarn binary (push) Failing after 3s
Build & Test / E2E BlockSuite Test (3) (push) Failing after 3s
Build & Test / Analyze (javascript, blocksuite) (push) Failing after 3s
Build & Test / Analyze (typescript, blocksuite) (push) Failing after 3s
Build & Test / Mobile native build filter (push) Failing after 3s
Build & Test / E2E BlockSuite Test (1) (push) Failing after 4s
Build & Test / E2E BlockSuite Test (2) (push) Failing after 4s
Build & Test / E2E Mobile Test (1) (push) Failing after 3s
Build & Test / Unit Test (1) (push) Has been skipped
Build & Test / Unit Test (2) (push) Has been skipped
Build & Test / Unit Test (3) (push) Has been skipped
Build & Test / Unit Test (4) (push) Has been skipped
Build & Test / Unit Test (5) (push) Has been skipped
Build & Test / Native Unit Test (push) Has been skipped
Build & Test / E2E BlockSuite Test (4) (push) Failing after 3s
Build & Test / E2E BlockSuite Test (5) (push) Failing after 3s
Build & Test / E2E BlockSuite Cross Browser Test (push) Failing after 3s
Build & Test / E2E Mobile Test (2) (push) Failing after 3s
Build & Test / Build AFFiNE native (x86_64-unknown-linux-gnu) (push) Failing after 3s
Build & Test / Build Server native (push) Failing after 3s
Build & Test / Check Git Status (push) Has been skipped
Build & Test / Server Test (0, 4) (push) Has been skipped
Build & Test / Server Test (1, 4) (push) Has been skipped
Build & Test / Server Test (2, 4) (push) Has been skipped
Build & Test / Server Test (3, 4) (push) Has been skipped
Build & Test / Server Test with Elasticsearch (push) Has been skipped
Build & Test / Build @affine/electron renderer (push) Failing after 3s
Build & Test / Copilot test filter (push) Failing after 4s
Build & Test / Lint Rust (push) Has been skipped
Build & Test / Server Test with Embedded Search (push) Has been skipped
Build & Test / Server Test with Manticore Search (push) Has been skipped
Build & Test / Server E2E Test (push) Has been skipped
Build & Test / Cloud Desktop E2E Test (push) Has been skipped
Build & Test / Cloud E2E Test 1/2 (push) Has been skipped
Build & Test / Cloud E2E Test 2/2 (push) Has been skipped
Build & Test / Build Android app (push) Has been skipped
Build & Test / Test Android app (push) Has been skipped
Build & Test / Run native tests (push) Has been skipped
Build & Test / Server Copilot Api Test (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (1, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (2, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (3, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (4, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (5, 5) (push) Has been skipped
Release / Canary Gate (push) Has been skipped
Build & Test / Build AFFiNE native (aarch64-apple-darwin) (push) Has been cancelled
Build & Test / Lint (push) Has been cancelled
Build & Test / Typecheck (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-apple-darwin) (push) Has been cancelled
Build & Test / Desktop Test (ubuntu-latest, linux, x64, x86_64-unknown-linux-gnu, true) (push) Has been cancelled
Build & Test / Desktop Test (windows-latest, windows, x64, x86_64-pc-windows-msvc, true) (push) Has been cancelled
Build & Test / E2E Test (1) (push) Has been cancelled
Build & Test / E2E Test (2) (push) Has been cancelled
Build & Test / E2E Test (3) (push) Has been cancelled
Build & Test / E2E Test (4) (push) Has been cancelled
Build & Test / E2E Test (5) (push) Has been cancelled
Build & Test / Build AFFiNE native (aarch64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, arm64, aarch64-apple-darwin, true) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, x64, x86_64-apple-darwin, false) (push) Has been cancelled
Build & Test / 3, 2, 1 Launch (push) Has been cancelled
Build & Test / Build iOS app (push) Has been cancelled
Copilot Test Automatically / Setup Test (push) Failing after 1s
Release / Prepare (push) Failing after 2s
Release / Release Cloud (push) Has been skipped
Release / Release Desktop (push) Has been skipped
Release / Release Docker Image (push) Has been skipped
Release / Release Mobile (push) Has been skipped
159 lines
4.0 KiB
TypeScript
159 lines
4.0 KiB
TypeScript
import { DefaultInlineManagerExtension } from '@blocksuite/affine-inline-preset';
|
|
import type { DetailSlotProps } from '@blocksuite/data-view';
|
|
import type {
|
|
KanbanSingleView,
|
|
TableSingleView,
|
|
} from '@blocksuite/data-view/view-presets';
|
|
import { WithDisposable } from '@blocksuite/global/lit';
|
|
import type { EditorHost } from '@blocksuite/std';
|
|
import { ShadowlessElement } from '@blocksuite/std';
|
|
import { cssVarV2 } from '@toeverything/theme/v2';
|
|
import { css, html, unsafeCSS } from 'lit';
|
|
import { property } from 'lit/decorators.js';
|
|
|
|
export class BlockRenderer
|
|
extends WithDisposable(ShadowlessElement)
|
|
implements DetailSlotProps
|
|
{
|
|
static override styles = css`
|
|
database-datasource-block-renderer {
|
|
padding-top: 36px;
|
|
padding-bottom: 16px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 16px;
|
|
margin-bottom: 12px;
|
|
border-bottom: 1px solid ${unsafeCSS(cssVarV2.layer.insideBorder.border)};
|
|
font-size: var(--affine-font-base);
|
|
line-height: var(--affine-line-height);
|
|
}
|
|
|
|
database-datasource-block-renderer .tips-placeholder {
|
|
display: none;
|
|
}
|
|
|
|
database-datasource-block-renderer rich-text {
|
|
font-size: 15px;
|
|
line-height: 24px;
|
|
}
|
|
|
|
database-datasource-block-renderer.empty rich-text::before {
|
|
content: 'Untitled';
|
|
position: absolute;
|
|
color: var(--affine-text-disable-color);
|
|
font-size: 15px;
|
|
line-height: 24px;
|
|
user-select: none;
|
|
pointer-events: none;
|
|
}
|
|
|
|
.database-block-detail-header-icon {
|
|
width: 20px;
|
|
height: 20px;
|
|
padding: 2px;
|
|
border-radius: 4px;
|
|
background-color: var(--affine-background-secondary-color);
|
|
}
|
|
|
|
.database-block-detail-header-icon svg {
|
|
width: 16px;
|
|
height: 16px;
|
|
}
|
|
`;
|
|
|
|
get attributeRenderer() {
|
|
return this.inlineManager.getRenderer();
|
|
}
|
|
|
|
get attributesSchema() {
|
|
return this.inlineManager.getSchema();
|
|
}
|
|
|
|
get inlineManager() {
|
|
return this.host.std.get(DefaultInlineManagerExtension.identifier);
|
|
}
|
|
|
|
get model() {
|
|
return this.host?.store.getBlock(this.rowId)?.model;
|
|
}
|
|
|
|
override connectedCallback() {
|
|
super.connectedCallback();
|
|
if (this.model && this.model.text) {
|
|
const cb = () => {
|
|
if (this.model?.text?.length == 0) {
|
|
this.classList.add('empty');
|
|
} else {
|
|
this.classList.remove('empty');
|
|
}
|
|
};
|
|
this.model.text.yText.observe(cb);
|
|
this.disposables.add(() => {
|
|
this.model?.text?.yText.unobserve(cb);
|
|
});
|
|
}
|
|
this._disposables.addFromEvent(
|
|
this,
|
|
'keydown',
|
|
e => {
|
|
if (e.key === 'Enter' && !e.shiftKey && !e.isComposing) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
return;
|
|
}
|
|
if (
|
|
e.key === 'Backspace' &&
|
|
!e.shiftKey &&
|
|
!e.metaKey &&
|
|
this.model?.text?.length === 0
|
|
) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
return;
|
|
}
|
|
},
|
|
true
|
|
);
|
|
}
|
|
|
|
protected override render(): unknown {
|
|
const model = this.model;
|
|
if (!model) {
|
|
return;
|
|
}
|
|
return html`
|
|
${this.renderIcon()}
|
|
<rich-text
|
|
.yText=${model.text}
|
|
.attributesSchema=${this.attributesSchema}
|
|
.attributeRenderer=${this.attributeRenderer}
|
|
.embedChecker=${this.inlineManager.embedChecker}
|
|
.markdownMatches=${this.inlineManager.markdownMatches}
|
|
class="inline-editor"
|
|
></rich-text>
|
|
`;
|
|
}
|
|
|
|
renderIcon() {
|
|
const iconColumn = this.view.mainProperties$.value.iconColumn;
|
|
if (!iconColumn) {
|
|
return;
|
|
}
|
|
return html` <div class="database-block-detail-header-icon">
|
|
${this.view.cellGetOrCreate(this.rowId, iconColumn).value$.value}
|
|
</div>`;
|
|
}
|
|
|
|
@property({ attribute: false })
|
|
accessor host!: EditorHost;
|
|
|
|
@property({ attribute: false })
|
|
accessor openDoc!: (docId: string) => void;
|
|
|
|
@property({ attribute: false })
|
|
accessor rowId!: string;
|
|
|
|
@property({ attribute: false })
|
|
accessor view!: TableSingleView | KanbanSingleView;
|
|
}
|