mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-05 00:54:56 +00:00
Compare commits
39 Commits
v0.19.2
...
v0.19.5-be
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b14f1cdb7c | ||
|
|
22a8694972 | ||
|
|
bbe88c57b7 | ||
|
|
a3b502fad7 | ||
|
|
28f0dad3f9 | ||
|
|
f64d62d869 | ||
|
|
1c6c2194c4 | ||
|
|
e3d681306c | ||
|
|
43adb85e7d | ||
|
|
e8aabed3fa | ||
|
|
b51de2ac4c | ||
|
|
597b631918 | ||
|
|
353eaf7fbe | ||
|
|
83915c2e90 | ||
|
|
8732801f06 | ||
|
|
9dc1b5e25b | ||
|
|
1e34ec8487 | ||
|
|
0f03c3fc5e | ||
|
|
7aba836dbe | ||
|
|
09427e846e | ||
|
|
adf14d11d5 | ||
|
|
7c41775c7f | ||
|
|
9c119e6505 | ||
|
|
887732179e | ||
|
|
6883cc2ded | ||
|
|
2b47625deb | ||
|
|
79e006467c | ||
|
|
397a48380e | ||
|
|
8d269c838d | ||
|
|
ade317d26b | ||
|
|
a9f890017e | ||
|
|
c28f918527 | ||
|
|
e526106f45 | ||
|
|
d4053a345e | ||
|
|
8b3d99929f | ||
|
|
a85707a2e7 | ||
|
|
8463e4d683 | ||
|
|
569e63377d | ||
|
|
580e3eb13c |
47
.github/actions/build-rust/action.yml
vendored
47
.github/actions/build-rust/action.yml
vendored
@@ -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
|
||||
|
||||
47
.github/actions/setup-node/action.yml
vendored
47
.github/actions/setup-node/action.yml
vendored
@@ -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
|
||||
|
||||
28
.github/actions/setup-rust/action.yml
vendored
28
.github/actions/setup-rust/action.yml
vendored
@@ -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
|
||||
22
.github/workflows/build-test.yml
vendored
22
.github/workflows/build-test.yml
vendored
@@ -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,
|
||||
|
||||
3
.github/workflows/copilot-test.yml
vendored
3
.github/workflows/copilot-test.yml
vendored
@@ -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
|
||||
|
||||
12
.github/workflows/release-mobile.yml
vendored
12
.github/workflows/release-mobile.yml
vendored
@@ -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
|
||||
|
||||
@@ -8,16 +8,7 @@
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../framework/global"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/store"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/block-std"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/inline"
|
||||
"path": "../../framework"
|
||||
},
|
||||
{
|
||||
"path": "../../blocks"
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -8,16 +8,7 @@
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../framework/global"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/store"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/block-std"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/inline"
|
||||
"path": "../../framework"
|
||||
},
|
||||
{
|
||||
"path": "../model"
|
||||
|
||||
@@ -8,16 +8,7 @@
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../framework/global"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/store"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/block-std"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/inline"
|
||||
"path": "../../framework"
|
||||
},
|
||||
{
|
||||
"path": "../model"
|
||||
|
||||
@@ -8,16 +8,7 @@
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../framework/global"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/store"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/block-std"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/inline"
|
||||
"path": "../../framework"
|
||||
},
|
||||
{
|
||||
"path": "../model"
|
||||
|
||||
45
blocksuite/affine/block-data-view/package.json
Normal file
45
blocksuite/affine/block-data-view/package.json
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "@blocksuite/affine-block-data-view",
|
||||
"description": "Data view 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-database": "workspace:*",
|
||||
"@blocksuite/affine-components": "workspace:*",
|
||||
"@blocksuite/affine-model": "workspace:*",
|
||||
"@blocksuite/affine-shared": "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",
|
||||
"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"
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { richTextColumnConfig } from '@blocksuite/affine-block-database';
|
||||
import { type ListBlockModel, ListBlockSchema } from '@blocksuite/affine-model';
|
||||
import { propertyPresets } from '@blocksuite/data-view/property-presets';
|
||||
|
||||
import { richTextColumnConfig } from '../../database-block/properties/rich-text/cell-renderer.js';
|
||||
import { createBlockMeta } from './base.js';
|
||||
|
||||
export const todoMeta = createBlockMeta<ListBlockModel>({
|
||||
@@ -1,8 +1,7 @@
|
||||
import { richTextColumnConfig } from '@blocksuite/affine-block-database';
|
||||
import type { PropertyMetaConfig } from '@blocksuite/data-view';
|
||||
import { propertyPresets } from '@blocksuite/data-view/property-presets';
|
||||
|
||||
import { richTextColumnConfig } from '../../database-block/properties/rich-text/cell-renderer.js';
|
||||
|
||||
export const queryBlockColumns = [
|
||||
propertyPresets.datePropertyConfig,
|
||||
propertyPresets.numberPropertyConfig,
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
databaseBlockAllPropertyMap,
|
||||
databasePropertyConverts,
|
||||
} from '@blocksuite/affine-block-database';
|
||||
import type { Column } from '@blocksuite/affine-model';
|
||||
import {
|
||||
insertPositionToIndex,
|
||||
@@ -9,10 +13,6 @@ import { propertyPresets } from '@blocksuite/data-view/property-presets';
|
||||
import { assertExists, Slot } from '@blocksuite/global/utils';
|
||||
import type { Block, Doc } from '@blocksuite/store';
|
||||
|
||||
import {
|
||||
databaseBlockAllPropertyMap,
|
||||
databasePropertyConverts,
|
||||
} from '../database-block/properties/index.js';
|
||||
import type { BlockMeta } from './block-meta/base.js';
|
||||
import { blockMetaMap } from './block-meta/index.js';
|
||||
import { queryBlockAllColumnMap, queryBlockColumns } from './columns/index.js';
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { NoteBlockComponent } from '@blocksuite/affine-block-note';
|
||||
import { BlockRenderer, NoteRenderer } from '@blocksuite/affine-block-database';
|
||||
import { CaptionedBlockComponent } from '@blocksuite/affine-components/caption';
|
||||
import {
|
||||
menu,
|
||||
@@ -12,12 +12,17 @@ import {
|
||||
} from '@blocksuite/affine-components/icons';
|
||||
import { PeekViewProvider } from '@blocksuite/affine-components/peek';
|
||||
import { toast } from '@blocksuite/affine-components/toast';
|
||||
import { NOTE_SELECTOR } from '@blocksuite/affine-shared/consts';
|
||||
import {
|
||||
DocModeProvider,
|
||||
NotificationProvider,
|
||||
type TelemetryEventMap,
|
||||
TelemetryProvider,
|
||||
} from '@blocksuite/affine-shared/services';
|
||||
import { RANGE_SYNC_EXCLUDE_ATTR } from '@blocksuite/block-std';
|
||||
import {
|
||||
type BlockComponent,
|
||||
RANGE_SYNC_EXCLUDE_ATTR,
|
||||
} from '@blocksuite/block-std';
|
||||
import {
|
||||
createRecordDetail,
|
||||
createUniComponentFromWebComponent,
|
||||
@@ -39,12 +44,6 @@ import { computed, signal } from '@preact/signals-core';
|
||||
import { css, nothing, unsafeCSS } from 'lit';
|
||||
import { html } from 'lit/static-html.js';
|
||||
|
||||
import { BlockRenderer } from '../database-block/detail-panel/block-renderer.js';
|
||||
import { NoteRenderer } from '../database-block/detail-panel/note-renderer.js';
|
||||
import {
|
||||
EdgelessRootBlockComponent,
|
||||
type RootService,
|
||||
} from '../root-block/index.js';
|
||||
import { BlockQueryDataSource } from './data-source.js';
|
||||
import type { DataViewBlockModel } from './data-view-model.js';
|
||||
|
||||
@@ -154,10 +153,6 @@ export class DataViewBlockComponent extends CaptionedBlockComponent<DataViewBloc
|
||||
};
|
||||
};
|
||||
|
||||
getRootService = () => {
|
||||
return this.std.getService<RootService>('affine:page');
|
||||
};
|
||||
|
||||
headerWidget: DataViewWidget = defineUniComponent(
|
||||
(props: DataViewWidgetProps) => {
|
||||
return html`
|
||||
@@ -231,9 +226,8 @@ export class DataViewBlockComponent extends CaptionedBlockComponent<DataViewBloc
|
||||
}
|
||||
|
||||
override get topContenteditableElement() {
|
||||
if (this.rootComponent instanceof EdgelessRootBlockComponent) {
|
||||
const note = this.closest<NoteBlockComponent>('affine-note');
|
||||
return note;
|
||||
if (this.std.get(DocModeProvider).getEditorMode() === 'edgeless') {
|
||||
return this.closest<BlockComponent>(NOTE_SELECTOR);
|
||||
}
|
||||
return this.rootComponent;
|
||||
}
|
||||
14
blocksuite/affine/block-data-view/src/effects.ts
Normal file
14
blocksuite/affine/block-data-view/src/effects.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { DataViewBlockComponent } from './data-view-block';
|
||||
import type { DataViewBlockModel } from './data-view-model';
|
||||
|
||||
export function effects() {
|
||||
customElements.define('affine-data-view', DataViewBlockComponent);
|
||||
}
|
||||
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface BlockModels {
|
||||
'affine:data-view': DataViewBlockModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
blocksuite/affine/block-data-view/src/index.ts
Normal file
3
blocksuite/affine/block-data-view/src/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './data-view-block.js';
|
||||
export * from './data-view-model.js';
|
||||
export * from './data-view-spec.js';
|
||||
29
blocksuite/affine/block-data-view/tsconfig.json
Normal file
29
blocksuite/affine/block-data-view/tsconfig.json
Normal 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": "../block-database"
|
||||
}
|
||||
]
|
||||
}
|
||||
46
blocksuite/affine/block-database/package.json
Normal file
46
blocksuite/affine/block-database/package.json
Normal 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"
|
||||
}
|
||||
4
blocksuite/affine/block-database/src/adapters/index.ts
Normal file
4
blocksuite/affine/block-database/src/adapters/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from './html';
|
||||
export * from './markdown';
|
||||
export * from './notion-html';
|
||||
export * from './plain-text';
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
import type { DatabaseBlockModel } from '@blocksuite/affine-model';
|
||||
import {
|
||||
insertPositionToIndex,
|
||||
@@ -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;
|
||||
}
|
||||
68
blocksuite/affine/block-database/src/effects.ts
Normal file
68
blocksuite/affine/block-database/src/effects.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
blocksuite/affine/block-database/src/index.ts
Normal file
16
blocksuite/affine/block-database/src/index.ts
Normal 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';
|
||||
@@ -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);
|
||||
29
blocksuite/affine/block-database/tsconfig.json
Normal file
29
blocksuite/affine/block-database/tsconfig.json
Normal 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"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -8,16 +8,7 @@
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../framework/global"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/store"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/block-std"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/inline"
|
||||
"path": "../../framework"
|
||||
},
|
||||
{
|
||||
"path": "../model"
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -8,16 +8,7 @@
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../framework/global"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/store"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/block-std"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/inline"
|
||||
"path": "../../framework"
|
||||
},
|
||||
{
|
||||
"path": "../model"
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { ExtensionType } from '@blocksuite/block-std';
|
||||
|
||||
import { EmbedSyncedDocBlockHtmlAdapterExtension } from './html.js';
|
||||
import { EmbedSyncedDocBlockMarkdownAdapterExtension } from './markdown.js';
|
||||
import { EmbedSyncedDocMarkdownAdapterExtension } from './markdown.js';
|
||||
import { EmbedSyncedDocBlockPlainTextAdapterExtension } from './plain-text.js';
|
||||
|
||||
export const EmbedSyncedDocBlockAdapterExtensions: ExtensionType[] = [
|
||||
EmbedSyncedDocBlockHtmlAdapterExtension,
|
||||
EmbedSyncedDocBlockMarkdownAdapterExtension,
|
||||
EmbedSyncedDocMarkdownAdapterExtension,
|
||||
EmbedSyncedDocBlockPlainTextAdapterExtension,
|
||||
];
|
||||
|
||||
@@ -60,5 +60,5 @@ export const embedSyncedDocBlockMarkdownAdapterMatcher: BlockMarkdownAdapterMatc
|
||||
},
|
||||
};
|
||||
|
||||
export const EmbedSyncedDocBlockMarkdownAdapterExtension =
|
||||
export const EmbedSyncedDocMarkdownAdapterExtension =
|
||||
BlockMarkdownAdapterExtension(embedSyncedDocBlockMarkdownAdapterMatcher);
|
||||
|
||||
@@ -8,16 +8,7 @@
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../framework/global"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/store"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/block-std"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/inline"
|
||||
"path": "../../framework"
|
||||
},
|
||||
{
|
||||
"path": "../model"
|
||||
|
||||
@@ -8,16 +8,7 @@
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../framework/global"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/store"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/block-std"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/inline"
|
||||
"path": "../../framework"
|
||||
},
|
||||
{
|
||||
"path": "../model"
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -8,16 +8,7 @@
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../framework/global"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/store"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/block-std"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/inline"
|
||||
"path": "../../framework"
|
||||
},
|
||||
{
|
||||
"path": "../model"
|
||||
|
||||
@@ -8,16 +8,7 @@
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../framework/global"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/store"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/block-std"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/inline"
|
||||
"path": "../../framework"
|
||||
},
|
||||
{
|
||||
"path": "../model"
|
||||
|
||||
@@ -8,16 +8,7 @@
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../framework/global"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/store"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/block-std"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/inline"
|
||||
"path": "../../framework"
|
||||
},
|
||||
{
|
||||
"path": "../model"
|
||||
|
||||
@@ -8,16 +8,7 @@
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../framework/global"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/store"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/block-std"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/inline"
|
||||
"path": "../../framework"
|
||||
},
|
||||
{
|
||||
"path": "../model"
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -8,16 +8,7 @@
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../framework/global"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/store"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/block-std"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/inline"
|
||||
"path": "../../framework"
|
||||
},
|
||||
{
|
||||
"path": "../model"
|
||||
|
||||
48
blocksuite/affine/block-surface-ref/package.json
Normal file
48
blocksuite/affine/block-surface-ref/package.json
Normal 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"
|
||||
}
|
||||
@@ -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 {
|
||||
@@ -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';
|
||||
@@ -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(
|
||||
3
blocksuite/affine/block-surface-ref/src/types.ts
Normal file
3
blocksuite/affine/block-surface-ref/src/types.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export interface EdgelessPreviewer {
|
||||
editorViewportSelector: string;
|
||||
}
|
||||
23
blocksuite/affine/block-surface-ref/tsconfig.json
Normal file
23
blocksuite/affine/block-surface-ref/tsconfig.json
Normal 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"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -8,16 +8,7 @@
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../framework/global"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/store"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/block-std"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/inline"
|
||||
"path": "../../framework"
|
||||
},
|
||||
{
|
||||
"path": "../model"
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
"exports": {
|
||||
".": "./src/index.ts",
|
||||
"./ai-item": "./src/ai-item/index.ts",
|
||||
"./color-picker": "./src/color-picker/index.ts",
|
||||
"./icons": "./src/icons/index.ts",
|
||||
"./peek": "./src/peek/index.ts",
|
||||
"./portal": "./src/portal/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { EditorMenuButton } from '@blocksuite/affine-components/toolbar';
|
||||
import type { ColorScheme, Palette } from '@blocksuite/affine-model';
|
||||
import { resolveColor } from '@blocksuite/affine-model';
|
||||
import type { ColorEvent } from '@blocksuite/affine-shared/utils';
|
||||
import { WithDisposable } from '@blocksuite/global/utils';
|
||||
import { html, LitElement } from 'lit';
|
||||
import { property, query, state } from 'lit/decorators.js';
|
||||
@@ -8,7 +8,7 @@ import { choose } from 'lit/directives/choose.js';
|
||||
import { ifDefined } from 'lit/directives/if-defined.js';
|
||||
import { styleMap } from 'lit/directives/style-map.js';
|
||||
|
||||
import type { ColorEvent } from '../panel/color-panel.js';
|
||||
import type { EditorMenuButton } from '../toolbar/menu-button.js';
|
||||
import type { ModeType, PickColorEvent, PickColorType } from './types.js';
|
||||
import { keepColor, preprocessColor, rgbaToHex8 } from './utils.js';
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user