mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-05 00:54:56 +00:00
Compare commits
2 Commits
04-02-chor
...
fix-toc-se
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5526696357 | ||
|
|
5be0292536 |
@@ -5,7 +5,7 @@ rustflags = ["-C", "target-feature=+crt-static"]
|
||||
[target.'cfg(target_os = "linux")']
|
||||
rustflags = ["-C", "link-args=-Wl,--warn-unresolved-symbols"]
|
||||
[target.'cfg(target_os = "macos")']
|
||||
rustflags = ["-C", "link-args=-Wl,-undefined,dynamic_lookup,-no_fixup_chains", "-C", "link-args=-all_load", "-C", "link-args=-weak_framework ScreenCaptureKit"]
|
||||
rustflags = ["-C", "link-args=-all_load", "-C", "link-args=-weak_framework ScreenCaptureKit"]
|
||||
# https://sourceware.org/bugzilla/show_bug.cgi?id=21032
|
||||
# https://sourceware.org/bugzilla/show_bug.cgi?id=21031
|
||||
# https://github.com/rust-lang/rust/issues/134820
|
||||
|
||||
@@ -44,7 +44,7 @@ services:
|
||||
|
||||
redis:
|
||||
image: redis
|
||||
container_name: affine_redis
|
||||
container_name: redis
|
||||
healthcheck:
|
||||
test: ['CMD', 'redis-cli', '--raw', 'incr', 'ping']
|
||||
interval: 10s
|
||||
@@ -54,7 +54,7 @@ services:
|
||||
|
||||
postgres:
|
||||
image: postgres:16
|
||||
container_name: affine_postgres
|
||||
container_name: postgres
|
||||
volumes:
|
||||
- ${DB_DATA_LOCATION}:/var/lib/postgresql/data
|
||||
environment:
|
||||
|
||||
@@ -200,6 +200,11 @@
|
||||
"type": "object",
|
||||
"description": "Configuration for mailer module",
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean",
|
||||
"description": "Whether enabled mail service.\n@default false",
|
||||
"default": false
|
||||
},
|
||||
"SMTP.host": {
|
||||
"type": "string",
|
||||
"description": "Host of the email server (e.g. smtp.gmail.com)\n@default \"\"\n@environment `MAILER_HOST`",
|
||||
@@ -507,7 +512,8 @@
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "A recognizable name for the server. Will be shown when connected with AFFiNE Desktop.\n@default undefined"
|
||||
"description": "A recognizable name for the server. Will be shown when connected with AFFiNE Desktop.\n@default \"AFFiNE Cloud\"",
|
||||
"default": "AFFiNE Cloud"
|
||||
},
|
||||
"externalUrl": {
|
||||
"type": "string",
|
||||
@@ -531,7 +537,7 @@
|
||||
},
|
||||
"path": {
|
||||
"type": "string",
|
||||
"description": "Subpath where the server get deployed if there is one.(e.g. /affine)\n@default \"\"\n@environment `AFFINE_SERVER_SUB_PATH`",
|
||||
"description": "Subpath where the server get deployed if there is.\n@default \"\"\n@environment `AFFINE_SERVER_SUB_PATH`",
|
||||
"default": ""
|
||||
}
|
||||
}
|
||||
|
||||
6
.github/actions/server-test-env/action.yml
vendored
6
.github/actions/server-test-env/action.yml
vendored
@@ -24,10 +24,8 @@ runs:
|
||||
- name: Import config
|
||||
shell: bash
|
||||
run: |
|
||||
printf '{"copilot":{"enabled":true,"providers.fal":{"apiKey":"%s"},"providers.gemini":{"apiKey":"%s"},"providers.openai":{"apiKey":"%s"},"providers.perplexity":{"apiKey":"%s"},"providers.anthropic":{"apiKey":"%s"},"exa":{"key":"%s"}}}' \
|
||||
printf '{"copilot":{"enabled":true,"providers.fal":{"apiKey":"%s"},"providers.gemini":{"apiKey":"%s"},"providers.openai":{"apiKey":"%s"},"providers.perplexity":{"apiKey":"%s"}}}' \
|
||||
"$COPILOT_FAL_API_KEY" \
|
||||
"$COPILOT_GOOGLE_API_KEY" \
|
||||
"$COPILOT_OPENAI_API_KEY" \
|
||||
"$COPILOT_PERPLEXITY_API_KEY" \
|
||||
"$COPILOT_ANTHROPIC_API_KEY" \
|
||||
"$COPILOT_EXA_API_KEY" > ./packages/backend/server/config.json
|
||||
"$COPILOT_PERPLEXITY_API_KEY" > ./packages/backend/server/config.json
|
||||
|
||||
2
.github/deployment/node/Dockerfile
vendored
2
.github/deployment/node/Dockerfile
vendored
@@ -10,4 +10,4 @@ RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends openssl && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
CMD ["node", "./dist/main.js"]
|
||||
CMD ["node", "--import", "./scripts/register.js", "./dist/index.js"]
|
||||
|
||||
60
.github/deployment/self-host/compose.yaml
vendored
Normal file
60
.github/deployment/self-host/compose.yaml
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
services:
|
||||
affine:
|
||||
image: ghcr.io/toeverything/affine-graphql:stable
|
||||
container_name: affine_selfhosted
|
||||
command:
|
||||
['sh', '-c', 'node ./scripts/self-host-predeploy && node ./dist/index.js']
|
||||
ports:
|
||||
- '3010:3010'
|
||||
- '5555:5555'
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
volumes:
|
||||
# custom configurations
|
||||
- ~/.affine/self-host/config:/root/.affine/config
|
||||
# blob storage
|
||||
- ~/.affine/self-host/storage:/root/.affine/storage
|
||||
logging:
|
||||
driver: 'json-file'
|
||||
options:
|
||||
max-size: '1000m'
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- NODE_OPTIONS="--import=./scripts/register.js"
|
||||
- AFFINE_CONFIG_PATH=/root/.affine/config
|
||||
- REDIS_SERVER_HOST=redis
|
||||
- DATABASE_URL=postgres://affine:affine@postgres:5432/affine
|
||||
- NODE_ENV=production
|
||||
# Telemetry allows us to collect data on how you use the affine. This data will helps us improve the app and provide better features.
|
||||
# Uncomment next line if you wish to quit telemetry.
|
||||
# - TELEMETRY_ENABLE=false
|
||||
redis:
|
||||
image: redis
|
||||
container_name: affine_redis
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ~/.affine/self-host/redis:/data
|
||||
healthcheck:
|
||||
test: ['CMD', 'redis-cli', '--raw', 'incr', 'ping']
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
postgres:
|
||||
image: postgres:16
|
||||
container_name: affine_postgres
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ~/.affine/self-host/postgres:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'pg_isready -U affine']
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
environment:
|
||||
POSTGRES_USER: affine
|
||||
POSTGRES_PASSWORD: affine
|
||||
POSTGRES_DB: affine
|
||||
PGDATA: /var/lib/postgresql/data/pgdata
|
||||
28
.github/renovate.json
vendored
28
.github/renovate.json
vendored
@@ -21,34 +21,16 @@
|
||||
"groupName": "oxlint"
|
||||
},
|
||||
{
|
||||
"groupName": "all non-major rust dependencies",
|
||||
"groupSlug": "all-minor-patch",
|
||||
"matchUpdateTypes": ["minor", "patch"],
|
||||
"matchManagers": ["cargo"]
|
||||
},
|
||||
{
|
||||
"groupName": "all non-major npm dependencies",
|
||||
"groupSlug": "all-minor-patch",
|
||||
"matchUpdateTypes": ["minor", "patch"],
|
||||
"matchManagers": ["npm"],
|
||||
"matchPackageNames": ["*", "!/^@blocksuite//", "!/oxlint/"]
|
||||
"groupName": "blocksuite",
|
||||
"rangeStrategy": "replace",
|
||||
"changelogUrl": "https://github.com/toeverything/blocksuite/blob/master/packages/blocks/CHANGELOG.md",
|
||||
"matchPackageNames": ["/^@blocksuite/", "!@blocksuite/icons"]
|
||||
},
|
||||
{
|
||||
"groupName": "all non-major dependencies",
|
||||
"groupSlug": "all-minor-patch",
|
||||
"matchUpdateTypes": ["minor", "patch"],
|
||||
"matchManagers": [
|
||||
"dockerfile",
|
||||
"github-actions",
|
||||
"helmv3",
|
||||
"helm-values",
|
||||
"gradle-wrapper",
|
||||
"gradle",
|
||||
"docker-compose",
|
||||
"devcontainer",
|
||||
"cocoapods",
|
||||
"bundler"
|
||||
]
|
||||
"matchPackageNames": ["*", "!/^@blocksuite//", "!/oxlint/"]
|
||||
},
|
||||
{
|
||||
"groupName": "rust toolchain",
|
||||
|
||||
86
.github/workflows/build-images.yml
vendored
86
.github/workflows/build-images.yml
vendored
@@ -13,6 +13,31 @@ permissions:
|
||||
packages: 'write'
|
||||
|
||||
jobs:
|
||||
build-server:
|
||||
name: Build Server
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Version
|
||||
id: version
|
||||
uses: ./.github/actions/setup-version
|
||||
- name: Setup Node.js
|
||||
uses: ./.github/actions/setup-node
|
||||
with:
|
||||
electron-install: false
|
||||
extra-flags: workspaces focus @affine/server @types/affine__env
|
||||
- name: Build Server
|
||||
run: |
|
||||
find packages/backend/server/src -type d -name "__tests__" -exec rm -rf {} +
|
||||
rm -rf packages/backend/server/src/seed
|
||||
yarn workspace @affine/server build
|
||||
- name: Upload server dist
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: server-dist
|
||||
path: ./packages/backend/server/dist
|
||||
if-no-files-found: error
|
||||
|
||||
build-web:
|
||||
name: Build @affine/web
|
||||
runs-on: ubuntu-latest
|
||||
@@ -118,7 +143,7 @@ jobs:
|
||||
matrix:
|
||||
targets:
|
||||
- name: x86_64-unknown-linux-gnu
|
||||
file: server-native.x64.node
|
||||
file: server-native.node
|
||||
- name: aarch64-unknown-linux-gnu
|
||||
file: server-native.arm64.node
|
||||
- name: armv7-unknown-linux-gnueabihf
|
||||
@@ -139,46 +164,11 @@ jobs:
|
||||
with:
|
||||
target: ${{ matrix.targets.name }}
|
||||
package: '@affine/server-native'
|
||||
- name: Rename ${{ matrix.targets.file }}
|
||||
run: |
|
||||
mv ./packages/backend/native/server-native.node ./packages/backend/native/${{ matrix.targets.file }}
|
||||
- name: Upload ${{ matrix.targets.file }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: server-native-${{ matrix.targets.file }}
|
||||
path: ./packages/backend/native/${{ matrix.targets.file }}
|
||||
if-no-files-found: error
|
||||
|
||||
build-server:
|
||||
name: Build Server
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build-server-native
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Version
|
||||
id: version
|
||||
uses: ./.github/actions/setup-version
|
||||
- name: Setup Node.js
|
||||
uses: ./.github/actions/setup-node
|
||||
with:
|
||||
electron-install: false
|
||||
extra-flags: workspaces focus @affine/server @types/affine__env
|
||||
- name: Download server-native
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: server-native-*
|
||||
merge-multiple: true
|
||||
path: ./packages/backend/native
|
||||
- name: List server-native files
|
||||
run: ls -alh ./packages/backend/native
|
||||
- name: Build Server
|
||||
run: yarn workspace @affine/server build
|
||||
- name: Upload server dist
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: server-dist
|
||||
path: ./packages/backend/server/dist
|
||||
name: ${{ matrix.targets.file }}
|
||||
path: ./packages/backend/native/server-native.node
|
||||
if-no-files-found: error
|
||||
|
||||
build-images:
|
||||
@@ -189,6 +179,7 @@ jobs:
|
||||
- build-web
|
||||
- build-mobile
|
||||
- build-admin
|
||||
- build-server-native
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download server dist
|
||||
@@ -196,6 +187,25 @@ jobs:
|
||||
with:
|
||||
name: server-dist
|
||||
path: ./packages/backend/server/dist
|
||||
- name: Download server-native.node
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: server-native.node
|
||||
path: ./packages/backend/server
|
||||
- name: Download server-native.node arm64
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: server-native.arm64.node
|
||||
path: ./packages/backend/native
|
||||
- name: Download server-native.node arm64
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: server-native.armv7.node
|
||||
path: .
|
||||
- name: move server-native files
|
||||
run: |
|
||||
mv ./packages/backend/native/server-native.node ./packages/backend/server/server-native.arm64.node
|
||||
mv server-native.node ./packages/backend/server/server-native.armv7.node
|
||||
- name: Setup env
|
||||
run: |
|
||||
echo "GIT_SHORT_HASH=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
|
||||
|
||||
197
.github/workflows/build-test.yml
vendored
197
.github/workflows/build-test.yml
vendored
@@ -218,43 +218,7 @@ jobs:
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: test-results-e2e-bs-${{ matrix.shard }}
|
||||
path: ./test-results
|
||||
if-no-files-found: ignore
|
||||
|
||||
e2e-blocksuite-cross-browser-test:
|
||||
name: E2E BlockSuite Cross Browser Test
|
||||
runs-on: ubuntu-latest
|
||||
needs: optimize_ci
|
||||
if: needs.optimize_ci.outputs.skip == 'false'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
shard: [1, 2]
|
||||
browser: ['chromium', 'firefox', 'webkit']
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Node.js
|
||||
uses: ./.github/actions/setup-node
|
||||
with:
|
||||
playwright-install: true
|
||||
playwright-platform: ${{ matrix.browser }}
|
||||
electron-install: false
|
||||
full-cache: true
|
||||
|
||||
- name: Run playground build
|
||||
run: yarn workspace @blocksuite/playground build
|
||||
|
||||
- name: Run playwright tests
|
||||
env:
|
||||
BROWSER: ${{ matrix.browser }}
|
||||
run: yarn workspace @affine-test/blocksuite test "cross-platform/" --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }}
|
||||
|
||||
- name: Upload test results
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: test-results-e2e-bs-cross-browser-${{ matrix.browser }}-${{ matrix.shard }}
|
||||
name: test-results-e2e-legacy-bs-${{ matrix.shard }}
|
||||
path: ./test-results
|
||||
if-no-files-found: ignore
|
||||
|
||||
@@ -542,8 +506,8 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node_index: [0, 1, 2, 3]
|
||||
total_nodes: [4]
|
||||
node_index: [0, 1, 2, 3, 4, 5, 6, 7]
|
||||
total_nodes: [8]
|
||||
env:
|
||||
NODE_ENV: test
|
||||
DATABASE_URL: postgresql://affine:affine@localhost:5432/affine
|
||||
@@ -582,7 +546,7 @@ jobs:
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: server-native.node
|
||||
path: ./packages/backend/native
|
||||
path: ./packages/backend/server
|
||||
|
||||
- name: Prepare Server Test Environment
|
||||
uses: ./.github/actions/server-test-env
|
||||
@@ -644,7 +608,7 @@ jobs:
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: server-native.node
|
||||
path: ./packages/backend/native
|
||||
path: ./packages/backend/server
|
||||
|
||||
- name: Prepare Server Test Environment
|
||||
uses: ./.github/actions/server-test-env
|
||||
@@ -661,142 +625,6 @@ jobs:
|
||||
name: affine
|
||||
fail_ci_if_error: false
|
||||
|
||||
miri:
|
||||
name: miri code check
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- optimize_ci
|
||||
if: needs.optimize_ci.outputs.skip == 'false'
|
||||
env:
|
||||
RUST_BACKTRACE: full
|
||||
CARGO_TERM_COLOR: always
|
||||
MIRIFLAGS: -Zmiri-backtrace=full -Zmiri-tree-borrows
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
toolchain: nightly
|
||||
components: miri
|
||||
- name: Install latest nextest release
|
||||
uses: taiki-e/install-action@nextest
|
||||
|
||||
- name: Miri Code Check
|
||||
continue-on-error: true
|
||||
run: |
|
||||
cargo +nightly miri nextest run -p y-octo -j4
|
||||
|
||||
loom:
|
||||
name: loom thread test
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- optimize_ci
|
||||
if: needs.optimize_ci.outputs.skip == 'false'
|
||||
env:
|
||||
RUSTFLAGS: --cfg loom
|
||||
RUST_BACKTRACE: full
|
||||
CARGO_TERM_COLOR: always
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
toolchain: stable
|
||||
- name: Install latest nextest release
|
||||
uses: taiki-e/install-action@nextest
|
||||
|
||||
- name: Loom Thread Test
|
||||
run: |
|
||||
cargo nextest run -p y-octo --lib
|
||||
|
||||
fuzzing:
|
||||
name: fuzzing
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- optimize_ci
|
||||
if: needs.optimize_ci.outputs.skip == 'false'
|
||||
env:
|
||||
RUSTFLAGS: -D warnings
|
||||
CARGO_TERM_COLOR: always
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
toolchain: nightly
|
||||
|
||||
- name: fuzzing
|
||||
working-directory: ./packages/common/y-octo/utils
|
||||
run: |
|
||||
cargo install cargo-fuzz
|
||||
cargo +nightly fuzz run apply_update -- -max_total_time=30
|
||||
cargo +nightly fuzz run codec_doc_any_struct -- -max_total_time=30
|
||||
cargo +nightly fuzz run codec_doc_any -- -max_total_time=30
|
||||
cargo +nightly fuzz run decode_bytes -- -max_total_time=30
|
||||
cargo +nightly fuzz run i32_decode -- -max_total_time=30
|
||||
cargo +nightly fuzz run i32_encode -- -max_total_time=30
|
||||
cargo +nightly fuzz run ins_del_text -- -max_total_time=30
|
||||
cargo +nightly fuzz run sync_message -- -max_total_time=30
|
||||
cargo +nightly fuzz run u64_decode -- -max_total_time=30
|
||||
cargo +nightly fuzz run u64_encode -- -max_total_time=30
|
||||
cargo +nightly fuzz run apply_update -- -max_total_time=30
|
||||
|
||||
- name: upload fuzz artifacts
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: fuzz-artifact
|
||||
path: packages/common/y-octo/utils/fuzz/artifacts/**/*
|
||||
|
||||
y-octo-binding-test:
|
||||
name: y-octo binding test on ${{ matrix.settings.target }}
|
||||
runs-on: ${{ matrix.settings.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
settings:
|
||||
- { target: 'x86_64-unknown-linux-gnu', os: 'ubuntu-latest' }
|
||||
- { target: 'aarch64-unknown-linux-gnu', os: 'ubuntu-24.04-arm' }
|
||||
- { target: 'x86_64-apple-darwin', os: 'macos-13' }
|
||||
- { target: 'aarch64-apple-darwin', os: 'macos-latest' }
|
||||
- { target: 'x86_64-pc-windows-msvc', os: 'windows-latest' }
|
||||
- { target: 'aarch64-pc-windows-msvc', os: 'windows-11-arm' }
|
||||
needs:
|
||||
- optimize_ci
|
||||
if: needs.optimize_ci.outputs.skip == 'false'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Node.js
|
||||
uses: ./.github/actions/setup-node
|
||||
with:
|
||||
extra-flags: workspaces focus @affine-tools/cli @affine/monorepo @y-octo/node
|
||||
electron-install: false
|
||||
- name: Install rustup (Windows 11 ARM)
|
||||
if: matrix.settings.os == 'windows-11-arm'
|
||||
shell: pwsh
|
||||
run: |
|
||||
Invoke-WebRequest -Uri "https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe" -OutFile rustup-init.exe
|
||||
.\rustup-init.exe --default-toolchain none -y
|
||||
"$env:USERPROFILE\.cargo\bin" | Out-File -Append -Encoding ascii $env:GITHUB_PATH
|
||||
"CARGO_HOME=$env:USERPROFILE\.cargo" | Out-File -Append -Encoding ascii $env:GITHUB_ENV
|
||||
- name: Install Rust (Windows 11 ARM)
|
||||
if: matrix.settings.os == 'windows-11-arm'
|
||||
shell: pwsh
|
||||
run: |
|
||||
rustup install stable
|
||||
rustup target add ${{ matrix.settings.target }}
|
||||
cargo --version
|
||||
- name: Build Rust
|
||||
uses: ./.github/actions/build-rust
|
||||
with:
|
||||
target: ${{ matrix.settings.target }}
|
||||
package: '@y-octo/node'
|
||||
- name: Run tests
|
||||
run: yarn affine @y-octo/node test
|
||||
|
||||
rust-test:
|
||||
name: Run native tests
|
||||
runs-on: ubuntu-latest
|
||||
@@ -885,7 +713,7 @@ jobs:
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: server-native.node
|
||||
path: ./packages/backend/native
|
||||
path: ./packages/backend/server
|
||||
|
||||
- name: Prepare Server Test Environment
|
||||
if: ${{ steps.check-blocksuite-update.outputs.skip != 'true' || steps.apifilter.outputs.changed == 'true' }}
|
||||
@@ -894,8 +722,6 @@ jobs:
|
||||
COPILOT_GOOGLE_API_KEY: ${{ secrets.COPILOT_GOOGLE_API_KEY }}
|
||||
COPILOT_FAL_API_KEY: ${{ secrets.COPILOT_FAL_API_KEY }}
|
||||
COPILOT_PERPLEXITY_API_KEY: ${{ secrets.COPILOT_PERPLEXITY_API_KEY }}
|
||||
COPILOT_ANTHROPIC_API_KEY: ${{ secrets.COPILOT_ANTHROPIC_API_KEY }}
|
||||
COPILOT_EXA_API_KEY: ${{ secrets.COPILOT_EXA_API_KEY }}
|
||||
uses: ./.github/actions/server-test-env
|
||||
|
||||
- name: Run server tests
|
||||
@@ -984,7 +810,7 @@ jobs:
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: server-native.node
|
||||
path: ./packages/backend/native
|
||||
path: ./packages/backend/server
|
||||
|
||||
- name: Prepare Server Test Environment
|
||||
if: ${{ steps.check-blocksuite-update.outputs.skip != 'true' || steps.e2efilter.outputs.changed == 'true' }}
|
||||
@@ -993,8 +819,6 @@ jobs:
|
||||
COPILOT_GOOGLE_API_KEY: ${{ secrets.COPILOT_GOOGLE_API_KEY }}
|
||||
COPILOT_FAL_API_KEY: ${{ secrets.COPILOT_FAL_API_KEY }}
|
||||
COPILOT_PERPLEXITY_API_KEY: ${{ secrets.COPILOT_PERPLEXITY_API_KEY }}
|
||||
COPILOT_ANTHROPIC_API_KEY: ${{ secrets.COPILOT_ANTHROPIC_API_KEY }}
|
||||
COPILOT_EXA_API_KEY: ${{ secrets.COPILOT_EXA_API_KEY }}
|
||||
uses: ./.github/actions/server-test-env
|
||||
|
||||
- name: Run Copilot E2E Test ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
|
||||
@@ -1081,7 +905,7 @@ jobs:
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: server-native.node
|
||||
path: ./packages/backend/native
|
||||
path: ./packages/backend/server
|
||||
|
||||
- name: Download affine.linux-x64-gnu.node
|
||||
uses: actions/download-artifact@v4
|
||||
@@ -1317,7 +1141,6 @@ jobs:
|
||||
- check-yarn-binary
|
||||
- e2e-test
|
||||
- e2e-blocksuite-test
|
||||
- e2e-blocksuite-cross-browser-test
|
||||
- e2e-mobile-test
|
||||
- unit-test
|
||||
- build-native
|
||||
@@ -1325,10 +1148,6 @@ jobs:
|
||||
- build-server-native
|
||||
- build-electron-renderer
|
||||
- native-unit-test
|
||||
- miri
|
||||
- loom
|
||||
- fuzzing
|
||||
- y-octo-binding-test
|
||||
- server-test
|
||||
- server-e2e-test
|
||||
- rust-test
|
||||
|
||||
8
.github/workflows/copilot-test.yml
vendored
8
.github/workflows/copilot-test.yml
vendored
@@ -73,7 +73,7 @@ jobs:
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: server-native.node
|
||||
path: ./packages/backend/native
|
||||
path: ./packages/backend/server
|
||||
|
||||
- name: Prepare Server Test Environment
|
||||
env:
|
||||
@@ -81,8 +81,6 @@ jobs:
|
||||
COPILOT_FAL_API_KEY: ${{ secrets.COPILOT_FAL_API_KEY }}
|
||||
COPILOT_GOOGLE_API_KEY: ${{ secrets.COPILOT_GOOGLE_API_KEY }}
|
||||
COPILOT_PERPLEXITY_API_KEY: ${{ secrets.COPILOT_PERPLEXITY_API_KEY }}
|
||||
COPILOT_ANTHROPIC_API_KEY: ${{ secrets.COPILOT_ANTHROPIC_API_KEY }}
|
||||
COPILOT_EXA_API_KEY: ${{ secrets.COPILOT_EXA_API_KEY }}
|
||||
uses: ./.github/actions/server-test-env
|
||||
|
||||
- name: Run server tests
|
||||
@@ -144,7 +142,7 @@ jobs:
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: server-native.node
|
||||
path: ./packages/backend/native
|
||||
path: ./packages/backend/server
|
||||
|
||||
- name: Prepare Server Test Environment
|
||||
env:
|
||||
@@ -152,8 +150,6 @@ jobs:
|
||||
COPILOT_FAL_API_KEY: ${{ secrets.COPILOT_FAL_API_KEY }}
|
||||
COPILOT_GOOGLE_API_KEY: ${{ secrets.COPILOT_GOOGLE_API_KEY }}
|
||||
COPILOT_PERPLEXITY_API_KEY: ${{ secrets.COPILOT_PERPLEXITY_API_KEY }}
|
||||
COPILOT_ANTHROPIC_API_KEY: ${{ secrets.COPILOT_ANTHROPIC_API_KEY }}
|
||||
COPILOT_EXA_API_KEY: ${{ secrets.COPILOT_EXA_API_KEY }}
|
||||
uses: ./.github/actions/server-test-env
|
||||
|
||||
- name: Run Copilot E2E Test ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
|
||||
|
||||
10
.github/workflows/release-mobile.yml
vendored
10
.github/workflows/release-mobile.yml
vendored
@@ -200,18 +200,11 @@ jobs:
|
||||
- build-android-web
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Version
|
||||
id: version
|
||||
uses: ./.github/actions/setup-version
|
||||
- name: Download mobile artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: android
|
||||
path: packages/frontend/apps/android/dist
|
||||
- name: Load Google Service file
|
||||
env:
|
||||
DATA: ${{ secrets.FIREBASE_ANDROID_GOOGLE_SERVICE_JSON }}
|
||||
run: echo $DATA | base64 -di > packages/frontend/apps/android/App/app/google-services.json
|
||||
- name: Setup Node.js
|
||||
uses: ./.github/actions/setup-node
|
||||
timeout-minutes: 10
|
||||
@@ -261,14 +254,13 @@ jobs:
|
||||
AFFINE_ANDROID_KEYSTORE_PASSWORD: ${{ secrets.AFFINE_ANDROID_KEYSTORE_PASSWORD }}
|
||||
AFFINE_ANDROID_KEYSTORE_ALIAS_PASSWORD: ${{ secrets.AFFINE_ANDROID_KEYSTORE_ALIAS_PASSWORD }}
|
||||
AFFINE_ANDROID_SIGN_KEYSTORE: ${{ secrets.AFFINE_ANDROID_SIGN_KEYSTORE }}
|
||||
VERSION_NAME: ${{ steps.version.outputs.APP_VERSION }}
|
||||
|
||||
- name: Upload to Google Play
|
||||
uses: r0adkll/upload-google-play@v1
|
||||
if: ${{ env.BUILD_TARGET == 'distribution' }}
|
||||
with:
|
||||
serviceAccountJson: ${{ steps.auth.outputs.credentials_file_path }}
|
||||
packageName: app.affine.pro
|
||||
releaseName: ${{ steps.version.outputs.APP_VERSION }}
|
||||
releaseFiles: packages/frontend/apps/android/App/app/build/outputs/bundle/${{ env.BUILD_TYPE }}Release/app-${{ env.BUILD_TYPE }}-release-signed.aab
|
||||
track: internal
|
||||
status: draft
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -85,6 +85,3 @@ packages/frontend/core/public/static/templates
|
||||
af
|
||||
af.cmd
|
||||
*.resolved
|
||||
|
||||
# playwright
|
||||
storageState.json
|
||||
|
||||
5
.vscode/launch.template.json
vendored
5
.vscode/launch.template.json
vendored
@@ -29,7 +29,10 @@
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"name": "Debug AFFiNE Web",
|
||||
"url": "http://localhost:8080"
|
||||
"url": "http://localhost:8080",
|
||||
"sourceMapPathOverrides": {
|
||||
"webpack://affine/blocksuite/*": "${workspaceFolder}/blocksuite/*"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -10,6 +10,6 @@ npmAuthToken: "${NPM_TOKEN:-NONE}"
|
||||
|
||||
npmPublishAccess: public
|
||||
|
||||
npmRegistryServer: "https://registry.npmjs.org"
|
||||
npmPublishRegistry: "https://registry.npmjs.org"
|
||||
|
||||
yarnPath: .yarn/releases/yarn-4.9.1.cjs
|
||||
yarnPath: .yarn/releases/yarn-4.9.0.cjs
|
||||
|
||||
652
Cargo.lock
generated
652
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
33
Cargo.toml
33
Cargo.toml
@@ -2,9 +2,6 @@
|
||||
members = [
|
||||
"./packages/backend/native",
|
||||
"./packages/common/native",
|
||||
"./packages/common/y-octo/core",
|
||||
"./packages/common/y-octo/node",
|
||||
"./packages/common/y-octo/utils",
|
||||
"./packages/frontend/mobile-native",
|
||||
"./packages/frontend/native",
|
||||
"./packages/frontend/native/nbstore",
|
||||
@@ -19,61 +16,39 @@ edition = "2024"
|
||||
[workspace.dependencies]
|
||||
affine_common = { path = "./packages/common/native" }
|
||||
affine_nbstore = { path = "./packages/frontend/native/nbstore" }
|
||||
ahash = "0.8"
|
||||
anyhow = "1"
|
||||
arbitrary = { version = "1.3", features = ["derive"] }
|
||||
assert-json-diff = "2.0"
|
||||
async-lock = { version = "3.4.0", features = ["loom"] }
|
||||
base64-simd = "0.8"
|
||||
bitvec = "1.0"
|
||||
block2 = "0.6"
|
||||
byteorder = "1.5"
|
||||
chrono = "0.4"
|
||||
clap = { version = "4.4", features = ["derive"] }
|
||||
core-foundation = "0.10"
|
||||
coreaudio-rs = "0.12"
|
||||
criterion = { version = "0.5", features = ["html_reports"] }
|
||||
criterion2 = { version = "3", default-features = false }
|
||||
dispatch2 = "0.3"
|
||||
dispatch2 = "0.2"
|
||||
docx-parser = { git = "https://github.com/toeverything/docx-parser" }
|
||||
dotenvy = "0.15"
|
||||
file-format = { version = "0.26", features = ["reader"] }
|
||||
homedir = "0.3"
|
||||
infer = { version = "0.19.0" }
|
||||
lasso = { version = "0.7", features = ["multi-threaded"] }
|
||||
lib0 = { version = "0.16", features = ["lib0-serde"] }
|
||||
libc = "0.2"
|
||||
log = "0.4"
|
||||
loom = { version = "0.7", features = ["checkpoint"] }
|
||||
mimalloc = "0.1"
|
||||
nanoid = "0.4"
|
||||
napi = { version = "3.0.0-alpha.31", features = ["async", "chrono_date", "error_anyhow", "napi9", "serde"] }
|
||||
napi-build = { version = "2" }
|
||||
napi-derive = { version = "3.0.0-alpha.28" }
|
||||
nom = "8"
|
||||
notify = { version = "8", features = ["serde"] }
|
||||
objc2 = "0.6"
|
||||
objc2-foundation = "0.3"
|
||||
once_cell = "1"
|
||||
ordered-float = "5"
|
||||
parking_lot = "0.12"
|
||||
path-ext = "0.1.1"
|
||||
pdf-extract = { git = "https://github.com/toeverything/pdf-extract", branch = "darksky/improve-font-decoding" }
|
||||
phf = { version = "0.11", features = ["macros"] }
|
||||
proptest = "1.3"
|
||||
proptest-derive = "0.5"
|
||||
pdf-extract = { git = "https://github.com/toeverything/pdf-extract" }
|
||||
rand = "0.9"
|
||||
rand_chacha = "0.9"
|
||||
rand_distr = "0.5"
|
||||
rayon = "1.10"
|
||||
readability = { version = "0.3.0", default-features = false }
|
||||
regex = "1.10"
|
||||
rubato = "0.16"
|
||||
screencapturekit = "0.3"
|
||||
serde = "1"
|
||||
serde_json = "1"
|
||||
sha3 = "0.10"
|
||||
smol_str = "0.3"
|
||||
sqlx = { version = "0.8", default-features = false, features = ["chrono", "macros", "migrate", "runtime-tokio", "sqlite", "tls-rustls"] }
|
||||
strum_macros = "0.27.0"
|
||||
symphonia = { version = "0.5", features = ["all", "opt-simd"] }
|
||||
@@ -97,9 +72,7 @@ uniffi = "0.29"
|
||||
url = { version = "2.5" }
|
||||
uuid = "1.8"
|
||||
v_htmlescape = "0.15"
|
||||
y-octo = { path = "./packages/common/y-octo/core" }
|
||||
y-sync = { version = "0.4" }
|
||||
yrs = "0.23.0"
|
||||
y-octo = { git = "https://github.com/y-crdt/y-octo.git", branch = "main" }
|
||||
|
||||
[profile.dev.package.sqlx-macros]
|
||||
opt-level = 3
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
"@blocksuite/affine-block-divider": "workspace:*",
|
||||
"@blocksuite/affine-block-edgeless-text": "workspace:*",
|
||||
"@blocksuite/affine-block-embed": "workspace:*",
|
||||
"@blocksuite/affine-block-embed-doc": "workspace:*",
|
||||
"@blocksuite/affine-block-frame": "workspace:*",
|
||||
"@blocksuite/affine-block-image": "workspace:*",
|
||||
"@blocksuite/affine-block-latex": "workspace:*",
|
||||
@@ -31,18 +30,14 @@
|
||||
"@blocksuite/affine-block-surface-ref": "workspace:*",
|
||||
"@blocksuite/affine-block-table": "workspace:*",
|
||||
"@blocksuite/affine-components": "workspace:*",
|
||||
"@blocksuite/affine-ext-loader": "workspace:*",
|
||||
"@blocksuite/affine-foundation": "workspace:*",
|
||||
"@blocksuite/affine-fragment-doc-title": "workspace:*",
|
||||
"@blocksuite/affine-fragment-frame-panel": "workspace:*",
|
||||
"@blocksuite/affine-fragment-outline": "workspace:*",
|
||||
"@blocksuite/affine-gfx-brush": "workspace:*",
|
||||
"@blocksuite/affine-gfx-connector": "workspace:*",
|
||||
"@blocksuite/affine-gfx-group": "workspace:*",
|
||||
"@blocksuite/affine-gfx-link": "workspace:*",
|
||||
"@blocksuite/affine-gfx-mindmap": "workspace:*",
|
||||
"@blocksuite/affine-gfx-note": "workspace:*",
|
||||
"@blocksuite/affine-gfx-pointer": "workspace:*",
|
||||
"@blocksuite/affine-gfx-shape": "workspace:*",
|
||||
"@blocksuite/affine-gfx-template": "workspace:*",
|
||||
"@blocksuite/affine-gfx-text": "workspace:*",
|
||||
@@ -59,16 +54,11 @@
|
||||
"@blocksuite/affine-widget-drag-handle": "workspace:*",
|
||||
"@blocksuite/affine-widget-edgeless-auto-connect": "workspace:*",
|
||||
"@blocksuite/affine-widget-edgeless-toolbar": "workspace:*",
|
||||
"@blocksuite/affine-widget-edgeless-zoom-toolbar": "workspace:*",
|
||||
"@blocksuite/affine-widget-frame-title": "workspace:*",
|
||||
"@blocksuite/affine-widget-keyboard-toolbar": "workspace:*",
|
||||
"@blocksuite/affine-widget-linked-doc": "workspace:*",
|
||||
"@blocksuite/affine-widget-page-dragging-area": "workspace:*",
|
||||
"@blocksuite/affine-widget-remote-selection": "workspace:*",
|
||||
"@blocksuite/affine-widget-scroll-anchoring": "workspace:*",
|
||||
"@blocksuite/affine-widget-slash-menu": "workspace:*",
|
||||
"@blocksuite/affine-widget-toolbar": "workspace:*",
|
||||
"@blocksuite/affine-widget-viewport-overlay": "workspace:*",
|
||||
"@blocksuite/data-view": "workspace:*",
|
||||
"@blocksuite/global": "workspace:*",
|
||||
"@blocksuite/std": "workspace:*",
|
||||
@@ -79,7 +69,6 @@
|
||||
"exports": {
|
||||
".": "./src/index.ts",
|
||||
"./effects": "./src/effects.ts",
|
||||
"./ext-loader": "./src/ext-loader/index.ts",
|
||||
"./std": "./src/std/index.ts",
|
||||
"./std/gfx": "./src/std/gfx.ts",
|
||||
"./std/inline": "./src/std/inline.ts",
|
||||
@@ -95,147 +84,57 @@
|
||||
"./global/lit": "./src/global/lit.ts",
|
||||
"./store": "./src/store/index.ts",
|
||||
"./store/test": "./src/store/test.ts",
|
||||
"./blocks/attachment": "./src/blocks/attachment/index.ts",
|
||||
"./blocks/attachment/store": "./src/blocks/attachment/store.ts",
|
||||
"./blocks/attachment/view": "./src/blocks/attachment/view.ts",
|
||||
"./blocks/bookmark": "./src/blocks/bookmark/index.ts",
|
||||
"./blocks/bookmark/store": "./src/blocks/bookmark/store.ts",
|
||||
"./blocks/bookmark/view": "./src/blocks/bookmark/view.ts",
|
||||
"./blocks/callout": "./src/blocks/callout/index.ts",
|
||||
"./blocks/callout/store": "./src/blocks/callout/store.ts",
|
||||
"./blocks/callout/view": "./src/blocks/callout/view.ts",
|
||||
"./blocks/code": "./src/blocks/code/index.ts",
|
||||
"./blocks/code/store": "./src/blocks/code/store.ts",
|
||||
"./blocks/code/view": "./src/blocks/code/view.ts",
|
||||
"./blocks/data-view": "./src/blocks/data-view/index.ts",
|
||||
"./blocks/data-view/store": "./src/blocks/data-view/store.ts",
|
||||
"./blocks/data-view/view": "./src/blocks/data-view/view.ts",
|
||||
"./blocks/database": "./src/blocks/database/index.ts",
|
||||
"./blocks/database/store": "./src/blocks/database/store.ts",
|
||||
"./blocks/database/view": "./src/blocks/database/view.ts",
|
||||
"./blocks/divider": "./src/blocks/divider/index.ts",
|
||||
"./blocks/divider/store": "./src/blocks/divider/store.ts",
|
||||
"./blocks/divider/view": "./src/blocks/divider/view.ts",
|
||||
"./blocks/edgeless-text": "./src/blocks/edgeless-text/index.ts",
|
||||
"./blocks/edgeless-text/store": "./src/blocks/edgeless-text/store.ts",
|
||||
"./blocks/edgeless-text/view": "./src/blocks/edgeless-text/view.ts",
|
||||
"./blocks/embed": "./src/blocks/embed/index.ts",
|
||||
"./blocks/embed/store": "./src/blocks/embed/store.ts",
|
||||
"./blocks/embed/view": "./src/blocks/embed/view.ts",
|
||||
"./blocks/embed-doc": "./src/blocks/embed-doc/index.ts",
|
||||
"./blocks/embed-doc/store": "./src/blocks/embed-doc/store.ts",
|
||||
"./blocks/embed-doc/view": "./src/blocks/embed-doc/view.ts",
|
||||
"./blocks/frame": "./src/blocks/frame/index.ts",
|
||||
"./blocks/frame/store": "./src/blocks/frame/store.ts",
|
||||
"./blocks/frame/view": "./src/blocks/frame/view.ts",
|
||||
"./blocks/image": "./src/blocks/image/index.ts",
|
||||
"./blocks/image/store": "./src/blocks/image/store.ts",
|
||||
"./blocks/image/view": "./src/blocks/image/view.ts",
|
||||
"./blocks/latex": "./src/blocks/latex/index.ts",
|
||||
"./blocks/latex/store": "./src/blocks/latex/store.ts",
|
||||
"./blocks/latex/view": "./src/blocks/latex/view.ts",
|
||||
"./blocks/list": "./src/blocks/list/index.ts",
|
||||
"./blocks/list/store": "./src/blocks/list/store.ts",
|
||||
"./blocks/list/view": "./src/blocks/list/view.ts",
|
||||
"./blocks/note": "./src/blocks/note/index.ts",
|
||||
"./blocks/note/store": "./src/blocks/note/store.ts",
|
||||
"./blocks/note/view": "./src/blocks/note/view.ts",
|
||||
"./blocks/paragraph": "./src/blocks/paragraph/index.ts",
|
||||
"./blocks/paragraph/store": "./src/blocks/paragraph/store.ts",
|
||||
"./blocks/paragraph/view": "./src/blocks/paragraph/view.ts",
|
||||
"./blocks/root": "./src/blocks/root/index.ts",
|
||||
"./blocks/root/store": "./src/blocks/root/store.ts",
|
||||
"./blocks/root/view": "./src/blocks/root/view.ts",
|
||||
"./blocks/surface": "./src/blocks/surface/index.ts",
|
||||
"./blocks/surface/store": "./src/blocks/surface/store.ts",
|
||||
"./blocks/surface/view": "./src/blocks/surface/view.ts",
|
||||
"./blocks/surface-ref": "./src/blocks/surface-ref/index.ts",
|
||||
"./blocks/surface-ref/store": "./src/blocks/surface-ref/store.ts",
|
||||
"./blocks/surface-ref/view": "./src/blocks/surface-ref/view.ts",
|
||||
"./blocks/table": "./src/blocks/table/index.ts",
|
||||
"./blocks/table/store": "./src/blocks/table/store.ts",
|
||||
"./blocks/table/view": "./src/blocks/table/view.ts",
|
||||
"./blocks/attachment": "./src/blocks/attachment.ts",
|
||||
"./blocks/bookmark": "./src/blocks/bookmark.ts",
|
||||
"./blocks/callout": "./src/blocks/callout.ts",
|
||||
"./blocks/code": "./src/blocks/code.ts",
|
||||
"./blocks/data-view": "./src/blocks/data-view.ts",
|
||||
"./blocks/database": "./src/blocks/database.ts",
|
||||
"./blocks/divider": "./src/blocks/divider.ts",
|
||||
"./blocks/edgeless-text": "./src/blocks/edgeless-text.ts",
|
||||
"./blocks/embed": "./src/blocks/embed.ts",
|
||||
"./blocks/frame": "./src/blocks/frame.ts",
|
||||
"./blocks/image": "./src/blocks/image.ts",
|
||||
"./blocks/latex": "./src/blocks/latex.ts",
|
||||
"./blocks/list": "./src/blocks/list.ts",
|
||||
"./blocks/note": "./src/blocks/note.ts",
|
||||
"./blocks/paragraph": "./src/blocks/paragraph.ts",
|
||||
"./blocks/root": "./src/blocks/root.ts",
|
||||
"./blocks/surface": "./src/blocks/surface.ts",
|
||||
"./blocks/surface-ref": "./src/blocks/surface-ref.ts",
|
||||
"./blocks/table": "./src/blocks/table.ts",
|
||||
"./data-view": "./src/data-view/index.ts",
|
||||
"./data-view/effects": "./src/data-view/effects.ts",
|
||||
"./inlines/link": "./src/inlines/link/index.ts",
|
||||
"./inlines/link/store": "./src/inlines/link/store.ts",
|
||||
"./inlines/link/view": "./src/inlines/link/view.ts",
|
||||
"./inlines/reference": "./src/inlines/reference/index.ts",
|
||||
"./inlines/reference/store": "./src/inlines/reference/store.ts",
|
||||
"./inlines/reference/view": "./src/inlines/reference/view.ts",
|
||||
"./inlines/preset": "./src/inlines/preset/index.ts",
|
||||
"./inlines/preset/store": "./src/inlines/preset/store.ts",
|
||||
"./inlines/preset/view": "./src/inlines/preset/view.ts",
|
||||
"./inlines/footnote": "./src/inlines/footnote/index.ts",
|
||||
"./inlines/footnote/view": "./src/inlines/footnote/view.ts",
|
||||
"./inlines/footnote/store": "./src/inlines/footnote/store.ts",
|
||||
"./inlines/latex": "./src/inlines/latex/index.ts",
|
||||
"./inlines/latex/store": "./src/inlines/latex/store.ts",
|
||||
"./inlines/latex/view": "./src/inlines/latex/view.ts",
|
||||
"./inlines/mention": "./src/inlines/mention/index.ts",
|
||||
"./inlines/mention/view": "./src/inlines/mention/view.ts",
|
||||
"./widgets/drag-handle": "./src/widgets/drag-handle/index.ts",
|
||||
"./widgets/drag-handle/view": "./src/widgets/drag-handle/view.ts",
|
||||
"./widgets/edgeless-auto-connect": "./src/widgets/edgeless-auto-connect/index.ts",
|
||||
"./widgets/edgeless-auto-connect/view": "./src/widgets/edgeless-auto-connect/view.ts",
|
||||
"./widgets/edgeless-toolbar": "./src/widgets/edgeless-toolbar/index.ts",
|
||||
"./widgets/edgeless-toolbar/view": "./src/widgets/edgeless-toolbar/view.ts",
|
||||
"./widgets/frame-title": "./src/widgets/frame-title/index.ts",
|
||||
"./widgets/frame-title/view": "./src/widgets/frame-title/view.ts",
|
||||
"./widgets/linked-doc": "./src/widgets/linked-doc/index.ts",
|
||||
"./widgets/linked-doc/view": "./src/widgets/linked-doc/view.ts",
|
||||
"./widgets/remote-selection": "./src/widgets/remote-selection/index.ts",
|
||||
"./widgets/remote-selection/view": "./src/widgets/remote-selection/view.ts",
|
||||
"./widgets/scroll-anchoring": "./src/widgets/scroll-anchoring/index.ts",
|
||||
"./widgets/scroll-anchoring/view": "./src/widgets/scroll-anchoring/view.ts",
|
||||
"./widgets/slash-menu": "./src/widgets/slash-menu/index.ts",
|
||||
"./widgets/slash-menu/view": "./src/widgets/slash-menu/view.ts",
|
||||
"./widgets/toolbar": "./src/widgets/toolbar/index.ts",
|
||||
"./widgets/toolbar/view": "./src/widgets/toolbar/view.ts",
|
||||
"./widgets/keyboard-toolbar": "./src/widgets/keyboard-toolbar/index.ts",
|
||||
"./widgets/keyboard-toolbar/view": "./src/widgets/keyboard-toolbar/view.ts",
|
||||
"./widgets/viewport-overlay": "./src/widgets/viewport-overlay/index.ts",
|
||||
"./widgets/viewport-overlay/view": "./src/widgets/viewport-overlay/view.ts",
|
||||
"./widgets/page-dragging-area": "./src/widgets/page-dragging-area/index.ts",
|
||||
"./widgets/page-dragging-area/view": "./src/widgets/page-dragging-area/view.ts",
|
||||
"./fragments/doc-title": "./src/fragments/doc-title/index.ts",
|
||||
"./fragments/doc-title/view": "./src/fragments/doc-title/view.ts",
|
||||
"./fragments/frame-panel": "./src/fragments/frame-panel/index.ts",
|
||||
"./fragments/frame-panel/view": "./src/fragments/frame-panel/view.ts",
|
||||
"./fragments/outline": "./src/fragments/outline/index.ts",
|
||||
"./fragments/outline/view": "./src/fragments/outline/view.ts",
|
||||
"./gfx/text": "./src/gfx/text/index.ts",
|
||||
"./gfx/text/store": "./src/gfx/text/store.ts",
|
||||
"./gfx/text/view": "./src/gfx/text/view.ts",
|
||||
"./gfx/brush": "./src/gfx/brush/index.ts",
|
||||
"./gfx/brush/store": "./src/gfx/brush/store.ts",
|
||||
"./gfx/brush/view": "./src/gfx/brush/view.ts",
|
||||
"./gfx/pointer": "./src/gfx/pointer/index.ts",
|
||||
"./gfx/pointer/view": "./src/gfx/pointer/view.ts",
|
||||
"./gfx/shape": "./src/gfx/shape/index.ts",
|
||||
"./gfx/shape/store": "./src/gfx/shape/store.ts",
|
||||
"./gfx/shape/view": "./src/gfx/shape/view.ts",
|
||||
"./gfx/link": "./src/gfx/link/index.ts",
|
||||
"./gfx/link/view": "./src/gfx/link/view.ts",
|
||||
"./gfx/note": "./src/gfx/note/index.ts",
|
||||
"./gfx/note/view": "./src/gfx/note/view.ts",
|
||||
"./gfx/mindmap": "./src/gfx/mindmap/index.ts",
|
||||
"./gfx/mindmap/store": "./src/gfx/mindmap/store.ts",
|
||||
"./gfx/mindmap/view": "./src/gfx/mindmap/view.ts",
|
||||
"./gfx/connector": "./src/gfx/connector/index.ts",
|
||||
"./gfx/connector/store": "./src/gfx/connector/store.ts",
|
||||
"./gfx/connector/view": "./src/gfx/connector/view.ts",
|
||||
"./gfx/group": "./src/gfx/group/index.ts",
|
||||
"./gfx/group/store": "./src/gfx/group/store.ts",
|
||||
"./gfx/group/view": "./src/gfx/group/view.ts",
|
||||
"./gfx/template": "./src/gfx/template/index.ts",
|
||||
"./gfx/template/view": "./src/gfx/template/view.ts",
|
||||
"./inlines/link": "./src/inlines/link.ts",
|
||||
"./inlines/reference": "./src/inlines/reference.ts",
|
||||
"./inlines/preset": "./src/inlines/preset.ts",
|
||||
"./inlines/footnote": "./src/inlines/footnote.ts",
|
||||
"./inlines/latex": "./src/inlines/latex.ts",
|
||||
"./inlines/mention": "./src/inlines/mention.ts",
|
||||
"./widgets/drag-handle": "./src/widgets/drag-handle.ts",
|
||||
"./widgets/edgeless-auto-connect": "./src/widgets/edgeless-auto-connect.ts",
|
||||
"./widgets/edgeless-toolbar": "./src/widgets/edgeless-toolbar.ts",
|
||||
"./widgets/frame-title": "./src/widgets/frame-title.ts",
|
||||
"./widgets/remote-selection": "./src/widgets/remote-selection.ts",
|
||||
"./widgets/scroll-anchoring": "./src/widgets/scroll-anchoring.ts",
|
||||
"./widgets/slash-menu": "./src/widgets/slash-menu.ts",
|
||||
"./widgets/toolbar": "./src/widgets/toolbar.ts",
|
||||
"./fragments/doc-title": "./src/fragments/doc-title.ts",
|
||||
"./fragments/frame-panel": "./src/fragments/frame-panel.ts",
|
||||
"./fragments/outline": "./src/fragments/outline.ts",
|
||||
"./gfx/text": "./src/gfx/text.ts",
|
||||
"./gfx/brush": "./src/gfx/brush.ts",
|
||||
"./gfx/shape": "./src/gfx/shape.ts",
|
||||
"./gfx/note": "./src/gfx/note.ts",
|
||||
"./gfx/mindmap": "./src/gfx/mindmap.ts",
|
||||
"./gfx/connector": "./src/gfx/connector.ts",
|
||||
"./gfx/group": "./src/gfx/group.ts",
|
||||
"./gfx/template": "./src/gfx/template.ts",
|
||||
"./gfx/turbo-renderer": "./src/gfx/turbo-renderer.ts",
|
||||
"./components/block-selection": "./src/components/block-selection.ts",
|
||||
"./components/block-zero-width": "./src/components/block-zero-width.ts",
|
||||
"./components/caption": "./src/components/caption.ts",
|
||||
"./components/card-style-dropdown-menu": "./src/components/card-style-dropdown-menu.ts",
|
||||
"./components/citation": "./src/components/citation.ts",
|
||||
"./components/color-picker": "./src/components/color-picker.ts",
|
||||
"./components/context-menu": "./src/components/context-menu.ts",
|
||||
"./components/date-picker": "./src/components/date-picker.ts",
|
||||
@@ -272,8 +171,8 @@
|
||||
"./schemas": "./src/schemas.ts",
|
||||
"./model": "./src/model/index.ts",
|
||||
"./sync": "./src/sync/index.ts",
|
||||
"./extensions/store": "./src/extensions/store.ts",
|
||||
"./extensions/view": "./src/extensions/view.ts"
|
||||
"./adapters": "./src/adapters/index.ts",
|
||||
"./extensions": "./src/extensions/index.ts"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
@@ -284,6 +183,6 @@
|
||||
"version": "0.21.0",
|
||||
"devDependencies": {
|
||||
"@vanilla-extract/vite-plugin": "^5.0.0",
|
||||
"vitest": "3.1.2"
|
||||
"vitest": "3.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ describe('snapshot to html', () => {
|
||||
};
|
||||
|
||||
const html = template(
|
||||
`<pre><code class="code-python">import this</code></pre>`
|
||||
`<pre class="shiki light-plus" style="background-color:#FFFFFF;color:#000000" tabindex="0"><code><span class="line"><span style="color:#AF00DB">import</span><span style="color:#000000"> this</span></span></code></pre>`
|
||||
);
|
||||
|
||||
const htmlAdapter = new HtmlAdapter(createJob(), provider);
|
||||
@@ -191,7 +191,7 @@ describe('snapshot to html', () => {
|
||||
};
|
||||
|
||||
const html = template(
|
||||
`<pre><code class="code-PYTHON">import this</code></pre>`
|
||||
`<pre class="shiki light-plus" style="background-color:#FFFFFF;color:#000000" tabindex="0"><code><span class="line"><span>import this</span></span></code></pre>`
|
||||
);
|
||||
|
||||
const htmlAdapter = new HtmlAdapter(createJob(), provider);
|
||||
@@ -257,7 +257,7 @@ describe('snapshot to html', () => {
|
||||
};
|
||||
|
||||
const html = template(
|
||||
`<pre><code class="code-unknown">import this</code></pre>`
|
||||
`<pre class="shiki light-plus" style="background-color:#FFFFFF;color:#000000" tabindex="0"><code><span class="line"><span>import this</span></span></code></pre>`
|
||||
);
|
||||
|
||||
const htmlAdapter = new HtmlAdapter(createJob(), provider);
|
||||
|
||||
@@ -2396,9 +2396,6 @@ World!
|
||||
reference: {
|
||||
type: 'url',
|
||||
url: 'https://www.example.com',
|
||||
favicon: 'https://www.example.com/favicon.ico',
|
||||
title: 'Example Domain',
|
||||
description: 'Example Domain',
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -2440,122 +2437,7 @@ World!
|
||||
};
|
||||
|
||||
const markdown =
|
||||
'aaa[^1][^2][^3]\n\n[^1]: {"type":"url","url":"https%3A%2F%2Fwww.example.com","favicon":"https%3A%2F%2Fwww.example.com%2Ffavicon.ico","title":"Example Domain","description":"Example Domain"}\n\n[^2]: {"type":"doc","docId":"deadbeef"}\n\n[^3]: {"type":"attachment","blobId":"abcdefg","fileName":"test.txt","fileType":"text/plain"}\n';
|
||||
|
||||
const mdAdapter = new MarkdownAdapter(createJob(), provider);
|
||||
const target = await mdAdapter.fromBlockSnapshot({
|
||||
snapshot: blockSnapshot,
|
||||
});
|
||||
expect(target.file).toBe(markdown);
|
||||
});
|
||||
|
||||
test('callout', async () => {
|
||||
const blockSnapshot: BlockSnapshot = {
|
||||
type: 'block',
|
||||
id: 'block:vu6SK6WJpW',
|
||||
flavour: 'affine:page',
|
||||
props: {
|
||||
title: {
|
||||
'$blocksuite:internal:text$': true,
|
||||
delta: [],
|
||||
},
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'block:Tk4gSPocAt',
|
||||
flavour: 'affine:surface',
|
||||
props: {
|
||||
elements: {},
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
type: 'block',
|
||||
id: 'block:WfnS5ZDCJT',
|
||||
flavour: 'affine:note',
|
||||
props: {
|
||||
xywh: '[0,0,800,95]',
|
||||
background: DefaultTheme.noteBackgrounColor,
|
||||
index: 'a0',
|
||||
hidden: false,
|
||||
displayMode: NoteDisplayMode.DocAndEdgeless,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'block:8hOLxad5Fv',
|
||||
flavour: 'affine:callout',
|
||||
props: {
|
||||
emoji: '💡',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'block:8hOLxad5Fv',
|
||||
flavour: 'affine:paragraph',
|
||||
props: {
|
||||
type: 'text',
|
||||
text: {
|
||||
'$blocksuite:internal:text$': true,
|
||||
delta: [{ insert: 'First callout' }],
|
||||
},
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'block',
|
||||
id: 'block:8hOLxadvdv',
|
||||
flavour: 'affine:callout',
|
||||
props: {
|
||||
emoji: '',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'block:8hOLxad5Fv',
|
||||
flavour: 'affine:paragraph',
|
||||
props: {
|
||||
type: 'text',
|
||||
text: {
|
||||
'$blocksuite:internal:text$': true,
|
||||
delta: [{ insert: 'Second callout without emoji' }],
|
||||
},
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'block',
|
||||
id: 'block:8hOLxbfdb',
|
||||
flavour: 'affine:paragraph',
|
||||
props: {
|
||||
type: 'quote',
|
||||
text: {
|
||||
'$blocksuite:internal:text$': true,
|
||||
delta: [{ insert: 'This is a regular blockquote' }],
|
||||
},
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const markdown = `> \\[!💡]
|
||||
>
|
||||
> First callout
|
||||
|
||||
> \\[!]
|
||||
>
|
||||
> Second callout without emoji
|
||||
|
||||
> This is a regular blockquote
|
||||
`;
|
||||
'aaa[^1][^2][^3]\n\n[^1]: {"type":"url","url":"https%3A%2F%2Fwww.example.com"}\n\n[^2]: {"type":"doc","docId":"deadbeef"}\n\n[^3]: {"type":"attachment","blobId":"abcdefg","fileName":"test.txt","fileType":"text/plain"}\n';
|
||||
|
||||
const mdAdapter = new MarkdownAdapter(createJob(), provider);
|
||||
const target = await mdAdapter.fromBlockSnapshot({
|
||||
@@ -2566,262 +2448,203 @@ World!
|
||||
});
|
||||
|
||||
describe('markdown to snapshot', () => {
|
||||
describe('code', () => {
|
||||
test('markdown code block', async () => {
|
||||
const markdown = '```python\nimport this\n```\n';
|
||||
test('code', async () => {
|
||||
const markdown = '```python\nimport this\n```\n';
|
||||
|
||||
const blockSnapshot: BlockSnapshot = {
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[0]',
|
||||
flavour: 'affine:note',
|
||||
props: {
|
||||
xywh: '[0,0,800,95]',
|
||||
background: DefaultTheme.noteBackgrounColor,
|
||||
index: 'a0',
|
||||
hidden: false,
|
||||
displayMode: NoteDisplayMode.DocAndEdgeless,
|
||||
const blockSnapshot: BlockSnapshot = {
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[0]',
|
||||
flavour: 'affine:note',
|
||||
props: {
|
||||
xywh: '[0,0,800,95]',
|
||||
background: DefaultTheme.noteBackgrounColor,
|
||||
index: 'a0',
|
||||
hidden: false,
|
||||
displayMode: NoteDisplayMode.DocAndEdgeless,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[1]',
|
||||
flavour: 'affine:code',
|
||||
props: {
|
||||
language: 'python',
|
||||
wrap: false,
|
||||
text: {
|
||||
'$blocksuite:internal:text$': true,
|
||||
delta: [
|
||||
{
|
||||
insert: 'import this',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[1]',
|
||||
flavour: 'affine:code',
|
||||
props: {
|
||||
language: 'python',
|
||||
wrap: false,
|
||||
text: {
|
||||
'$blocksuite:internal:text$': true,
|
||||
delta: [
|
||||
{
|
||||
insert: 'import this',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
};
|
||||
],
|
||||
};
|
||||
|
||||
const mdAdapter = new MarkdownAdapter(createJob(), provider);
|
||||
const rawBlockSnapshot = await mdAdapter.toBlockSnapshot({
|
||||
file: markdown,
|
||||
});
|
||||
expect(nanoidReplacement(rawBlockSnapshot)).toEqual(blockSnapshot);
|
||||
const mdAdapter = new MarkdownAdapter(createJob(), provider);
|
||||
const rawBlockSnapshot = await mdAdapter.toBlockSnapshot({
|
||||
file: markdown,
|
||||
});
|
||||
expect(nanoidReplacement(rawBlockSnapshot)).toEqual(blockSnapshot);
|
||||
});
|
||||
|
||||
test('code with indentation 1 - slice', async () => {
|
||||
const markdown = '```python\n import this\n```';
|
||||
test('code with indentation 1 - slice', async () => {
|
||||
const markdown = '```python\n import this\n```';
|
||||
|
||||
const sliceSnapshot: SliceSnapshot = {
|
||||
type: 'slice',
|
||||
content: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[0]',
|
||||
flavour: 'affine:note',
|
||||
props: {
|
||||
xywh: '[0,0,800,95]',
|
||||
background: DefaultTheme.noteBackgrounColor,
|
||||
index: 'a0',
|
||||
hidden: false,
|
||||
displayMode: 'both',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[1]',
|
||||
flavour: 'affine:code',
|
||||
props: {
|
||||
language: 'python',
|
||||
wrap: false,
|
||||
text: {
|
||||
'$blocksuite:internal:text$': true,
|
||||
delta: [
|
||||
{
|
||||
insert: ' import this',
|
||||
},
|
||||
],
|
||||
},
|
||||
const sliceSnapshot: SliceSnapshot = {
|
||||
type: 'slice',
|
||||
content: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[0]',
|
||||
flavour: 'affine:note',
|
||||
props: {
|
||||
xywh: '[0,0,800,95]',
|
||||
background: DefaultTheme.noteBackgrounColor,
|
||||
index: 'a0',
|
||||
hidden: false,
|
||||
displayMode: 'both',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[1]',
|
||||
flavour: 'affine:code',
|
||||
props: {
|
||||
language: 'python',
|
||||
wrap: false,
|
||||
text: {
|
||||
'$blocksuite:internal:text$': true,
|
||||
delta: [
|
||||
{
|
||||
insert: ' import this',
|
||||
},
|
||||
],
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
workspaceId: '',
|
||||
pageId: '',
|
||||
};
|
||||
|
||||
const mdAdapter = new MarkdownAdapter(createJob(), provider);
|
||||
const rawSliceSnapshot = await mdAdapter.toSliceSnapshot({
|
||||
file: markdown,
|
||||
workspaceId: '',
|
||||
pageId: '',
|
||||
});
|
||||
expect(nanoidReplacement(rawSliceSnapshot!)).toEqual(sliceSnapshot);
|
||||
});
|
||||
|
||||
test('code with indentation 2 - slice', async () => {
|
||||
const markdown = '````python\n```python\n import this\n```\n````';
|
||||
|
||||
const sliceSnapshot: SliceSnapshot = {
|
||||
type: 'slice',
|
||||
content: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[0]',
|
||||
flavour: 'affine:note',
|
||||
props: {
|
||||
xywh: '[0,0,800,95]',
|
||||
background: DefaultTheme.noteBackgrounColor,
|
||||
index: 'a0',
|
||||
hidden: false,
|
||||
displayMode: 'both',
|
||||
children: [],
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[1]',
|
||||
flavour: 'affine:code',
|
||||
props: {
|
||||
language: 'python',
|
||||
wrap: false,
|
||||
text: {
|
||||
'$blocksuite:internal:text$': true,
|
||||
delta: [
|
||||
{
|
||||
insert: '```python\n import this\n```',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
workspaceId: '',
|
||||
pageId: '',
|
||||
};
|
||||
|
||||
const mdAdapter = new MarkdownAdapter(createJob(), provider);
|
||||
const rawSliceSnapshot = await mdAdapter.toSliceSnapshot({
|
||||
file: markdown,
|
||||
workspaceId: '',
|
||||
pageId: '',
|
||||
});
|
||||
expect(nanoidReplacement(rawSliceSnapshot!)).toEqual(sliceSnapshot);
|
||||
});
|
||||
|
||||
test('code with indentation 3 - slice', async () => {
|
||||
const markdown = '~~~~python\n````python\n import this\n````\n~~~~';
|
||||
|
||||
const sliceSnapshot: SliceSnapshot = {
|
||||
type: 'slice',
|
||||
content: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[0]',
|
||||
flavour: 'affine:note',
|
||||
props: {
|
||||
xywh: '[0,0,800,95]',
|
||||
background: DefaultTheme.noteBackgrounColor,
|
||||
index: 'a0',
|
||||
hidden: false,
|
||||
displayMode: 'both',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[1]',
|
||||
flavour: 'affine:code',
|
||||
props: {
|
||||
language: 'python',
|
||||
wrap: false,
|
||||
text: {
|
||||
'$blocksuite:internal:text$': true,
|
||||
delta: [
|
||||
{
|
||||
insert: '````python\n import this\n````',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
workspaceId: '',
|
||||
pageId: '',
|
||||
};
|
||||
|
||||
const mdAdapter = new MarkdownAdapter(createJob(), provider);
|
||||
const rawSliceSnapshot = await mdAdapter.toSliceSnapshot({
|
||||
file: markdown,
|
||||
workspaceId: '',
|
||||
pageId: '',
|
||||
});
|
||||
expect(nanoidReplacement(rawSliceSnapshot!)).toEqual(sliceSnapshot);
|
||||
});
|
||||
|
||||
test('html block import as code block', async () => {
|
||||
const markdown = `<div class="container">
|
||||
<header>
|
||||
<h1>Welcome to My Page</h1>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="#home">Home</a></li>
|
||||
<li><a href="#about">About</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
<main>
|
||||
<p>This is a sample HTML content</p>
|
||||
</main>
|
||||
</div>`;
|
||||
|
||||
const blockSnapshot: BlockSnapshot = {
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[0]',
|
||||
flavour: 'affine:note',
|
||||
props: {
|
||||
xywh: '[0,0,800,95]',
|
||||
background: DefaultTheme.noteBackgrounColor,
|
||||
index: 'a0',
|
||||
hidden: false,
|
||||
displayMode: NoteDisplayMode.DocAndEdgeless,
|
||||
],
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[1]',
|
||||
flavour: 'affine:code',
|
||||
props: {
|
||||
language: 'html',
|
||||
wrap: false,
|
||||
text: {
|
||||
'$blocksuite:internal:text$': true,
|
||||
delta: [
|
||||
{
|
||||
insert:
|
||||
'<div class="container">\n <header>\n <h1>Welcome to My Page</h1>\n <nav>\n <ul>\n <li><a href="#home">Home</a></li>\n <li><a href="#about">About</a></li>\n </ul>\n </nav>\n </header>\n <main>\n <p>This is a sample HTML content</p>\n </main>\n</div>',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
};
|
||||
],
|
||||
workspaceId: '',
|
||||
pageId: '',
|
||||
};
|
||||
|
||||
const mdAdapter = new MarkdownAdapter(createJob(), provider);
|
||||
const rawBlockSnapshot = await mdAdapter.toBlockSnapshot({
|
||||
file: markdown,
|
||||
});
|
||||
expect(nanoidReplacement(rawBlockSnapshot)).toEqual(blockSnapshot);
|
||||
const mdAdapter = new MarkdownAdapter(createJob(), provider);
|
||||
const rawSliceSnapshot = await mdAdapter.toSliceSnapshot({
|
||||
file: markdown,
|
||||
workspaceId: '',
|
||||
pageId: '',
|
||||
});
|
||||
expect(nanoidReplacement(rawSliceSnapshot!)).toEqual(sliceSnapshot);
|
||||
});
|
||||
|
||||
test('code with indentation 2 - slice', async () => {
|
||||
const markdown = '````python\n```python\n import this\n```\n````';
|
||||
|
||||
const sliceSnapshot: SliceSnapshot = {
|
||||
type: 'slice',
|
||||
content: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[0]',
|
||||
flavour: 'affine:note',
|
||||
props: {
|
||||
xywh: '[0,0,800,95]',
|
||||
background: DefaultTheme.noteBackgrounColor,
|
||||
index: 'a0',
|
||||
hidden: false,
|
||||
displayMode: 'both',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[1]',
|
||||
flavour: 'affine:code',
|
||||
props: {
|
||||
language: 'python',
|
||||
wrap: false,
|
||||
text: {
|
||||
'$blocksuite:internal:text$': true,
|
||||
delta: [
|
||||
{
|
||||
insert: '```python\n import this\n```',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
workspaceId: '',
|
||||
pageId: '',
|
||||
};
|
||||
|
||||
const mdAdapter = new MarkdownAdapter(createJob(), provider);
|
||||
const rawSliceSnapshot = await mdAdapter.toSliceSnapshot({
|
||||
file: markdown,
|
||||
workspaceId: '',
|
||||
pageId: '',
|
||||
});
|
||||
expect(nanoidReplacement(rawSliceSnapshot!)).toEqual(sliceSnapshot);
|
||||
});
|
||||
|
||||
test('code with indentation 3 - slice', async () => {
|
||||
const markdown = '~~~~python\n````python\n import this\n````\n~~~~';
|
||||
|
||||
const sliceSnapshot: SliceSnapshot = {
|
||||
type: 'slice',
|
||||
content: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[0]',
|
||||
flavour: 'affine:note',
|
||||
props: {
|
||||
xywh: '[0,0,800,95]',
|
||||
background: DefaultTheme.noteBackgrounColor,
|
||||
index: 'a0',
|
||||
hidden: false,
|
||||
displayMode: 'both',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[1]',
|
||||
flavour: 'affine:code',
|
||||
props: {
|
||||
language: 'python',
|
||||
wrap: false,
|
||||
text: {
|
||||
'$blocksuite:internal:text$': true,
|
||||
delta: [
|
||||
{
|
||||
insert: '````python\n import this\n````',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
workspaceId: '',
|
||||
pageId: '',
|
||||
};
|
||||
|
||||
const mdAdapter = new MarkdownAdapter(createJob(), provider);
|
||||
const rawSliceSnapshot = await mdAdapter.toSliceSnapshot({
|
||||
file: markdown,
|
||||
workspaceId: '',
|
||||
pageId: '',
|
||||
});
|
||||
expect(nanoidReplacement(rawSliceSnapshot!)).toEqual(sliceSnapshot);
|
||||
});
|
||||
|
||||
test('paragraph', async () => {
|
||||
@@ -3703,7 +3526,7 @@ bbb
|
||||
props: {
|
||||
xywh: '[0,0,800,95]',
|
||||
background: {
|
||||
dark: '#252525',
|
||||
dark: '#000000',
|
||||
light: '#ffffff',
|
||||
},
|
||||
index: 'a0',
|
||||
@@ -3815,6 +3638,48 @@ bbb
|
||||
expect(nanoidReplacement(rawBlockSnapshot)).toEqual(blockSnapshot);
|
||||
});
|
||||
|
||||
test('html tag', async () => {
|
||||
const markdown = `<aaa>\n`;
|
||||
|
||||
const blockSnapshot: BlockSnapshot = {
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[0]',
|
||||
flavour: 'affine:note',
|
||||
props: {
|
||||
xywh: '[0,0,800,95]',
|
||||
background: DefaultTheme.noteBackgrounColor,
|
||||
index: 'a0',
|
||||
hidden: false,
|
||||
displayMode: NoteDisplayMode.DocAndEdgeless,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[1]',
|
||||
flavour: 'affine:paragraph',
|
||||
props: {
|
||||
text: {
|
||||
'$blocksuite:internal:text$': true,
|
||||
delta: [
|
||||
{
|
||||
insert: '<aaa>',
|
||||
},
|
||||
],
|
||||
},
|
||||
type: 'text',
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const mdAdapter = new MarkdownAdapter(createJob(), provider);
|
||||
const rawBlockSnapshot = await mdAdapter.toBlockSnapshot({
|
||||
file: markdown,
|
||||
});
|
||||
expect(nanoidReplacement(rawBlockSnapshot)).toEqual(blockSnapshot);
|
||||
});
|
||||
|
||||
describe('inline latex', () => {
|
||||
test.each([
|
||||
['dollar sign syntax', 'inline $E=mc^2$ latex\n'],
|
||||
@@ -4146,12 +4011,11 @@ hhh
|
||||
expect(nanoidReplacement(rawBlockSnapshot)).toEqual(blockSnapshot);
|
||||
});
|
||||
|
||||
describe('footnote', () => {
|
||||
const url = 'https://www.example.com';
|
||||
const favicon = 'https://www.example.com/favicon.ico';
|
||||
const title = 'Example Domain';
|
||||
const description = 'Example Domain';
|
||||
const blockSnapshot = {
|
||||
test('without footnote middleware', async () => {
|
||||
const markdown =
|
||||
'aaa[^1][^2][^3]\n\n[^1]: {"type":"url","url":"https%3A%2F%2Fwww.example.com"}\n\n[^2]: {"type":"doc","docId":"deadbeef"}\n\n[^3]: {"type":"attachment","blobId":"abcdefg","fileName":"test.txt","fileType":"text/plain"}\n';
|
||||
|
||||
const blockSnapshot: BlockSnapshot = {
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[0]',
|
||||
flavour: 'affine:note',
|
||||
@@ -4182,10 +4046,7 @@ hhh
|
||||
label: '1',
|
||||
reference: {
|
||||
type: 'url',
|
||||
url,
|
||||
favicon,
|
||||
title,
|
||||
description,
|
||||
url: 'https://www.example.com',
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -4224,135 +4085,10 @@ hhh
|
||||
],
|
||||
};
|
||||
|
||||
test('with encoded url and favicon', async () => {
|
||||
const encodedUrl = encodeURIComponent(url);
|
||||
const encodedFavicon = encodeURIComponent(favicon);
|
||||
const markdown = `aaa[^1][^2][^3]\n\n[^1]: {"type":"url","url":"${encodedUrl}","favicon":"${encodedFavicon}","title":"${title}","description":"${description}"}\n\n[^2]: {"type":"doc","docId":"deadbeef"}\n\n[^3]: {"type":"attachment","blobId":"abcdefg","fileName":"test.txt","fileType":"text/plain"}\n`;
|
||||
|
||||
const mdAdapter = new MarkdownAdapter(createJob(), provider);
|
||||
const rawBlockSnapshot = await mdAdapter.toBlockSnapshot({
|
||||
file: markdown,
|
||||
});
|
||||
expect(nanoidReplacement(rawBlockSnapshot)).toEqual(blockSnapshot);
|
||||
});
|
||||
|
||||
test('with unencoded url and favicon', async () => {
|
||||
const markdown = `aaa[^1][^2][^3]\n\n[^1]: {"type":"url","url":"${url}","favicon":"${favicon}","title":"${title}","description":"${description}"}\n\n[^2]: {"type":"doc","docId":"deadbeef"}\n\n[^3]: {"type":"attachment","blobId":"abcdefg","fileName":"test.txt","fileType":"text/plain"}\n`;
|
||||
|
||||
const mdAdapter = new MarkdownAdapter(createJob(), provider);
|
||||
const rawBlockSnapshot = await mdAdapter.toBlockSnapshot({
|
||||
file: markdown,
|
||||
});
|
||||
expect(nanoidReplacement(rawBlockSnapshot)).toEqual(blockSnapshot);
|
||||
});
|
||||
});
|
||||
|
||||
test('should not wrap url with angle brackets if it is not a url', async () => {
|
||||
const markdown = 'prompt: How many people will live in the world in 2040?';
|
||||
const sliceSnapshot: SliceSnapshot = {
|
||||
type: 'slice',
|
||||
content: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[0]',
|
||||
flavour: 'affine:note',
|
||||
props: {
|
||||
xywh: '[0,0,800,95]',
|
||||
background: DefaultTheme.noteBackgrounColor,
|
||||
index: 'a0',
|
||||
hidden: false,
|
||||
displayMode: NoteDisplayMode.DocAndEdgeless,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[1]',
|
||||
flavour: 'affine:paragraph',
|
||||
props: {
|
||||
type: 'text',
|
||||
text: {
|
||||
'$blocksuite:internal:text$': true,
|
||||
delta: [
|
||||
{
|
||||
insert:
|
||||
'prompt: How many people will live in the world in 2040?',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
workspaceId: '',
|
||||
pageId: '',
|
||||
};
|
||||
|
||||
const mdAdapter = new MarkdownAdapter(createJob(), provider);
|
||||
const rawSliceSnapshot = await mdAdapter.toSliceSnapshot({
|
||||
const rawBlockSnapshot = await mdAdapter.toBlockSnapshot({
|
||||
file: markdown,
|
||||
workspaceId: '',
|
||||
pageId: '',
|
||||
});
|
||||
expect(nanoidReplacement(rawSliceSnapshot!)).toEqual(sliceSnapshot);
|
||||
});
|
||||
|
||||
describe('callout', () => {
|
||||
const calloutBlockSnapshot: BlockSnapshot = {
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[0]',
|
||||
flavour: 'affine:note',
|
||||
props: {
|
||||
xywh: '[0,0,800,95]',
|
||||
background: DefaultTheme.noteBackgrounColor,
|
||||
index: 'a0',
|
||||
hidden: false,
|
||||
displayMode: NoteDisplayMode.DocAndEdgeless,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[1]',
|
||||
flavour: 'affine:callout',
|
||||
props: {
|
||||
emoji: '💬',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'block',
|
||||
id: 'matchesReplaceMap[2]',
|
||||
flavour: 'affine:paragraph',
|
||||
props: {
|
||||
type: 'text',
|
||||
text: {
|
||||
'$blocksuite:internal:text$': true,
|
||||
delta: [{ insert: 'This is a callout' }],
|
||||
},
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
test('callout start with escape character', async () => {
|
||||
const markdown = '> \\[!💬]\n> This is a callout';
|
||||
const mdAdapter = new MarkdownAdapter(createJob(), provider);
|
||||
const rawBlockSnapshot = await mdAdapter.toBlockSnapshot({
|
||||
file: markdown,
|
||||
});
|
||||
expect(nanoidReplacement(rawBlockSnapshot)).toEqual(calloutBlockSnapshot);
|
||||
});
|
||||
|
||||
test('callout start without escape character', async () => {
|
||||
const markdown = '> [!💬]\n> This is a callout';
|
||||
const mdAdapter = new MarkdownAdapter(createJob(), provider);
|
||||
const rawBlockSnapshot = await mdAdapter.toBlockSnapshot({
|
||||
file: markdown,
|
||||
});
|
||||
expect(nanoidReplacement(rawBlockSnapshot)).toEqual(calloutBlockSnapshot);
|
||||
});
|
||||
expect(nanoidReplacement(rawBlockSnapshot)).toEqual(blockSnapshot);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { defaultImageProxyMiddleware } from '@blocksuite/affine-shared/adapters';
|
||||
import { defaultImageProxyMiddleware } from '@blocksuite/affine-block-image';
|
||||
import { SpecProvider } from '@blocksuite/affine-shared/utils';
|
||||
import {
|
||||
Schema,
|
||||
Transformer,
|
||||
@@ -7,7 +8,6 @@ import {
|
||||
import { TestWorkspace } from '@blocksuite/store/test';
|
||||
|
||||
import { AffineSchemas } from '../../schemas.js';
|
||||
import { testStoreExtensions } from './store.js';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
@@ -27,7 +27,7 @@ export function createJob(middlewares?: TransformerMiddleware[]) {
|
||||
testMiddlewares.push(defaultImageProxyMiddleware);
|
||||
const schema = new Schema().register(AffineSchemas);
|
||||
const docCollection = new TestWorkspace();
|
||||
docCollection.storeExtensions = testStoreExtensions;
|
||||
docCollection.storeExtensions = SpecProvider._.getSpec('store').value;
|
||||
docCollection.meta.initialize();
|
||||
return new Transformer({
|
||||
schema,
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
import { SpecProvider } from '@blocksuite/affine-shared/utils';
|
||||
import { Container } from '@blocksuite/global/di';
|
||||
|
||||
import { testStoreExtensions } from './store';
|
||||
import {
|
||||
registerBlockSpecs,
|
||||
registerStoreSpecs,
|
||||
} from '../../extensions/register';
|
||||
|
||||
registerStoreSpecs();
|
||||
registerBlockSpecs();
|
||||
|
||||
export function getProvider() {
|
||||
const container = new Container();
|
||||
const exts = testStoreExtensions;
|
||||
const exts = SpecProvider._.getSpec('store').value;
|
||||
exts.forEach(ext => {
|
||||
ext.setup(container);
|
||||
});
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import { StoreExtensionManager } from '@blocksuite/affine-ext-loader';
|
||||
|
||||
import { getInternalStoreExtensions } from '../../extensions/store';
|
||||
|
||||
const manager = new StoreExtensionManager(getInternalStoreExtensions());
|
||||
|
||||
export const testStoreExtensions = manager.get('store');
|
||||
69
blocksuite/affine/all/src/adapters/extension.ts
Normal file
69
blocksuite/affine/all/src/adapters/extension.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import {
|
||||
HtmlInlineToDeltaAdapterExtensions,
|
||||
InlineDeltaToHtmlAdapterExtensions,
|
||||
InlineDeltaToMarkdownAdapterExtensions,
|
||||
InlineDeltaToPlainTextAdapterExtensions,
|
||||
MarkdownInlineToDeltaAdapterExtensions,
|
||||
NotionHtmlInlineToDeltaAdapterExtensions,
|
||||
} from '@blocksuite/affine-inline-preset';
|
||||
import {
|
||||
AttachmentAdapterFactoryExtension,
|
||||
HtmlAdapterFactoryExtension,
|
||||
ImageAdapterFactoryExtension,
|
||||
MarkdownAdapterFactoryExtension,
|
||||
MixTextAdapterFactoryExtension,
|
||||
NotionHtmlAdapterFactoryExtension,
|
||||
NotionTextAdapterFactoryExtension,
|
||||
PlainTextAdapterFactoryExtension,
|
||||
} from '@blocksuite/affine-shared/adapters';
|
||||
import type { ExtensionType } from '@blocksuite/store';
|
||||
|
||||
import { defaultBlockHtmlAdapterMatchers } from './html/block-matcher';
|
||||
import { defaultBlockMarkdownAdapterMatchers } from './markdown/block-matcher';
|
||||
import { defaultMarkdownPreprocessors } from './markdown/preprocessor';
|
||||
import { defaultBlockNotionHtmlAdapterMatchers } from './notion-html/block-matcher';
|
||||
import { defaultBlockPlainTextAdapterMatchers } from './plain-text/block-matcher';
|
||||
|
||||
export function getAdapterFactoryExtensions(): ExtensionType[] {
|
||||
return [
|
||||
AttachmentAdapterFactoryExtension,
|
||||
ImageAdapterFactoryExtension,
|
||||
MarkdownAdapterFactoryExtension,
|
||||
PlainTextAdapterFactoryExtension,
|
||||
HtmlAdapterFactoryExtension,
|
||||
NotionTextAdapterFactoryExtension,
|
||||
NotionHtmlAdapterFactoryExtension,
|
||||
MixTextAdapterFactoryExtension,
|
||||
];
|
||||
}
|
||||
|
||||
export function getHtmlAdapterExtensions(): ExtensionType[] {
|
||||
return [
|
||||
...HtmlInlineToDeltaAdapterExtensions,
|
||||
...defaultBlockHtmlAdapterMatchers,
|
||||
...InlineDeltaToHtmlAdapterExtensions,
|
||||
];
|
||||
}
|
||||
|
||||
export function getMarkdownAdapterExtensions(): ExtensionType[] {
|
||||
return [
|
||||
...MarkdownInlineToDeltaAdapterExtensions,
|
||||
...defaultBlockMarkdownAdapterMatchers,
|
||||
...InlineDeltaToMarkdownAdapterExtensions,
|
||||
...defaultMarkdownPreprocessors,
|
||||
];
|
||||
}
|
||||
|
||||
export function getNotionHtmlAdapterExtensions(): ExtensionType[] {
|
||||
return [
|
||||
...NotionHtmlInlineToDeltaAdapterExtensions,
|
||||
...defaultBlockNotionHtmlAdapterMatchers,
|
||||
];
|
||||
}
|
||||
|
||||
export function getPlainTextAdapterExtensions(): ExtensionType[] {
|
||||
return [
|
||||
...defaultBlockPlainTextAdapterMatchers,
|
||||
...InlineDeltaToPlainTextAdapterExtensions,
|
||||
];
|
||||
}
|
||||
37
blocksuite/affine/all/src/adapters/html/block-matcher.ts
Normal file
37
blocksuite/affine/all/src/adapters/html/block-matcher.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { BookmarkBlockHtmlAdapterExtension } from '@blocksuite/affine-block-bookmark';
|
||||
import { CodeBlockHtmlAdapterExtension } from '@blocksuite/affine-block-code';
|
||||
import { DatabaseBlockHtmlAdapterExtension } from '@blocksuite/affine-block-database';
|
||||
import { DividerBlockHtmlAdapterExtension } from '@blocksuite/affine-block-divider';
|
||||
import {
|
||||
EmbedFigmaBlockHtmlAdapterExtension,
|
||||
EmbedGithubBlockHtmlAdapterExtension,
|
||||
EmbedIframeBlockHtmlAdapterExtension,
|
||||
EmbedLinkedDocHtmlAdapterExtension,
|
||||
EmbedLoomBlockHtmlAdapterExtension,
|
||||
EmbedSyncedDocBlockHtmlAdapterExtension,
|
||||
EmbedYoutubeBlockHtmlAdapterExtension,
|
||||
} from '@blocksuite/affine-block-embed';
|
||||
import { ImageBlockHtmlAdapterExtension } from '@blocksuite/affine-block-image';
|
||||
import { ListBlockHtmlAdapterExtension } from '@blocksuite/affine-block-list';
|
||||
import { ParagraphBlockHtmlAdapterExtension } from '@blocksuite/affine-block-paragraph';
|
||||
import { RootBlockHtmlAdapterExtension } from '@blocksuite/affine-block-root';
|
||||
import { TableBlockHtmlAdapterExtension } from '@blocksuite/affine-block-table';
|
||||
|
||||
export const defaultBlockHtmlAdapterMatchers = [
|
||||
ListBlockHtmlAdapterExtension,
|
||||
ParagraphBlockHtmlAdapterExtension,
|
||||
CodeBlockHtmlAdapterExtension,
|
||||
DividerBlockHtmlAdapterExtension,
|
||||
ImageBlockHtmlAdapterExtension,
|
||||
RootBlockHtmlAdapterExtension,
|
||||
EmbedYoutubeBlockHtmlAdapterExtension,
|
||||
EmbedFigmaBlockHtmlAdapterExtension,
|
||||
EmbedLoomBlockHtmlAdapterExtension,
|
||||
EmbedGithubBlockHtmlAdapterExtension,
|
||||
EmbedIframeBlockHtmlAdapterExtension,
|
||||
BookmarkBlockHtmlAdapterExtension,
|
||||
DatabaseBlockHtmlAdapterExtension,
|
||||
TableBlockHtmlAdapterExtension,
|
||||
EmbedLinkedDocHtmlAdapterExtension,
|
||||
EmbedSyncedDocBlockHtmlAdapterExtension,
|
||||
];
|
||||
6
blocksuite/affine/all/src/adapters/index.ts
Normal file
6
blocksuite/affine/all/src/adapters/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export * from './extension.js';
|
||||
export * from './html/block-matcher.js';
|
||||
export * from './markdown/block-matcher.js';
|
||||
export * from './markdown/preprocessor.js';
|
||||
export * from './notion-html/block-matcher.js';
|
||||
export * from './plain-text/block-matcher.js';
|
||||
41
blocksuite/affine/all/src/adapters/markdown/block-matcher.ts
Normal file
41
blocksuite/affine/all/src/adapters/markdown/block-matcher.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { BookmarkBlockMarkdownAdapterExtension } from '@blocksuite/affine-block-bookmark';
|
||||
import { CodeBlockMarkdownAdapterExtension } from '@blocksuite/affine-block-code';
|
||||
import { DatabaseBlockMarkdownAdapterExtension } from '@blocksuite/affine-block-database';
|
||||
import { DividerBlockMarkdownAdapterExtension } from '@blocksuite/affine-block-divider';
|
||||
import {
|
||||
EmbedFigmaMarkdownAdapterExtension,
|
||||
EmbedGithubMarkdownAdapterExtension,
|
||||
EmbedIframeBlockMarkdownAdapterExtension,
|
||||
EmbedLinkedDocMarkdownAdapterExtension,
|
||||
EmbedLoomMarkdownAdapterExtension,
|
||||
EmbedSyncedDocMarkdownAdapterExtension,
|
||||
EmbedYoutubeMarkdownAdapterExtension,
|
||||
} from '@blocksuite/affine-block-embed';
|
||||
import { ImageBlockMarkdownAdapterExtension } from '@blocksuite/affine-block-image';
|
||||
import { LatexBlockMarkdownAdapterExtension } from '@blocksuite/affine-block-latex';
|
||||
import { ListBlockMarkdownAdapterExtension } from '@blocksuite/affine-block-list';
|
||||
import { DocNoteBlockMarkdownAdapterExtension } from '@blocksuite/affine-block-note';
|
||||
import { ParagraphBlockMarkdownAdapterExtension } from '@blocksuite/affine-block-paragraph';
|
||||
import { RootBlockMarkdownAdapterExtension } from '@blocksuite/affine-block-root';
|
||||
import { TableBlockMarkdownAdapterExtension } from '@blocksuite/affine-block-table';
|
||||
|
||||
export const defaultBlockMarkdownAdapterMatchers = [
|
||||
RootBlockMarkdownAdapterExtension,
|
||||
DocNoteBlockMarkdownAdapterExtension,
|
||||
EmbedFigmaMarkdownAdapterExtension,
|
||||
EmbedGithubMarkdownAdapterExtension,
|
||||
EmbedLinkedDocMarkdownAdapterExtension,
|
||||
EmbedLoomMarkdownAdapterExtension,
|
||||
EmbedSyncedDocMarkdownAdapterExtension,
|
||||
EmbedYoutubeMarkdownAdapterExtension,
|
||||
EmbedIframeBlockMarkdownAdapterExtension,
|
||||
ListBlockMarkdownAdapterExtension,
|
||||
ParagraphBlockMarkdownAdapterExtension,
|
||||
BookmarkBlockMarkdownAdapterExtension,
|
||||
CodeBlockMarkdownAdapterExtension,
|
||||
DatabaseBlockMarkdownAdapterExtension,
|
||||
TableBlockMarkdownAdapterExtension,
|
||||
DividerBlockMarkdownAdapterExtension,
|
||||
ImageBlockMarkdownAdapterExtension,
|
||||
LatexBlockMarkdownAdapterExtension,
|
||||
];
|
||||
@@ -0,0 +1,7 @@
|
||||
import { CodeMarkdownPreprocessorExtension } from '@blocksuite/affine-block-code';
|
||||
import { LatexMarkdownPreprocessorExtension } from '@blocksuite/affine-block-latex';
|
||||
|
||||
export const defaultMarkdownPreprocessors = [
|
||||
LatexMarkdownPreprocessorExtension,
|
||||
CodeMarkdownPreprocessorExtension,
|
||||
];
|
||||
@@ -0,0 +1,34 @@
|
||||
import { AttachmentBlockNotionHtmlAdapterExtension } from '@blocksuite/affine-block-attachment';
|
||||
import { BookmarkBlockNotionHtmlAdapterExtension } from '@blocksuite/affine-block-bookmark';
|
||||
import { CodeBlockNotionHtmlAdapterExtension } from '@blocksuite/affine-block-code';
|
||||
import { DatabaseBlockNotionHtmlAdapterExtension } from '@blocksuite/affine-block-database';
|
||||
import { DividerBlockNotionHtmlAdapterExtension } from '@blocksuite/affine-block-divider';
|
||||
import {
|
||||
EmbedFigmaBlockNotionHtmlAdapterExtension,
|
||||
EmbedGithubBlockNotionHtmlAdapterExtension,
|
||||
EmbedLoomBlockNotionHtmlAdapterExtension,
|
||||
EmbedYoutubeBlockNotionHtmlAdapterExtension,
|
||||
} from '@blocksuite/affine-block-embed';
|
||||
import { ImageBlockNotionHtmlAdapterExtension } from '@blocksuite/affine-block-image';
|
||||
import { LatexBlockNotionHtmlAdapterExtension } from '@blocksuite/affine-block-latex';
|
||||
import { ListBlockNotionHtmlAdapterExtension } from '@blocksuite/affine-block-list';
|
||||
import { ParagraphBlockNotionHtmlAdapterExtension } from '@blocksuite/affine-block-paragraph';
|
||||
import { RootBlockNotionHtmlAdapterExtension } from '@blocksuite/affine-block-root';
|
||||
import type { ExtensionType } from '@blocksuite/store';
|
||||
|
||||
export const defaultBlockNotionHtmlAdapterMatchers: ExtensionType[] = [
|
||||
ListBlockNotionHtmlAdapterExtension,
|
||||
ParagraphBlockNotionHtmlAdapterExtension,
|
||||
CodeBlockNotionHtmlAdapterExtension,
|
||||
DividerBlockNotionHtmlAdapterExtension,
|
||||
ImageBlockNotionHtmlAdapterExtension,
|
||||
RootBlockNotionHtmlAdapterExtension,
|
||||
BookmarkBlockNotionHtmlAdapterExtension,
|
||||
DatabaseBlockNotionHtmlAdapterExtension,
|
||||
LatexBlockNotionHtmlAdapterExtension,
|
||||
EmbedYoutubeBlockNotionHtmlAdapterExtension,
|
||||
EmbedFigmaBlockNotionHtmlAdapterExtension,
|
||||
EmbedGithubBlockNotionHtmlAdapterExtension,
|
||||
EmbedLoomBlockNotionHtmlAdapterExtension,
|
||||
AttachmentBlockNotionHtmlAdapterExtension,
|
||||
];
|
||||
@@ -0,0 +1,34 @@
|
||||
import { BookmarkBlockPlainTextAdapterExtension } from '@blocksuite/affine-block-bookmark';
|
||||
import { CodeBlockPlainTextAdapterExtension } from '@blocksuite/affine-block-code';
|
||||
import { DatabaseBlockPlainTextAdapterExtension } from '@blocksuite/affine-block-database';
|
||||
import { DividerBlockPlainTextAdapterExtension } from '@blocksuite/affine-block-divider';
|
||||
import {
|
||||
EmbedFigmaBlockPlainTextAdapterExtension,
|
||||
EmbedGithubBlockPlainTextAdapterExtension,
|
||||
EmbedIframeBlockPlainTextAdapterExtension,
|
||||
EmbedLinkedDocBlockPlainTextAdapterExtension,
|
||||
EmbedLoomBlockPlainTextAdapterExtension,
|
||||
EmbedSyncedDocBlockPlainTextAdapterExtension,
|
||||
EmbedYoutubeBlockPlainTextAdapterExtension,
|
||||
} from '@blocksuite/affine-block-embed';
|
||||
import { LatexBlockPlainTextAdapterExtension } from '@blocksuite/affine-block-latex';
|
||||
import { ListBlockPlainTextAdapterExtension } from '@blocksuite/affine-block-list';
|
||||
import { ParagraphBlockPlainTextAdapterExtension } from '@blocksuite/affine-block-paragraph';
|
||||
import type { ExtensionType } from '@blocksuite/store';
|
||||
|
||||
export const defaultBlockPlainTextAdapterMatchers: ExtensionType[] = [
|
||||
ParagraphBlockPlainTextAdapterExtension,
|
||||
ListBlockPlainTextAdapterExtension,
|
||||
DividerBlockPlainTextAdapterExtension,
|
||||
CodeBlockPlainTextAdapterExtension,
|
||||
BookmarkBlockPlainTextAdapterExtension,
|
||||
EmbedFigmaBlockPlainTextAdapterExtension,
|
||||
EmbedGithubBlockPlainTextAdapterExtension,
|
||||
EmbedLoomBlockPlainTextAdapterExtension,
|
||||
EmbedYoutubeBlockPlainTextAdapterExtension,
|
||||
EmbedLinkedDocBlockPlainTextAdapterExtension,
|
||||
EmbedSyncedDocBlockPlainTextAdapterExtension,
|
||||
EmbedIframeBlockPlainTextAdapterExtension,
|
||||
LatexBlockPlainTextAdapterExtension,
|
||||
DatabaseBlockPlainTextAdapterExtension,
|
||||
];
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-attachment/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-attachment/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-bookmark/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-bookmark/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-callout/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-callout/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-code/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-code/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-data-view/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-data-view/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-database/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-database/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-divider/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-divider/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-edgeless-text/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-edgeless-text/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-embed-doc';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-embed-doc/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-embed-doc/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-embed/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-embed/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-frame/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-frame/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-image/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-image/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-latex/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-latex/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-list/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-list/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-note/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-note/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-paragraph/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-paragraph/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-root/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-root/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-surface-ref/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-surface-ref/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-surface/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-surface/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-table/store';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-block-table/view';
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-components/citation';
|
||||
@@ -1,24 +1,93 @@
|
||||
import { type effects as blockRootEffects } from '@blocksuite/affine-block-root/effects';
|
||||
import { type effects as componentCaptionEffects } from '@blocksuite/affine-components/caption';
|
||||
import { type effects as componentColorPickerEffects } from '@blocksuite/affine-components/color-picker';
|
||||
import { type effects as componentContextMenuEffects } from '@blocksuite/affine-components/context-menu';
|
||||
import { type effects as componentDatePickerEffects } from '@blocksuite/affine-components/date-picker';
|
||||
import { type effects as componentDropIndicatorEffects } from '@blocksuite/affine-components/drop-indicator';
|
||||
import { type effects as componentEmbedCardModalEffects } from '@blocksuite/affine-components/embed-card-modal';
|
||||
import { type effects as componentHighlightDropdownMenuEffects } from '@blocksuite/affine-components/highlight-dropdown-menu';
|
||||
import { type effects as componentLinkPreviewEffects } from '@blocksuite/affine-components/link-preview';
|
||||
import { type effects as componentLinkedDocTitleEffects } from '@blocksuite/affine-components/linked-doc-title';
|
||||
import { type effects as componentPortalEffects } from '@blocksuite/affine-components/portal';
|
||||
import { type effects as componentToggleButtonEffects } from '@blocksuite/affine-components/toggle-button';
|
||||
import { type effects as componentToolbarEffects } from '@blocksuite/affine-components/toolbar';
|
||||
import { type effects as componentViewDropdownMenuEffects } from '@blocksuite/affine-components/view-dropdown-menu';
|
||||
import { type effects as richTextEffects } from '@blocksuite/affine-rich-text/effects';
|
||||
import { type effects as stdEffects } from '@blocksuite/std/effects';
|
||||
import { effects as blockAttachmentEffects } from '@blocksuite/affine-block-attachment/effects';
|
||||
import { effects as blockBookmarkEffects } from '@blocksuite/affine-block-bookmark/effects';
|
||||
import { effects as blockCalloutEffects } from '@blocksuite/affine-block-callout/effects';
|
||||
import { effects as blockCodeEffects } from '@blocksuite/affine-block-code/effects';
|
||||
import { effects as blockDataViewEffects } from '@blocksuite/affine-block-data-view/effects';
|
||||
import { effects as blockDatabaseEffects } from '@blocksuite/affine-block-database/effects';
|
||||
import { effects as blockDividerEffects } from '@blocksuite/affine-block-divider/effects';
|
||||
import { effects as blockEdgelessTextEffects } from '@blocksuite/affine-block-edgeless-text/effects';
|
||||
import { effects as blockEmbedEffects } from '@blocksuite/affine-block-embed/effects';
|
||||
import { effects as blockFrameEffects } from '@blocksuite/affine-block-frame/effects';
|
||||
import { effects as blockImageEffects } from '@blocksuite/affine-block-image/effects';
|
||||
import { effects as blockLatexEffects } from '@blocksuite/affine-block-latex/effects';
|
||||
import { effects as blockListEffects } from '@blocksuite/affine-block-list/effects';
|
||||
import { effects as blockNoteEffects } from '@blocksuite/affine-block-note/effects';
|
||||
import { effects as blockParagraphEffects } from '@blocksuite/affine-block-paragraph/effects';
|
||||
import { effects as blockRootEffects } from '@blocksuite/affine-block-root/effects';
|
||||
import { effects as blockSurfaceEffects } from '@blocksuite/affine-block-surface/effects';
|
||||
import { effects as blockSurfaceRefEffects } from '@blocksuite/affine-block-surface-ref/effects';
|
||||
import { effects as blockTableEffects } from '@blocksuite/affine-block-table/effects';
|
||||
import { BlockSelection } from '@blocksuite/affine-components/block-selection';
|
||||
import { BlockZeroWidth } from '@blocksuite/affine-components/block-zero-width';
|
||||
import { effects as componentCaptionEffects } from '@blocksuite/affine-components/caption';
|
||||
import { effects as componentCardStyleDropdownMenuEffects } from '@blocksuite/affine-components/card-style-dropdown-menu';
|
||||
import { effects as componentColorPickerEffects } from '@blocksuite/affine-components/color-picker';
|
||||
import { effects as componentContextMenuEffects } from '@blocksuite/affine-components/context-menu';
|
||||
import { effects as componentDatePickerEffects } from '@blocksuite/affine-components/date-picker';
|
||||
import { effects as componentDropIndicatorEffects } from '@blocksuite/affine-components/drop-indicator';
|
||||
import { effects as componentEdgelessLineStylesEffects } from '@blocksuite/affine-components/edgeless-line-styles-panel';
|
||||
import { effects as componentEdgelessLineWidthEffects } from '@blocksuite/affine-components/edgeless-line-width-panel';
|
||||
import { effects as componentEdgelessShapeColorPickerEffects } from '@blocksuite/affine-components/edgeless-shape-color-picker';
|
||||
import { effects as componentEmbedCardModalEffects } from '@blocksuite/affine-components/embed-card-modal';
|
||||
import { FilterableListComponent } from '@blocksuite/affine-components/filterable-list';
|
||||
import { effects as componentHighlightDropdownMenuEffects } from '@blocksuite/affine-components/highlight-dropdown-menu';
|
||||
import { IconButton } from '@blocksuite/affine-components/icon-button';
|
||||
import { effects as componentLinkPreviewEffects } from '@blocksuite/affine-components/link-preview';
|
||||
import { effects as componentLinkedDocTitleEffects } from '@blocksuite/affine-components/linked-doc-title';
|
||||
import { effects as componentOpenDocDropdownMenuEffects } from '@blocksuite/affine-components/open-doc-dropdown-menu';
|
||||
import { effects as componentPortalEffects } from '@blocksuite/affine-components/portal';
|
||||
import { effects as componentSizeDropdownMenuEffects } from '@blocksuite/affine-components/size-dropdown-menu';
|
||||
import { SmoothCorner } from '@blocksuite/affine-components/smooth-corner';
|
||||
import { effects as componentToggleButtonEffects } from '@blocksuite/affine-components/toggle-button';
|
||||
import { ToggleSwitch } from '@blocksuite/affine-components/toggle-switch';
|
||||
import { effects as componentToolbarEffects } from '@blocksuite/affine-components/toolbar';
|
||||
import { effects as componentTooltipContentWithShortcutEffects } from '@blocksuite/affine-components/tooltip-content-with-shortcut';
|
||||
import { effects as componentViewDropdownMenuEffects } from '@blocksuite/affine-components/view-dropdown-menu';
|
||||
import { effects as fragmentDocTitleEffects } from '@blocksuite/affine-fragment-doc-title/effects';
|
||||
import { effects as fragmentFramePanelEffects } from '@blocksuite/affine-fragment-frame-panel/effects';
|
||||
import { effects as fragmentOutlineEffects } from '@blocksuite/affine-fragment-outline/effects';
|
||||
import { effects as inlineFootnoteEffects } from '@blocksuite/affine-inline-footnote/effects';
|
||||
import { effects as inlineLatexEffects } from '@blocksuite/affine-inline-latex/effects';
|
||||
import { effects as inlineLinkEffects } from '@blocksuite/affine-inline-link/effects';
|
||||
import { effects as inlineMentionEffects } from '@blocksuite/affine-inline-mention';
|
||||
import { effects as inlinePresetEffects } from '@blocksuite/affine-inline-preset/effects';
|
||||
import { effects as inlineReferenceEffects } from '@blocksuite/affine-inline-reference/effects';
|
||||
import { effects as richTextEffects } from '@blocksuite/affine-rich-text/effects';
|
||||
import { effects as widgetDragHandleEffects } from '@blocksuite/affine-widget-drag-handle/effects';
|
||||
import { effects as widgetEdgelessAutoConnectEffects } from '@blocksuite/affine-widget-edgeless-auto-connect/effects';
|
||||
import { effects as widgetFrameTitleEffects } from '@blocksuite/affine-widget-frame-title/effects';
|
||||
import { effects as widgetRemoteSelectionEffects } from '@blocksuite/affine-widget-remote-selection/effects';
|
||||
import { effects as widgetScrollAnchoringEffects } from '@blocksuite/affine-widget-scroll-anchoring/effects';
|
||||
import { effects as widgetSlashMenuEffects } from '@blocksuite/affine-widget-slash-menu/effects';
|
||||
import { effects as widgetToolbarEffects } from '@blocksuite/affine-widget-toolbar/effects';
|
||||
import { effects as dataViewEffects } from '@blocksuite/data-view/effects';
|
||||
import { effects as stdEffects } from '@blocksuite/std/effects';
|
||||
|
||||
import { registerBlockSpecs } from './extensions';
|
||||
|
||||
export declare const _GLOBAL_:
|
||||
| typeof stdEffects
|
||||
| typeof dataViewEffects
|
||||
| typeof richTextEffects
|
||||
| typeof blockNoteEffects
|
||||
| typeof blockAttachmentEffects
|
||||
| typeof blockBookmarkEffects
|
||||
| typeof blockFrameEffects
|
||||
| typeof blockListEffects
|
||||
| typeof blockParagraphEffects
|
||||
| typeof blockEmbedEffects
|
||||
| typeof blockSurfaceEffects
|
||||
| typeof blockImageEffects
|
||||
| typeof blockDatabaseEffects
|
||||
| typeof blockSurfaceRefEffects
|
||||
| typeof blockLatexEffects
|
||||
| typeof blockEdgelessTextEffects
|
||||
| typeof blockDividerEffects
|
||||
| typeof blockDataViewEffects
|
||||
| typeof blockCodeEffects
|
||||
| typeof blockTableEffects
|
||||
| typeof blockRootEffects
|
||||
| typeof blockCalloutEffects
|
||||
| typeof componentCaptionEffects
|
||||
| typeof componentContextMenuEffects
|
||||
| typeof componentDatePickerEffects
|
||||
@@ -31,4 +100,89 @@ export declare const _GLOBAL_:
|
||||
| typeof componentToolbarEffects
|
||||
| typeof componentToggleButtonEffects
|
||||
| typeof componentColorPickerEffects
|
||||
| typeof componentViewDropdownMenuEffects;
|
||||
| typeof componentViewDropdownMenuEffects
|
||||
| typeof widgetScrollAnchoringEffects
|
||||
| typeof widgetFrameTitleEffects
|
||||
| typeof widgetRemoteSelectionEffects
|
||||
| typeof widgetDragHandleEffects
|
||||
| typeof widgetEdgelessAutoConnectEffects
|
||||
| typeof widgetToolbarEffects
|
||||
| typeof widgetSlashMenuEffects
|
||||
| typeof fragmentDocTitleEffects
|
||||
| typeof fragmentFramePanelEffects
|
||||
| typeof fragmentOutlineEffects;
|
||||
|
||||
export function effects() {
|
||||
registerBlockSpecs();
|
||||
stdEffects();
|
||||
|
||||
dataViewEffects();
|
||||
richTextEffects();
|
||||
|
||||
inlineReferenceEffects();
|
||||
inlinePresetEffects();
|
||||
inlineLinkEffects();
|
||||
inlineFootnoteEffects();
|
||||
inlineLatexEffects();
|
||||
inlineMentionEffects();
|
||||
|
||||
blockNoteEffects();
|
||||
blockAttachmentEffects();
|
||||
blockBookmarkEffects();
|
||||
blockFrameEffects();
|
||||
blockListEffects();
|
||||
blockParagraphEffects();
|
||||
blockEmbedEffects();
|
||||
blockSurfaceEffects();
|
||||
blockImageEffects();
|
||||
blockDatabaseEffects();
|
||||
blockSurfaceRefEffects();
|
||||
blockLatexEffects();
|
||||
blockEdgelessTextEffects();
|
||||
blockDividerEffects();
|
||||
blockDataViewEffects();
|
||||
blockCodeEffects();
|
||||
blockTableEffects();
|
||||
blockRootEffects();
|
||||
blockCalloutEffects();
|
||||
|
||||
componentCaptionEffects();
|
||||
componentContextMenuEffects();
|
||||
componentDatePickerEffects();
|
||||
componentPortalEffects();
|
||||
componentToolbarEffects();
|
||||
componentDropIndicatorEffects();
|
||||
componentToggleButtonEffects();
|
||||
componentColorPickerEffects();
|
||||
componentEmbedCardModalEffects();
|
||||
componentLinkPreviewEffects();
|
||||
componentLinkedDocTitleEffects();
|
||||
componentCardStyleDropdownMenuEffects();
|
||||
componentHighlightDropdownMenuEffects();
|
||||
componentViewDropdownMenuEffects();
|
||||
componentTooltipContentWithShortcutEffects();
|
||||
componentSizeDropdownMenuEffects();
|
||||
componentEdgelessLineWidthEffects();
|
||||
componentEdgelessLineStylesEffects();
|
||||
componentEdgelessShapeColorPickerEffects();
|
||||
componentOpenDocDropdownMenuEffects();
|
||||
|
||||
widgetScrollAnchoringEffects();
|
||||
widgetFrameTitleEffects();
|
||||
widgetRemoteSelectionEffects();
|
||||
widgetDragHandleEffects();
|
||||
widgetEdgelessAutoConnectEffects();
|
||||
widgetSlashMenuEffects();
|
||||
widgetToolbarEffects();
|
||||
|
||||
fragmentDocTitleEffects();
|
||||
fragmentFramePanelEffects();
|
||||
fragmentOutlineEffects();
|
||||
|
||||
customElements.define('icon-button', IconButton);
|
||||
customElements.define('smooth-corner', SmoothCorner);
|
||||
customElements.define('toggle-switch', ToggleSwitch);
|
||||
customElements.define('affine-filterable-list', FilterableListComponent);
|
||||
customElements.define('block-zero-width', BlockZeroWidth);
|
||||
customElements.define('affine-block-selection', BlockSelection);
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export * from '@blocksuite/affine-ext-loader';
|
||||
124
blocksuite/affine/all/src/extensions/common.ts
Normal file
124
blocksuite/affine/all/src/extensions/common.ts
Normal file
@@ -0,0 +1,124 @@
|
||||
import { AttachmentBlockSpec } from '@blocksuite/affine-block-attachment';
|
||||
import { BookmarkBlockSpec } from '@blocksuite/affine-block-bookmark';
|
||||
import { CalloutBlockSpec } from '@blocksuite/affine-block-callout';
|
||||
import { CodeBlockSpec } from '@blocksuite/affine-block-code';
|
||||
import { DataViewBlockSpec } from '@blocksuite/affine-block-data-view';
|
||||
import { DatabaseBlockSpec } from '@blocksuite/affine-block-database';
|
||||
import { DividerBlockSpec } from '@blocksuite/affine-block-divider';
|
||||
import { EdgelessTextBlockSpec } from '@blocksuite/affine-block-edgeless-text';
|
||||
import { EmbedExtensions } from '@blocksuite/affine-block-embed';
|
||||
import { FrameBlockSpec } from '@blocksuite/affine-block-frame';
|
||||
import { ImageBlockSpec } from '@blocksuite/affine-block-image';
|
||||
import { LatexBlockSpec } from '@blocksuite/affine-block-latex';
|
||||
import { ListBlockSpec } from '@blocksuite/affine-block-list';
|
||||
import {
|
||||
EdgelessNoteBlockSpec,
|
||||
NoteBlockSpec,
|
||||
} from '@blocksuite/affine-block-note';
|
||||
import { ParagraphBlockSpec } from '@blocksuite/affine-block-paragraph';
|
||||
import {
|
||||
EdgelessSurfaceBlockAdapterExtensions,
|
||||
EdgelessSurfaceBlockSpec,
|
||||
PageSurfaceBlockSpec,
|
||||
SurfaceBlockAdapterExtensions,
|
||||
} from '@blocksuite/affine-block-surface';
|
||||
import {
|
||||
EdgelessSurfaceRefBlockSpec,
|
||||
PageSurfaceRefBlockSpec,
|
||||
} from '@blocksuite/affine-block-surface-ref';
|
||||
import { TableBlockSpec } from '@blocksuite/affine-block-table';
|
||||
import {
|
||||
brushToMarkdownAdapterMatcher,
|
||||
brushToPlainTextAdapterMatcher,
|
||||
} from '@blocksuite/affine-gfx-brush';
|
||||
import {
|
||||
connectorToMarkdownAdapterMatcher,
|
||||
connectorToPlainTextAdapterMatcher,
|
||||
} from '@blocksuite/affine-gfx-connector';
|
||||
import {
|
||||
groupToMarkdownAdapterMatcher,
|
||||
groupToPlainTextAdapterMatcher,
|
||||
} from '@blocksuite/affine-gfx-group';
|
||||
import {
|
||||
mindmapToMarkdownAdapterMatcher,
|
||||
mindmapToPlainTextAdapterMatcher,
|
||||
} from '@blocksuite/affine-gfx-mindmap';
|
||||
import {
|
||||
shapeToMarkdownAdapterMatcher,
|
||||
shapeToPlainTextAdapterMatcher,
|
||||
} from '@blocksuite/affine-gfx-shape';
|
||||
import {
|
||||
textToMarkdownAdapterMatcher,
|
||||
textToPlainTextAdapterMatcher,
|
||||
} from '@blocksuite/affine-gfx-text';
|
||||
import { inlinePresetExtensions } from '@blocksuite/affine-inline-preset';
|
||||
import {
|
||||
DefaultOpenDocExtension,
|
||||
DocDisplayMetaService,
|
||||
EditPropsStore,
|
||||
FontLoaderService,
|
||||
} from '@blocksuite/affine-shared/services';
|
||||
import type { ExtensionType } from '@blocksuite/store';
|
||||
|
||||
const elementToPlainTextAdapterMatchers = [
|
||||
groupToPlainTextAdapterMatcher,
|
||||
shapeToPlainTextAdapterMatcher,
|
||||
connectorToPlainTextAdapterMatcher,
|
||||
brushToPlainTextAdapterMatcher,
|
||||
textToPlainTextAdapterMatcher,
|
||||
mindmapToPlainTextAdapterMatcher,
|
||||
];
|
||||
|
||||
const elementToMarkdownAdapterMatchers = [
|
||||
groupToMarkdownAdapterMatcher,
|
||||
shapeToMarkdownAdapterMatcher,
|
||||
connectorToMarkdownAdapterMatcher,
|
||||
brushToMarkdownAdapterMatcher,
|
||||
textToMarkdownAdapterMatcher,
|
||||
mindmapToMarkdownAdapterMatcher,
|
||||
];
|
||||
|
||||
export const CommonBlockSpecs: ExtensionType[] = [
|
||||
inlinePresetExtensions,
|
||||
DocDisplayMetaService,
|
||||
EditPropsStore,
|
||||
LatexBlockSpec,
|
||||
ListBlockSpec,
|
||||
DatabaseBlockSpec,
|
||||
TableBlockSpec,
|
||||
DataViewBlockSpec,
|
||||
DividerBlockSpec,
|
||||
BookmarkBlockSpec,
|
||||
EmbedExtensions,
|
||||
AttachmentBlockSpec,
|
||||
CodeBlockSpec,
|
||||
ImageBlockSpec,
|
||||
ParagraphBlockSpec,
|
||||
DefaultOpenDocExtension,
|
||||
FontLoaderService,
|
||||
CalloutBlockSpec,
|
||||
FrameBlockSpec,
|
||||
|
||||
elementToPlainTextAdapterMatchers,
|
||||
elementToMarkdownAdapterMatchers,
|
||||
].flat();
|
||||
|
||||
export const PageFirstPartyBlockSpecs: ExtensionType[] = [
|
||||
CommonBlockSpecs,
|
||||
NoteBlockSpec,
|
||||
PageSurfaceBlockSpec,
|
||||
PageSurfaceRefBlockSpec,
|
||||
|
||||
...SurfaceBlockAdapterExtensions,
|
||||
].flat();
|
||||
|
||||
export const EdgelessFirstPartyBlockSpecs: ExtensionType[] = [
|
||||
CommonBlockSpecs,
|
||||
|
||||
EdgelessNoteBlockSpec,
|
||||
EdgelessSurfaceBlockSpec,
|
||||
EdgelessSurfaceRefBlockSpec,
|
||||
EdgelessTextBlockSpec,
|
||||
|
||||
...EdgelessSurfaceBlockAdapterExtensions,
|
||||
].flat();
|
||||
20
blocksuite/affine/all/src/extensions/editor-specs.ts
Normal file
20
blocksuite/affine/all/src/extensions/editor-specs.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import {
|
||||
EdgelessBuiltInSpecs,
|
||||
PageRootBlockSpec,
|
||||
} from '@blocksuite/affine-block-root';
|
||||
import type { ExtensionType } from '@blocksuite/store';
|
||||
|
||||
import {
|
||||
EdgelessFirstPartyBlockSpecs,
|
||||
PageFirstPartyBlockSpecs,
|
||||
} from './common';
|
||||
|
||||
export const EdgelessEditorBlockSpecs: ExtensionType[] = [
|
||||
EdgelessBuiltInSpecs,
|
||||
EdgelessFirstPartyBlockSpecs,
|
||||
].flat();
|
||||
|
||||
export const PageEditorBlockSpecs: ExtensionType[] = [
|
||||
PageRootBlockSpec,
|
||||
PageFirstPartyBlockSpecs,
|
||||
].flat();
|
||||
5
blocksuite/affine/all/src/extensions/index.ts
Normal file
5
blocksuite/affine/all/src/extensions/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export * from './common';
|
||||
export * from './editor-specs';
|
||||
export * from './preview-specs';
|
||||
export * from './register';
|
||||
export * from './store';
|
||||
23
blocksuite/affine/all/src/extensions/preview-specs.ts
Normal file
23
blocksuite/affine/all/src/extensions/preview-specs.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import {
|
||||
PreviewEdgelessRootBlockSpec,
|
||||
PreviewPageRootBlockSpec,
|
||||
ReadOnlyClipboard,
|
||||
} from '@blocksuite/affine-block-root';
|
||||
import type { ExtensionType } from '@blocksuite/store';
|
||||
|
||||
import {
|
||||
EdgelessFirstPartyBlockSpecs,
|
||||
PageFirstPartyBlockSpecs,
|
||||
} from './common.js';
|
||||
|
||||
export const PreviewEdgelessEditorBlockSpecs: ExtensionType[] = [
|
||||
PreviewEdgelessRootBlockSpec,
|
||||
EdgelessFirstPartyBlockSpecs,
|
||||
ReadOnlyClipboard,
|
||||
].flat();
|
||||
|
||||
export const PreviewPageEditorBlockSpecs: ExtensionType[] = [
|
||||
PreviewPageRootBlockSpec,
|
||||
PageFirstPartyBlockSpecs,
|
||||
ReadOnlyClipboard,
|
||||
].flat();
|
||||
22
blocksuite/affine/all/src/extensions/register.ts
Normal file
22
blocksuite/affine/all/src/extensions/register.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { SpecProvider } from '@blocksuite/affine-shared/utils';
|
||||
|
||||
import {
|
||||
EdgelessEditorBlockSpecs,
|
||||
PageEditorBlockSpecs,
|
||||
} from './editor-specs.js';
|
||||
import {
|
||||
PreviewEdgelessEditorBlockSpecs,
|
||||
PreviewPageEditorBlockSpecs,
|
||||
} from './preview-specs.js';
|
||||
import { StoreExtensions } from './store.js';
|
||||
|
||||
export function registerStoreSpecs() {
|
||||
SpecProvider._.addSpec('store', StoreExtensions);
|
||||
}
|
||||
|
||||
export function registerBlockSpecs() {
|
||||
SpecProvider._.addSpec('page', PageEditorBlockSpecs);
|
||||
SpecProvider._.addSpec('edgeless', EdgelessEditorBlockSpecs);
|
||||
SpecProvider._.addSpec('preview:page', PreviewPageEditorBlockSpecs);
|
||||
SpecProvider._.addSpec('preview:edgeless', PreviewEdgelessEditorBlockSpecs);
|
||||
}
|
||||
@@ -1,72 +1,112 @@
|
||||
import { AttachmentStoreExtension } from '@blocksuite/affine-block-attachment/store';
|
||||
import { BookmarkStoreExtension } from '@blocksuite/affine-block-bookmark/store';
|
||||
import { CalloutStoreExtension } from '@blocksuite/affine-block-callout/store';
|
||||
import { CodeStoreExtension } from '@blocksuite/affine-block-code/store';
|
||||
import { DataViewStoreExtension } from '@blocksuite/affine-block-data-view/store';
|
||||
import { DatabaseStoreExtension } from '@blocksuite/affine-block-database/store';
|
||||
import { DividerStoreExtension } from '@blocksuite/affine-block-divider/store';
|
||||
import { EdgelessTextStoreExtension } from '@blocksuite/affine-block-edgeless-text/store';
|
||||
import { EmbedStoreExtension } from '@blocksuite/affine-block-embed/store';
|
||||
import { EmbedDocStoreExtension } from '@blocksuite/affine-block-embed-doc/store';
|
||||
import { FrameStoreExtension } from '@blocksuite/affine-block-frame/store';
|
||||
import { ImageStoreExtension } from '@blocksuite/affine-block-image/store';
|
||||
import { LatexStoreExtension } from '@blocksuite/affine-block-latex/store';
|
||||
import { ListStoreExtension } from '@blocksuite/affine-block-list/store';
|
||||
import { NoteStoreExtension } from '@blocksuite/affine-block-note/store';
|
||||
import { ParagraphStoreExtension } from '@blocksuite/affine-block-paragraph/store';
|
||||
import { RootStoreExtension } from '@blocksuite/affine-block-root/store';
|
||||
import { SurfaceStoreExtension } from '@blocksuite/affine-block-surface/store';
|
||||
import { SurfaceRefStoreExtension } from '@blocksuite/affine-block-surface-ref/store';
|
||||
import { TableStoreExtension } from '@blocksuite/affine-block-table/store';
|
||||
import { FoundationStoreExtension } from '@blocksuite/affine-foundation/store';
|
||||
import { BrushStoreExtension } from '@blocksuite/affine-gfx-brush/store';
|
||||
import { ConnectorStoreExtension } from '@blocksuite/affine-gfx-connector/store';
|
||||
import { GroupStoreExtension } from '@blocksuite/affine-gfx-group/store';
|
||||
import { MindmapStoreExtension } from '@blocksuite/affine-gfx-mindmap/store';
|
||||
import { ShapeStoreExtension } from '@blocksuite/affine-gfx-shape/store';
|
||||
import { TextStoreExtension } from '@blocksuite/affine-gfx-text/store';
|
||||
import { FootnoteStoreExtension } from '@blocksuite/affine-inline-footnote/store';
|
||||
import { LatexStoreExtension as InlineLatexStoreExtension } from '@blocksuite/affine-inline-latex/store';
|
||||
import { LinkStoreExtension } from '@blocksuite/affine-inline-link/store';
|
||||
import { InlinePresetStoreExtension } from '@blocksuite/affine-inline-preset/store';
|
||||
import { ReferenceStoreExtension } from '@blocksuite/affine-inline-reference/store';
|
||||
import { DataViewBlockSchemaExtension } from '@blocksuite/affine-block-data-view';
|
||||
import { DatabaseSelectionExtension } from '@blocksuite/affine-block-database';
|
||||
import { EmbedIframeConfigExtensions } from '@blocksuite/affine-block-embed';
|
||||
import { ImageStoreSpec } from '@blocksuite/affine-block-image';
|
||||
import { SurfaceBlockSchemaExtension } from '@blocksuite/affine-block-surface';
|
||||
import { TableSelectionExtension } from '@blocksuite/affine-block-table';
|
||||
import {
|
||||
AttachmentBlockSchemaExtension,
|
||||
BookmarkBlockSchemaExtension,
|
||||
CalloutBlockSchemaExtension,
|
||||
CodeBlockSchemaExtension,
|
||||
DatabaseBlockSchemaExtension,
|
||||
DividerBlockSchemaExtension,
|
||||
EdgelessTextBlockSchemaExtension,
|
||||
EmbedFigmaBlockSchemaExtension,
|
||||
EmbedGithubBlockSchemaExtension,
|
||||
EmbedHtmlBlockSchemaExtension,
|
||||
EmbedIframeBlockSchemaExtension,
|
||||
EmbedLinkedDocBlockSchemaExtension,
|
||||
EmbedLoomBlockSchemaExtension,
|
||||
EmbedSyncedDocBlockSchemaExtension,
|
||||
EmbedYoutubeBlockSchemaExtension,
|
||||
FrameBlockSchemaExtension,
|
||||
ImageBlockSchemaExtension,
|
||||
LatexBlockSchemaExtension,
|
||||
ListBlockSchemaExtension,
|
||||
NoteBlockSchemaExtension,
|
||||
ParagraphBlockSchemaExtension,
|
||||
RootBlockSchemaExtension,
|
||||
SurfaceRefBlockSchemaExtension,
|
||||
TableBlockSchemaExtension,
|
||||
TranscriptionBlockSchemaExtension,
|
||||
} from '@blocksuite/affine-model';
|
||||
import {
|
||||
HighlightSelectionExtension,
|
||||
ImageSelectionExtension,
|
||||
} from '@blocksuite/affine-shared/selection';
|
||||
import {
|
||||
BlockMetaService,
|
||||
EmbedIframeService,
|
||||
FeatureFlagService,
|
||||
FileSizeLimitService,
|
||||
LinkPreviewerService,
|
||||
} from '@blocksuite/affine-shared/services';
|
||||
import {
|
||||
BlockSelectionExtension,
|
||||
CursorSelectionExtension,
|
||||
SurfaceSelectionExtension,
|
||||
TextSelectionExtension,
|
||||
} from '@blocksuite/std';
|
||||
import type { ExtensionType } from '@blocksuite/store';
|
||||
|
||||
export function getInternalStoreExtensions() {
|
||||
return [
|
||||
FoundationStoreExtension,
|
||||
import {
|
||||
getAdapterFactoryExtensions,
|
||||
getHtmlAdapterExtensions,
|
||||
getMarkdownAdapterExtensions,
|
||||
getNotionHtmlAdapterExtensions,
|
||||
getPlainTextAdapterExtensions,
|
||||
} from '../adapters/extension.js';
|
||||
|
||||
AttachmentStoreExtension,
|
||||
BookmarkStoreExtension,
|
||||
CalloutStoreExtension,
|
||||
CodeStoreExtension,
|
||||
DataViewStoreExtension,
|
||||
DatabaseStoreExtension,
|
||||
DividerStoreExtension,
|
||||
EdgelessTextStoreExtension,
|
||||
EmbedStoreExtension,
|
||||
EmbedDocStoreExtension,
|
||||
FrameStoreExtension,
|
||||
ImageStoreExtension,
|
||||
LatexStoreExtension,
|
||||
ListStoreExtension,
|
||||
NoteStoreExtension,
|
||||
ParagraphStoreExtension,
|
||||
SurfaceRefStoreExtension,
|
||||
TableStoreExtension,
|
||||
SurfaceStoreExtension,
|
||||
RootStoreExtension,
|
||||
export const StoreExtensions: ExtensionType[] = [
|
||||
CodeBlockSchemaExtension,
|
||||
ParagraphBlockSchemaExtension,
|
||||
RootBlockSchemaExtension,
|
||||
ListBlockSchemaExtension,
|
||||
NoteBlockSchemaExtension,
|
||||
DividerBlockSchemaExtension,
|
||||
ImageBlockSchemaExtension,
|
||||
SurfaceBlockSchemaExtension,
|
||||
BookmarkBlockSchemaExtension,
|
||||
FrameBlockSchemaExtension,
|
||||
DatabaseBlockSchemaExtension,
|
||||
SurfaceRefBlockSchemaExtension,
|
||||
DataViewBlockSchemaExtension,
|
||||
AttachmentBlockSchemaExtension,
|
||||
EmbedSyncedDocBlockSchemaExtension,
|
||||
EmbedLinkedDocBlockSchemaExtension,
|
||||
EmbedHtmlBlockSchemaExtension,
|
||||
EmbedIframeBlockSchemaExtension,
|
||||
EmbedGithubBlockSchemaExtension,
|
||||
EmbedFigmaBlockSchemaExtension,
|
||||
EmbedLoomBlockSchemaExtension,
|
||||
EmbedYoutubeBlockSchemaExtension,
|
||||
EdgelessTextBlockSchemaExtension,
|
||||
LatexBlockSchemaExtension,
|
||||
TableBlockSchemaExtension,
|
||||
CalloutBlockSchemaExtension,
|
||||
TranscriptionBlockSchemaExtension,
|
||||
|
||||
FootnoteStoreExtension,
|
||||
LinkStoreExtension,
|
||||
ReferenceStoreExtension,
|
||||
InlineLatexStoreExtension,
|
||||
InlinePresetStoreExtension,
|
||||
BlockSelectionExtension,
|
||||
TextSelectionExtension,
|
||||
SurfaceSelectionExtension,
|
||||
CursorSelectionExtension,
|
||||
HighlightSelectionExtension,
|
||||
ImageSelectionExtension,
|
||||
DatabaseSelectionExtension,
|
||||
TableSelectionExtension,
|
||||
|
||||
BrushStoreExtension,
|
||||
ShapeStoreExtension,
|
||||
MindmapStoreExtension,
|
||||
ConnectorStoreExtension,
|
||||
GroupStoreExtension,
|
||||
TextStoreExtension,
|
||||
];
|
||||
}
|
||||
getHtmlAdapterExtensions(),
|
||||
getMarkdownAdapterExtensions(),
|
||||
getNotionHtmlAdapterExtensions(),
|
||||
getPlainTextAdapterExtensions(),
|
||||
getAdapterFactoryExtensions(),
|
||||
|
||||
FeatureFlagService,
|
||||
LinkPreviewerService,
|
||||
FileSizeLimitService,
|
||||
ImageStoreSpec,
|
||||
BlockMetaService,
|
||||
EmbedIframeConfigExtensions,
|
||||
EmbedIframeService,
|
||||
].flat();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user