Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(blocks): microsheet-block init #8687

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ca3554d
feat(blocks): fork microsheet-block from database-block
Oct 21, 2024
b2ab680
feat(blocks): microsheet-block init
Oct 23, 2024
515d3da
feat(blocks): microsheet-block event init
Oct 23, 2024
8270e64
feat(blocks): microsheet-block feature complete
Nov 6, 2024
38d57e2
feat(blocks): remove kanbanview
Nov 7, 2024
00eea94
Merge branch 'toeverything:master' into feat/microsheet-init
raintoway Nov 7, 2024
afdf487
fix(blocks): microsheet-block remove unsed file and impove the use-ex…
Nov 14, 2024
6ad524f
Merge remote-tracking branch 'origin/master' into feat/microsheet-init
Nov 14, 2024
4a994da
fix(examples): update yarn.lock
Nov 14, 2024
5e8f1c2
chore(examples): upgrade the theme's version to 0.17.0
Nov 14, 2024
7b96258
fix(blocks): remove the console statement
Nov 14, 2024
68a9d9d
Merge remote-tracking branch 'origin/master' into feat/microsheet-init
Nov 15, 2024
91a9175
fix(blocks): cell-block remove the selectBlock
Nov 15, 2024
c4ce493
fix(blocks): micorsheet-block : change the alias
Nov 18, 2024
5a6b0c0
Merge remote-tracking branch 'origin/master' into feat/microsheet-init
Nov 18, 2024
d519d98
fix(blocks): e2e-test: native、slash-menu fit the microsheet-block
Nov 18, 2024
cc15d80
fix(blocks): cell-block remove the command of selectBlock
Nov 18, 2024
eb52c54
Merge branch 'master' into feat/microsheet-init
raintoway Nov 18, 2024
3d1200a
Merge branch 'master' into feat/microsheet-init
raintoway Nov 19, 2024
4a0d09b
Merge branch 'master' into feat/microsheet-init
raintoway Nov 21, 2024
52c98b5
chore(playground): update icon
Nov 21, 2024
dd7be14
Merge remote-tracking branch 'origin/master' into feat/microsheet-init
Nov 21, 2024
ace0d15
Merge branch 'toeverything:master' into feat/microsheet-init
raintoway Nov 29, 2024
b65668b
Merge branch 'master' into feat/microsheet-init
raintoway Dec 2, 2024
25b6d05
Merge remote-tracking branch 'origin/master' into feat/microsheet-init
Dec 17, 2024
b72ee5f
fix(examples): dedupe check
Dec 18, 2024
5e0dc58
fix(page): fix microsheet-block's rich-text's type error
Dec 18, 2024
0d8d561
Merge branch 'master' into feat/microsheet-init
raintoway Dec 18, 2024
5c6749e
Merge branch 'master' into feat/microsheet-init
raintoway Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(blocks): remove kanbanview
  • Loading branch information
[email protected] committed Nov 7, 2024
commit 38d57e264a2318e6feeddefe3b364f92c6c590bf
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import type { KanbanCard } from '../../../view-presets/kanban/card.js';
import type { KanbanCardSelection } from '../../../view-presets/kanban/types.js';
import type { RecordDetail } from './detail.js';

import { KanbanCell } from '../../../view-presets/kanban/cell.js';
import { RecordField } from './field.js';

type DetailViewSelection = {
@@ -101,14 +98,7 @@ export class DetailSelection {
if (!selection || selection?.isEditing) {
return;
}
const nextContainer =
this.getFocusCellContainer(selection)?.nextElementSibling;
if (nextContainer instanceof KanbanCell) {
this.selection = {
propertyId: nextContainer.column.id,
isEditing: false,
};
}
this.getFocusCellContainer(selection)?.nextElementSibling;
}

focusFirstCell() {
@@ -143,16 +133,4 @@ export class DetailSelection {
`affine-microsheet-data-view-record-field[data-column-id="${selection.propertyId}"]`
) as RecordField | undefined;
}

getSelectCard(selection: KanbanCardSelection) {
const { groupKey, cardId } = selection.cards[0];

return this.viewEle
.querySelector(
`affine-microsheet-data-view-kanban-group[data-key="${groupKey}"]`
)
?.querySelector(
`affine-microsheet-data-view-kanban-card[data-card-id="${cardId}"]`
) as KanbanCard | undefined;
}
}
Original file line number Diff line number Diff line change
@@ -15,14 +15,10 @@ import { property, query } from 'lit/decorators.js';
import { repeat } from 'lit/directives/repeat.js';
import Sortable from 'sortablejs';

