Skip to content

Commit

Permalink
Merge branch 'canary' into 12-20-feat_blocksuite_add_plain_text_adapt…
Browse files Browse the repository at this point in the history
…er_for_database_block
  • Loading branch information
donteatfriedrice authored Dec 23, 2024
2 parents 185ba27 + a187f23 commit b9cfaaf
Show file tree
Hide file tree
Showing 1,014 changed files with 60,774 additions and 4,028 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/blocksuite/ @toeverything/blocksuite-core
38 changes: 37 additions & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,36 @@ jobs:
yarn set version $(node -e "console.log(require('./package.json').packageManager.split('@')[1])")
git diff --exit-code
e2e-legacy-blocksuite-test:
name: Legacy Blocksuite E2E Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
playwright-install: true
electron-install: false
full-cache: true

- name: Run playground build
run: yarn workspace @blocksuite/playground build

- name: Run playwright tests
run: yarn workspace @blocksuite/legacy-e2e test --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }}

- name: Upload test results
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: test-results-e2e-legacy-bs-${{ matrix.shard }}
path: ./test-results
if-no-files-found: ignore

e2e-test:
name: E2E Test
runs-on: ubuntu-latest
Expand Down Expand Up @@ -179,12 +209,17 @@ jobs:
- build-native
env:
DISTRIBUTION: web
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
electron-install: true
playwright-install: true
full-cache: true

- name: Download affine.linux-x64-gnu.node
Expand All @@ -194,7 +229,7 @@ jobs:
path: ./packages/frontend/native

- name: Unit Test
run: yarn test:coverage
run: yarn test:coverage --shard=${{ matrix.shard }}/${{ strategy.job-total }}

- name: Upload unit test coverage results
uses: codecov/codecov-action@v5
Expand Down Expand Up @@ -767,6 +802,7 @@ jobs:
- lint
- check-yarn-binary
- e2e-test
- e2e-legacy-blocksuite-test
- e2e-mobile-test
- unit-test
- build-native
Expand Down
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ packages/frontend/templates/onboarding
packages/backend/native/index.d.ts
packages/frontend/native/index.d.ts
packages/frontend/native/index.js
compose.yaml
compose.yaml

