Compare commits

..

15 Commits

Author SHA1 Message Date
Peng Xiao
6883cc2ded fix(electron): page history api fetch issue (#9440) 2024-12-31 10:19:25 +08:00
doodlewind
2b47625deb refactor(editor): render presentation toolbar on demand (#9442) 2024-12-31 02:01:35 +00:00
pengx17
79e006467c fix(core): split view solo view crash (#9432) 2024-12-30 16:54:45 +00:00
Saul-Mirone
397a48380e refactor(editor): simplify tsconfig (#9439) 2024-12-30 16:15:34 +00:00
Saul-Mirone
8d269c838d fix(editor): touch event browser copability (#9437)
Fix: https://toeverything.sentry.io/issues/6180659644/events/82bf2e7bb8fc4ad69678261522b7fdf3/
2024-12-30 14:59:10 +00:00
Saul-Mirone
ade317d26b fix(editor): caret can be null in firefox (#9438)
Fix: https://toeverything.sentry.io/issues/6185588184/events/b205b6caf0224b51882c1d10bb3dd9bc/
2024-12-30 14:44:11 +00:00
Saul-Mirone
a9f890017e fix(editor): missing dependencies (#9436) 2024-12-30 14:10:37 +00:00
Saul-Mirone
c28f918527 refactor(editor): extract database block (#9435)
Part of: [BS-2269](https://linear.app/affine-design/issue/BS-2269/%E8%BF%81%E7%A7%BB-database-block-%E5%88%B0-affine-%E6%96%87%E4%BB%B6%E5%A4%B9%E4%B8%8B%E5%B9%B6%E5%BC%80%E5%90%AF-nouncheckedindexedaccess)
2024-12-30 12:59:57 +00:00
Saul-Mirone
e526106f45 refactor(editor): extract surface ref block (#9433) 2024-12-30 12:09:26 +00:00
doodlewind
d4053a345e perf(editor): reduce per frame viewport dom ops (#9431)
Currently when panning / zooming on whiteboard, both position and transform of each block component are updated per frame. The positioning part lead to heavy layout costs, which can be reduced.

Before (~35fps):

![image](https://github.com/user-attachments/assets/3f6d8a76-26a5-4ed6-a64c-b519a453cbc0)

After (~50fps):

![image](https://github.com/user-attachments/assets/43bc4b0a-db01-4526-8400-2ec95c3bdd0b)

Tested environment: TibetTravel templet, Windows 11, i5-1130G7 1.1GHz
2024-12-30 10:50:33 +00:00
LongYinan
8b3d99929f ci: fix Windows Rust cache path 2024-12-30 18:49:27 +08:00
renovate
a85707a2e7 chore: bump up oxlint version to v0.15.4 (#9161)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [oxlint](https://oxc.rs) ([source](https://redirect.github.com/oxc-project/oxc/tree/HEAD/npm/oxlint)) | [`0.15.0` -> `0.15.4`](https://renovatebot.com/diffs/npm/oxlint/0.15.0/0.15.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/oxlint/0.15.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/oxlint/0.15.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/oxlint/0.15.0/0.15.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/oxlint/0.15.0/0.15.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>oxc-project/oxc (oxlint)</summary>

### [`v0.15.4`](https://redirect.github.com/oxc-project/oxc/releases/tag/oxlint_v0.15.4): oxlint v0.15.4

[Compare Source](https://redirect.github.com/oxc-project/oxc/compare/oxlint_v0.15.3...oxlint_v0.15.4)

#### \[0.15.4] - 2024-12-30

-   [`ed75e42`](https://redirect.github.com/oxc-project/oxc/commit/ed75e42) semantic: \[**BREAKING**] Make SymbolTable fields `pub(crate)` instead of `pub` ([#&#8203;7999](https://redirect.github.com/oxc-project/oxc/issues/7999)) (Boshen)

##### Features

-   [`47cea9a`](https://redirect.github.com/oxc-project/oxc/commit/47cea9a) linter: Implement `eslint/no-extra-label` ([#&#8203;8181](https://redirect.github.com/oxc-project/oxc/issues/8181)) (Anson Heung)
-   [`ef76e28`](https://redirect.github.com/oxc-project/oxc/commit/ef76e28) linter: Implement `eslint/no-multi-assign` ([#&#8203;8158](https://redirect.github.com/oxc-project/oxc/issues/8158)) (Anson Heung)
-   [`384858b`](https://redirect.github.com/oxc-project/oxc/commit/384858b) linter: Implement `jsx-a11y/no-noninteractive-tabindex`  ([#&#8203;8167](https://redirect.github.com/oxc-project/oxc/issues/8167)) (Tyler Earls)
-   [`afc21a6`](https://redirect.github.com/oxc-project/oxc/commit/afc21a6) linter: Implement `eslint/vars-on-top` ([#&#8203;8157](https://redirect.github.com/oxc-project/oxc/issues/8157)) (Yuichiro Yamashita)
-   [`65796c4`](https://redirect.github.com/oxc-project/oxc/commit/65796c4) linter: Implement `eslint/prefer-rest-params` ([#&#8203;8155](https://redirect.github.com/oxc-project/oxc/issues/8155)) (Yuichiro Yamashita)
-   [`5234d96`](https://redirect.github.com/oxc-project/oxc/commit/5234d96) linter: Implement `eslint/no-nested-ternary` ([#&#8203;8150](https://redirect.github.com/oxc-project/oxc/issues/8150)) (Yuichiro Yamashita)
-   [`1c5db72`](https://redirect.github.com/oxc-project/oxc/commit/1c5db72) linter: Implement eslint/no-labels ([#&#8203;8131](https://redirect.github.com/oxc-project/oxc/issues/8131)) (Anson Heung)
-   [`0b04288`](https://redirect.github.com/oxc-project/oxc/commit/0b04288) linter: Move `import/named` to nursery ([#&#8203;8068](https://redirect.github.com/oxc-project/oxc/issues/8068)) (Boshen)

##### Bug Fixes

-   [`0794bee`](https://redirect.github.com/oxc-project/oxc/commit/0794bee) editor/vscode: Set minimum supported ver. to `^1.93.0` ([#&#8203;8182](https://redirect.github.com/oxc-project/oxc/issues/8182)) (Pavel Smirnov)
-   [`f3050d4`](https://redirect.github.com/oxc-project/oxc/commit/f3050d4) linter: Exclude svelte files from `no_unused_vars` rule ([#&#8203;8170](https://redirect.github.com/oxc-project/oxc/issues/8170)) (Yuichiro Yamashita)
-   [`faf7464`](https://redirect.github.com/oxc-project/oxc/commit/faf7464) linter: Disable rule `react/rules-of-hook` by file extension ([#&#8203;8168](https://redirect.github.com/oxc-project/oxc/issues/8168)) (Alexander S.)
-   [`1171e00`](https://redirect.github.com/oxc-project/oxc/commit/1171e00) linter: Disable `react/rules-of-hooks` for vue and svelte files ([#&#8203;8165](https://redirect.github.com/oxc-project/oxc/issues/8165)) (Alexander S.)
-   [`1b9a5ba`](https://redirect.github.com/oxc-project/oxc/commit/1b9a5ba) linter: False positiver in private member expr in oxc/const-comparison ([#&#8203;8164](https://redirect.github.com/oxc-project/oxc/issues/8164)) (camc314)
-   [`6bd9ddb`](https://redirect.github.com/oxc-project/oxc/commit/6bd9ddb) linter: False positive in `typescript/ban-tslint-comment` ([#&#8203;8094](https://redirect.github.com/oxc-project/oxc/issues/8094)) (dalaoshu)
-   [`10a1fd5`](https://redirect.github.com/oxc-project/oxc/commit/10a1fd5) linter: Rule: `no-restricted-imports` support option `patterns` with `group` key ([#&#8203;8050](https://redirect.github.com/oxc-project/oxc/issues/8050)) (Alexander S.)
-   [`b3f38ae`](https://redirect.github.com/oxc-project/oxc/commit/b3f38ae) linter: Rule `no-restricted-imports`: support option `allowImportNames` ([#&#8203;8002](https://redirect.github.com/oxc-project/oxc/issues/8002)) (Alexander S.)
-   [`340cc90`](https://redirect.github.com/oxc-project/oxc/commit/340cc90) linter: Rule `no-restricted-imports`: fix option "importNames" ([#&#8203;7943](https://redirect.github.com/oxc-project/oxc/issues/7943)) (Alexander S.)
-   [`ec2128e`](https://redirect.github.com/oxc-project/oxc/commit/ec2128e) linter: Fix line calculation for `eslint/max-lines` in diagnostics ([#&#8203;7962](https://redirect.github.com/oxc-project/oxc/issues/7962)) (Dmitry Zakharov)
-   [`79af100`](https://redirect.github.com/oxc-project/oxc/commit/79af100) semantic: Reference flags not correctly resolved when after an export stmt ([#&#8203;8134](https://redirect.github.com/oxc-project/oxc/issues/8134)) (camc314)

##### Performance

-   [`d8d2ec6`](https://redirect.github.com/oxc-project/oxc/commit/d8d2ec6) linter: Run rules which require typescript syntax only when source type is actually typescript ([#&#8203;8166](https://redirect.github.com/oxc-project/oxc/issues/8166)) (Alexander S.)
-   [`2736657`](https://redirect.github.com/oxc-project/oxc/commit/2736657) semantic: Allocate `UnresolvedReferences` in allocator ([#&#8203;8046](https://redirect.github.com/oxc-project/oxc/issues/8046)) (Boshen)

##### Refactor

-   [`de8246b`](https://redirect.github.com/oxc-project/oxc/commit/de8246b) language_server: Move structs into own file ([#&#8203;8026](https://redirect.github.com/oxc-project/oxc/issues/8026)) (Alexander S.)
-   [`774babb`](https://redirect.github.com/oxc-project/oxc/commit/774babb) linter: Read `exported_bindings_from_star_export` lazily ([#&#8203;8062](https://redirect.github.com/oxc-project/oxc/issues/8062)) (Boshen)
-   [`547c102`](https://redirect.github.com/oxc-project/oxc/commit/547c102) linter: Use `RwLock<FxHashMap>` instead of `FxDashMap` for module record data ([#&#8203;8061](https://redirect.github.com/oxc-project/oxc/issues/8061)) (Boshen)
-   [`952d7e4`](https://redirect.github.com/oxc-project/oxc/commit/952d7e4) linter: Rename `flat.rs` to `config.rs` ([#&#8203;8033](https://redirect.github.com/oxc-project/oxc/issues/8033)) (camc314)
-   [`50848ed`](https://redirect.github.com/oxc-project/oxc/commit/50848ed) linter: Simplify `ConfigStore` to prep for nested configs ([#&#8203;8032](https://redirect.github.com/oxc-project/oxc/issues/8032)) (camc314)
-   [`b2a4a78`](https://redirect.github.com/oxc-project/oxc/commit/b2a4a78) linter: Remove unused `with_rules` and `set_rule` methods ([#&#8203;8029](https://redirect.github.com/oxc-project/oxc/issues/8029)) (camc314)
-   [`6da0b21`](https://redirect.github.com/oxc-project/oxc/commit/6da0b21) oxlint: Remove unused `git.rs` ([#&#8203;7990](https://redirect.github.com/oxc-project/oxc/issues/7990)) (Boshen)
-   [`58e7777`](https://redirect.github.com/oxc-project/oxc/commit/58e7777) oxlint: Remove extra if check in `Walkdir` ([#&#8203;7989](https://redirect.github.com/oxc-project/oxc/issues/7989)) (Boshen)
-   [`02f968d`](https://redirect.github.com/oxc-project/oxc/commit/02f968d) semantic: Change `Bindings` to a plain `FxHashMap` ([#&#8203;8019](https://redirect.github.com/oxc-project/oxc/issues/8019)) (Boshen)

### [`v0.15.3`](https://redirect.github.com/oxc-project/oxc/releases/tag/oxlint_v0.15.3): oxlint v0.15.3

[Compare Source](https://redirect.github.com/oxc-project/oxc/compare/oxlint_v0.15.2...oxlint_v0.15.3)

#### \[0.15.3] - 2024-12-17

##### Features

-   [`25ddb35`](https://redirect.github.com/oxc-project/oxc/commit/25ddb35) linter: Add the import/no_named_default rule ([#&#8203;7902](https://redirect.github.com/oxc-project/oxc/issues/7902)) (Guillaume Piedigrossi)
-   [`ee26b44`](https://redirect.github.com/oxc-project/oxc/commit/ee26b44) linter: Enhance `get_element_type` to resolve more element types ([#&#8203;7885](https://redirect.github.com/oxc-project/oxc/issues/7885)) (dalaoshu)

##### Bug Fixes

-   [`6f41d92`](https://redirect.github.com/oxc-project/oxc/commit/6f41d92) linter: False positive in `unicorn/no-useless-spread` ([#&#8203;7940](https://redirect.github.com/oxc-project/oxc/issues/7940)) (dalaoshu)
-   [`0867b40`](https://redirect.github.com/oxc-project/oxc/commit/0867b40) linter: Fix configuration parser for `no-restricted-imports` ([#&#8203;7921](https://redirect.github.com/oxc-project/oxc/issues/7921)) (Alexander S.)
-   [`9c9b73d`](https://redirect.github.com/oxc-project/oxc/commit/9c9b73d) linter: Fix incorrect fixer for `prefer-regexp-test` ([#&#8203;7898](https://redirect.github.com/oxc-project/oxc/issues/7898)) (Cameron)
-   [`32935e6`](https://redirect.github.com/oxc-project/oxc/commit/32935e6) linter: False positive in `jsx-a11y/label-has-associated-control` ([#&#8203;7881](https://redirect.github.com/oxc-project/oxc/issues/7881)) (dalaoshu)
-   [`14c51ff`](https://redirect.github.com/oxc-project/oxc/commit/14c51ff) semantic: Remove inherting `ScopeFlags::Modifier` from parent scope ([#&#8203;7932](https://redirect.github.com/oxc-project/oxc/issues/7932)) (Dunqing)

##### Refactor

-   [`3858221`](https://redirect.github.com/oxc-project/oxc/commit/3858221) global: Sort imports ([#&#8203;7883](https://redirect.github.com/oxc-project/oxc/issues/7883)) (overlookmotel)
-   [`b99ee37`](https://redirect.github.com/oxc-project/oxc/commit/b99ee37) linter: Move rule "no-restricted-imports" to nursery ([#&#8203;7897](https://redirect.github.com/oxc-project/oxc/issues/7897)) (Alexander S.)
-   [`ff2a68f`](https://redirect.github.com/oxc-project/oxc/commit/ff2a68f) linter/yoda: Simplify code ([#&#8203;7941](https://redirect.github.com/oxc-project/oxc/issues/7941)) (overlookmotel)

##### Styling

-   [`7fb9d47`](https://redirect.github.com/oxc-project/oxc/commit/7fb9d47) rust: `cargo +nightly fmt` ([#&#8203;7877](https://redirect.github.com/oxc-project/oxc/issues/7877)) (Boshen)

### [`v0.15.2`](https://redirect.github.com/oxc-project/oxc/releases/tag/oxlint_v0.15.2): oxlint v0.15.2

[Compare Source](https://redirect.github.com/oxc-project/oxc/compare/oxlint_v0.15.1...oxlint_v0.15.2)

#### \[0.15.2] - 2024-12-14

Fix the previous broken release caused by [https://github.com/softprops/action-gh-release/issues/555](https://redirect.github.com/softprops/action-gh-release/issues/555)

### [`v0.15.1`](https://redirect.github.com/oxc-project/oxc/releases/tag/oxlint_v0.15.1): oxlint v0.15.1

[Compare Source](https://redirect.github.com/oxc-project/oxc/compare/oxlint_v0.15.0...oxlint_v0.15.1)

#### \[0.15.1] - 2024-12-13

##### Features

-   [`38b1c2e`](https://redirect.github.com/oxc-project/oxc/commit/38b1c2e) editor: Create a command to apply all auto-fixes for the current active text editor ([#&#8203;7672](https://redirect.github.com/oxc-project/oxc/issues/7672)) (Nicholas Rayburn)

##### Bug Fixes

-   [`2b187e5`](https://redirect.github.com/oxc-project/oxc/commit/2b187e5) linter: Fix configuration casing for `typescript/no_this_alias` ([#&#8203;7836](https://redirect.github.com/oxc-project/oxc/issues/7836)) (Boshen)
-   [`06e6d38`](https://redirect.github.com/oxc-project/oxc/commit/06e6d38) linter: Fix unicorn/prefer-query-selector to use the correct replacement for getElementsByClassName ([#&#8203;7796](https://redirect.github.com/oxc-project/oxc/issues/7796)) (Nicholas Rayburn)
-   [`7a83230`](https://redirect.github.com/oxc-project/oxc/commit/7a83230) semantic: Missing reference when `export default` references a type alias binding ([#&#8203;7813](https://redirect.github.com/oxc-project/oxc/issues/7813)) (Dunqing)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/toeverything/AFFiNE).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS41OC4xIiwidXBkYXRlZEluVmVyIjoiMzkuODUuMCIsInRhcmdldEJyYW5jaCI6ImNhbmFyeSIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=-->
2024-12-30 10:28:04 +00:00
Brooooooklyn
8463e4d683 ci: speedup Windows CI (#9426) 2024-12-30 10:10:59 +00:00
fundon
569e63377d fix(core): should sync name after renaming in pdf embed view (#9398)
https://github.com/user-attachments/assets/f6a3d7b8-9ae3-4d8f-833f-d7aca1e0fffa
2024-12-30 09:56:02 +00:00
fundon
580e3eb13c chore(editor): use colors from default theme instead (#9425) 2024-12-30 09:41:00 +00:00
140 changed files with 777 additions and 595 deletions

View File

@@ -7,6 +7,10 @@ inputs:
package:
description: 'Package to build'
required: true
no-build:
description: 'Whether to skip building'
required: false
default: 'false'
runs:
using: 'composite'
@@ -14,20 +18,34 @@ runs:
- name: Print rustup toolchain version
shell: bash
id: rustup-version
working-directory: ${{ env.DEV_DRIVE_WORKSPACE || github.workspace }}
run: |
export RUST_TOOLCHAIN_VERSION="$(grep 'channel' rust-toolchain.toml | head -1 | awk -F '"' '{print $2}')"
echo "Rust toolchain version: $RUST_TOOLCHAIN_VERSION"
echo "RUST_TOOLCHAIN_VERSION=$RUST_TOOLCHAIN_VERSION" >> "$GITHUB_OUTPUT"
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
if: ${{ runner.os != 'Windows' }}
with:
toolchain: '${{ steps.rustup-version.outputs.RUST_TOOLCHAIN_VERSION }}'
targets: ${{ inputs.target }}
env:
CARGO_INCREMENTAL: '1'
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
if: ${{ runner.os == 'Windows' }}
with:
toolchain: '${{ steps.rustup-version.outputs.RUST_TOOLCHAIN_VERSION }}'
targets: ${{ inputs.target }}
env:
CARGO_INCREMENTAL: '1'
CARGO_HOME: ${{ env.DEV_DRIVE }}/.cargo
RUSTUP_HOME: ${{ env.DEV_DRIVE }}/.rustup
- name: Set CC
if: ${{ contains(inputs.target, 'linux') && inputs.package != '@affine/native' }}
if: ${{ contains(inputs.target, 'linux') && inputs.package != '@affine/native' && inputs.no-build != 'true' }}
working-directory: ${{ env.DEV_DRIVE_WORKSPACE || github.workspace }}
shell: bash
run: |
echo "CC=clang" >> "$GITHUB_ENV"
@@ -35,12 +53,37 @@ runs:
- name: Cache cargo
uses: Swatinem/rust-cache@v2
if: ${{ runner.os == 'Windows' }}
with:
workspaces: ${{ env.DEV_DRIVE_WORKSPACE }}
save-if: ${{ github.ref_name == 'canary' }}
shared-key: ${{ inputs.target }}-${{ inputs.package }}
env:
CARGO_HOME: ${{ env.DEV_DRIVE }}/.cargo
RUSTUP_HOME: ${{ env.DEV_DRIVE }}/.rustup
- name: Cache cargo
uses: Swatinem/rust-cache@v2
if: ${{ runner.os != 'Windows' }}
with:
save-if: ${{ github.ref_name == 'canary' }}
shared-key: ${{ inputs.target }}-inputs.package
shared-key: ${{ inputs.target }}-${{ inputs.package }}
- name: Build
shell: bash
if: ${{ runner.os != 'Windows' && inputs.no-build != 'true' }}
run: |
yarn workspace ${{ inputs.package }} build --target ${{ inputs.target }} --use-napi-cross
env:
DEBUG: 'napi:*'
- name: Build
working-directory: ${{ env.DEV_DRIVE_WORKSPACE || github.workspace }}
shell: bash
if: ${{ runner.os == 'Windows' && inputs.no-build != 'true' }}
run: |
yarn workspace ${{ inputs.package }} build --target ${{ inputs.target }} --use-napi-cross
env:
DEBUG: 'napi:*'
CARGO_HOME: ${{ env.DEV_DRIVE }}/.cargo
RUSTUP_HOME: ${{ env.DEV_DRIVE }}/.rustup

View File

@@ -35,10 +35,19 @@ inputs:
full-cache:
description: 'Full installation cache'
required: false
runs:
using: 'composite'
steps:
- name: Output workspace path
id: workspace-path
shell: bash
run: |
if [ -n "${{ env.DEV_DRIVE_WORKSPACE }}" ]; then
echo "workspace_path=${{ env.DEV_DRIVE_WORKSPACE }}" >> $GITHUB_OUTPUT
else
echo "workspace_path=${{ github.workspace }}" >> $GITHUB_OUTPUT
fi
- name: Setup Node.js
uses: actions/setup-node@v4
with:
@@ -52,26 +61,31 @@ runs:
- name: Init CorePack
if: ${{ inputs.corepack-install == 'true' }}
shell: bash
working-directory: ${{ steps.workspace-path.outputs.workspace_path }}
run: corepack enable
- name: Set nmMode
if: ${{ inputs.hard-link-nm == 'false' }}
shell: bash
working-directory: ${{ steps.workspace-path.outputs.workspace_path }}
run: yarn config set nmMode classic
- name: Set nmHoistingLimits
if: ${{ inputs.nmHoistingLimits }}
shell: bash
working-directory: ${{ steps.workspace-path.outputs.workspace_path }}
run: yarn config set nmHoistingLimits ${{ inputs.nmHoistingLimits }}
- name: Set enableScripts
if: ${{ inputs.enableScripts == 'false' }}
shell: bash
working-directory: ${{ steps.workspace-path.outputs.workspace_path }}
run: yarn config set enableScripts false
- name: Set yarn global cache path
shell: bash
id: yarn-cache
working-directory: ${{ steps.workspace-path.outputs.workspace_path }}
run: node -e "const p = $(yarn config cacheFolder --json).effective; console.log('yarn_global_cache=' + p)" >> $GITHUB_OUTPUT
- name: Cache non-full yarn cache on Linux
@@ -79,7 +93,7 @@ runs:
if: ${{ inputs.full-cache != 'true' && runner.os == 'Linux' }}
with:
path: |
node_modules
${{ steps.workspace-path.outputs.workspace_path }}/node_modules
${{ steps.yarn-cache.outputs.yarn_global_cache }}
key: node_modules-cache-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-${{ steps.system-info.outputs.name }}-${{ steps.system-info.outputs.release }}-${{ steps.system-info.outputs.version }}
@@ -115,17 +129,7 @@ runs:
if: ${{ inputs.package-install == 'true' }}
continue-on-error: true
shell: bash
run: yarn ${{ inputs.extra-flags }}
env:
HUSKY: '0'
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
ELECTRON_SKIP_BINARY_DOWNLOAD: '1'
SENTRYCLI_SKIP_DOWNLOAD: '1'
DEBUG: '*'
- name: yarn install (try again)
if: ${{ steps.install.outcome == 'failure' }}
shell: bash
working-directory: ${{ steps.workspace-path.outputs.workspace_path }}
run: yarn ${{ inputs.extra-flags }}
env:
HUSKY: '0'
@@ -138,6 +142,7 @@ runs:
id: playwright-version
if: ${{ inputs.playwright-install == 'true' }}
shell: bash
working-directory: ${{ steps.workspace-path.outputs.workspace_path }}
run: echo "version=$(yarn why --json @playwright/test | grep -h 'workspace:.' | jq --raw-output '.children[].locator' | sed -e 's/@playwright\/test@.*://' | head -n 1)" >> $GITHUB_OUTPUT
# Attempt to restore the correct Playwright browser binaries based on the
@@ -150,7 +155,7 @@ runs:
id: playwright-cache
if: ${{ inputs.playwright-install == 'true' }}
with:
path: ${{ github.workspace }}/node_modules/.cache/ms-playwright
path: ${{ steps.workspace-path.outputs.workspace_path }}/node_modules/.cache/ms-playwright
key: '${{ runner.os }}-${{ runner.arch }}-${{ steps.system-info.outputs.name }}-${{ steps.system-info.outputs.release }}-${{ steps.system-info.outputs.version }}-playwright-${{ steps.playwright-version.outputs.version }}'
# As a fallback, if the Playwright version has changed, try use the
# most recently cached version. There's a good chance that at least one
@@ -169,12 +174,14 @@ runs:
shell: bash
if: inputs.playwright-install == 'true'
run: yarn playwright install --with-deps chromium webkit
working-directory: ${{ steps.workspace-path.outputs.workspace_path }}
env:
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/node_modules/.cache/ms-playwright
PLAYWRIGHT_BROWSERS_PATH: ${{ steps.workspace-path.outputs.workspace_path }}/node_modules/.cache/ms-playwright
- name: Get installed Electron version
id: electron-version
if: ${{ inputs.electron-install == 'true' }}
working-directory: ${{ steps.workspace-path.outputs.workspace_path }}
shell: bash
run: |
echo "version=$(yarn why --json electron | grep -h 'workspace:.' | jq --raw-output '.children[].locator' | sed -e 's/@playwright\/test@.*://' | head -n 1)" >> $GITHUB_OUTPUT
@@ -183,7 +190,7 @@ runs:
id: electron-cache
if: ${{ inputs.electron-install == 'true' }}
with:
path: 'node_modules/.cache/electron'
path: ${{ steps.workspace-path.outputs.workspace_path }}/node_modules/.cache/electron
key: '${{ runner.os }}-${{ runner.arch }}-${{ steps.system-info.outputs.name }}-${{ steps.system-info.outputs.release }}-${{ steps.system-info.outputs.version }}-electron-${{ steps.electron-version.outputs.version }}'
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-${{ steps.system-info.outputs.name }}-${{ steps.system-info.outputs.release }}-${{ steps.system-info.outputs.version }}-electron-
@@ -192,5 +199,11 @@ runs:
shell: bash
if: inputs.electron-install == 'true'
run: node ./node_modules/electron/install.js
working-directory: ${{ steps.workspace-path.outputs.workspace_path }}
env:
electron_config_cache: ./node_modules/.cache/electron
electron_config_cache: ${{ steps.workspace-path.outputs.workspace_path }}/node_modules/.cache/electron
- name: Write PLAYWRIGHT_BROWSERS_PATH env
shell: bash
run: |
echo "PLAYWRIGHT_BROWSERS_PATH=${{ steps.workspace-path.outputs.workspace_path }}/node_modules/.cache/ms-playwright" >> $GITHUB_ENV

View File

@@ -1,28 +0,0 @@
name: 'Rust setup'
description: 'Rust setup, including cache configuration'
inputs:
components:
description: 'Cargo components'
required: false
targets:
description: 'Cargo target'
required: false
toolchain:
description: 'Rustup toolchain'
required: false
default: 'stable'
runs:
using: 'composite'
steps:
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ inputs.toolchain }}
targets: ${{ inputs.targets }}
components: ${{ inputs.components }}
- name: Add Targets
if: ${{ inputs.targets }}
run: rustup target add ${{ inputs.targets }}
shell: bash
- uses: Swatinem/rust-cache@v2

View File

@@ -19,7 +19,6 @@ env:
AFFINE_ENV: dev
COVERAGE: true
MACOSX_DEPLOYMENT_TARGET: '10.13'
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/node_modules/.cache/ms-playwright
DEPLOYMENT_TYPE: affine
concurrency:
@@ -280,11 +279,16 @@ jobs:
spec:
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu }
- { os: windows-latest, target: x86_64-pc-windows-msvc }
- { os: macos-14, target: x86_64-apple-darwin }
- { os: macos-14, target: aarch64-apple-darwin }
- { os: macos-latest, target: x86_64-apple-darwin }
- { os: macos-latest, target: aarch64-apple-darwin }
steps:
- uses: actions/checkout@v4
- uses: samypr100/setup-dev-drive@v3
if: ${{ matrix.spec.os == 'windows-latest' }}
with:
workspace-copy: true
drive-size: 8GB
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
@@ -292,6 +296,7 @@ jobs:
electron-install: false
- name: Setup filename
id: filename
working-directory: ${{ env.DEV_DRIVE_WORKSPACE || github.workspace }}
shell: bash
run: |
export PLATFORM_ARCH_ABI=$(node -e "console.log(require('@napi-rs/cli').parseTriple('${{ matrix.spec.target }}').platformArchABI)")
@@ -305,7 +310,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{ steps.filename.outputs.filename }}
path: ./packages/frontend/native/${{ steps.filename.outputs.filename }}
path: ${{ env.DEV_DRIVE_WORKSPACE || github.workspace }}/packages/frontend/native/${{ steps.filename.outputs.filename }}
if-no-files-found: error
build-server-native:
@@ -435,7 +440,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: ./.github/actions/setup-rust
uses: ./.github/actions/build-rust
with:
package: 'affine'
no-build: 'true'
- name: Install latest nextest release
uses: taiki-e/install-action@nextest
@@ -717,14 +725,14 @@ jobs:
matrix:
spec:
- {
os: macos-14,
os: macos-latest,
platform: macos,
arch: x64,
target: x86_64-apple-darwin,
test: false,
}
- {
os: macos-14,
os: macos-latest,
platform: macos,
arch: arm64,
target: aarch64-apple-darwin,

View File

@@ -3,9 +3,6 @@ name: Copilot Cron Test
on:
workflow_dispatch:
env:
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/node_modules/.cache/ms-playwright
jobs:
build-server-native:
name: Build Server native

View File

@@ -149,9 +149,11 @@ jobs:
p12-file-base64: ${{ secrets.CERTIFICATES_P12_MOBILE }}
p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD_MOBILE }}
- name: Setup Rust
uses: ./.github/actions/setup-rust
uses: ./.github/actions/build-rust
with:
targets: 'aarch64-apple-ios'
target: 'aarch64-apple-ios'
package: 'affine_mobile_native'
no-build: 'true'
- name: Build Rust
run: |
brew install swiftformat
@@ -195,9 +197,11 @@ jobs:
hard-link-nm: false
enableScripts: false
- name: Setup Rust
uses: ./.github/actions/setup-rust
uses: ./.github/actions/build-rust
with:
targets: 'aarch64-linux-android'
target: 'aarch64-linux-android'
package: 'affine_mobile_native'
no-build: 'true'
- name: Cap sync
run: yarn workspace @affine/android cap sync
- uses: actions/setup-python@v5

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
},
{
"path": "../../blocks"

View File

@@ -29,10 +29,7 @@ export const AttachmentDropOption = FileDropConfigExtension({
if (!attachmentFiles.length) return false;
if (
targetModel &&
!matchFlavours(targetModel, ['affine:surface' as BlockSuite.Flavour])
) {
if (targetModel && !matchFlavours(targetModel, ['affine:surface'])) {
addSiblingAttachmentBlocks(
std.host,
attachmentFiles,

View File

@@ -1,3 +1,7 @@
import type * as SurfaceEffects from '@blocksuite/affine-block-surface/effects';
declare type _GLOBAL_ = typeof SurfaceEffects;
export * from './adapters/notion-html';
export * from './attachment-block';
export * from './attachment-service';

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
},
{
"path": "../model"

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
},
{
"path": "../model"

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
},
{
"path": "../model"

View File

@@ -0,0 +1,46 @@
{
"name": "@blocksuite/affine-block-database",
"description": "Database block for BlockSuite.",
"type": "module",
"scripts": {
"build": "tsc",
"test:unit": "nx vite:test --run --passWithNoTests",
"test:unit:coverage": "nx vite:test --run --coverage",
"test:e2e": "playwright test"
},
"sideEffects": false,
"keywords": [],
"author": "toeverything",
"license": "MIT",
"dependencies": {
"@blocksuite/affine-components": "workspace:*",
"@blocksuite/affine-model": "workspace:*",
"@blocksuite/affine-shared": "workspace:*",
"@blocksuite/affine-widget-drag-handle": "workspace:*",
"@blocksuite/block-std": "workspace:*",
"@blocksuite/data-view": "workspace:*",
"@blocksuite/global": "workspace:*",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@floating-ui/dom": "^1.6.10",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.3",
"@types/mdast": "^4.0.4",
"date-fns": "^4.0.0",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
"zod": "^3.23.8"
},
"exports": {
".": "./src/index.ts",
"./effects": "./src/effects.ts"
},
"files": [
"src",
"dist",
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.19.0"
}

View File

@@ -0,0 +1,4 @@
export * from './html';
export * from './markdown';
export * from './notion-html';
export * from './plain-text';

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import type { DatabaseBlockModel } from '@blocksuite/affine-model';
import {
insertPositionToIndex,

View File

@@ -1,4 +1,3 @@
import type { NoteBlockComponent } from '@blocksuite/affine-block-note';
import { CaptionedBlockComponent } from '@blocksuite/affine-components/caption';
import {
menu,
@@ -17,7 +16,10 @@ import {
TelemetryProvider,
} from '@blocksuite/affine-shared/services';
import { getDropResult } from '@blocksuite/affine-widget-drag-handle';
import { RANGE_SYNC_EXCLUDE_ATTR } from '@blocksuite/block-std';
import {
type BlockComponent,
RANGE_SYNC_EXCLUDE_ATTR,
} from '@blocksuite/block-std';
import {
createRecordDetail,
createUniComponentFromWebComponent,
@@ -46,7 +48,6 @@ import { autoUpdate } from '@floating-ui/dom';
import { computed, signal } from '@preact/signals-core';
import { css, html, nothing, unsafeCSS } from 'lit';
import { EdgelessRootBlockComponent } from '../root-block/index.js';
import { popSideDetail } from './components/layout.js';
import type { DatabaseOptionsConfig } from './config.js';
import { HostContextKey } from './context/host-context.js';
@@ -346,14 +347,13 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<
get optionsConfig(): DatabaseOptionsConfig {
return {
configure: (_model, options) => options,
...this.std.getConfig('affine:page')?.databaseOptions,
...this.std.getConfig('affine:database'),
};
}
override get topContenteditableElement() {
if (this.rootComponent instanceof EdgelessRootBlockComponent) {
const note = this.closest<NoteBlockComponent>(NOTE_SELECTOR);
return note;
if (this.std.get(DocModeProvider).getEditorMode() === 'edgeless') {
return this.closest<BlockComponent>(NOTE_SELECTOR);
}
return this.rootComponent;
}

View File

@@ -0,0 +1,68 @@
import type { insertDatabaseBlockCommand } from './commands';
import { CenterPeek } from './components/layout';
import { DatabaseTitle } from './components/title';
import type { DatabaseOptionsConfig } from './config';
import { DatabaseBlockComponent } from './database-block';
import type { DatabaseBlockService } from './database-service';
import { BlockRenderer } from './detail-panel/block-renderer';
import { NoteRenderer } from './detail-panel/note-renderer';
import { LinkCell, LinkCellEditing } from './properties/link/cell-renderer';
import { LinkNode } from './properties/link/components/link-node';
import {
RichTextCell,
RichTextCellEditing,
} from './properties/rich-text/cell-renderer';
import { IconCell } from './properties/title/icon';
import {
HeaderAreaTextCell,
HeaderAreaTextCellEditing,
} from './properties/title/text';
export function effects() {
customElements.define('affine-database-title', DatabaseTitle);
customElements.define('data-view-header-area-icon', IconCell);
customElements.define('affine-database-link-cell', LinkCell);
customElements.define('affine-database-link-cell-editing', LinkCellEditing);
customElements.define('data-view-header-area-text', HeaderAreaTextCell);
customElements.define(
'data-view-header-area-text-editing',
HeaderAreaTextCellEditing
);
customElements.define('affine-database-rich-text-cell', RichTextCell);
customElements.define(
'affine-database-rich-text-cell-editing',
RichTextCellEditing
);
customElements.define('center-peek', CenterPeek);
customElements.define('database-datasource-note-renderer', NoteRenderer);
customElements.define('database-datasource-block-renderer', BlockRenderer);
customElements.define('affine-database-link-node', LinkNode);
customElements.define('affine-database', DatabaseBlockComponent);
}
declare global {
namespace BlockSuite {
interface BlockConfigs {
'affine:database': Partial<DatabaseOptionsConfig>;
}
interface CommandContext {
insertedDatabaseBlockId?: string;
}
interface Commands {
/**
* insert a database block after or before the current block selection
* @param latex the LaTeX content. A input dialog will be shown if not provided
* @param removeEmptyLine remove the current block if it is empty
* @param place where to insert the LaTeX block
* @returns the id of the inserted LaTeX block
*/
insertDatabaseBlock: typeof insertDatabaseBlockCommand;
}
interface BlockServices {
'affine:database': DatabaseBlockService;
}
}
}

View File

@@ -0,0 +1,16 @@
import type * as CommandType from '@blocksuite/affine-shared/commands';
declare type _GLOBAL_ = typeof CommandType;
export * from './adapters';
export type { DatabaseOptionsConfig } from './config';
export * from './data-source';
export * from './database-block';
export * from './database-service';
export * from './database-spec';
export * from './detail-panel/block-renderer';
export * from './detail-panel/note-renderer';
export * from './properties';
export * from './properties/rich-text/cell-renderer';
export * from './properties/utils';
export * from './utils/block-utils';

View File

@@ -22,7 +22,6 @@ import { css, type TemplateResult } from 'lit';
import { property, query } from 'lit/decorators.js';
import { html } from 'lit/static-html.js';
import { ClipboardAdapter } from '../../../root-block/clipboard/adapter.js';
import { HostContextKey } from '../../context/host-context.js';
import type { DatabaseBlockComponent } from '../../database-block.js';
import { getSingleDocIdFromText } from '../../utils/title-doc.js';
@@ -262,7 +261,7 @@ export class HeaderAreaTextCellEditing extends BaseTextCell {
};
const snapshot = this.std?.clipboard?.readFromClipboard(
e.clipboardData
)[ClipboardAdapter.MIME];
)['BLOCKSUITE/SNAPSHOT'];
const deltas = (
JSON.parse(snapshot).snapshot.content as BlockSnapshot[]
).flatMap(getDeltas);

View File

@@ -0,0 +1,29 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src/",
"outDir": "./dist/",
"noEmit": false
},
"include": ["./src"],
"references": [
{
"path": "../../framework"
},
{
"path": "../model"
},
{
"path": "../components"
},
{
"path": "../shared"
},
{
"path": "../data-view"
},
{
"path": "../widget-drag-handle"
}
]
}

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
},
{
"path": "../model"

View File

@@ -87,34 +87,32 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
this.updateComplete
.then(() => {
const command = this.std.command;
const blockSelections = this.model.children.map(
child =>
this.std.selection.create('block', {
blockId: child.id,
})
// FIXME: BS-2216
) as never;
const blockSelections = this.model.children.map(child =>
this.std.selection.create('block', {
blockId: child.id,
})
);
if (key === 'fontStyle') {
command.exec('formatBlock', {
blockSelections,
styles: {
italic: null,
} as never,
},
});
} else if (key === 'color') {
command.exec('formatBlock', {
blockSelections,
styles: {
color: null,
} as never,
},
});
} else if (key === 'fontWeight') {
command.exec('formatBlock', {
blockSelections,
styles: {
bold: null,
} as never,
},
});
}
})

View File

@@ -1,2 +1,6 @@
import type * as CommandType from '@blocksuite/affine-shared/commands';
declare type _GLOBAL_ = typeof CommandType;
export * from './edgeless-text-block.js';
export * from './edgeless-text-spec.js';

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
},
{
"path": "../model"

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
},
{
"path": "../model"

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
},
{
"path": "../model"

View File

@@ -28,10 +28,7 @@ export const ImageDropOption = FileDropConfigExtension({
const imageFiles = files.filter(file => file.type.startsWith('image/'));
if (!imageFiles.length) return false;
if (
targetModel &&
!matchFlavours(targetModel, ['affine:surface' as BlockSuite.Flavour])
) {
if (targetModel && !matchFlavours(targetModel, ['affine:surface'])) {
addSiblingImageBlock(
std.host,
imageFiles,

View File

@@ -1,3 +1,7 @@
import type * as SurfaceEffects from '@blocksuite/affine-block-surface/effects';
declare type _GLOBAL_ = typeof SurfaceEffects;
export * from './adapters';
export * from './image-block';
export * from './image-edgeless-block';

View File

@@ -523,7 +523,6 @@ export async function addImages(
editing: false,
});
if (isMultipleFiles) {
// @ts-expect-error FIXME(command): BS-2216
std.command.exec('autoResizeElements');
}
return blockIds;

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
},
{
"path": "../model"

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
},
{
"path": "../model"

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
},
{
"path": "../model"

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
},
{
"path": "../model"

View File

@@ -21,7 +21,6 @@ export function forwardDelete(std: BlockStdScope) {
const ignoreForwardDeleteFlavourList: BlockSuite.Flavour[] = [
'affine:attachment',
'affine:bookmark',
// @ts-expect-error FIXME: should be fixed after database model is migrated to affine-models
'affine:database',
'affine:code',
'affine:image',

View File

@@ -86,7 +86,6 @@ export function mergeWithPrev(editorHost: EditorHost, model: BlockModel) {
return true;
}
// @ts-expect-error FIXME: should be fixed after database model is migrated to affine-models
if (matchFlavours(parent, ['affine:database'])) {
doc.deleteBlock(model);
focusTextModel(editorHost.std, prevBlock.id, prevBlock.text?.yText.length);

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
},
{
"path": "../model"

View File

@@ -0,0 +1,48 @@
{
"name": "@blocksuite/affine-block-surface-ref",
"description": "Surface ref block for BlockSuite.",
"type": "module",
"scripts": {
"build": "tsc",
"test:unit": "nx vite:test --run --passWithNoTests",
"test:unit:coverage": "nx vite:test --run --coverage",
"test:e2e": "playwright test"
},
"sideEffects": false,
"keywords": [],
"author": "toeverything",
"license": "MIT",
"dependencies": {
"@blocksuite/affine-block-surface": "workspace:*",
"@blocksuite/affine-components": "workspace:*",
"@blocksuite/affine-model": "workspace:*",
"@blocksuite/affine-shared": "workspace:*",
"@blocksuite/block-std": "workspace:*",
"@blocksuite/global": "workspace:*",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.3",
"fractional-indexing": "^3.2.0",
"lit": "^3.2.0",
"lodash.chunk": "^4.2.0",
"nanoid": "^5.0.7",
"zod": "^3.23.8"
},
"devDependencies": {
"@types/dompurify": "^3.0.5",
"@types/lodash.chunk": "^4.2.9"
},
"exports": {
".": "./src/index.ts",
"./effects": "./src/effects.ts"
},
"files": [
"src",
"dist",
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.19.0"
}

View File

@@ -1,7 +1,20 @@
import type { insertSurfaceRefBlockCommand } from './commands.js';
import { SurfaceRefGenericBlockPortal } from './portal/generic-block.js';
import { SurfaceRefNotePortal } from './portal/note.js';
import { SurfaceRefBlockComponent } from './surface-ref-block.js';
import { EdgelessSurfaceRefBlockComponent } from './surface-ref-block-edgeless.js';
export function effects() {
// TODO(@L-Sun): move other effects to this file
customElements.define(
'surface-ref-generic-block-portal',
SurfaceRefGenericBlockPortal
);
customElements.define('affine-surface-ref', SurfaceRefBlockComponent);
customElements.define(
'affine-edgeless-surface-ref',
EdgelessSurfaceRefBlockComponent
);
customElements.define('surface-ref-note-portal', SurfaceRefNotePortal);
}
declare global {

View File

@@ -1,7 +1,10 @@
import '@blocksuite/affine-shared/commands';
export * from './surface-ref-block.js';
export * from './surface-ref-block-edgeless.js';
export {
EdgelessSurfaceRefBlockSpec,
PageSurfaceRefBlockSpec,
} from './surface-ref-spec.js';
export * from './types.js';
export * from './utils.js';

View File

@@ -1,4 +1,5 @@
import {
EdgelessCRUDExtension,
getSurfaceBlock,
type SurfaceBlockModel,
SurfaceElementModel,
@@ -20,7 +21,10 @@ import {
EditPropsStore,
ThemeProvider,
} from '@blocksuite/affine-shared/services';
import { requestConnectedFrame } from '@blocksuite/affine-shared/utils';
import {
requestConnectedFrame,
SpecProvider,
} from '@blocksuite/affine-shared/utils';
import {
type BaseSelection,
BlockComponent,
@@ -29,7 +33,10 @@ import {
type EditorHost,
LifeCycleWatcher,
} from '@blocksuite/block-std';
import { GfxBlockElementModel } from '@blocksuite/block-std/gfx';
import {
GfxBlockElementModel,
GfxControllerIdentifier,
} from '@blocksuite/block-std/gfx';
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import {
assertExists,
@@ -43,9 +50,7 @@ import { css, html, nothing, type TemplateResult } from 'lit';
import { query, state } from 'lit/decorators.js';
import { styleMap } from 'lit/directives/style-map.js';
import { SpecProvider } from '../_specs/index.js';
import type { EdgelessRootPreviewBlockComponent } from '../root-block/edgeless/edgeless-root-preview-block.js';
import { EdgelessRootService } from '../root-block/index.js';
import type { EdgelessPreviewer } from './types.js';
import { noContentPlaceholder } from './utils.js';
const REF_LABEL_ICON = {
@@ -418,18 +423,20 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
private _initSpec() {
const refreshViewport = this._refreshViewport.bind(this);
class PageViewWatcher extends BlockServiceWatcher {
static override readonly flavour = 'affine:page';
override mounted() {
this.blockService.disposables.add(
this.blockService.specSlots.viewConnected.once(({ component }) => {
const edgelessBlock =
component as EdgelessRootPreviewBlockComponent;
const edgelessBlock = component as BlockComponent &
EdgelessPreviewer;
edgelessBlock.editorViewportSelector = 'ref-viewport';
refreshViewport();
edgelessBlock.service.viewport.sizeUpdated.once(() => {
const gfx = edgelessBlock.std.get(GfxControllerIdentifier);
gfx.viewport.sizeUpdated.once(() => {
refreshViewport();
});
})
@@ -449,11 +456,12 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
private readonly _disposable = new DisposableGroup();
override mounted() {
const edgelessService = this.std.get(EdgelessRootService);
const crud = this.std.get(EdgelessCRUDExtension);
const { _disposable } = this;
const surfaceModel = getSurfaceBlock(this.std.doc);
if (!surfaceModel) return;
const referenceElement =
edgelessService.crud.getElementById(referenceId);
const referenceElement = crud.getElementById(referenceId);
if (!referenceElement) {
throw new BlockSuiteError(
ErrorCode.MissingViewModelError,
@@ -470,7 +478,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
);
} else if (referenceElement instanceof GroupElementModel) {
_disposable.add(
edgelessService.surface.elementUpdated.on(({ id, oldValues }) => {
surfaceModel.elementUpdated.on(({ id, oldValues }) => {
if (
id === referenceId &&
oldValues.xywh !== referenceElement.xywh
@@ -500,13 +508,10 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
if (!previewEditorHost) return;
const edgelessService = previewEditorHost.std.getService(
'affine:page'
) as EdgelessRootService;
const gfx = previewEditorHost.std.get(GfxControllerIdentifier);
const viewport = gfx.viewport;
edgelessService.viewport.setViewportByBound(
Bound.deserialize(this._referenceXYWH)
);
viewport.setViewportByBound(Bound.deserialize(this._referenceXYWH));
}
private _renderMask(

View File

@@ -0,0 +1,3 @@
export interface EdgelessPreviewer {
editorViewportSelector: string;
}

View File

@@ -0,0 +1,23 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src/",
"outDir": "./dist/",
"noEmit": false
},
"include": ["./src"],
"references": [
{
"path": "../../framework"
},
{
"path": "../model"
},
{
"path": "../components"
},
{
"path": "../shared"
}
]
}

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
},
{
"path": "../model"

View File

@@ -37,7 +37,6 @@ export function getInlineEditorByModel(
typeof model === 'string'
? editorHost.std.doc.getBlock(model)?.model
: model;
// @ts-expect-error TODO: migrate database model to `@blocksuite/affine-model`
if (!blockModel || matchFlavours(blockModel, ['affine:database'])) {
// Not support database model since it's may be have multiple inline editor instances.
// Support to enter the editing state through the Enter key in the database.

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
},
{
"path": "../shared"

View File

@@ -74,8 +74,12 @@ export function hasViewportRelativeCoordinates(
return 'clientX' in event && 'clientY' in event;
}
function isTouchEvent(event: Event): event is TouchEvent {
return 'TouchEvent' in globalThis && event instanceof TouchEvent;
}
const getEventCoordinates = (event: Event) => {
if (event instanceof TouchEvent) {
if (isTouchEvent(event)) {
if (event.touches && event.touches.length) {
const touch = event.touches[0];
if (!touch) return;

View File

@@ -15,13 +15,7 @@
"path": "../shared"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
"path": "../../framework"
}
]
}

View File

@@ -28,3 +28,11 @@ export const DatabaseBlockSchema = defineBlockSchema({
},
toModel: () => new DatabaseBlockModel(),
});
declare global {
namespace BlockSuite {
interface BlockModels {
'affine:database': DatabaseBlockModel;
}
}
}

View File

@@ -28,7 +28,7 @@ import {
Vec,
} from '@blocksuite/global/utils';
import type { Color } from '../../themes/index.js';
import { type Color, DefaultTheme } from '../../themes/index';
export type BrushProps = BaseElementProps & {
/**
@@ -131,7 +131,7 @@ export class BrushElementModel extends GfxPrimitiveElementModel<BrushProps> {
}
@field()
accessor color: Color = '#000000';
accessor color: Color = DefaultTheme.black;
@watch((_, instance) => {
instance['_local'].delete('commands');

View File

@@ -37,8 +37,8 @@ import {
StrokeStyle,
TextAlign,
type TextStyleProps,
} from '../../consts/index.js';
import type { Color } from '../../themes/index.ts';
} from '../../consts/index';
import { type Color, DefaultTheme } from '../../themes/index';
export type SerializedConnection = {
id?: string;
@@ -433,7 +433,7 @@ export class ConnectorElementModel extends GfxPrimitiveElementModel<ConnectorEle
* Defines the style of the label.
*/
@field({
color: '#000000',
color: DefaultTheme.black,
fontFamily: FontFamily.Inter,
fontSize: 16,
fontStyle: FontStyle.Normal,
@@ -486,7 +486,7 @@ export class ConnectorElementModel extends GfxPrimitiveElementModel<ConnectorEle
};
@field()
accessor stroke: Color = '#000000';
accessor stroke: Color = DefaultTheme.connectorColor;
@field()
accessor strokeStyle: StrokeStyle = StrokeStyle.Solid;

View File

@@ -6,8 +6,8 @@ import {
DEFAULT_ROUGHNESS,
type PointStyle,
StrokeStyle,
} from '../../consts/index.js';
import type { Color } from '../../themes/index.ts';
} from '../../consts/index';
import { type Color, DefaultTheme } from '../../themes/index';
import type { Connection } from './connector.js';
export class LocalConnectorElementModel extends GfxLocalElementModel {
@@ -29,7 +29,7 @@ export class LocalConnectorElementModel extends GfxLocalElementModel {
position: [0, 0],
};
stroke: Color = '#000000';
stroke: Color = DefaultTheme.connectorColor;
strokeStyle: StrokeStyle = StrokeStyle.Solid;

View File

@@ -98,7 +98,7 @@ export class ShapeElementModel extends GfxPrimitiveElementModel<ShapeProps> {
});
}
@field('#000000' as Color)
@field(DefaultTheme.shapeTextColor)
accessor color!: Color;
@field()
@@ -200,7 +200,7 @@ export class LocalShapeElementModel extends GfxLocalElementModel {
}
@prop()
accessor color: Color = '#000000';
accessor color: Color = DefaultTheme.shapeTextColor;
@prop()
accessor fillColor: Color = DefaultTheme.shapeFillColor;

View File

@@ -16,8 +16,8 @@ import {
FontWeight,
TextAlign,
type TextStyleProps,
} from '../../consts/index.js';
import type { Color } from '../../themes/index.js';
} from '../../consts/index';
import { type Color, DefaultTheme } from '../../themes/index';
export type TextElementProps = BaseElementProps & {
text: Y.Text;
@@ -61,7 +61,7 @@ export class TextElementModel extends GfxPrimitiveElementModel<TextElementProps>
}
@field()
accessor color: Color = '#000000';
accessor color: Color = DefaultTheme.black;
@field()
accessor fontFamily: FontFamily = FontFamily.Inter;

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
}
]
}

View File

@@ -43,9 +43,7 @@ export function calcDropTarget(
*/
allowSublist: boolean = true
): DropResult | null {
const schema = model.doc.getSchemaByFlavour(
'affine:database' as BlockSuite.Flavour
);
const schema = model.doc.getSchemaByFlavour('affine:database');
const children = schema?.model.children ?? [];
let shouldAppendToDatabase = true;
@@ -56,10 +54,7 @@ export function calcDropTarget(
.every(m => children.includes(m.flavour));
}
if (
!shouldAppendToDatabase &&
!matchFlavours(model, ['affine:database' as BlockSuite.Flavour])
) {
if (!shouldAppendToDatabase && !matchFlavours(model, ['affine:database'])) {
const databaseBlockComponent =
element.closest<BlockComponent>('affine-database');
if (databaseBlockComponent) {

View File

@@ -24,9 +24,7 @@ export function getDropRectByPoint(
flag: DropFlags.Normal,
};
const isDatabase = matchFlavours(model, [
'affine:database' as BlockSuite.Flavour,
]);
const isDatabase = matchFlavours(model, ['affine:database']);
if (isDatabase) {
const table = getDatabaseBlockTableElement(element);

View File

@@ -9,7 +9,7 @@ declare global {
): {
offsetNode: Node;
offset: number;
};
} | null;
}
}
@@ -23,6 +23,9 @@ export function caretRangeFromPoint(
): Range | null {
if (IS_FIREFOX) {
const caret = document.caretPositionFromPoint(clientX, clientY);
if (!caret) {
return null;
}
// TODO handle caret is covered by popup
const range = document.createRange();
range.setStart(caret.offsetNode, caret.offset);

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
},
{
"path": "../model"

View File

@@ -75,9 +75,7 @@ export class AffineDragHandleWidget extends WidgetComponent<RootBlockModel> {
const blockId = closestBlock.model.id;
const model = closestBlock.model;
const isDatabase = matchFlavours(model, [
'affine:database' as BlockSuite.Flavour,
]);
const isDatabase = matchFlavours(model, ['affine:database']);
if (isDatabase) return null;
// note block can only be dropped into another note block

View File

@@ -188,9 +188,7 @@ export const getDropResult = (
const model = closestBlock.model;
const isDatabase = matchFlavours(model, [
'affine:database' as BlockSuite.Flavour,
]);
const isDatabase = matchFlavours(model, ['affine:database']);
if (isDatabase) {
return dropIndicator;
}

View File

@@ -8,16 +8,7 @@
"include": ["./src"],
"references": [
{
"path": "../../framework/global"
},
{
"path": "../../framework/store"
},
{
"path": "../../framework/block-std"
},
{
"path": "../../framework/inline"
"path": "../../framework"
},
{
"path": "../model"

View File

@@ -61,7 +61,6 @@ export class AffineDocRemoteSelectionWidget extends WidgetComponent {
return (
matchFlavours(block, [
'affine:code',
// @ts-expect-error FIXME: fix after database model moved to affine-model
'affine:database',
'affine:image',
'affine:attachment',

Some files were not shown because too many files have changed in this diff Show More