import type {
KanbanViewData,
TableViewData,
} from '../../../view-presets/index.js';
import type { TableViewData } from '../../../view-presets/index.js';
import type { SingleView } from '../../view-manager/single-view.js';
import type { GroupRenderProps } from './types.js';

import { KanbanSingleView } from '../../../view-presets/kanban/kanban-view-manager.js';
import { TableSingleView } from '../../../view-presets/table/table-view-manager.js';
import { renderUniLit } from '../../utils/uni-component/uni-component.js';
import { dataViewCssVariable } from '../css-variable.js';
@@ -149,11 +145,11 @@ export class GroupSetting extends SignalWatcher(
accessor groupContainer!: HTMLElement;

@property({ attribute: false })
accessor view!: TableSingleView | KanbanSingleView;
accessor view!: TableSingleView;
}

export const selectGroupByProperty = (
view: SingleView<TableViewData | KanbanViewData>,
view: SingleView<TableViewData>,
ops?: {
onSelect?: (id?: string) => void;
onClose?: () => void;
@@ -183,10 +179,7 @@ export const selectGroupByProperty = (
.uni="${property.icon}"
></microsheet-uni-lit>`,
select: () => {
if (
view instanceof TableSingleView ||
view instanceof KanbanSingleView
) {
if (view instanceof TableSingleView) {
view.changeGroup(id);
ops?.onSelect?.(id);
}
@@ -197,9 +190,7 @@ export const selectGroupByProperty = (
items: [
menu.action({
prefix: DeleteIcon(),
hide: () =>
view instanceof KanbanSingleView ||
view.data$.value?.groupBy == null,
hide: () => view.data$.value?.groupBy == null,
class: 'delete-item',
name: 'Remove Grouping',
select: () => {
@@ -216,7 +207,7 @@ export const selectGroupByProperty = (
};
export const popSelectGroupByProperty = (
target: PopupTarget,
view: SingleView<TableViewData | KanbanViewData>,
view: SingleView<TableViewData>,
ops?: {
onSelect?: () => void;
onClose?: () => void;
@@ -229,7 +220,7 @@ export const popSelectGroupByProperty = (
};
export const popGroupSetting = (
target: PopupTarget,
view: SingleView<TableViewData | KanbanViewData>,
view: SingleView<TableViewData>,
onBack: () => void
) => {
const groupBy = view.data$.value?.groupBy;
Original file line number Diff line number Diff line change
@@ -32,37 +32,9 @@ const TableViewSelectionSchema = z.union([
}),
]);

const KanbanCellSelectionSchema = z.object({
selectionType: z.literal('cell'),
groupKey: z.string(),
cardId: z.string(),
columnId: z.string(),
isEditing: z.boolean(),
});

const KanbanCardSelectionSchema = z.object({
selectionType: z.literal('card'),
cards: z.array(
z.object({
groupKey: z.string(),
cardId: z.string(),
})
),
});

const KanbanGroupSelectionSchema = z.object({
selectionType: z.literal('group'),
groupKeys: z.array(z.string()),
});

const MicrosheetSelectionSchema = z.object({
blockId: z.string(),
viewSelection: z.union([
TableViewSelectionSchema,
KanbanCellSelectionSchema,
KanbanCardSelectionSchema,
KanbanGroupSelectionSchema,
]),
viewSelection: z.union([TableViewSelectionSchema]),
});

export class MicrosheetSelection extends BaseSelection {
5 changes: 1 addition & 4 deletions packages/affine/microsheet-data-view/src/core/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import type { KanbanViewSelectionWithType } from '../view-presets/kanban/types.js';
import type { TableViewSelectionWithType } from '../view-presets/table/types.js';

export type DataViewSelection =
| TableViewSelectionWithType
| KanbanViewSelectionWithType;
export type DataViewSelection = TableViewSelectionWithType;
export type GetDataViewSelection<
K extends DataViewSelection['type'],
T = DataViewSelection,
Original file line number Diff line number Diff line change
@@ -34,8 +34,6 @@ export interface ViewManager {
viewDataGet(id: string): DataViewDataType | undefined;

moveTo(id: string, position: InsertToPosition): void;

viewChangeType(id: string, type: string): void;
}

export class ViewManagerBase implements ViewManager {
@@ -84,29 +82,6 @@ export class ViewManagerBase implements ViewManager {
return id;
}

viewChangeType(id: string, type: string): void {
const from = this.viewGet(id).type;
const meta = this.dataSource.viewMetaGet(type);
this.dataSource.viewDataUpdate(id, old => {
let data = {
...meta.model.defaultData(this),
id: old.id,
name: old.name,
mode: type,
};
const convertFunction = this.dataSource.viewConverts.find(
v => v.from === from && v.to === type
);
if (convertFunction) {
data = {
...data,
...convertFunction.convert(old),
};
}
return data;
});
}

viewDataGet(id: string): DataViewDataType | undefined {
return this.dataSource.viewDataGet(id);
}
17 changes: 1 addition & 16 deletions packages/affine/microsheet-data-view/src/effects.ts
Original file line number Diff line number Diff line change
@@ -54,11 +54,7 @@ import {
TextCell,
TextCellEditing,
} from './property-presets/text/cell-renderer.js';
import { DataViewKanban, DataViewTable } from './view-presets/index.js';
import { KanbanCard } from './view-presets/kanban/card.js';
import { KanbanCell } from './view-presets/kanban/cell.js';
import { KanbanGroup } from './view-presets/kanban/group.js';
import { KanbanHeader } from './view-presets/kanban/header.js';
import { DataViewTable } from './view-presets/index.js';
import { MicrosheetCellContainer } from './view-presets/table/cell.js';
import { DragToFillElement } from './view-presets/table/controller/drag-to-fill.js';
import { SelectionElement } from './view-presets/table/controller/selection.js';
@@ -147,13 +143,11 @@ export function effects() {
'microsheet-data-view-group-title-string-view',
StringGroupView
);
customElements.define('affine-microsheet-data-view-kanban-card', KanbanCard);
customElements.define('microsheet-filter-bar', FilterBar);
customElements.define(
'microsheet-data-view-group-title-number-view',
NumberGroupView
);
customElements.define('affine-microsheet-data-view-kanban-cell', KanbanCell);
customElements.define('affine-microsheet-lit-icon', AffineLitIcon);
customElements.define(
'microsheet-filter-condition-view',
@@ -208,10 +202,6 @@ export function effects() {
'affine-microsheet-new-record-preview',
NewRecordPreview
);
customElements.define(
'affine-microsheet-data-view-kanban-group',
KanbanGroup
);
customElements.define(
'microsheet-data-view-header-tools-filter',
DataViewHeaderToolsFilter
@@ -220,11 +210,6 @@ export function effects() {
'microsheet-data-view-header-tools-view-options',
DataViewHeaderToolsViewOptions
);
customElements.define('affine-microsheet-data-view-kanban', DataViewKanban);
customElements.define(
'affine-microsheet-data-view-kanban-header',
KanbanHeader
);
customElements.define('microsheet-variable-ref-view', VariableRefView);
customElements.define(
'affine-microsheet-data-view-record-detail',
21 changes: 0 additions & 21 deletions packages/affine/microsheet-data-view/src/view-presets/convert.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { kanbanViewMeta } from './kanban/index.js';
import { tableViewMeta } from './table/index.js';

export * from './convert.js';
export * from './kanban/index.js';
export * from './table/index.js';

export const viewPresets = {
tableViewMeta: tableViewMeta,
kanbanViewMeta: kanbanViewMeta,
};
Loading