blocksuite/tests-legacy/snapshots
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blocksuite/affine/all/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineConfig({
target: 'es2018',
},
test: {
globalSetup: '../../../scripts/vitest-global.ts',
globalSetup: '../../../scripts/vitest-global.js',
include: ['src/__tests__/**/*.unit.spec.ts'],
testTimeout: 1000,
coverage: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class EmbedHtmlFullscreenToolbar extends LitElement {
}
`;

private _popSettings = () => {
private readonly _popSettings = () => {
this._popperVisible = true;
popMenu(popupTargetFromElement(this._fullScreenToolbarContainer), {
options: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { getEmbedLinkedDocIcons } from './utils.js';
export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinkedDocModel> {
static override styles = styles;

private _load = async () => {
private readonly _load = async () => {
const {
loading = true,
isError = false,
Expand Down Expand Up @@ -103,15 +103,15 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
}
};

private _selectBlock = () => {
private readonly _selectBlock = () => {
const selectionManager = this.host.selection;
const blockSelection = selectionManager.create('block', {
blockId: this.blockId,
});
selectionManager.setGroup('note', [blockSelection]);
};

private _setDocUpdatedAt = () => {
private readonly _setDocUpdatedAt = () => {
const meta = this.doc.collection.meta.getDocMeta(this.model.pageId);
if (meta) {
const date = meta.updatedDate || meta.createDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
// Caches total bounds, includes all blocks and elements.
private _cachedBounds: Bound | null = null;

private _initEdgelessFitEffect = () => {
private readonly _initEdgelessFitEffect = () => {
const fitToContent = () => {
if (this.isPageMode) return;

Expand Down Expand Up @@ -99,7 +99,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
.catch(() => {});
};

private _pageFilter: Query = {
private readonly _pageFilter: Query = {
mode: 'loose',
match: [
{
Expand Down
2 changes: 1 addition & 1 deletion blocksuite/affine/block-embed/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineConfig({
target: 'es2018',
},
test: {
globalSetup: '../../../scripts/vitest-global.ts',
globalSetup: '../../../scripts/vitest-global.js',
include: ['src/__tests__/**/*.unit.spec.ts'],
testTimeout: 1000,
coverage: {
Expand Down
2 changes: 1 addition & 1 deletion blocksuite/affine/block-list/src/list-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class ListBlockComponent extends CaptionedBlockComponent<

private _inlineRangeProvider: InlineRangeProvider | null = null;

private _onClickIcon = (e: MouseEvent) => {
private readonly _onClickIcon = (e: MouseEvent) => {
e.stopPropagation();

if (this.model.type === 'toggle') {
Expand Down
2 changes: 1 addition & 1 deletion blocksuite/affine/block-list/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineConfig({
target: 'es2018',
},
test: {
globalSetup: '../../../scripts/vitest-global.ts',
globalSetup: '../../../scripts/vitest-global.js',
include: ['src/__tests__/**/*.unit.spec.ts'],
testTimeout: 1000,
coverage: {
Expand Down
6 changes: 3 additions & 3 deletions blocksuite/affine/block-paragraph/src/paragraph-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ export class ParagraphBlockComponent extends CaptionedBlockComponent<
> {
static override styles = paragraphBlockStyles;

private _composing = signal(false);
private readonly _composing = signal(false);

private _displayPlaceholder = signal(false);
private readonly _displayPlaceholder = signal(false);

private _inlineRangeProvider: InlineRangeProvider | null = null;

private _isInDatabase = () => {
private readonly _isInDatabase = () => {
let parent = this.parentElement;
while (parent && parent !== document.body) {
if (parent.tagName.toLowerCase() === 'affine-database') {
Expand Down
2 changes: 1 addition & 1 deletion blocksuite/affine/block-paragraph/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineConfig({
target: 'es2018',
},
test: {
globalSetup: '../../../scripts/vitest-global.ts',
globalSetup: '../../../scripts/vitest-global.js',
include: ['src/__tests__/**/*.unit.spec.ts'],
testTimeout: 1000,
coverage: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ export class PathGenerator {

export class ConnectorPathGenerator extends PathGenerator {
constructor(
private options: {
private readonly options: {
getElementById: (id: string) => GfxModel | null;
}
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ type RendererOptions = {
export class CanvasRenderer {
private _container!: HTMLElement;

private _disposables = new DisposableGroup();
private readonly _disposables = new DisposableGroup();

private _overlays = new Set<Overlay>();
private readonly _overlays = new Set<Overlay>();

private _refreshRafId: number | null = null;

Expand Down
2 changes: 1 addition & 1 deletion blocksuite/affine/block-surface/src/surface-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class SurfaceBlockComponent extends BlockComponent<

private _cachedViewport = new Bound();

private _initThemeObserver = () => {
private readonly _initThemeObserver = () => {
const theme = this.std.get(ThemeProvider);
this.disposables.add(theme.theme$.subscribe(() => this.requestUpdate()));
};
Expand Down
2 changes: 1 addition & 1 deletion blocksuite/affine/block-surface/src/surface-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const SurfaceBlockSchema = defineBlockSchema({
export type SurfaceMiddleware = (surface: SurfaceBlockModel) => () => void;

export class SurfaceBlockModel extends BaseSurfaceModel {
private _disposables: DisposableGroup = new DisposableGroup();
private readonly _disposables: DisposableGroup = new DisposableGroup();

override _init() {
this._extendElement(elementsCtorMap);
Expand Down
19 changes: 11 additions & 8 deletions blocksuite/affine/block-surface/src/utils/a-star.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,27 @@ function pointAlmostEqual(a: IVec3, b: IVec3): boolean {
}

export class AStarRunner {
private _cameFrom = new Map<IVec3, { from: IVec3[]; indexs: number[] }>();
private readonly _cameFrom = new Map<
IVec3,
{ from: IVec3[]; indexs: number[] }
>();

private _complete = false;

private _costSoFar = new Map<IVec3, number[]>();
private readonly _costSoFar = new Map<IVec3, number[]>();

private _current: IVec3 | null = null;

private _diagonalCount = new Map<IVec3, number[]>();
private readonly _diagonalCount = new Map<IVec3, number[]>();

private _frontier!: PriorityQueue<
IVec3,
[diagonalCount: number, pointPriority: number, distCost: number]
>;

private _graph: Graph<IVec3>;
private readonly _graph: Graph<IVec3>;

private _pointPriority = new Map<IVec3, number[]>();
private readonly _pointPriority = new Map<IVec3, number[]>();

get path() {
const result: IVec3[] = [];
Expand All @@ -72,9 +75,9 @@ export class AStarRunner {

constructor(
points: IVec3[],
private _sp: IVec3,
private _ep: IVec3,
private _originalSp: IVec3,
private readonly _sp: IVec3,
private readonly _ep: IVec3,
private readonly _originalSp: IVec3,
private _originalEp: IVec3,
blocks: Bound[] = [],
expandBlocks: Bound[] = []
Expand Down
12 changes: 6 additions & 6 deletions blocksuite/affine/block-surface/src/utils/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ function arrayAlmostEqual(point: IVec | IVec3, point2: IVec | IVec3) {
}

export class Graph<V extends IVec | IVec3 = IVec> {
private _xMap = new Map<number, V[]>();
private readonly _xMap = new Map<number, V[]>();

private _yMap = new Map<number, V[]>();
private readonly _yMap = new Map<number, V[]>();

constructor(
private points: V[],
private blocks: Bound[] = [],
private expandedBlocks: Bound[] = [],
private excludedPoints: V[] = []
private readonly points: V[],
private readonly blocks: Bound[] = [],
private readonly expandedBlocks: Bound[] = [],
private readonly excludedPoints: V[] = []
) {
const xMap = this._xMap;
const yMap = this._yMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type PriorityQueueNode<T, K> = {
export class PriorityQueue<T, K> {
heap: PriorityQueueNode<T, K>[] = [];

constructor(private _compare: (a: K, b: K) => number) {}
constructor(private readonly _compare: (a: K, b: K) => number) {}

bubbleDown(): void {
let index = 0;
Expand Down
Loading

0 comments on commit b9cfaaf

Please sign in to comment.