Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
SaikaSakura committed 2022-08-04 18:50:26 +08:00
commit c46c55312e
122 files changed
+2887 -1414

No files matched your search

+10 -10
View File
@@ -1,5 +1,5 @@
{ {
"projectName": "Ligo-Virgo", "projectName": "toeverything",
"projectOwner": "toeverything", "projectOwner": "toeverything",
"repoType": "github", "repoType": "github",
"repoHost": "https://github.com", "repoHost": "https://github.com",
@@ -25,7 +25,7 @@
"login": "tzhangchi", "login": "tzhangchi",
"name": "Chi Zhang", "name": "Chi Zhang",
"avatar_url": "https://avatars.githubusercontent.com/u/5910926?v=4", "avatar_url": "https://avatars.githubusercontent.com/u/5910926?v=4",
"profile": "https://zhangchi.blog.csdn.net/", "profile": "http://zhangchi.page/",
"contributions": [ "contributions": [
"code", "code",
"doc" "doc"
@@ -33,7 +33,7 @@
}, },
{ {
"login": "alt1o", "login": "alt1o",
"name": "alt1o", "name": "wang xinglong",
"avatar_url": "https://avatars.githubusercontent.com/u/21084335?v=4", "avatar_url": "https://avatars.githubusercontent.com/u/21084335?v=4",
"profile": "https://github.com/alt1o", "profile": "https://github.com/alt1o",
"contributions": [ "contributions": [
@@ -43,7 +43,7 @@
}, },
{ {
"login": "DiamondThree", "login": "DiamondThree",
"name": "Diamond", "name": "DiamondThree",
"avatar_url": "https://avatars.githubusercontent.com/u/24630517?v=4", "avatar_url": "https://avatars.githubusercontent.com/u/24630517?v=4",
"profile": "https://github.com/DiamondThree", "profile": "https://github.com/DiamondThree",
"contributions": [ "contributions": [
@@ -63,7 +63,7 @@
}, },
{ {
"login": "zuoxiaodong0815", "login": "zuoxiaodong0815",
"name": "zuoxiaodong0815", "name": "xiaodong zuo",
"avatar_url": "https://avatars.githubusercontent.com/u/53252747?v=4", "avatar_url": "https://avatars.githubusercontent.com/u/53252747?v=4",
"profile": "https://github.com/zuoxiaodong0815", "profile": "https://github.com/zuoxiaodong0815",
"contributions": [ "contributions": [
@@ -73,7 +73,7 @@
}, },
{ {
"login": "SaikaSakura", "login": "SaikaSakura",
"name": "SaikaSakura", "name": "MingLIang Wang",
"avatar_url": "https://avatars.githubusercontent.com/u/11530942?v=4", "avatar_url": "https://avatars.githubusercontent.com/u/11530942?v=4",
"profile": "https://github.com/SaikaSakura", "profile": "https://github.com/SaikaSakura",
"contributions": [ "contributions": [
@@ -92,10 +92,10 @@
] ]
}, },
{ {
"login": "tuluffy", "login": "mitsuhatu",
"name": "tuluffy", "name": "mitsuhatu",
"avatar_url": "https://avatars.githubusercontent.com/u/26808339?v=4", "avatar_url": "https://avatars.githubusercontent.com/u/110213079?v=4",
"profile": "https://tuluffy.github.io/angular.github.io/", "profile": "https://github.com/mitsuhatu",
"contributions": [ "contributions": [
"code", "code",
"doc" "doc"
+28
View File
@@ -0,0 +1,28 @@
:3000 {
root /* ./dist
file_server {
precompressed br
}
encode {
zstd
gzip 9
}
@notStatic {
not path /*.css
not path /*.js
not path /*.png
not path /*.jpg
not path /*.svg
not path /*.ttf
not path /*.eot
not path /*.woff
not path /*.woff2
}
handle @notStatic {
try_files {path} /index.html
}
}
File renamed without changes.
File renamed without changes.
+21
View File
@@ -0,0 +1,21 @@
FROM node:16-alpine as builder
WORKDIR /app
COPY . .
RUN apk add g++ make python3 git libpng-dev
RUN npm i -g pnpm@7 && pnpm i --frozen-lockfile --store=node_modules/.pnpm-store && pnpm run build:local
FROM node:16-alpine as relocate
WORKDIR /app
COPY --from=builder /app/dist/apps/ligo-virgo ./dist
COPY --from=builder /app/.github/deployment/Caddyfile-affine ./Caddyfile
RUN rm ./dist/*.txt
# =============
# AFFiNE image
# =============
FROM caddy:2.4.6-alpine as AFFiNE
WORKDIR /app
COPY --from=relocate /app .
EXPOSE 3000
CMD ["caddy", "run"]
@@ -1,7 +1,7 @@
FROM node:16-alpine as builder FROM node:16-alpine as builder
WORKDIR /app WORKDIR /app
COPY . . COPY . .
RUN apk add g++ make python3 git RUN apk add g++ make python3 git libpng-dev
RUN npm i -g pnpm@7 && pnpm i --frozen-lockfile --store=node_modules/.pnpm-store && pnpm run build:keck RUN npm i -g pnpm@7 && pnpm i --frozen-lockfile --store=node_modules/.pnpm-store && pnpm run build:keck
FROM node:16-alpine as node_modules FROM node:16-alpine as node_modules
@@ -1,13 +1,13 @@
FROM node:16-alpine as builder FROM node:16-alpine as builder
WORKDIR /app WORKDIR /app
COPY . . COPY . .
RUN apk add g++ make python3 git RUN apk add g++ make python3 git libpng-dev
RUN npm i -g pnpm@7 && pnpm i --frozen-lockfile --store=node_modules/.pnpm-store && pnpm run build RUN npm i -g pnpm@7 && pnpm i --frozen-lockfile --store=node_modules/.pnpm-store && pnpm run build
FROM node:16-alpine as relocate FROM node:16-alpine as relocate
WORKDIR /app WORKDIR /app
COPY --from=builder /app/dist/apps/ligo-virgo ./dist COPY --from=builder /app/dist/apps/ligo-virgo ./dist
COPY --from=builder /app/Caddyfile ./ COPY --from=builder /app/.github/deployment/Caddyfile-lisa ./Caddyfile
RUN rm ./dist/*.txt RUN rm ./dist/*.txt
# ============= # =============
@@ -1,13 +1,13 @@
FROM node:16-alpine as builder FROM node:16-alpine as builder
WORKDIR /app WORKDIR /app
COPY . . COPY . .
RUN apk add g++ make python3 git RUN apk add g++ make python3 git libpng-dev
RUN npm i -g pnpm@7 && pnpm i --frozen-lockfile --store=node_modules/.pnpm-store && pnpm run build:venus RUN npm i -g pnpm@7 && pnpm i --frozen-lockfile --store=node_modules/.pnpm-store && pnpm run build:venus
FROM node:16-alpine as relocate FROM node:16-alpine as relocate
WORKDIR /app WORKDIR /app
COPY --from=builder /app/dist/apps/venus ./dist COPY --from=builder /app/dist/apps/venus ./dist
COPY --from=builder /app/Caddyfile-venus ./Caddyfile COPY --from=builder /app/.github/deployment/Caddyfile-venus ./Caddyfile
RUN rm ./dist/*.txt RUN rm ./dist/*.txt
# ============= # =============
+57
View File
@@ -0,0 +1,57 @@
name: Build AFFiNE-Local
on:
push:
branches: [master]
pull_request:
branches: [master]
# Cancels all previous workflow runs for pull requests that have not completed.
# See https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
# The concurrency group contains the workflow name and the branch name for
# pull requests or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
NAMESPACE: toeverything
AFFINE_IMAGE_NAME: AFFiNE
IMAGE_TAG_LATEST: nightly-latest
jobs:
ligo-virgo:
runs-on: self-hosted
environment: development
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker (AFFiNE-Local)
id: meta_affine
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.AFFINE_IMAGE_NAME }}
tags: ${{ env.IMAGE_TAG_LATEST }}
- name: Build and push Docker image (AFFINE-Local)
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: ./.github/deployment/Dockerfile-affine
push: ${{ github.ref == 'refs/heads/master' && true || false }}
tags: ${{ steps.meta_affine.outputs.tags }}
labels: ${{ steps.meta_affine.outputs.labels }}
target: AFFiNE
+3 -1
View File
@@ -6,11 +6,13 @@ on:
branches: [master] branches: [master]
paths: paths:
- 'apps/keck/**' - 'apps/keck/**'
- '.github/deployment'
- '.github/workflows/keck.yml' - '.github/workflows/keck.yml'
pull_request: pull_request:
branches: [master] branches: [master]
paths: paths:
- 'apps/keck/**' - 'apps/keck/**'
- '.github/deployment'
- '.github/workflows/keck.yml' - '.github/workflows/keck.yml'
# Cancels all previous workflow runs for pull requests that have not completed. # Cancels all previous workflow runs for pull requests that have not completed.
@@ -60,7 +62,7 @@ jobs:
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with: with:
context: . context: .
file: ./Dockerfile-keck file: ./.github/deployment/Dockerfile-keck
push: ${{ github.ref == 'refs/heads/field' && true || false }} push: ${{ github.ref == 'refs/heads/field' && true || false }}
tags: ${{ steps.meta_keck.outputs.tags }} tags: ${{ steps.meta_keck.outputs.tags }}
labels: ${{ steps.meta_keck.outputs.labels }} labels: ${{ steps.meta_keck.outputs.labels }}
+1
View File
@@ -53,6 +53,7 @@ jobs:
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with: with:
context: . context: .
file: ./.github/deployment/Dockerfile-lisa
push: ${{ github.ref == 'refs/heads/master' && true || false }} push: ${{ github.ref == 'refs/heads/master' && true || false }}
tags: ${{ steps.meta_lisa.outputs.tags }} tags: ${{ steps.meta_lisa.outputs.tags }}
labels: ${{ steps.meta_lisa.outputs.labels }} labels: ${{ steps.meta_lisa.outputs.labels }}
+2 -1
View File
@@ -5,6 +5,7 @@ on:
branches: [master] branches: [master]
paths: paths:
- 'apps/venus/**' - 'apps/venus/**'
- '.github/deployment'
- '.github/workflows/venus.yml' - '.github/workflows/venus.yml'
pull_request: pull_request:
branches: [master] branches: [master]
@@ -59,7 +60,7 @@ jobs:
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with: with:
context: . context: .
file: ./Dockerfile-venus file: ./.github/deployment/Dockerfile-venus
push: ${{ github.ref == 'refs/heads/master' && true || false }} push: ${{ github.ref == 'refs/heads/master' && true || false }}
tags: ${{ steps.meta_venus.outputs.tags }} tags: ${{ steps.meta_venus.outputs.tags }}
labels: ${{ steps.meta_venus.outputs.labels }} labels: ${{ steps.meta_venus.outputs.labels }}
+33 -14
View File
@@ -14,7 +14,7 @@ Planning, Sorting and Creating all Together. Open-source, Privacy-First, and Fre
<!-- <!--
Make New Badge Pattern badges inline Make New Badge Pattern badges inline
See https://github.com/all-contributors/all-contributors/issues/361#issuecomment-637166066 See https://github.com/all-?/all-contributors/issues/361#issuecomment-637166066
--> -->
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
@@ -38,21 +38,27 @@ See https://github.com/all-contributors/all-contributors/issues/361#issuecomment
<a href="https://t.me/affineworkos"><b>Telegram</b></a> <a href="https://t.me/affineworkos"><b>Telegram</b></a>
</p> </p>
<p align="center"><img width="1920" alt="affine_screen" src="https://user-images.githubusercontent.com/79301703/182363099-48b479c3-dc26-4fc3-8f9b-45f9cf358f9a.png"><p/> <p align="center"><img width="1920" alt="affine_screen" src="https://user-images.githubusercontent.com/21084335/182552060-972cac0e-6258-4ccb-85bd-3bb466c30ccd.png"><p/>
# Stay Up-to-Date # Stay Up-to-Date
![952cd7a5-70fe-48ab-b74f-23981d94d2c5](https://user-images.githubusercontent.com/79301703/182365526-df074c64-cee4-45f6-b8e0-b912f17332c6.gif) ![952cd7a5-70fe-48ab-b74f-23981d94d2c5](https://user-images.githubusercontent.com/79301703/182365526-df074c64-cee4-45f6-b8e0-b912f17332c6.gif)
# How to use
If you have experience in front-end development, please [refer to here](https://affine.gitbook.io/affine/basic-documentation/contribute-to-affine); if you want to experience our latest version, please wait a moment, we will launch a web version in the near future
# Table of contents # Table of contents
- [Stay Up-to-Date](#stay-up-to-date) - [Stay Up-to-Date](#stay-up-to-date)
- [How to Use](#how-to-use)
- [Table of contents](#table-of-contents) - [Table of contents](#table-of-contents)
- [Shape your page](#shape-your-page) - [Shape your page](#shape-your-page)
- [Plan your task](#plan-your-task) - [Plan your task](#plan-your-task)
- [Sort your knowledge](#sort-your-knowledge) - [Sort your knowledge](#sort-your-knowledge)
- [Create your story](#create-your-story) - [Create your story](#create-your-story)
- [Getting Started with development](#getting-started-with-development) - [Documentation](#documentation)
- [Getting Started with development](#getting-started-with-development)
- [Roadmap](#roadmap) - [Roadmap](#roadmap)
- [Releases](#releases) - [Releases](#releases)
- [Feature requests](#feature-requests) - [Feature requests](#feature-requests)
@@ -60,6 +66,7 @@ See https://github.com/all-contributors/all-contributors/issues/361#issuecomment
- [The Philosophy of AFFiNE](#the-philosophy-of-affine) - [The Philosophy of AFFiNE](#the-philosophy-of-affine)
- [Community](#community) - [Community](#community)
- [Contributors](#contributors) - [Contributors](#contributors)
- [Acknowledgments](#acknowledgments)
- [License](#license) - [License](#license)
## Shape your page ## Shape your page
@@ -80,9 +87,13 @@ We want your data always to be yours, and we don't want to make any sacrifice to
Collaboration isn't only necessary for teams -- you may take and insert pics on your phone, then edit them on your desktop, and share them with your collaborators. Collaboration isn't only necessary for teams -- you may take and insert pics on your phone, then edit them on your desktop, and share them with your collaborators.
Affine is fully built with web technologies so that consistency and accessibility are always guaranteed on Mac, Windows and Linux. The local file system support will be available when version 0.0.1beta is released. Affine is fully built with web technologies so that consistency and accessibility are always guaranteed on Mac, Windows and Linux. The local file system support will be available when version 0.0.1beta is released.
# Getting Started with development # Documentation
Please view the [documentation](https://affine.gitbook.io/affine/) in Contribute-to-AFFiNE/Software-Contributions/Environment-setup. Please view the [documentation](https://affine.gitbook.io/affine/)
## Getting Started with development
Please view the path Contribute-to-AFFiNE/Software-Contributions/Quick-Start in documentation.
# Roadmap # Roadmap
@@ -134,9 +145,17 @@ We would like to give special thanks to the innovators and pioneers who greatly
We would also like to give thanks to open-source projects that make affine possible: We would also like to give thanks to open-source projects that make affine possible:
- Yjs & Yrs - [Yjs](https://github.com/yjs/yjs) & [Yrs](https://github.com/y-crdt/y-crdt) -- Fundamental support of CRDTs for our implements on state management and data sync.
- React - [React](https://github.com/facebook/react) -- View layer support and web GUI framework.
- Rust - [Rust](https://github.com/rust-lang/rust) -- High performance language that extends the ability and availability of our real-time backend, JWST.
- [Fossil](https://www2.fossil-scm.org/home/doc/trunk/www/index.wiki) -- Source code management tool made with CRDTs which inspired our design on block data structure.
- [slatejs](https://github.com/ianstormtaylor/slate) -- Customizable rich-text editor.
- [Jotai](https://github.com/pmndrs/jotai) -- Minimal state management tool for frontend.
- [Tldraw](https://github.com/tldraw/tldraw) -- Excellent drawing board.
- [MUI](https://github.com/mui/material-ui) -- Our most used graphic UI component library.
- Other [dependancies](https://github.com/toeverything/AFFiNE/network/dependencies)
Thanks a lot to the community for providing such powerful and simple libraries, so that we can focus more on the implementation of the product logic, and we hope that in the future our projects will also provide a more easy-to-use knowledge base for everyone.
# Community # Community
@@ -152,16 +171,16 @@ For help, discussion about best practices, or any other conversation that would
<table> <table>
<tr> <tr>
<td align="center"><a href="https://darksky.eu.org/"><img src="https://avatars.githubusercontent.com/u/25152247?v=4?s=100" width="100px;" alt=""/><br /><sub><b>DarkSky</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=darkskygit" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=darkskygit" title="Documentation">📖</a></td> <td align="center"><a href="https://darksky.eu.org/"><img src="https://avatars.githubusercontent.com/u/25152247?v=4?s=100" width="100px;" alt=""/><br /><sub><b>DarkSky</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=darkskygit" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=darkskygit" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/tzhangchi"><img src="https://avatars.githubusercontent.com/u/5910926?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Chi Zhang</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=tzhangchi" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=tzhangchi" title="Documentation">📖</a></td> <td align="center"><a href="http://zhangchi.page/"><img src="https://avatars.githubusercontent.com/u/5910926?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Chi Zhang</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=tzhangchi" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=tzhangchi" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/alt1o"><img src="https://avatars.githubusercontent.com/u/21084335?v=4?s=100" width="100px;" alt=""/><br /><sub><b>alt1o</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=alt1o" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=alt1o" title="Documentation">📖</a></td> <td align="center"><a href="https://github.com/alt1o"><img src="https://avatars.githubusercontent.com/u/21084335?v=4?s=100" width="100px;" alt=""/><br /><sub><b>wang xinglong</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=alt1o" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=alt1o" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/DiamondThree"><img src="https://avatars.githubusercontent.com/u/24630517?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Diamond</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=DiamondThree" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=DiamondThree" title="Documentation">📖</a></td> <td align="center"><a href="https://github.com/DiamondThree"><img src="https://avatars.githubusercontent.com/u/24630517?v=4?s=100" width="100px;" alt=""/><br /><sub><b>DiamondThree</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=DiamondThree" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=DiamondThree" title="Documentation">📖</a></td>
<td align="center"><a href="https://lawvs.github.io/profile/"><img src="https://avatars.githubusercontent.com/u/18554747?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Whitewater</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=lawvs" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=lawvs" title="Documentation">📖</a></td> <td align="center"><a href="https://lawvs.github.io/profile/"><img src="https://avatars.githubusercontent.com/u/18554747?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Whitewater</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=lawvs" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=lawvs" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/zuoxiaodong0815"><img src="https://avatars.githubusercontent.com/u/53252747?v=4?s=100" width="100px;" alt=""/><br /><sub><b>zuoxiaodong0815</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=zuoxiaodong0815" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=zuoxiaodong0815" title="Documentation">📖</a></td> <td align="center"><a href="https://github.com/zuoxiaodong0815"><img src="https://avatars.githubusercontent.com/u/53252747?v=4?s=100" width="100px;" alt=""/><br /><sub><b>xiaodong zuo</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=zuoxiaodong0815" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=zuoxiaodong0815" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/SaikaSakura"><img src="https://avatars.githubusercontent.com/u/11530942?v=4?s=100" width="100px;" alt=""/><br /><sub><b>SaikaSakura</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=SaikaSakura" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=SaikaSakura" title="Documentation">📖</a></td> <td align="center"><a href="https://github.com/SaikaSakura"><img src="https://avatars.githubusercontent.com/u/11530942?v=4?s=100" width="100px;" alt=""/><br /><sub><b>MingLIang Wang</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=SaikaSakura" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=SaikaSakura" title="Documentation">📖</a></td>
</tr> </tr>
<tr> <tr>
<td align="center"><a href="https://github.com/QiShaoXuan"><img src="https://avatars.githubusercontent.com/u/22772830?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Qi</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=QiShaoXuan" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=QiShaoXuan" title="Documentation">📖</a></td> <td align="center"><a href="https://github.com/QiShaoXuan"><img src="https://avatars.githubusercontent.com/u/22772830?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Qi</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=QiShaoXuan" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=QiShaoXuan" title="Documentation">📖</a></td>
<td align="center"><a href="https://tuluffy.github.io/angular.github.io/"><img src="https://avatars.githubusercontent.com/u/26808339?v=4?s=100" width="100px;" alt=""/><br /><sub><b>tuluffy</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=tuluffy" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=tuluffy" title="Documentation">📖</a></td> <td align="center"><a href="https://github.com/mitsuhatu"><img src="https://avatars.githubusercontent.com/u/110213079?v=4?s=100" width="100px;" alt=""/><br /><sub><b>mitsuhatu</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=mitsuhatu" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=mitsuhatu" title="Documentation">📖</a></td>
<td align="center"><a href="https://shockwave.me/"><img src="https://avatars.githubusercontent.com/u/15013925?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Austaras</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=Austaras" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=Austaras" title="Documentation">📖</a></td> <td align="center"><a href="https://shockwave.me/"><img src="https://avatars.githubusercontent.com/u/15013925?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Austaras</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=Austaras" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=Austaras" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/uptonking?tab=repositories&type=source"><img src="https://avatars.githubusercontent.com/u/11391549?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jin Yao</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=uptonking" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=uptonking" title="Documentation">📖</a></td> <td align="center"><a href="https://github.com/uptonking?tab=repositories&type=source"><img src="https://avatars.githubusercontent.com/u/11391549?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jin Yao</b></sub></a><br /><a href="https://github.com/toeverything/AFFiNE/commits?author=uptonking" title="Code">💻</a> <a href="https://github.com/toeverything/AFFiNE/commits?author=uptonking" title="Documentation">📖</a></td>
</tr> </tr>
@@ -1,16 +1,9 @@
/* eslint-disable filename-rules/match */ /* eslint-disable filename-rules/match */
import { import { useEffect, useRef, type UIEvent, useState } from 'react';
useEffect,
useRef,
type UIEvent,
useState,
useLayoutEffect,
} from 'react';
import { useParams } from 'react-router'; import { useParams } from 'react-router';
import { import {
MuiBox as Box, MuiBox as Box,
MuiCircularProgress as CircularProgress, MuiCircularProgress as CircularProgress,
MuiDivider as Divider,
styled, styled,
} from '@toeverything/components/ui'; } from '@toeverything/components/ui';
import { AffineEditor } from '@toeverything/components/affine-editor'; import { AffineEditor } from '@toeverything/components/affine-editor';
@@ -31,7 +24,7 @@ import { WorkspaceName } from './workspace-name';
import { CollapsiblePageTree } from './collapsible-page-tree'; import { CollapsiblePageTree } from './collapsible-page-tree';
import { useFlag } from '@toeverything/datasource/feature-flags'; import { useFlag } from '@toeverything/datasource/feature-flags';
import { type BlockEditor } from '@toeverything/components/editor-core'; import { type BlockEditor } from '@toeverything/components/editor-core';
import { Tabs } from './components/tabs';
type PageProps = { type PageProps = {
workspace: string; workspace: string;
}; };
@@ -54,11 +47,11 @@ export function Page(props: PageProps) {
} }
); );
// await services.api.userConfig.addRecentPage( await services.api.userConfig.addRecentPage(
// props.workspace, props.workspace,
// user.id, user.id,
// page_id page_id
// ); );
await services.api.editorBlock.clearUndoRedo(props.workspace); await services.api.editorBlock.clearUndoRedo(props.workspace);
}; };
updateRecentPages(); updateRecentPages();
@@ -80,7 +73,9 @@ export function Page(props: PageProps) {
onMouseLeave={() => setSpaceSidebarVisible(false)} onMouseLeave={() => setSpaceSidebarVisible(false)}
> >
<WorkspaceName /> <WorkspaceName />
<Divider light={true} sx={{ my: 1, margin: '6px 0px' }} />
<Tabs />
<WorkspaceSidebarContent> <WorkspaceSidebarContent>
<div> <div>
{dailyNotesFlag && ( {dailyNotesFlag && (
@@ -92,14 +87,14 @@ export function Page(props: PageProps) {
)} )}
<div> <div>
<CollapsibleTitle <CollapsibleTitle
title="Activities" title="ACTIVITIES"
initialOpen={false} initialOpen={false}
> >
<Activities /> <Activities />
</CollapsibleTitle> </CollapsibleTitle>
</div> </div>
<div> <div>
<CollapsiblePageTree title="Page Tree"> <CollapsiblePageTree title="PAGES">
{page_id ? <PageTree /> : null} {page_id ? <PageTree /> : null}
</CollapsiblePageTree> </CollapsiblePageTree>
</div> </div>
@@ -146,7 +141,7 @@ const EditorContainer = ({
obv.observe(scrollContainerRef.current); obv.observe(scrollContainerRef.current);
return () => obv.disconnect(); return () => obv.disconnect();
} }
}); }, [setPageClientWidth]);
return ( return (
<StyledEditorContainer <StyledEditorContainer
@@ -198,7 +193,7 @@ const LigoLeftContainer = styled('div')({
position: 'relative', position: 'relative',
}); });
const WorkspaceSidebar = styled('div')(({ hidden }) => ({ const WorkspaceSidebar = styled('div')(({ theme }) => ({
position: 'absolute', position: 'absolute',
bottom: '48px', bottom: '48px',
top: '12px', top: '12px',
@@ -208,7 +203,7 @@ const WorkspaceSidebar = styled('div')(({ hidden }) => ({
width: 300, width: 300,
minWidth: 300, minWidth: 300,
borderRadius: '0px 10px 10px 0px', borderRadius: '0px 10px 10px 0px',
boxShadow: '0px 1px 10px rgba(152, 172, 189, 0.6)', boxShadow: theme.affine.shadows.shadow1,
backgroundColor: '#FFFFFF', backgroundColor: '#FFFFFF',
transitionProperty: 'left', transitionProperty: 'left',
transitionDuration: '0.35s', transitionDuration: '0.35s',
@@ -219,4 +214,5 @@ const WorkspaceSidebar = styled('div')(({ hidden }) => ({
const WorkspaceSidebarContent = styled('div')({ const WorkspaceSidebarContent = styled('div')({
flex: 'auto', flex: 'auto',
overflow: 'hidden auto', overflow: 'hidden auto',
marginTop: '18px',
}); });
@@ -1,34 +1,34 @@
import { useCallback, useState } from 'react'; import React, { useCallback, useState } from 'react';
import { useNavigate, useParams } from 'react-router-dom'; import { useNavigate, useParams } from 'react-router-dom';
import clsx from 'clsx';
import style9 from 'style9';
import { import {
MuiBox as Box, MuiBox as Box,
MuiButton as Button, MuiButton as Button,
MuiCollapse as Collapse, MuiCollapse as Collapse,
MuiIconButton as IconButton, MuiIconButton as IconButton,
styled,
} from '@toeverything/components/ui'; } from '@toeverything/components/ui';
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'; import {
import ArrowRightIcon from '@mui/icons-material/ArrowRight'; ArrowDropDownIcon,
ArrowRightIcon,
} from '@toeverything/components/icons';
import { services } from '@toeverything/datasource/db-service'; import { services } from '@toeverything/datasource/db-service';
import { NewpageIcon } from '@toeverything/components/common';
import { import {
usePageTree, usePageTree,
useCalendarHeatmap, useCalendarHeatmap,
} from '@toeverything/components/layout'; } from '@toeverything/components/layout';
import { AddIcon } from '@toeverything/components/icons';
const styles = style9.create({ const StyledContainer = styled('div')({
ligoButton: { height: '32px',
display: 'flex',
alignItems: 'center',
});
const StyledBtn = styled('div')({
color: '#98ACBD',
textTransform: 'none', textTransform: 'none',
}, fontSize: '12px',
newPage: { fontWeight: '600',
color: '#B6C7D3',
width: '26px',
fontSize: '18px',
textAlign: 'center',
cursor: 'pointer',
},
}); });
export type CollapsiblePageTreeProps = { export type CollapsiblePageTreeProps = {
@@ -73,31 +73,35 @@ export function CollapsiblePageTree(props: CollapsiblePageTreeProps) {
justifyContent: 'space-between', justifyContent: 'space-between',
alignItems: 'center', alignItems: 'center',
paddingRight: 1, paddingRight: 1,
'&:hover': {
background: '#f5f7f8',
borderRadius: '5px',
},
}} }}
onMouseEnter={() => setNewPageBtnVisible(true)} onMouseEnter={() => setNewPageBtnVisible(true)}
onMouseLeave={() => setNewPageBtnVisible(false)} onMouseLeave={() => setNewPageBtnVisible(false)}
> >
<Button <StyledContainer>
startIcon={ {open ? (
open ? <ArrowDropDownIcon /> : <ArrowRightIcon /> <ArrowDropDownIcon sx={{ color: '#566B7D' }} />
} ) : (
onClick={() => setOpen(prev => !prev)} <ArrowRightIcon sx={{ color: '#566B7D' }} />
sx={{ color: '#566B7D', textTransform: 'none' }} )}
className={clsx(styles('ligoButton'), className)} <StyledBtn onClick={() => setOpen(prev => !prev)}>
style={style}
disableElevation
disableRipple
>
{title} {title}
</Button> </StyledBtn>
</StyledContainer>
{newPageBtnVisible && ( {newPageBtnVisible && (
<div <AddIcon
style={{
width: '20px',
height: '20px',
color: '#98ACBD',
cursor: 'pointer',
}}
onClick={create_page} onClick={create_page}
className={clsx(styles('newPage'), className)} />
>
+
</div>
)} )}
</Box> </Box>
{children ? ( {children ? (
@@ -0,0 +1,19 @@
export const Logo = ({ color, style, ...props }) => {
return (
<svg
width="52"
height="52"
viewBox="0 0 52 52"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<rect width="52" height="52" rx="10" fill="#3E6FDB" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M24.2189 11.4392L14.6321 38.7943H20.2472L26.3453 19.8747L32.4461 38.7943H38.0423L28.454 11.4392H24.2189Z"
fill="white"
/>
</svg>
);
};
@@ -0,0 +1 @@
export { Logo } from './Logo';
@@ -0,0 +1,61 @@
import { useState } from 'react';
import { MuiDivider as Divider, styled } from '@toeverything/components/ui';
import type { ValueOf } from '@toeverything/utils';
const StyledTabs = styled('div')({
width: '100%',
height: '12px',
marginTop: '12px',
display: 'flex',
alignItems: 'center',
cursor: 'pointer',
});
const StyledDivider = styled(Divider)<{ isActive?: boolean }>(
({ isActive }) => {
return {
flex: 1,
backgroundColor: isActive ? '#3E6FDB' : '#ECF1FB',
borderWidth: '2px',
};
}
);
const TAB_TITLE = {
PAGES: 'pages',
GALLERY: 'gallery',
TOC: 'toc',
} as const;
const TabMap = new Map<TabKey, TabValue>([
['PAGES', 'pages'],
['GALLERY', 'gallery'],
['TOC', 'toc'],
]);
type TabKey = keyof typeof TAB_TITLE;
type TabValue = ValueOf<typeof TAB_TITLE>;
const Tabs = () => {
const [activeTab, setActiveTab] = useState<TabValue>(TAB_TITLE.PAGES);
const onClick = (v: TabValue) => {
setActiveTab(v);
};
return (
<StyledTabs>
{[...TabMap.entries()].map(([k, v]) => {
return (
<StyledDivider
key={v}
isActive={v === activeTab}
onClick={() => onClick(v)}
/>
);
})}
</StyledTabs>
);
};
export { Tabs };
@@ -0,0 +1 @@
export { Tabs } from './Tabs';
@@ -1,27 +1,28 @@
import { import {
MuiButton as Button,
Switch,
styled, styled,
MuiOutlinedInput as OutlinedInput, MuiOutlinedInput as OutlinedInput,
} from '@toeverything/components/ui'; } from '@toeverything/components/ui';
import { LogoIcon } from '@toeverything/components/icons'; import { PinIcon } from '@toeverything/components/icons';
import { import {
useUserAndSpaces, useUserAndSpaces,
useShowSpaceSidebar, useShowSpaceSidebar,
} from '@toeverything/datasource/state'; } from '@toeverything/datasource/state';
import { useCallback, useEffect, useRef, useState } from 'react'; import React, { useCallback, useEffect, useState } from 'react';
import { services } from '@toeverything/datasource/db-service'; import { services } from '@toeverything/datasource/db-service';
import { Logo } from './components/logo/Logo';
const WorkspaceContainer = styled('div')({ const WorkspaceContainer = styled('div')({
display: 'flex', display: 'flex',
alignItems: 'center', flexDirection: 'column',
minHeight: 60, paddingBottom: '12px',
padding: '12px 0px',
color: '#566B7D', color: '#566B7D',
}); });
const LeftContainer = styled('div')({ const LeftContainer = styled('div')({
flex: 'auto', flex: 'auto',
display: 'flex', display: 'flex',
height: '52px',
alignItems: 'center',
margin: '0 12px',
}); });
const LogoContainer = styled('div')({ const LogoContainer = styled('div')({
@@ -32,20 +33,36 @@ const LogoContainer = styled('div')({
minWidth: 24, minWidth: 24,
}); });
const StyledLogoIcon = styled(LogoIcon)(({ theme }) => { const StyledPin = styled('div')({
return { display: 'flex',
color: theme.affine.palette.primary, justifyContent: 'end',
width: '16px !important', alignItems: 'center',
height: '16px !important', });
};
const StyledWorkspace = styled('div')({
height: '100%',
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
marginLeft: '12px',
paddingLeft: '12px',
});
const StyledWorkspaceDesc = styled('div')({
fontSize: '12px',
color: '#98ACBD',
height: '18px',
display: 'flex',
alignItems: 'center',
}); });
const WorkspaceNameContainer = styled('div')({ const WorkspaceNameContainer = styled('div')({
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',
flex: 'auto', flex: 'auto',
width: '100px', width: '165px',
marginRight: '10px', height: '34px',
input: { input: {
padding: '5px 10px', padding: '5px 10px',
}, },
@@ -58,21 +75,15 @@ const WorkspaceNameContainer = styled('div')({
}); });
const WorkspaceReNameContainer = styled('div')({ const WorkspaceReNameContainer = styled('div')({
marginRight: '10px', height: '34px',
display: 'flex',
alignItems: 'center',
input: { input: {
padding: '5px 10px', padding: '5px 10px',
}, },
}); });
const ToggleDisplayContainer = styled('div')({
display: 'flex',
alignItems: 'center',
fontSize: 12,
color: '#3E6FDB',
padding: 6,
minWidth: 64,
});
export const WorkspaceName = () => { export const WorkspaceName = () => {
const { currentSpaceId } = useUserAndSpaces(); const { currentSpaceId } = useUserAndSpaces();
const { fixedDisplay, toggleSpaceSidebar } = useShowSpaceSidebar(); const { fixedDisplay, toggleSpaceSidebar } = useShowSpaceSidebar();
@@ -139,14 +150,27 @@ export const WorkspaceName = () => {
return ( return (
<WorkspaceContainer> <WorkspaceContainer>
<StyledPin>
<PinIcon
style={{
width: '20px',
height: '20px',
color: fixedDisplay ? '#3E6FDB' : '',
cursor: 'pointer',
}}
onClick={toggleSpaceSidebar}
/>
</StyledPin>
<LeftContainer> <LeftContainer>
<LogoContainer> <LogoContainer>
<StyledLogoIcon /> <Logo color={undefined} style={undefined} />
</LogoContainer> </LogoContainer>
<StyledWorkspace>
{inRename ? ( {inRename ? (
<WorkspaceReNameContainer> <WorkspaceReNameContainer>
<OutlinedInput <OutlinedInput
style={{ width: '140px', height: '28px' }}
value={workspaceName} value={workspaceName}
onChange={handleChange} onChange={handleChange}
onKeyDown={handleKeyDown} onKeyDown={handleKeyDown}
@@ -160,14 +184,12 @@ export const WorkspaceName = () => {
</span> </span>
</WorkspaceNameContainer> </WorkspaceNameContainer>
)} )}
<StyledWorkspaceDesc>
To shape, Not to Adapt.
</StyledWorkspaceDesc>
</StyledWorkspace>
</LeftContainer> </LeftContainer>
<ToggleDisplayContainer onClick={toggleSpaceSidebar}>
<Switch
checked={fixedDisplay}
checkedLabel="ON"
uncheckedLabel="OFF"
/>
</ToggleDisplayContainer>
</WorkspaceContainer> </WorkspaceContainer>
); );
}; };
+4 -1
View File
@@ -14,6 +14,9 @@
}, },
"devDependencies": { "devDependencies": {
"mini-css-extract-plugin": "^2.6.1", "mini-css-extract-plugin": "^2.6.1",
"webpack": "^5.73.0" "image-minimizer-webpack-plugin": "^3.2.3",
"imagemin": "^8.0.1",
"imagemin-optipng": "^8.0.0",
"webpack": "^5.74.0"
} }
} }
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

+99 -51
View File
@@ -6,13 +6,18 @@ import clsx from 'clsx';
import { CssVarsProvider, styled } from '@mui/joy/styles'; import { CssVarsProvider, styled } from '@mui/joy/styles';
import { Box, Button, Container, Grid, SvgIcon, Typography } from '@mui/joy'; import { Box, Button, Container, Grid, SvgIcon, Typography } from '@mui/joy';
import Card from '@mui/joy/Card';
import GitHubIcon from '@mui/icons-material/GitHub'; import GitHubIcon from '@mui/icons-material/GitHub';
import RedditIcon from '@mui/icons-material/Reddit'; import RedditIcon from '@mui/icons-material/Reddit';
import TelegramIcon from '@mui/icons-material/Telegram'; import TelegramIcon from '@mui/icons-material/Telegram';
// eslint-disable-next-line no-restricted-imports // eslint-disable-next-line no-restricted-imports
import { useMediaQuery } from '@mui/material'; import { useMediaQuery } from '@mui/material';
import LogoImage from './logo.png';
import CollaborationImage from './collaboration.png';
import PageImage from './page.png';
import ShapeImage from './shape.png';
import TaskImage from './task.png';
const DiscordIcon = (props: any) => { const DiscordIcon = (props: any) => {
return ( return (
<SvgIcon <SvgIcon
@@ -20,12 +25,12 @@ const DiscordIcon = (props: any) => {
width="71" width="71"
height="55" height="55"
viewBox="0 0 71 55" viewBox="0 0 71 55"
fill="none" fill="currentcolor"
> >
<g clip-path="url(#clip0)"> <g clip-path="url(#clip0)">
<path <path
d="M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z" d="M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z"
fill="#23272A" fill="currentcolor"
/> />
</g> </g>
<defs> <defs>
@@ -407,10 +412,7 @@ export function App() {
}, },
}} }}
> >
<AffineImage <AffineImage src={PageImage} alt="AFFiNE main ui" />
src="/assets/page.png"
alt="AFFiNE main ui"
/>
</Box> </Box>
</Grid> </Grid>
<Grid xs={12} sx={{ display: 'flex' }}> <Grid xs={12} sx={{ display: 'flex' }}>
@@ -515,14 +517,16 @@ export function App() {
justifyContent: 'left', justifyContent: 'left',
textAlign: 'left', textAlign: 'left',
transition: 'all .5s', transition: 'all .5s',
// boxShadow: '2px 2px 40px #08f2', transform: 'scale(0.98)',
// ':hover': { boxShadow: '2px 2px 40px #0002',
// boxShadow: '2px 2px 40px #08f4', ':hover': {
// }, transform: 'scale(1)',
boxShadow: '2px 2px 40px #0004',
},
}} }}
> >
<AffineImage <AffineImage
src="/assets/shape.png" src={ShapeImage}
alt="AFFiNE Shape Your Page" alt="AFFiNE Shape Your Page"
/> />
</Box> </Box>
@@ -537,10 +541,10 @@ export function App() {
}} }}
> >
<Grid <Grid
xs={matches ? 12 : 4} xs={matches ? 12 : 6}
sx={{ sx={{
display: 'flex', display: 'flex',
...(matches ? {} : { marginRight: '4em' }), ...(matches ? {} : { marginLeft: '4em' }),
}} }}
> >
<Box <Box
@@ -584,7 +588,7 @@ export function App() {
</Box> </Box>
</Grid> </Grid>
<Grid <Grid
xs={matches ? 12 : 8} xs={matches ? 12 : 6}
sx={{ display: 'flex', width: '100%' }} sx={{ display: 'flex', width: '100%' }}
> >
<Box <Box
@@ -595,14 +599,16 @@ export function App() {
justifyContent: 'left', justifyContent: 'left',
textAlign: 'left', textAlign: 'left',
transition: 'all .5s', transition: 'all .5s',
// boxShadow: '2px 2px 40px #08f2', transform: 'scale(0.98)',
// ':hover': { boxShadow: '2px 2px 40px #0002',
// boxShadow: '2px 2px 40px #08f4', ':hover': {
// }, transform: 'scale(1)',
boxShadow: '2px 2px 40px #0004',
},
}} }}
> >
<AffineImage <AffineImage
src="/assets/task.png" src={TaskImage}
alt="AFFiNE Plan Your Task" alt="AFFiNE Plan Your Task"
/> />
</Box> </Box>
@@ -656,14 +662,14 @@ export function App() {
justifyContent: 'center', justifyContent: 'center',
margin: 'auto', margin: 'auto',
transition: 'all .5s', transition: 'all .5s',
// boxShadow: '2px 2px 40px #08f2', transform: 'scale(0.98)',
// ':hover': { ':hover': {
// boxShadow: '2px 2px 40px #08f4', transform: 'scale(1)',
// }, },
}} }}
> >
<AffineImage <AffineImage
src="/assets/collaboration.png" src={CollaborationImage}
alt="AFFiNE Privacy-first, and collaborative" alt="AFFiNE Privacy-first, and collaborative"
/> />
</Box> </Box>
@@ -676,7 +682,7 @@ export function App() {
margin: 'auto', margin: 'auto',
}} }}
> >
<AffineImage src="/assets/logo.png" alt="AFFiNE Logo" /> <AffineImage src={LogoImage} alt="AFFiNE Logo" />
</Box> </Box>
</Grid> </Grid>
<Grid xs={12} sx={{ display: 'flex' }}> <Grid xs={12} sx={{ display: 'flex' }}>
@@ -738,13 +744,20 @@ export function App() {
}} }}
> >
<Box sx={{ display: 'flex', width: '100%' }}> <Box sx={{ display: 'flex', width: '100%' }}>
<Card <Button
variant="plain"
sx={{ sx={{
display: 'flex',
flexDirection: 'column',
margin: 'auto', margin: 'auto',
minWidth: '4em', padding: '1em',
'--Card-padding': '4px', minWidth: '6em',
'--Card-radius': '0',
}} }}
onClick={() =>
window.open(
'https://github.com/toeverything/AFFiNE/'
)
}
> >
<Grid <Grid
xs={12} xs={12}
@@ -767,21 +780,30 @@ export function App() {
}} }}
> >
<Typography <Typography
sx={{ display: 'flex', color: '#888' }} sx={{
display: 'flex',
color: '#888',
fontSize: '0.5em',
}}
> >
GitHub GitHub
</Typography> </Typography>
</Grid> </Grid>
</Card> </Button>
</Box> </Box>
<Box sx={{ display: 'flex', width: '100%' }}> <Box sx={{ display: 'flex', width: '100%' }}>
<Card <Button
variant="plain"
sx={{ sx={{
display: 'flex',
flexDirection: 'column',
margin: 'auto', margin: 'auto',
minWidth: '4em', padding: '1em',
'--Card-padding': '4px', minWidth: '6em',
'--Card-radius': '0',
}} }}
onClick={() =>
window.open('https://www.reddit.com/r/Affine/')
}
> >
<Grid <Grid
xs={12} xs={12}
@@ -804,12 +826,16 @@ export function App() {
}} }}
> >
<Typography <Typography
sx={{ display: 'flex', color: '#888' }} sx={{
display: 'flex',
color: '#888',
fontSize: '0.5em',
}}
> >
Reddit Reddit
</Typography> </Typography>
</Grid> </Grid>
</Card> </Button>
</Box> </Box>
<Box <Box
sx={{ sx={{
@@ -817,13 +843,18 @@ export function App() {
width: '100%', width: '100%',
}} }}
> >
<Card <Button
variant="plain"
sx={{ sx={{
display: 'flex',
flexDirection: 'column',
margin: 'auto', margin: 'auto',
minWidth: '4em', padding: '1em',
'--Card-padding': '4px', minWidth: '6em',
'--Card-radius': '0',
}} }}
onClick={() =>
window.open('https://t.me/affineworkos')
}
> >
<Grid <Grid
xs={12} xs={12}
@@ -846,21 +877,30 @@ export function App() {
}} }}
> >
<Typography <Typography
sx={{ display: 'flex', color: '#888' }} sx={{
display: 'flex',
color: '#888',
fontSize: '0.5em',
}}
> >
Telegram Telegram
</Typography> </Typography>
</Grid> </Grid>
</Card> </Button>
</Box> </Box>
<Box sx={{ display: 'flex', width: '100%' }}> <Box sx={{ display: 'flex', width: '100%' }}>
<Card <Button
variant="plain"
sx={{ sx={{
display: 'flex',
flexDirection: 'column',
margin: 'auto', margin: 'auto',
minWidth: '4em', padding: '1em',
'--Card-padding': '4px', minWidth: '6em',
'--Card-radius': '0',
}} }}
onClick={() =>
window.open('https://discord.gg/yz6tGVsf5p')
}
> >
<Grid <Grid
xs={12} xs={12}
@@ -870,7 +910,11 @@ export function App() {
}} }}
> >
<DiscordIcon <DiscordIcon
sx={{ width: '36px', height: '36px' }} sx={{
width: '36px',
height: '36px',
color: '#09449d',
}}
/> />
</Grid> </Grid>
@@ -883,12 +927,16 @@ export function App() {
}} }}
> >
<Typography <Typography
sx={{ display: 'flex', color: '#888' }} sx={{
display: 'flex',
color: '#888',
fontSize: '0.5em',
}}
> >
Discord Discord
</Typography> </Typography>
</Grid> </Grid>
</Card> </Button>
</Box> </Box>
</Box> </Box>
<Grid xs={12} sx={{ display: 'flex', marginBottom: '2em' }}> <Grid xs={12} sx={{ display: 'flex', marginBottom: '2em' }}>
File renamed without changes.
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

-10
View File
@@ -1,10 +0,0 @@
<svg width="71" height="55" viewBox="0 0 71 55" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0)">
<path d="M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z" fill="#23272A"/>
</g>
<defs>
<clipPath id="clip0">
<rect width="71" height="55" fill="white"/>
</clipPath>
</defs>
</svg>

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

+9
View File
@@ -7,6 +7,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin'); const CompressionPlugin = require('compression-webpack-plugin');
const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin');
const Style9Plugin = require('style9/webpack'); const Style9Plugin = require('style9/webpack');
@@ -61,6 +62,14 @@ module.exports = function (webpackConfig) {
parallel: true, parallel: true,
}), }),
new CssMinimizerPlugin(), new CssMinimizerPlugin(),
new ImageMinimizerPlugin({
minimizer: {
implementation: ImageMinimizerPlugin.imageminMinify,
options: {
plugins: [['optipng', { optimizationLevel: 5 }]],
},
},
}),
], ],
splitChunks: { splitChunks: {
chunks: 'all', chunks: 'all',
@@ -29,6 +29,7 @@ import { ErrorBoundary } from 'react-error-boundary';
import { ErrorFallback } from './components/error-fallback'; import { ErrorFallback } from './components/error-fallback';
import { ZoomBar } from './components/zoom-bar'; import { ZoomBar } from './components/zoom-bar';
import { CommandPanel } from './components/command-panel'; import { CommandPanel } from './components/command-panel';
import { usePageClientWidth } from '@toeverything/datasource/state';
export interface TldrawProps extends TldrawAppCtorProps { export interface TldrawProps extends TldrawAppCtorProps {
/** /**
@@ -132,6 +133,9 @@ export function Tldraw({
tools, tools,
}: TldrawProps) { }: TldrawProps) {
const [sId, set_sid] = React.useState(id); const [sId, set_sid] = React.useState(id);
const { pageClientWidth } = usePageClientWidth();
// page padding left and right total 300px
const editorShapeInitSize = pageClientWidth - 300;
// Create a new app when the component mounts. // Create a new app when the component mounts.
const [app, setApp] = React.useState(() => { const [app, setApp] = React.useState(() => {
@@ -140,6 +144,7 @@ export function Tldraw({
callbacks, callbacks,
commands, commands,
getSession, getSession,
editorShapeInitSize,
tools, tools,
}); });
return app; return app;
@@ -11,6 +11,7 @@ import { StrokeLineStyleConfig } from './stroke-line-style-config';
import { Group, UnGroup } from './GroupOperation'; import { Group, UnGroup } from './GroupOperation';
import { DeleteShapes } from './DeleteOperation'; import { DeleteShapes } from './DeleteOperation';
import { Lock, Unlock } from './LockOperation'; import { Lock, Unlock } from './LockOperation';
import { FrameFillColorConfig } from './FrameFillColorConfig';
export const CommandPanel: FC<{ app: TldrawApp }> = ({ app }) => { export const CommandPanel: FC<{ app: TldrawApp }> = ({ app }) => {
const state = app.useStore(); const state = app.useStore();
@@ -51,6 +52,13 @@ export const CommandPanel: FC<{ app: TldrawApp }> = ({ app }) => {
shapes={config.fill.selectedShapes} shapes={config.fill.selectedShapes}
/> />
) : null, ) : null,
frameFill: config.frameFill.selectedShapes.length ? (
<FrameFillColorConfig
key="fill"
app={app}
shapes={config.frameFill.selectedShapes}
/>
) : null,
font: config.font.selectedShapes.length ? ( font: config.font.selectedShapes.length ? (
<FontSizeConfig <FontSizeConfig
key="font" key="font"
@@ -0,0 +1,89 @@
import type { FC } from 'react';
import type { TldrawApp } from '@toeverything/components/board-state';
import type { TDShape } from '@toeverything/components/board-types';
import {
Popover,
Tooltip,
IconButton,
useTheme,
} from '@toeverything/components/ui';
import {
ShapeColorNoneIcon,
ShapeColorDuotoneIcon,
} from '@toeverything/components/icons';
import { countBy, maxBy } from '@toeverything/utils';
import { getShapeIds } from './utils';
import { Palette } from '../palette';
interface BorderColorConfigProps {
app: TldrawApp;
shapes: TDShape[];
}
type ColorType = 'none' | string;
const _colors: ColorType[] = [
'rgba(255, 133, 137, 0.5)',
'rgba(255, 159, 101, 0.5)',
'rgba(255, 251, 69, 0.5)',
'rgba(64, 255, 138, 0.5)',
'rgba(26, 252, 255, 0.5)',
'rgba(198, 156, 255, 0.5)',
'rgba(255, 143, 224, 0.5)',
'rgba(152, 172, 189, 0.5)',
'rgba(216, 226, 248, 0.5)',
];
const _getIconRenderColor = (shapes: TDShape[]) => {
const counted = countBy(shapes, shape => shape.style.fill);
const max = maxBy(Object.entries(counted), ([c, n]) => n);
return max[0];
};
export const FrameFillColorConfig: FC<BorderColorConfigProps> = ({
app,
shapes,
}) => {
const theme = useTheme();
const setFillColor = (color: ColorType) => {
app.style(
{ fill: color, isFilled: color !== 'none' },
getShapeIds(shapes)
);
};
const iconColor = _getIconRenderColor(shapes);
return (
<Popover
trigger="hover"
placement="bottom-start"
content={
<Palette
colors={_colors}
selected={iconColor}
onSelect={setFillColor}
/>
}
>
<Tooltip content="Frame Background Color" placement="top-start">
<IconButton>
{iconColor === 'none' ? (
<ShapeColorNoneIcon />
) : (
<ShapeColorDuotoneIcon
style={{
color: iconColor,
border:
iconColor === '#FFFFFF'
? `1px solid ${theme.affine.palette.tagHover}`
: 0,
borderRadius: '5px',
}}
/>
)}
</IconButton>
</Tooltip>
</Popover>
);
};
@@ -7,6 +7,7 @@ interface Config {
type: type:
| 'stroke' | 'stroke'
| 'fill' | 'fill'
| 'frameFill'
| 'font' | 'font'
| 'group' | 'group'
| 'ungroup' | 'ungroup'
@@ -22,6 +23,10 @@ const _createInitConfig = (): Record<Config['type'], Config> => {
type: 'fill', type: 'fill',
selectedShapes: [], selectedShapes: [],
}, },
frameFill: {
type: 'frameFill',
selectedShapes: [],
},
stroke: { stroke: {
type: 'stroke', type: 'stroke',
selectedShapes: [], selectedShapes: [],
@@ -64,6 +69,7 @@ const _isSupportStroke = (shape: TDShape): boolean => {
TDShapeType.Pencil, TDShapeType.Pencil,
TDShapeType.Laser, TDShapeType.Laser,
TDShapeType.Highlight, TDShapeType.Highlight,
TDShapeType.Draw,
TDShapeType.Arrow, TDShapeType.Arrow,
TDShapeType.Line, TDShapeType.Line,
].some(type => type === shape.type); ].some(type => type === shape.type);
@@ -91,6 +97,10 @@ const _isSupportFont = (shape: TDShape): boolean => {
].some(type => type === shape.type); ].some(type => type === shape.type);
}; };
const _isSupportFrameFill = (shape: TDShape): boolean => {
return shape.type === TDShapeType.Frame;
};
export const useConfig = (app: TldrawApp): Record<Config['type'], Config> => { export const useConfig = (app: TldrawApp): Record<Config['type'], Config> => {
const state = app.useStore(); const state = app.useStore();
const selectedShapes = TLDR.get_selected_shapes(state, app.currentPageId); const selectedShapes = TLDR.get_selected_shapes(state, app.currentPageId);
@@ -105,6 +115,9 @@ export const useConfig = (app: TldrawApp): Record<Config['type'], Config> => {
if (_isSupportFont(cur)) { if (_isSupportFont(cur)) {
acc.font.selectedShapes.push(cur); acc.font.selectedShapes.push(cur);
} }
if (_isSupportFrameFill(cur)) {
acc.frameFill.selectedShapes.push(cur);
}
return acc; return acc;
}, },
_createInitConfig() _createInitConfig()
@@ -6,6 +6,7 @@ import {
TldrawPatch, TldrawPatch,
TDShape, TDShape,
TDStatus, TDStatus,
TDShapeType,
} from '@toeverything/components/board-types'; } from '@toeverything/components/board-types';
import { TLDR } from '@toeverything/components/board-state'; import { TLDR } from '@toeverything/components/board-state';
import { BaseSession } from './base-session'; import { BaseSession } from './base-session';
@@ -75,6 +76,10 @@ export class RotateSession extends BaseSession {
app: { currentPageId, currentPoint, shiftKey }, app: { currentPageId, currentPoint, shiftKey },
} = this; } = this;
const filteredShapes = initialShapes.filter(
shape => shape.shape.type !== TDShapeType.Editor
);
const shapes: Record<string, Partial<TDShape>> = {}; const shapes: Record<string, Partial<TDShape>> = {};
let directionDelta = let directionDelta =
@@ -85,7 +90,7 @@ export class RotateSession extends BaseSession {
} }
// Update the shapes // Update the shapes
initialShapes.forEach(({ center, shape }) => { filteredShapes.forEach(({ center, shape }) => {
const { rotation = 0 } = shape; const { rotation = 0 } = shape;
let shapeDelta = 0; let shapeDelta = 0;
@@ -1,12 +1,9 @@
import * as React from 'react'; /* eslint-disable no-restricted-syntax */
import { Utils, SVGContainer } from '@tldraw/core'; import { Utils, SVGContainer } from '@tldraw/core';
import { import {
FrameShape, FrameShape,
DashStyle,
TDShapeType, TDShapeType,
TDMeta, TDMeta,
GHOSTED_OPACITY,
LABEL_POINT,
} from '@toeverything/components/board-types'; } from '@toeverything/components/board-types';
import { TDShapeUtil } from '../TDShapeUtil'; import { TDShapeUtil } from '../TDShapeUtil';
import { import {
@@ -14,14 +11,13 @@ import {
getShapeStyle, getShapeStyle,
getBoundsRectangle, getBoundsRectangle,
transformRectangle, transformRectangle,
getFontStyle,
transformSingleRectangle, transformSingleRectangle,
} from '../shared'; } from '../shared';
import { DrawFrame } from './components/draw-frame'; import { Frame } from './components/Frame';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
type T = FrameShape; type T = FrameShape;
type E = HTMLDivElement; type E = SVGSVGElement;
export class FrameUtil extends TDShapeUtil<T, E> { export class FrameUtil extends TDShapeUtil<T, E> {
type = TDShapeType.Frame as const; type = TDShapeType.Frame as const;
@@ -56,10 +52,7 @@ export class FrameUtil extends TDShapeUtil<T, E> {
( (
{ {
shape, shape,
isEditing,
isBinding,
isSelected, isSelected,
isGhost,
meta, meta,
bounds, bounds,
events, events,
@@ -70,13 +63,13 @@ export class FrameUtil extends TDShapeUtil<T, E> {
) => { ) => {
const { id, size, style } = shape; const { id, size, style } = shape;
return ( return (
<FullWrapper ref={ref} {...events}>
<SVGContainer <SVGContainer
ref={ref}
{...events}
id={shape.id + '_svg'} id={shape.id + '_svg'}
opacity={1} opacity={1}
fill={'#fff'}
> >
<DrawFrame <Frame
id={id} id={id}
style={style} style={style}
size={size} size={size}
@@ -84,7 +77,6 @@ export class FrameUtil extends TDShapeUtil<T, E> {
isDarkMode={meta.isDarkMode} isDarkMode={meta.isDarkMode}
/> />
</SVGContainer> </SVGContainer>
</FullWrapper>
); );
} }
); );
@@ -121,27 +113,9 @@ export class FrameUtil extends TDShapeUtil<T, E> {
override transform = transformRectangle; override transform = transformRectangle;
override transformSingle = transformSingleRectangle; override transformSingle = transformSingleRectangle;
override hitTestPoint = (shape: T, point: number[]): boolean => {
return false;
};
override hitTestLineSegment = (
shape: T,
A: number[],
B: number[]
): boolean => {
return false;
};
} }
const FullWrapper = styled('div')({ const FullWrapper = styled('div')({
width: '100%', width: '100%',
height: '100%', height: '100%',
'.tl-fill-hitarea': {
fill: '#F7F9FF',
},
'.tl-stroke-hitarea': {
fill: '#F7F9FF',
},
}); });
@@ -0,0 +1,54 @@
import * as React from 'react';
import { BINDING_DISTANCE } from '@toeverything/components/board-types';
import type { ShapeStyles } from '@toeverything/components/board-types';
import { getShapeStyle } from '../../shared';
interface RectangleSvgProps {
id: string;
style: ShapeStyles;
isSelected: boolean;
size: number[];
isDarkMode: boolean;
}
export const Frame = React.memo(function DashedRectangle({
id,
style,
size,
isSelected,
isDarkMode,
}: RectangleSvgProps) {
const { strokeWidth, fill } = getShapeStyle(style, isDarkMode);
const _fill = fill && fill !== 'none' ? fill : '#F7F9FF';
const sw = 1 + strokeWidth * 1.618;
const w = Math.max(0, size[0] - sw / 2);
const h = Math.max(0, size[1] - sw / 2);
return (
<>
<rect
className={
isSelected || style.isFilled
? 'tl-fill-hitarea'
: 'tl-stroke-hitarea'
}
x={sw / 2}
y={sw / 2}
width={w}
height={h}
strokeWidth={BINDING_DISTANCE}
/>
<rect
x={sw / 2}
y={sw / 2}
width={w}
height={h}
fill={_fill}
pointerEvents="none"
/>
</>
);
});
@@ -1,42 +0,0 @@
import * as React from 'react';
import { BINDING_DISTANCE } from '@toeverything/components/board-types';
import type { ShapeStyles } from '@toeverything/components/board-types';
import { getShapeStyle } from '../../shared';
interface RectangleSvgProps {
id: string;
style: ShapeStyles;
isSelected: boolean;
size: number[];
isDarkMode: boolean;
}
export const DrawFrame = React.memo(function DashedRectangle({
id,
style,
size,
isSelected,
isDarkMode,
}: RectangleSvgProps) {
const { stroke, strokeWidth, fill } = getShapeStyle(style, isDarkMode);
const sw = 1 + strokeWidth * 1.618;
const w = Math.max(0, size[0] - sw / 2);
const h = Math.max(0, size[1] - sw / 2);
return (
<rect
className={
isSelected || style.isFilled
? 'tl-fill-hitarea'
: 'tl-stroke-hitarea'
}
x={sw / 2}
y={sw / 2}
width={w}
height={h}
strokeWidth={BINDING_DISTANCE}
/>
);
});
@@ -1 +1 @@
export * from './frame-util'; export * from './FrameUtil';
@@ -73,6 +73,7 @@ import { StateManager } from './manager/state-manager';
import { getClipboard, setClipboard } from './idb-clipboard'; import { getClipboard, setClipboard } from './idb-clipboard';
import type { Commands } from './types/commands'; import type { Commands } from './types/commands';
import type { BaseTool } from './types/tool'; import type { BaseTool } from './types/tool';
import { MIN_PAGE_WIDTH } from '@toeverything/components/editor-core';
const uuid = Utils.uniqueId(); const uuid = Utils.uniqueId();
@@ -178,6 +179,7 @@ export interface TldrawAppCtorProps {
getSession: (type: SessionType) => { getSession: (type: SessionType) => {
new (app: TldrawApp, ...args: any[]): BaseSessionType; new (app: TldrawApp, ...args: any[]): BaseSessionType;
}; };
editorShapeInitSize?: number;
commands: Commands; commands: Commands;
tools: Record<string, { new (app: TldrawApp): BaseTool }>; tools: Record<string, { new (app: TldrawApp): BaseTool }>;
} }
@@ -223,6 +225,8 @@ export class TldrawApp extends StateManager<TDSnapshot> {
fileSystemHandle: FileSystemHandle | null = null; fileSystemHandle: FileSystemHandle | null = null;
editorShapeInitSize = MIN_PAGE_WIDTH;
viewport = Utils.getBoundsFromPoints([ viewport = Utils.getBoundsFromPoints([
[0, 0], [0, 0],
[100, 100], [100, 100],
@@ -285,6 +289,10 @@ export class TldrawApp extends StateManager<TDSnapshot> {
return acc; return acc;
}, {} as Record<string, BaseTool>); }, {} as Record<string, BaseTool>);
this.currentTool = this.tools['select']; this.currentTool = this.tools['select'];
if (props.editorShapeInitSize) {
this.editorShapeInitSize = props.editorShapeInitSize;
}
} }
/* -------------------- Internal -------------------- */ /* -------------------- Internal -------------------- */
@@ -18,6 +18,7 @@ export class EditorTool extends BaseTool {
const { const {
currentPoint, currentPoint,
currentGrid, currentGrid,
editorShapeInitSize,
settings: { showGrid }, settings: { showGrid },
appState: { currentPageId, currentStyle }, appState: { currentPageId, currentStyle },
document: { id: workspace }, document: { id: workspace },
@@ -47,6 +48,7 @@ export class EditorTool extends BaseTool {
? Vec.snap(currentPoint, currentGrid) ? Vec.snap(currentPoint, currentGrid)
: currentPoint, : currentPoint,
style: { ...currentStyle }, style: { ...currentStyle },
size: [editorShapeInitSize, 200],
workspace, workspace,
}); });
// In order to make the cursor just positioned at the beginning of the first line, it needs to be adjusted according to the padding newShape.point = Vec.sub(newShape.point, [50, 30]); // In order to make the cursor just positioned at the beginning of the first line, it needs to be adjusted according to the padding newShape.point = Vec.sub(newShape.point, [50, 30]);
@@ -1,16 +1,21 @@
import { useState } from 'react'; import { useState } from 'react';
import clsx from 'clsx';
import style9 from 'style9';
import { import {
MuiButton as Button, MuiButton as Button,
MuiCollapse as Collapse, MuiCollapse as Collapse,
styled,
} from '@toeverything/components/ui'; } from '@toeverything/components/ui';
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'; import {
import ArrowRightIcon from '@mui/icons-material/ArrowRight'; ArrowDropDownIcon,
ArrowRightIcon,
} from '@toeverything/components/icons';
const styles = style9.create({ const StyledContainer = styled('div')({
ligoButton: { display: 'flex',
textTransform: 'none', alignItems: 'center',
cursor: 'pointer',
'&:hover': {
background: '#f5f7f8',
borderRadius: '5px',
}, },
}); });
@@ -24,29 +29,32 @@ export type CollapsibleTitleProps = {
}; };
export function CollapsibleTitle(props: CollapsibleTitleProps) { export function CollapsibleTitle(props: CollapsibleTitleProps) {
const { className, style, children, title, initialOpen = true } = props; const { children, title, initialOpen = true } = props;
const [open, setOpen] = useState(initialOpen); const [open, setOpen] = useState(initialOpen);
return ( return (
<> <>
<Button <StyledContainer onClick={() => setOpen(prev => !prev)}>
startIcon={ {open ? (
open ? (
<ArrowDropDownIcon sx={{ color: '#566B7D' }} /> <ArrowDropDownIcon sx={{ color: '#566B7D' }} />
) : ( ) : (
<ArrowRightIcon sx={{ color: '#566B7D' }} /> <ArrowRightIcon sx={{ color: '#566B7D' }} />
) )}
} <div
onClick={() => setOpen(prev => !prev)} style={{
sx={{ color: '#566B7D', textTransform: 'none' }} color: '#98ACBD',
className={clsx(styles('ligoButton'), className)} textTransform: 'none',
style={style} fontSize: '12px',
disableElevation fontWeight: '600',
disableRipple height: '32px',
display: 'flex',
alignItems: 'center',
}}
> >
{title} {title}
</Button> </div>
</StyledContainer>
{children ? ( {children ? (
<Collapse in={open} timeout="auto" unmountOnExit> <Collapse in={open} timeout="auto" unmountOnExit>
{children} {children}
@@ -121,11 +121,11 @@ const isLinkActive = (editor: ReactEditor) => {
const LinkStyledTooltip = styled(({ className, ...props }: MuiTooltipProps) => ( const LinkStyledTooltip = styled(({ className, ...props }: MuiTooltipProps) => (
<Tooltip {...props} classes={{ popper: className }} /> <Tooltip {...props} classes={{ popper: className }} />
))(() => ({ ))(({ theme }) => ({
[`& .${muiTooltipClasses.tooltip}`]: { [`& .${muiTooltipClasses.tooltip}`]: {
backgroundColor: '#fff', backgroundColor: '#fff',
color: '#4C6275', color: '#4C6275',
boxShadow: '0px 1px 10px rgba(152, 172, 189, 0.6)', boxShadow: theme.affine.shadows.shadow1,
fontSize: '14px', fontSize: '14px',
}, },
[`& .MuiTooltip-tooltipPlacementBottom`]: { [`& .MuiTooltip-tooltipPlacementBottom`]: {
@@ -412,8 +412,7 @@ export const LinkModal = memo((props: LinkModalProps) => {
visible && ( visible && (
<> <>
<LinkBehavior onMousedown={handle_mouse_down} rects={rects} /> <LinkBehavior onMousedown={handle_mouse_down} rects={rects} />
<div <LinkModalContainer
className={styles('linkModalContainer')}
style={{ style={{
top: top + height + GAP_BETWEEN_CONTENT_AND_MODAL, top: top + height + GAP_BETWEEN_CONTENT_AND_MODAL,
left, left,
@@ -431,7 +430,7 @@ export const LinkModal = memo((props: LinkModalProps) => {
autoComplete="off" autoComplete="off"
ref={inputEl} ref={inputEl}
/> />
</div> </LinkModalContainer>
</> </>
), ),
body body
@@ -491,19 +490,20 @@ const LinkBehavior = (props: {
); );
}; };
const styles = style9.create({ const LinkModalContainer = styled('div')(({ theme }) => ({
linkModalContainer: {
position: 'fixed', position: 'fixed',
width: '354px', width: '354px',
height: '40px', height: '40px',
padding: '12px', padding: '12px',
display: 'flex', display: 'flex',
borderRadius: '4px', borderRadius: '4px',
boxShadow: '0px 1px 10px rgba(152, 172, 189, 0.6)', boxShadow: theme.affine.shadows.shadow1,
backgroundColor: '#fff', backgroundColor: '#fff',
alignItems: 'center', alignItems: 'center',
zIndex: '1', zIndex: '1',
}, }));
const styles = style9.create({
linkModalContainerIcon: { linkModalContainerIcon: {
width: '16px', width: '16px',
margin: '0 16px 0 4px', margin: '0 16px 0 4px',
@@ -17,7 +17,7 @@ import {
supportChildren, supportChildren,
RenderBlockChildren, RenderBlockChildren,
useOnSelect, useOnSelect,
WrapperWithPendantAndDragDrop, BlockPendantProvider,
} from '@toeverything/components/editor-core'; } from '@toeverything/components/editor-core';
import { List } from '../../components/style-container'; import { List } from '../../components/style-container';
import { getChildrenType, BulletIcon, NumberType } from './data'; import { getChildrenType, BulletIcon, NumberType } from './data';
@@ -188,7 +188,7 @@ export const BulletView: FC<CreateView> = ({ block, editor }) => {
return ( return (
<BlockContainer editor={editor} block={block} selected={isSelect}> <BlockContainer editor={editor} block={block} selected={isSelect}>
<WrapperWithPendantAndDragDrop editor={editor} block={block}> <BlockPendantProvider block={block}>
<List> <List>
<BulletLeft> <BulletLeft>
<BulletIcon numberType={properties.numberType} /> <BulletIcon numberType={properties.numberType} />
@@ -206,7 +206,7 @@ export const BulletView: FC<CreateView> = ({ block, editor }) => {
/> />
</div> </div>
</List> </List>
</WrapperWithPendantAndDragDrop> </BlockPendantProvider>
<IndentWrapper> <IndentWrapper>
<RenderBlockChildren block={block} /> <RenderBlockChildren block={block} />
</IndentWrapper> </IndentWrapper>
@@ -50,7 +50,7 @@ import { Option, Select } from '@toeverything/components/ui';
import { import {
useOnSelect, useOnSelect,
WrapperWithPendantAndDragDrop, BlockPendantProvider,
} from '@toeverything/components/editor-core'; } from '@toeverything/components/editor-core';
import { copyToClipboard } from '@toeverything/utils'; import { copyToClipboard } from '@toeverything/utils';
interface CreateCodeView extends CreateView { interface CreateCodeView extends CreateView {
@@ -163,7 +163,7 @@ export const CodeView: FC<CreateCodeView> = ({ block, editor }) => {
editor.selectionManager.activePreviousNode(block.id, 'start'); editor.selectionManager.activePreviousNode(block.id, 'start');
}; };
return ( return (
<WrapperWithPendantAndDragDrop editor={editor} block={block}> <BlockPendantProvider block={block}>
<CodeBlock <CodeBlock
onKeyDown={e => { onKeyDown={e => {
e.stopPropagation(); e.stopPropagation();
@@ -222,6 +222,6 @@ export const CodeView: FC<CreateCodeView> = ({ block, editor }) => {
handleKeyArrowUp={handleKeyArrowUp} handleKeyArrowUp={handleKeyArrowUp}
/> />
</CodeBlock> </CodeBlock>
</WrapperWithPendantAndDragDrop> </BlockPendantProvider>
); );
}; };
@@ -1,7 +1,7 @@
import { FC, useState } from 'react'; import { FC, useState } from 'react';
import { CreateView } from '@toeverything/framework/virgo'; import { CreateView } from '@toeverything/framework/virgo';
import { import {
WrapperWithPendantAndDragDrop, BlockPendantProvider,
useOnSelect, useOnSelect,
} from '@toeverything/components/editor-core'; } from '@toeverything/components/editor-core';
import { Upload } from '../../components/upload/upload'; import { Upload } from '../../components/upload/upload';
@@ -33,7 +33,7 @@ export const EmbedLinkView: FC<EmbedLinkView> = props => {
}; };
return ( return (
<WrapperWithPendantAndDragDrop editor={editor} block={block}> <BlockPendantProvider block={block}>
<LinkContainer> <LinkContainer>
{embedLinkUrl ? ( {embedLinkUrl ? (
<SourceView <SourceView
@@ -53,6 +53,6 @@ export const EmbedLinkView: FC<EmbedLinkView> = props => {
/> />
)} )}
</LinkContainer> </LinkContainer>
</WrapperWithPendantAndDragDrop> </BlockPendantProvider>
); );
}; };
@@ -2,7 +2,7 @@ import { FC, useState } from 'react';
import { CreateView } from '@toeverything/framework/virgo'; import { CreateView } from '@toeverything/framework/virgo';
import { import {
useOnSelect, useOnSelect,
WrapperWithPendantAndDragDrop, BlockPendantProvider,
} from '@toeverything/components/editor-core'; } from '@toeverything/components/editor-core';
import { Upload } from '../../components/upload/upload'; import { Upload } from '../../components/upload/upload';
import { SourceView } from '../../components/source-view'; import { SourceView } from '../../components/source-view';
@@ -30,7 +30,7 @@ export const FigmaView: FC<FigmaView> = ({ block, editor }) => {
setIsSelect(isSelect); setIsSelect(isSelect);
}); });
return ( return (
<WrapperWithPendantAndDragDrop editor={editor} block={block}> <BlockPendantProvider block={block}>
<LinkContainer> <LinkContainer>
{figmaUrl ? ( {figmaUrl ? (
<SourceView <SourceView
@@ -52,6 +52,6 @@ export const FigmaView: FC<FigmaView> = ({ block, editor }) => {
/> />
)} )}
</LinkContainer> </LinkContainer>
</WrapperWithPendantAndDragDrop> </BlockPendantProvider>
); );
}; };
@@ -60,7 +60,7 @@ const GroupContainer = styled('div')<{ isSelect?: boolean }>(
({ isSelect, theme }) => ({ ({ isSelect, theme }) => ({
background: theme.affine.palette.white, background: theme.affine.palette.white,
border: '2px solid rgba(236,241,251,.5)', border: '2px solid rgba(236,241,251,.5)',
padding: '15px 12px', padding: `15px 16px 0 16px`,
borderRadius: '10px', borderRadius: '10px',
...(isSelect ...(isSelect
? { ? {
@@ -69,7 +69,7 @@ const GroupContainer = styled('div')<{ isSelect?: boolean }>(
} }
: { : {
'&:hover': { '&:hover': {
boxShadow: '0px 1px 10px rgb(152 172 189 / 60%)', boxShadow: theme.affine.shadows.shadow1,
}, },
}), }),
}) })
@@ -2,11 +2,11 @@ import { styled } from '@toeverything/components/ui';
import type { ComponentPropsWithRef, MouseEvent } from 'react'; import type { ComponentPropsWithRef, MouseEvent } from 'react';
import { forwardRef } from 'react'; import { forwardRef } from 'react';
const StyledPanel = styled('div')(() => ({ const StyledPanel = styled('div')(({ theme }) => ({
position: 'absolute', position: 'absolute',
top: 50, top: 50,
background: '#FFFFFF', background: '#FFFFFF',
boxShadow: '0px 1px 10px rgba(152, 172, 189, 0.6)', boxShadow: theme.affine.shadows.shadow1,
borderRadius: 10, borderRadius: 10,
padding: '12px 24px', padding: '12px 24px',
})); }));
@@ -41,6 +41,7 @@ const getKanbanColor = (
return DEFAULT_COLOR; return DEFAULT_COLOR;
} }
if ( if (
group.type === PropertyType.Status ||
group.type === PropertyType.Select || group.type === PropertyType.Select ||
group.type === PropertyType.MultiSelect || group.type === PropertyType.MultiSelect ||
group.type === DEFAULT_GROUP_ID group.type === DEFAULT_GROUP_ID
@@ -1,7 +1,7 @@
import { import {
useCurrentView, useCurrentView,
useOnSelect, useOnSelect,
WrapperWithPendantAndDragDrop, BlockPendantProvider,
} from '@toeverything/components/editor-core'; } from '@toeverything/components/editor-core';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import { services } from '@toeverything/datasource/db-service'; import { services } from '@toeverything/datasource/db-service';
@@ -158,7 +158,7 @@ export const ImageView: FC<ImageView> = ({ block, editor }) => {
}; };
return ( return (
<WrapperWithPendantAndDragDrop editor={editor} block={block}> <BlockPendantProvider block={block}>
<ImageBlock> <ImageBlock>
<div ref={resize_box}> <div ref={resize_box}>
{imgUrl ? ( {imgUrl ? (
@@ -229,6 +229,6 @@ export const ImageView: FC<ImageView> = ({ block, editor }) => {
</div> */} </div> */}
</div> </div>
</ImageBlock> </ImageBlock>
</WrapperWithPendantAndDragDrop> </BlockPendantProvider>
); );
}; };
@@ -19,9 +19,8 @@ import {
supportChildren, supportChildren,
RenderBlockChildren, RenderBlockChildren,
useOnSelect, useOnSelect,
WrapperWithPendantAndDragDrop, BlockPendantProvider,
} from '@toeverything/components/editor-core'; } from '@toeverything/components/editor-core';
import { styled } from '@toeverything/components/ui';
import { List } from '../../components/style-container'; import { List } from '../../components/style-container';
import { BlockContainer } from '../../components/BlockContainer'; import { BlockContainer } from '../../components/BlockContainer';
@@ -185,7 +184,7 @@ export const NumberedView: FC<CreateView> = ({ block, editor }) => {
return ( return (
<BlockContainer editor={editor} block={block} selected={isSelect}> <BlockContainer editor={editor} block={block} selected={isSelect}>
<WrapperWithPendantAndDragDrop editor={editor} block={block}> <BlockPendantProvider block={block}>
<List> <List>
<div className={'checkBoxContainer'}> <div className={'checkBoxContainer'}>
{getNumber(properties.numberType, number)}. {getNumber(properties.numberType, number)}.
@@ -203,7 +202,7 @@ export const NumberedView: FC<CreateView> = ({ block, editor }) => {
/> />
</div> </div>
</List> </List>
</WrapperWithPendantAndDragDrop> </BlockPendantProvider>
<IndentWrapper> <IndentWrapper>
<RenderBlockChildren block={block} /> <RenderBlockChildren block={block} />
@@ -8,7 +8,7 @@ import {
supportChildren, supportChildren,
unwrapGroup, unwrapGroup,
useOnSelect, useOnSelect,
WrapperWithPendantAndDragDrop, BlockPendantProvider,
} from '@toeverything/components/editor-core'; } from '@toeverything/components/editor-core';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import { Protocol } from '@toeverything/datasource/db-service'; import { Protocol } from '@toeverything/datasource/db-service';
@@ -231,7 +231,7 @@ export const TextView: FC<CreateTextView> = ({
selected={isSelect} selected={isSelect}
className={containerClassName} className={containerClassName}
> >
<WrapperWithPendantAndDragDrop editor={editor} block={block}> <BlockPendantProvider block={block}>
<TextBlock <TextBlock
block={block} block={block}
type={block.type} type={block.type}
@@ -242,7 +242,7 @@ export const TextView: FC<CreateTextView> = ({
handleConvert={handleConvert} handleConvert={handleConvert}
handleTab={onTab} handleTab={onTab}
/> />
</WrapperWithPendantAndDragDrop> </BlockPendantProvider>
<IndentWrapper> <IndentWrapper>
<RenderBlockChildren block={block} /> <RenderBlockChildren block={block} />
</IndentWrapper> </IndentWrapper>
@@ -3,7 +3,7 @@ import {
RenderBlock, RenderBlock,
useCurrentView, useCurrentView,
useOnSelect, useOnSelect,
WrapperWithPendantAndDragDrop, BlockPendantProvider,
} from '@toeverything/components/editor-core'; } from '@toeverything/components/editor-core';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import type { import type {
@@ -13,7 +13,6 @@ import type {
ReactElement, ReactElement,
} from 'react'; } from 'react';
import { forwardRef, useState } from 'react'; import { forwardRef, useState } from 'react';
import style9 from 'style9';
import { SCENE_CONFIG } from '../blocks/group/config'; import { SCENE_CONFIG } from '../blocks/group/config';
import { BlockContainer } from '../components/BlockContainer'; import { BlockContainer } from '../components/BlockContainer';
@@ -30,29 +29,15 @@ const TreeView = forwardRef<
{ lastItem?: boolean } & ComponentPropsWithRef<'div'> { lastItem?: boolean } & ComponentPropsWithRef<'div'>
>(({ lastItem, children, onClick, ...restProps }, ref) => { >(({ lastItem, children, onClick, ...restProps }, ref) => {
return ( return (
<div ref={ref} className={treeStyles('treeWrapper')} {...restProps}> <TreeWrapper ref={ref} {...restProps}>
<div className={treeStyles('treeView')}> <StyledTreeView>
<div <VerticalLine last={lastItem} onClick={onClick} />
className={treeStyles({ <HorizontalLine last={lastItem} onClick={onClick} />
line: true, {lastItem && <LastItemRadius />}
verticalLine: true, </StyledTreeView>
lastItemVerticalLine: lastItem,
})}
onClick={onClick}
/>
<div
className={treeStyles({
line: true,
horizontalLine: true,
lastItemHorizontalLine: lastItem,
})}
onClick={onClick}
/>
{lastItem && <div className={treeStyles('lastItemRadius')} />}
</div>
{/* maybe need a child wrapper */} {/* maybe need a child wrapper */}
{children} {children}
</div> </TreeWrapper>
); );
}); });
@@ -71,10 +56,7 @@ const ChildrenView = ({
const isKanbanScene = currentView.type === SCENE_CONFIG.KANBAN; const isKanbanScene = currentView.type === SCENE_CONFIG.KANBAN;
return ( return (
<div <Children style={{ ...(!isKanbanScene && { marginLeft: indent }) }}>
className={styles('children')}
style={{ ...(!isKanbanScene && { marginLeft: indent }) }}
>
{childrenIds.map((childId, idx) => { {childrenIds.map((childId, idx) => {
if (isKanbanScene) { if (isKanbanScene) {
return ( return (
@@ -94,7 +76,7 @@ const ChildrenView = ({
</TreeView> </TreeView>
); );
})} })}
</div> </Children>
); );
}; };
@@ -104,9 +86,7 @@ const CollapsedNode = forwardRef<
>((props, ref) => { >((props, ref) => {
return ( return (
<TreeView ref={ref} lastItem={true} {...props}> <TreeView ref={ref} lastItem={true} {...props}>
<div className={treeStyles('collapsed')} onClick={props.onClick}> <Collapsed onClick={props.onClick}>···</Collapsed>
···
</div>
</TreeView> </TreeView>
); );
}); });
@@ -146,11 +126,11 @@ export const withTreeViewChildren = (
editor={props.editor} editor={props.editor}
block={block} block={block}
selected={isSelect} selected={isSelect}
className={styles('wrapper')} className={Wrapper.toString()}
> >
<WrapperWithPendantAndDragDrop editor={editor} block={block}> <BlockPendantProvider block={block}>
<div className={styles('node')}>{creator(props)}</div> <div>{creator(props)}</div>
</WrapperWithPendantAndDragDrop> </BlockPendantProvider>
{collapsed && ( {collapsed && (
<CollapsedNode <CollapsedNode
@@ -170,93 +150,79 @@ export const withTreeViewChildren = (
}; };
}; };
const styles = style9.create({ const Wrapper = styled('div')({ display: 'flex', flexDirection: 'column' });
wrapper: {
display: 'flex',
flexDirection: 'column',
},
node: {},
children: { const Children = Wrapper;
display: 'flex',
flexDirection: 'column', const TREE_COLOR = '#D5DFE6';
}, // TODO determine the position of the horizontal line by the type of the item
const ITEM_POINT_HEIGHT = '12.5px'; // '50%'
const TreeWrapper = styled('div')({
position: 'relative',
}); });
const treeColor = '#D5DFE6'; const StyledTreeView = styled('div')({
// TODO determine the position of the horizontal line by the type of the item
const itemPointHeight = '12.5px'; // '50%'
const treeStyles = style9.create({
treeWrapper: {
position: 'relative',
},
treeView: {
position: 'absolute', position: 'absolute',
left: '-21px', left: '-21px',
height: '100%', height: '100%',
}, });
line: {
const Line = styled('div')({
position: 'absolute', position: 'absolute',
cursor: 'pointer', cursor: 'pointer',
backgroundColor: treeColor, backgroundColor: TREE_COLOR,
boxSizing: 'content-box', // somehow tldraw would override this
boxSizing: 'content-box!important' as any,
// See [Can I add background color only for padding?](https://stackoverflow.com/questions/14628601/can-i-add-background-color-only-for-padding) // See [Can I add background color only for padding?](https://stackoverflow.com/questions/14628601/can-i-add-background-color-only-for-padding)
backgroundClip: 'content-box', backgroundClip: 'content-box',
backgroundOrigin: 'content-box', backgroundOrigin: 'content-box',
// Increase click hot spot // Increase click hot spot
padding: '10px', padding: '10px',
}, });
verticalLine: {
const VerticalLine = styled(Line)<{ last: boolean }>(({ last }) => ({
width: '1px', width: '1px',
height: '100%', height: last ? ITEM_POINT_HEIGHT : '100%',
paddingTop: 0, paddingTop: 0,
paddingBottom: 0, paddingBottom: 0,
transform: 'translate(-50%, 0)', transform: 'translate(-50%, 0)',
},
horizontalLine: { opacity: last ? 0 : 'unset',
}));
const HorizontalLine = styled(Line)<{ last: boolean }>(({ last }) => ({
width: '16px', width: '16px',
height: '1px', height: '1px',
paddingLeft: 0, paddingLeft: 0,
paddingRight: 0, paddingRight: 0,
top: itemPointHeight, top: ITEM_POINT_HEIGHT,
transform: 'translate(0, -50%)', transform: 'translate(0, -50%)',
}, opacity: last ? 0 : 'unset',
noItemHorizontalLine: { }));
display: 'none',
},
lastItemHorizontalLine: { const Collapsed = styled('div')({
opacity: 0, cursor: 'pointer',
}, display: 'inline-block',
lastItemVerticalLine: { color: '#B9CAD5',
height: itemPointHeight, });
opacity: 0,
}, const LastItemRadius = styled('div')({
lastItemRadius: {
boxSizing: 'content-box', boxSizing: 'content-box',
position: 'absolute', position: 'absolute',
left: '-0.5px', left: '-0.5px',
top: 0, top: 0,
height: itemPointHeight, height: ITEM_POINT_HEIGHT,
bottom: '50%', bottom: '50%',
width: '16px', width: '16px',
borderWidth: '1px', borderWidth: '1px',
borderStyle: 'solid', borderStyle: 'solid',
borderLeftColor: treeColor, borderLeftColor: TREE_COLOR,
borderBottomColor: treeColor, borderBottomColor: TREE_COLOR,
borderTop: 'none', borderTop: 'none',
borderRight: 'none', borderRight: 'none',
borderRadius: '0 0 0 3px', borderRadius: '0 0 0 3px',
pointerEvents: 'none', pointerEvents: 'none',
},
collapsed: {
cursor: 'pointer',
display: 'inline-block',
color: '#B9CAD5',
},
}); });
const StyledBorder = styled('div')({ const StyledBorder = styled('div')({
@@ -1,21 +0,0 @@
import { AsyncBlock, BlockEditor } from '../editor';
import type { FC, ReactElement } from 'react';
import { BlockPendantProvider } from '../block-pendant';
import { DragDropWrapper } from '../drag-drop-wrapper';
type BlockContentWrapperProps = {
block: AsyncBlock;
editor: BlockEditor;
children: ReactElement | null;
};
export const WrapperWithPendantAndDragDrop: FC<BlockContentWrapperProps> =
function ({ block, children, editor }) {
return (
<DragDropWrapper block={block} editor={editor}>
<BlockPendantProvider block={block}>
{children}
</BlockPendantProvider>
</DragDropWrapper>
);
};
@@ -1 +0,0 @@
export * from './BlockContentWrapper';
@@ -1,5 +1,4 @@
import type { FC, PropsWithChildren } from 'react'; import type { FC, PropsWithChildren } from 'react';
import React, { useState } from 'react';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import type { AsyncBlock } from '../editor'; import type { AsyncBlock } from '../editor';
import { PendantPopover } from './pendant-popover'; import { PendantPopover } from './pendant-popover';
@@ -11,48 +10,28 @@ interface BlockTagProps {
block: AsyncBlock; block: AsyncBlock;
} }
/**
* @deprecated Need to be refactored
*/
export const BlockPendantProvider: FC<PropsWithChildren<BlockTagProps>> = ({ export const BlockPendantProvider: FC<PropsWithChildren<BlockTagProps>> = ({
block, block,
children, children,
}) => { }) => {
const [container, setContainer] = useState<HTMLElement>(null);
const [isHover, setIsHover] = useState(false);
return ( return (
<Container ref={(dom: HTMLElement) => setContainer(dom)}> <Container>
{children} {children}
{container && (
<PendantPopover <PendantPopover block={block}>
block={block} <StyledTriggerLine />
container={container}
onVisibleChange={visible => {
setIsHover(visible);
}}
>
<StyledTriggerLine
className="triggerLine"
isHover={isHover}
/>
</PendantPopover> </PendantPopover>
)}
<PendantRender block={block} /> <PendantRender block={block} />
</Container> </Container>
); );
}; };
const Container = styled('div')({ export const LINE_GAP = 16;
position: 'relative', const TAG_GAP = 4;
padding: '4px',
'&:hover .triggerLine::before': {
display: 'flex',
},
});
const StyledTriggerLine = styled('div')<{ isHover: boolean }>(({ isHover }) => { const StyledTriggerLine = styled('div')({
return { padding: `${TAG_GAP}px 0`,
padding: '4px 0',
width: '100px', width: '100px',
cursor: 'default', cursor: 'default',
display: 'flex', display: 'flex',
@@ -71,7 +50,7 @@ const StyledTriggerLine = styled('div')<{ isHover: boolean }>(({ isHover }) => {
}, },
'::after': { '::after': {
content: "''", content: "''",
width: isHover ? '100%' : '0', width: '0',
height: '2px', height: '2px',
background: '#aac4d5', background: '#aac4d5',
display: 'block', display: 'block',
@@ -80,5 +59,19 @@ const StyledTriggerLine = styled('div')<{ isHover: boolean }>(({ isHover }) => {
top: '4px', top: '4px',
transition: 'width .3s', transition: 'width .3s',
}, },
}; });
const Container = styled('div')({
position: 'relative',
paddingBottom: `${LINE_GAP - TAG_GAP * 2}px`,
'&:hover': {
[StyledTriggerLine.toString()]: {
'&::before': {
display: 'flex',
},
'&::after': {
width: '100%',
},
},
},
}); });
@@ -1,5 +1,4 @@
import React, { ReactNode, useRef, useEffect, useState } from 'react'; import React, { ReactNode, useRef, useEffect, useState } from 'react';
import { getPendantHistory } from '../utils';
import { import {
getRecastItemValue, getRecastItemValue,
RecastMetaProperty, RecastMetaProperty,
@@ -30,22 +29,22 @@ export const PendantHistoryPanel = ({
const [history, setHistory] = useState<RecastBlockValue[]>([]); const [history, setHistory] = useState<RecastBlockValue[]>([]);
const popoverHandlerRef = useRef<{ [key: string]: PopperHandler }>({}); const popoverHandlerRef = useRef<{ [key: string]: PopperHandler }>({});
const { getValueHistory } = getRecastItemValue(block);
useEffect(() => { useEffect(() => {
const init = async () => { const init = async () => {
const currentBlockValues = getRecastItemValue(block).getAllValue(); const currentBlockValues = getRecastItemValue(block).getAllValue();
const allProperties = getProperties(); const missValues = getProperties().filter(
const missProperties = allProperties.filter(
property => !currentBlockValues.find(v => v.id === property.id) property => !currentBlockValues.find(v => v.id === property.id)
); );
const pendantHistory = getPendantHistory({ const valueHistory = getValueHistory({
recastBlockId: recastBlock.id, recastBlockId: recastBlock.id,
}); });
const historyMap = missProperties.reduce<{ const historyMap = missValues.reduce<{
[key: RecastPropertyId]: string; [key: RecastPropertyId]: string[];
}>((history, property) => { }>((history, property) => {
if (pendantHistory[property.id]) { if (valueHistory[property.id]) {
history[property.id] = pendantHistory[property.id]; history[property.id] = valueHistory[property.id];
} }
return history; return history;
@@ -54,18 +53,30 @@ export const PendantHistoryPanel = ({
const blockHistory = ( const blockHistory = (
await Promise.all( await Promise.all(
Object.entries(historyMap).map( Object.entries(historyMap).map(
async ([propertyId, blockId]) => { async ([propertyId, blockIds]) => {
const latestValueBlock = ( const blocks = await groupBlock.children();
await groupBlock.children() const latestChangeBlock = blockIds
).find((block: AsyncBlock) => block.id === blockId); .reverse()
.reduce<AsyncBlock>((block, id) => {
if (!block) {
return blocks.find(
block => block.id === id
);
}
return block;
}, null);
if (latestChangeBlock) {
return getRecastItemValue( return getRecastItemValue(
latestValueBlock latestChangeBlock
).getValue(propertyId as RecastPropertyId); ).getValue(propertyId as RecastPropertyId);
} }
return null;
}
) )
) )
).filter(v => v); ).filter(v => v);
setHistory(blockHistory); setHistory(blockHistory);
}; };
@@ -4,7 +4,7 @@ import { ModifyPanelContentProps } from './types';
import { StyledDivider, StyledPopoverSubTitle } from '../StyledComponent'; import { StyledDivider, StyledPopoverSubTitle } from '../StyledComponent';
import { BasicSelect } from './Select'; import { BasicSelect } from './Select';
import { InformationProperty, InformationValue } from '../../recast-block'; import { InformationProperty, InformationValue } from '../../recast-block';
import { genInitialOptions, getPendantIconsConfigByName } from '../utils'; import { generateInitialOptions, getPendantIconsConfigByName } from '../utils';
export default (props: ModifyPanelContentProps) => { export default (props: ModifyPanelContentProps) => {
const { onPropertyChange, onValueChange, initialValue, property } = props; const { onPropertyChange, onValueChange, initialValue, property } = props;
@@ -38,7 +38,7 @@ export default (props: ModifyPanelContentProps) => {
}} }}
initialOptions={ initialOptions={
propProperty?.emailOptions || propProperty?.emailOptions ||
genInitialOptions( generateInitialOptions(
property?.type, property?.type,
getPendantIconsConfigByName('Email') getPendantIconsConfigByName('Email')
) )
@@ -66,7 +66,7 @@ export default (props: ModifyPanelContentProps) => {
}} }}
initialOptions={ initialOptions={
propProperty?.phoneOptions || propProperty?.phoneOptions ||
genInitialOptions( generateInitialOptions(
property?.type, property?.type,
getPendantIconsConfigByName('Phone') getPendantIconsConfigByName('Phone')
) )
@@ -94,7 +94,7 @@ export default (props: ModifyPanelContentProps) => {
}} }}
initialOptions={ initialOptions={
propProperty?.locationOptions || propProperty?.locationOptions ||
genInitialOptions( generateInitialOptions(
property?.type, property?.type,
getPendantIconsConfigByName('Location') getPendantIconsConfigByName('Location')
) )
@@ -18,7 +18,9 @@ export default ({
user: { username, nickname, photo }, user: { username, nickname, photo },
} = useUserAndSpaces(); } = useUserAndSpaces();
const [selectedValue, setSelectedValue] = useState(initialValue?.value); const [selectedValue, setSelectedValue] = useState(
initialValue?.value || ''
);
const [focus, setFocus] = useState(false); const [focus, setFocus] = useState(false);
const theme = useTheme(); const theme = useTheme();
return ( return (
@@ -21,7 +21,7 @@ import {
} from '@toeverything/components/ui'; } from '@toeverything/components/ui';
import { HighLightIconInput } from './IconInput'; import { HighLightIconInput } from './IconInput';
import { PendantConfig, IconNames, OptionIdType, OptionType } from '../types'; import { PendantConfig, IconNames, OptionIdType, OptionType } from '../types';
import { genBasicOption } from '../utils'; import { generateBasicOption } from '../utils';
type OptionItemType = { type OptionItemType = {
option: OptionType; option: OptionType;
@@ -66,7 +66,7 @@ export const BasicSelect = ({
const [selectIds, setSelectIds] = useState<OptionIdType[]>(initialValue); const [selectIds, setSelectIds] = useState<OptionIdType[]>(initialValue);
const insertOption = (insertId: OptionIdType) => { const insertOption = (insertId: OptionIdType) => {
const newOption = genBasicOption({ const newOption = generateBasicOption({
index: options.length + 1, index: options.length + 1,
iconConfig, iconConfig,
}); });
@@ -1,5 +1,4 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { nanoid } from 'nanoid';
import { Input, Option, Select, Tooltip } from '@toeverything/components/ui'; import { Input, Option, Select, Tooltip } from '@toeverything/components/ui';
import { HelpCenterIcon } from '@toeverything/components/icons'; import { HelpCenterIcon } from '@toeverything/components/icons';
import { AsyncBlock } from '../../editor'; import { AsyncBlock } from '../../editor';
@@ -15,13 +14,13 @@ import {
StyledPopoverSubTitle, StyledPopoverSubTitle,
StyledPopoverWrapper, StyledPopoverWrapper,
} from '../StyledComponent'; } from '../StyledComponent';
import { genInitialOptions, getPendantConfigByType } from '../utils'; import {
generateRandomFieldName,
generateInitialOptions,
getPendantConfigByType,
} from '../utils';
import { useOnCreateSure } from './hooks'; import { useOnCreateSure } from './hooks';
const upperFirst = (str: string) => {
return `${str[0].toUpperCase()}${str.slice(1)}`;
};
export const CreatePendantPanel = ({ export const CreatePendantPanel = ({
block, block,
onSure, onSure,
@@ -35,7 +34,7 @@ export const CreatePendantPanel = ({
useEffect(() => { useEffect(() => {
selectedOption && selectedOption &&
setFieldName(upperFirst(`${selectedOption.type}#${nanoid(4)}`)); setFieldName(generateRandomFieldName(selectedOption.type));
}, [selectedOption]); }, [selectedOption]);
return ( return (
@@ -45,7 +44,7 @@ export const CreatePendantPanel = ({
<Select <Select
width={284} width={284}
placeholder="Search for a field type" placeholder="Search for a field type"
value={selectedOption} value={selectedOption ?? null}
onChange={(selectedValue: PendantOptions) => { onChange={(selectedValue: PendantOptions) => {
setSelectedOption(selectedValue); setSelectedOption(selectedValue);
}} }}
@@ -93,7 +92,7 @@ export const CreatePendantPanel = ({
<PendantModifyPanel <PendantModifyPanel
type={selectedOption.type} type={selectedOption.type}
// Select, MultiSelect, Status use this props as initial property // Select, MultiSelect, Status use this props as initial property
initialOptions={genInitialOptions( initialOptions={generateInitialOptions(
selectedOption.type, selectedOption.type,
getPendantConfigByType(selectedOption.type) getPendantConfigByType(selectedOption.type)
)} )}
@@ -4,11 +4,11 @@ import { HelpCenterIcon } from '@toeverything/components/icons';
import { PendantModifyPanel } from '../pendant-modify-panel'; import { PendantModifyPanel } from '../pendant-modify-panel';
import type { AsyncBlock } from '../../editor'; import type { AsyncBlock } from '../../editor';
import { import {
getRecastItemValue,
type RecastBlockValue, type RecastBlockValue,
type RecastMetaProperty, type RecastMetaProperty,
} from '../../recast-block'; } from '../../recast-block';
import { getPendantConfigByType } from '../utils'; import { getPendantConfigByType } from '../utils';
import { usePendant } from '../use-pendant';
import { import {
StyledPopoverWrapper, StyledPopoverWrapper,
StyledOperationLabel, StyledOperationLabel,
@@ -42,7 +42,8 @@ export const UpdatePendantPanel = ({
}: Props) => { }: Props) => {
const pendantOption = pendantOptions.find(v => v.type === property.type); const pendantOption = pendantOptions.find(v => v.type === property.type);
const iconConfig = getPendantConfigByType(property.type); const iconConfig = getPendantConfigByType(property.type);
const { removePendant } = usePendant(block); const { removeValue } = getRecastItemValue(block);
const Icon = IconMap[iconConfig.iconName]; const Icon = IconMap[iconConfig.iconName];
const [fieldName, setFieldName] = useState(property.name); const [fieldName, setFieldName] = useState(property.name);
const onUpdateSure = useOnUpdateSure({ block, property }); const onUpdateSure = useOnUpdateSure({ block, property });
@@ -108,7 +109,7 @@ export const UpdatePendantPanel = ({
onDelete={ onDelete={
hasDelete hasDelete
? async () => { ? async () => {
await removePendant(property); await removeValue(property.id);
} }
: null : null
} }
@@ -1,16 +1,23 @@
import type { CSSProperties } from 'react'; import type { CSSProperties } from 'react';
import { import {
genSelectOptionId, genSelectOptionId,
getRecastItemValue,
type InformationProperty, type InformationProperty,
type MultiSelectProperty, type MultiSelectProperty,
type RecastMetaProperty, type RecastMetaProperty,
type SelectOption, type SelectOption,
type SelectProperty, type SelectProperty,
useRecastBlock,
useRecastBlockMeta, useRecastBlockMeta,
useSelectProperty, useSelectProperty,
SelectValue,
MultiSelectValue,
StatusValue,
InformationValue,
TextValue,
DateValue,
} from '../../recast-block'; } from '../../recast-block';
import { type AsyncBlock } from '../../editor'; import { type AsyncBlock } from '../../editor';
import { usePendant } from '../use-pendant';
import { import {
type OptionType, type OptionType,
PendantTypes, PendantTypes,
@@ -41,8 +48,8 @@ const genOptionWithId = (options: OptionType[] = []) => {
export const useOnCreateSure = ({ block }: { block: AsyncBlock }) => { export const useOnCreateSure = ({ block }: { block: AsyncBlock }) => {
const { addProperty } = useRecastBlockMeta(); const { addProperty } = useRecastBlockMeta();
const { createSelect } = useSelectProperty(); const { createSelect } = useSelectProperty();
const { setPendant } = usePendant(block); const recastBlock = useRecastBlock();
const { setValue } = getRecastItemValue(block);
return async ({ return async ({
type, type,
fieldName, fieldName,
@@ -79,7 +86,14 @@ export const useOnCreateSure = ({ block }: { block: AsyncBlock }) => {
tempSelectedId: newValue, tempSelectedId: newValue,
}); });
await setPendant(newProperty, selectedId); await setValue(
{
id: newProperty.id,
type: newProperty.type,
value: selectedId,
} as SelectValue | MultiSelectValue | StatusValue,
recastBlock.id
);
} else if (type === PendantTypes.Information) { } else if (type === PendantTypes.Information) {
const emailOptions = genOptionWithId(newPropertyItem.emailOptions); const emailOptions = genOptionWithId(newPropertyItem.emailOptions);
@@ -97,7 +111,11 @@ export const useOnCreateSure = ({ block }: { block: AsyncBlock }) => {
locationOptions, locationOptions,
} as Omit<InformationProperty, 'id'>); } as Omit<InformationProperty, 'id'>);
await setPendant(newProperty, { await setValue(
{
id: newProperty.id,
type: newProperty.type,
value: {
email: getOfficialSelected({ email: getOfficialSelected({
isMulti: true, isMulti: true,
options: emailOptions, options: emailOptions,
@@ -116,7 +134,10 @@ export const useOnCreateSure = ({ block }: { block: AsyncBlock }) => {
tempOptions: newPropertyItem.locationOptions, tempOptions: newPropertyItem.locationOptions,
tempSelectedId: newValue.location, tempSelectedId: newValue.location,
}), }),
}); },
} as InformationValue,
recastBlock.id
);
} else { } else {
// TODO: Color and background should use pendant config, but ui is not design now // TODO: Color and background should use pendant config, but ui is not design now
const iconConfig = getPendantConfigByType(type); const iconConfig = getPendantConfigByType(type);
@@ -129,8 +150,14 @@ export const useOnCreateSure = ({ block }: { block: AsyncBlock }) => {
color: iconConfig.color as CSSProperties['color'], color: iconConfig.color as CSSProperties['color'],
iconName: iconConfig.iconName, iconName: iconConfig.iconName,
}); });
await setValue(
await setPendant(newProperty, newValue); {
id: newProperty.id,
type: newProperty.type,
value: newValue,
} as TextValue | DateValue,
recastBlock.id
);
} }
}; };
}; };
@@ -144,8 +171,9 @@ export const useOnUpdateSure = ({
property: RecastMetaProperty; property: RecastMetaProperty;
}) => { }) => {
const { updateSelect } = useSelectProperty(); const { updateSelect } = useSelectProperty();
const { setPendant } = usePendant(block);
const { updateProperty } = useRecastBlockMeta(); const { updateProperty } = useRecastBlockMeta();
const { setValue } = getRecastItemValue(block);
const recastBlock = useRecastBlock();
return async ({ return async ({
type, type,
@@ -199,7 +227,14 @@ export const useOnUpdateSure = ({
tempSelectedId: newValue, tempSelectedId: newValue,
}); });
await setPendant(selectProperty, selectedId); await setValue(
{
id: selectProperty.id,
type: selectProperty.type,
value: selectedId,
} as SelectValue | MultiSelectValue | StatusValue,
recastBlock.id
);
} else if (type === PendantTypes.Information) { } else if (type === PendantTypes.Information) {
// const { emailOptions, phoneOptions, locationOptions } = // const { emailOptions, phoneOptions, locationOptions } =
// property as InformationProperty; // property as InformationProperty;
@@ -231,7 +266,11 @@ export const useOnUpdateSure = ({
locationOptions, locationOptions,
} as InformationProperty); } as InformationProperty);
await setPendant(newProperty, { await setValue(
{
id: newProperty.id,
type: newProperty.type,
value: {
email: getOfficialSelected({ email: getOfficialSelected({
isMulti: true, isMulti: true,
options: emailOptions as SelectOption[], options: emailOptions as SelectOption[],
@@ -250,9 +289,19 @@ export const useOnUpdateSure = ({
tempOptions: newPropertyItem.locationOptions, tempOptions: newPropertyItem.locationOptions,
tempSelectedId: newValue.location, tempSelectedId: newValue.location,
}), }),
}); },
} as InformationValue,
recastBlock.id
);
} else { } else {
await setPendant(property, newValue); await setValue(
{
id: property.id,
type: property.type,
value: newValue,
} as TextValue | DateValue,
recastBlock.id
);
} }
if (fieldName !== property.name) { if (fieldName !== property.name) {
@@ -1,4 +1,4 @@
import React, { FC, useRef } from 'react'; import { FC, useRef } from 'react';
import { AsyncBlock } from '../../editor'; import { AsyncBlock } from '../../editor';
import { PendantHistoryPanel } from '../pendant-history-panel'; import { PendantHistoryPanel } from '../pendant-history-panel';
import { import {
@@ -21,8 +21,6 @@ export const PendantPopover: FC<
pointerEnterDelay={300} pointerEnterDelay={300}
pointerLeaveDelay={200} pointerLeaveDelay={200}
placement="bottom-start" placement="bottom-start"
// visible={true}
// trigger="click"
content={ content={
<PendantHistoryPanel <PendantHistoryPanel
block={block} block={block}
@@ -1,5 +1,5 @@
import { import {
MuiZoom, MuiFade,
Popover, Popover,
PopperHandler, PopperHandler,
styled, styled,
@@ -100,16 +100,15 @@ export const PendantRender = ({ block }: { block: AsyncBlock }) => {
); );
})} })}
{hasAddBtn ? ( {hasAddBtn ? (
<MuiZoom in={showAddBtn}> <MuiFade in={showAddBtn}>
<div> <div>
<AddPendantPopover <AddPendantPopover
block={block} block={block}
iconStyle={{ marginTop: 4 }} iconStyle={{ marginTop: 4 }}
container={blockRenderContainerRef.current} container={blockRenderContainerRef.current}
trigger="click"
/> />
</div> </div>
</MuiZoom> </MuiFade>
) : null} ) : null}
</BlockPendantContainer> </BlockPendantContainer>
); );
@@ -1,41 +0,0 @@
import { removePropertyValueRecord, setPendantHistory } from './utils';
import { AsyncBlock } from '../editor';
import {
getRecastItemValue,
RecastMetaProperty,
useRecastBlock,
} from '../recast-block';
export const usePendant = (block: AsyncBlock) => {
// const { getProperties, removeProperty } = useRecastBlockMeta();
const recastBlock = useRecastBlock();
const { getValue, setValue, removeValue } = getRecastItemValue(block);
// const { updateSelect } = useSelectProperty();
const setPendant = async (property: RecastMetaProperty, newValue: any) => {
const nv = {
id: property.id,
type: property.type,
value: newValue,
};
await setValue(nv);
setPendantHistory({
recastBlockId: recastBlock.id,
blockId: block.id,
propertyId: property.id,
});
};
const removePendant = async (property: RecastMetaProperty) => {
await removeValue(property.id);
removePropertyValueRecord({
recastBlockId: block.id,
propertyId: property.id,
});
};
return {
setPendant,
removePendant,
};
};
@@ -1,84 +1,7 @@
import { import { PropertyType, SelectOption } from '../recast-block';
PropertyType, import { OptionIdType, OptionType, PendantConfig, PendantTypes } from './types';
RecastBlockValue,
RecastPropertyId,
SelectOption,
} from '../recast-block';
import { OptionIdType, OptionType } from './types';
import { pendantConfig } from './config'; import { pendantConfig } from './config';
import { PendantConfig, PendantTypes } from './types'; import { nanoid } from 'nanoid';
type Props = {
recastBlockId: string;
blockId: string;
propertyId: RecastPropertyId;
};
type StorageMap = {
[recastBlockId: string]: {
[propertyId: RecastPropertyId]: string;
};
};
const LOCAL_STORAGE_NAME = 'TEMPORARY_PENDANT_DATA';
const ensureLocalStorage = () => {
const data = localStorage.getItem(LOCAL_STORAGE_NAME);
if (!data) {
localStorage.setItem(LOCAL_STORAGE_NAME, JSON.stringify({}));
}
};
export const setPendantHistory = ({
recastBlockId,
blockId,
propertyId,
}: Props) => {
ensureLocalStorage();
const data: StorageMap = JSON.parse(
localStorage.getItem(LOCAL_STORAGE_NAME) as string
);
if (!data[recastBlockId]) {
data[recastBlockId] = {};
}
const propertyValueRecord = data[recastBlockId];
propertyValueRecord[propertyId] = blockId;
localStorage.setItem(LOCAL_STORAGE_NAME, JSON.stringify(data));
};
export const getPendantHistory = ({
recastBlockId,
}: {
recastBlockId: string;
}) => {
ensureLocalStorage();
const data: StorageMap = JSON.parse(
localStorage.getItem(LOCAL_STORAGE_NAME) as string
);
return data[recastBlockId] ?? {};
};
export const removePropertyValueRecord = ({
recastBlockId,
propertyId,
}: {
recastBlockId: string;
propertyId: RecastPropertyId;
}) => {
ensureLocalStorage();
const data: StorageMap = JSON.parse(
localStorage.getItem(LOCAL_STORAGE_NAME) as string
);
if (!data[recastBlockId]) {
return;
}
delete data[recastBlockId][propertyId];
localStorage.setItem(LOCAL_STORAGE_NAME, JSON.stringify(data));
};
/** /**
* In select pendant panel, use mock options instead of use `createSelect` when add or delete option * In select pendant panel, use mock options instead of use `createSelect` when add or delete option
@@ -107,7 +30,7 @@ export const getOfficialSelected = ({
.map(id => { .map(id => {
return tempOptions.findIndex((o: OptionType) => o.id === id); return tempOptions.findIndex((o: OptionType) => o.id === id);
}) })
.filter(index => index != -1); .filter(index => index !== -1);
selectedId = selectedIndex.map((index: number) => { selectedId = selectedIndex.map((index: number) => {
return options[index].id; return options[index].id;
}); });
@@ -130,7 +53,7 @@ export const getPendantIconsConfigByName = (
return pendantConfig[pendantName]; return pendantConfig[pendantName];
}; };
export const genBasicOption = ({ export const generateBasicOption = ({
index, index,
iconConfig, iconConfig,
name = '', name = '',
@@ -159,22 +82,22 @@ export const genBasicOption = ({
/** /**
* Status Pendant is a Select Pendant built-in some options * Status Pendant is a Select Pendant built-in some options
* **/ * **/
export const genInitialOptions = ( export const generateInitialOptions = (
type: PendantTypes, type: PendantTypes,
iconConfig: PendantConfig iconConfig: PendantConfig
) => { ) => {
if (type === PendantTypes.Status) { if (type === PendantTypes.Status) {
return [ return [
genBasicOption({ index: 0, iconConfig, name: 'No Started' }), generateBasicOption({ index: 0, iconConfig, name: 'No Started' }),
genBasicOption({ generateBasicOption({
index: 1, index: 1,
iconConfig, iconConfig,
name: 'In Progress', name: 'In Progress',
}), }),
genBasicOption({ index: 2, iconConfig, name: 'Complete' }), generateBasicOption({ index: 2, iconConfig, name: 'Complete' }),
]; ];
} }
return [genBasicOption({ index: 0, iconConfig })]; return [generateBasicOption({ index: 0, iconConfig })];
}; };
export const checkPendantForm = ( export const checkPendantForm = (
@@ -222,3 +145,10 @@ export const checkPendantForm = (
return { passed: true, message: 'Check passed !' }; return { passed: true, message: 'Check passed !' };
}; };
const upperFirst = (str: string) => {
return `${str[0].toUpperCase()}${str.slice(1)}`;
};
export const generateRandomFieldName = (type: PendantTypes) =>
upperFirst(`${type}#${nanoid(4)}`);
@@ -1,28 +0,0 @@
import { AsyncBlock, BlockEditor } from '../editor';
import { ReactElement } from 'react';
interface DragDropWrapperProps {
editor: BlockEditor;
block: AsyncBlock;
children: ReactElement | null;
}
export function DragDropWrapper({
children,
editor,
block,
}: DragDropWrapperProps) {
const handlerDragOver: React.DragEventHandler<HTMLDivElement> = event => {
event.preventDefault();
if (block.dom) {
editor.getHooks().afterOnNodeDragOver(event, {
blockId: block.id,
dom: block.dom,
rect: block.dom?.getBoundingClientRect(),
type: block.type,
properties: block.getProperties(),
});
}
};
return <div onDragOver={handlerDragOver}>{children}</div>;
}
@@ -1 +0,0 @@
export * from './DragDropWrapper';
@@ -35,20 +35,6 @@ export class KeyboardManager {
} }
this.handler_map = {}; this.handler_map = {};
// WARNING: Remove the filter of hotkeys, the input event of input/select/textarea will be filtered out by default
// When there is a problem with the input of the text component, you need to pay attention to this
const old_filter = HotKeys.filter;
HotKeys.filter = event => {
let parent = (event.target as Element).parentElement;
while (parent) {
if (parent === editor.container) {
return old_filter(event);
}
parent = parent.parentElement;
}
return true;
};
HotKeys.setScope('editor'); HotKeys.setScope('editor');
// this.init_common_shortcut_cb(); // this.init_common_shortcut_cb();
@@ -113,13 +113,6 @@ export class Hooks implements HooksRunner, PluginHooks {
this._runHook(HookType.ON_ROOTNODE_DRAG_OVER_CAPTURE, e); this._runHook(HookType.ON_ROOTNODE_DRAG_OVER_CAPTURE, e);
} }
public afterOnNodeDragOver(
e: React.DragEvent<Element>,
node: BlockDomInfo
): void {
this._runHook(HookType.AFTER_ON_NODE_DRAG_OVER, e, node);
}
public onSearch(): void { public onSearch(): void {
this._runHook(HookType.ON_SEARCH); this._runHook(HookType.ON_SEARCH);
} }
@@ -30,7 +30,6 @@ export class ScrollManager {
constructor(editor: BlockEditor) { constructor(editor: BlockEditor) {
this._editor = editor; this._editor = editor;
(window as any).scrollManager = this;
} }
private _updateScrollInfo(left: number, top: number) { private _updateScrollInfo(left: number, top: number) {
@@ -111,6 +110,7 @@ export class ScrollManager {
} }
public emitScrollEvent(event: UIEvent) { public emitScrollEvent(event: UIEvent) {
this.scrollContainer = event.target as HTMLElement;
this._scrollDirection = this._getScrollDirection(); this._scrollDirection = this._getScrollDirection();
this._scrollMoveOffset = Math.abs( this._scrollMoveOffset = Math.abs(
this.scrollContainer.scrollTop - this._scrollRecord[0] this.scrollContainer.scrollTop - this._scrollRecord[0]
@@ -177,7 +177,6 @@ export enum HookType {
ON_ROOTNODE_DRAG_END = 'onRootNodeDragEnd', ON_ROOTNODE_DRAG_END = 'onRootNodeDragEnd',
ON_ROOTNODE_DRAG_OVER_CAPTURE = 'onRootNodeDragOverCapture', ON_ROOTNODE_DRAG_OVER_CAPTURE = 'onRootNodeDragOverCapture',
ON_ROOTNODE_DROP = 'onRootNodeDrop', ON_ROOTNODE_DROP = 'onRootNodeDrop',
AFTER_ON_NODE_DRAG_OVER = 'afterOnNodeDragOver',
BEFORE_COPY = 'beforeCopy', BEFORE_COPY = 'beforeCopy',
BEFORE_CUT = 'beforeCut', BEFORE_CUT = 'beforeCut',
ON_ROOTNODE_SCROLL = 'onRootNodeScroll', ON_ROOTNODE_SCROLL = 'onRootNodeScroll',
@@ -219,10 +218,6 @@ export interface HooksRunner {
onRootNodeDragEnd: (e: React.DragEvent<Element>) => void; onRootNodeDragEnd: (e: React.DragEvent<Element>) => void;
onRootNodeDragLeave: (e: React.DragEvent<Element>) => void; onRootNodeDragLeave: (e: React.DragEvent<Element>) => void;
onRootNodeDrop: (e: React.DragEvent<Element>) => void; onRootNodeDrop: (e: React.DragEvent<Element>) => void;
afterOnNodeDragOver: (
e: React.DragEvent<Element>,
node: BlockDomInfo
) => void;
beforeCopy: (e: ClipboardEvent) => void; beforeCopy: (e: ClipboardEvent) => void;
beforeCut: (e: ClipboardEvent) => void; beforeCut: (e: ClipboardEvent) => void;
onRootNodeScroll: (e: React.UIEvent) => void; onRootNodeScroll: (e: React.UIEvent) => void;
-3
View File
@@ -15,7 +15,4 @@ export * from './kanban/types';
export * from './utils'; export * from './utils';
export * from './drag-drop-wrapper';
export * from './block-content-wrapper';
export * from './editor'; export * from './editor';
+65 -25
View File
@@ -6,10 +6,15 @@ import {
PropertyType, PropertyType,
RecastBlockValue, RecastBlockValue,
RecastMetaProperty, RecastMetaProperty,
RecastPropertyId,
} from '../recast-block/types'; } from '../recast-block/types';
import type { DefaultGroup, KanbanGroup } from './types'; import type { DefaultGroup, KanbanGroup } from './types';
import { DEFAULT_GROUP_ID } from './types'; import { DEFAULT_GROUP_ID } from './types';
import {
generateInitialOptions,
generateRandomFieldName,
getPendantIconsConfigByName,
} from '../block-pendant/utils';
import { SelectOption } from '../recast-block';
/** /**
* - If the `groupBy` is `SelectProperty` or `MultiSelectProperty`, return `(Multi)SelectProperty.options`. * - If the `groupBy` is `SelectProperty` or `MultiSelectProperty`, return `(Multi)SelectProperty.options`.
@@ -23,6 +28,7 @@ export const getGroupOptions = async (
return []; return [];
} }
switch (groupBy.type) { switch (groupBy.type) {
case PropertyType.Status:
case PropertyType.Select: case PropertyType.Select:
case PropertyType.MultiSelect: { case PropertyType.MultiSelect: {
return groupBy.options.map(option => ({ return groupBy.options.map(option => ({
@@ -51,12 +57,15 @@ const isValueBelongOption = (
option: KanbanGroup option: KanbanGroup
) => { ) => {
switch (propertyValue.type) { switch (propertyValue.type) {
case PropertyType.Select: { case PropertyType.Select || PropertyType.Status: {
return propertyValue.value === option.id; return propertyValue.value === option.id;
} }
case PropertyType.MultiSelect: { case PropertyType.MultiSelect: {
return propertyValue.value.some(i => i === option.id); return propertyValue.value.some(i => i === option.id);
} }
// case PropertyType.Status: {
// return propertyValue.value === option.id;
// }
// case PropertyType.Text: { // case PropertyType.Text: {
// TOTODO:DO support this type // TOTODO:DO support this type
// } // }
@@ -96,40 +105,67 @@ export const calcCardGroup = (
/** /**
* Set group value for the card block * Set group value for the card block
*/ */
export const moveCardToGroup = async ( export const moveCardToGroup = async ({
groupById: RecastPropertyId, groupBy,
cardBlock: RecastItem, cardBlock,
group: KanbanGroup group,
) => { recastBlock,
}: {
groupBy: RecastMetaProperty;
cardBlock: RecastItem;
group: KanbanGroup;
recastBlock: RecastBlock;
}) => {
const { setValue, removeValue } = getRecastItemValue(cardBlock); const { setValue, removeValue } = getRecastItemValue(cardBlock);
let success = false; let success = false;
if (group.id === DEFAULT_GROUP_ID) { if (group.id === DEFAULT_GROUP_ID) {
success = await removeValue(groupById); success = await removeValue(groupBy.id);
return false; return false;
} }
switch (group.type) { switch (group.type) {
case PropertyType.Select: { case PropertyType.Select: {
success = await setValue({ success = await setValue(
id: groupById, {
id: groupBy.id,
type: group.type, type: group.type,
value: group.id, value: group.id,
}); },
recastBlock.id
);
break;
}
case PropertyType.Status: {
success = await setValue(
{
id: groupBy.id,
type: group.type,
value: group.id,
},
recastBlock.id
);
break; break;
} }
case PropertyType.MultiSelect: { case PropertyType.MultiSelect: {
success = await setValue({ success = await setValue(
id: groupById, {
id: groupBy.id,
type: group.type, type: group.type,
value: [group.id], value: [group.id],
}); },
recastBlock.id
);
break; break;
} }
case PropertyType.Text: { case PropertyType.Text: {
success = await setValue({ success = await setValue(
id: groupById, {
id: groupBy.id,
type: group.type, type: group.type,
value: group.id, value: group.id,
}); },
recastBlock.id
);
break; break;
} }
default: default:
@@ -194,14 +230,18 @@ export const genDefaultGroup = (groupBy: RecastMetaProperty): DefaultGroup => ({
items: [], items: [],
}); });
export const DEFAULT_GROUP_BY_PROPERTY = { export const generateDefaultGroupByProperty = (): {
name: 'Status', name: string;
options: [ options: Omit<SelectOption, 'id'>[];
{ name: 'No Started', color: '#E53535', background: '#FFCECE' }, type: PropertyType.Status;
{ name: 'In Progress', color: '#A77F1A', background: '#FFF5AB' }, } => ({
{ name: 'Complete', color: '#3C8867', background: '#C5FBE0' }, name: generateRandomFieldName(PropertyType.Status),
], type: PropertyType.Status,
}; options: generateInitialOptions(
PropertyType.Status,
getPendantIconsConfigByName(PropertyType.Status)
),
});
/** /**
* Unwrap blocks from the grid recursively. * Unwrap blocks from the grid recursively.
@@ -7,6 +7,7 @@ export const useKanbanGroup = (groupBy: RecastMetaProperty) => {
const { updateSelect } = useSelectProperty(); const { updateSelect } = useSelectProperty();
switch (groupBy.type) { switch (groupBy.type) {
case PropertyType.Status:
case PropertyType.MultiSelect: case PropertyType.MultiSelect:
case PropertyType.Select: { case PropertyType.Select: {
const { const {
@@ -18,8 +18,8 @@ import {
import { supportChildren } from '../utils'; import { supportChildren } from '../utils';
import { import {
calcCardGroup, calcCardGroup,
DEFAULT_GROUP_BY_PROPERTY,
genDefaultGroup, genDefaultGroup,
generateDefaultGroupByProperty,
getCardGroup, getCardGroup,
getGroupOptions, getGroupOptions,
moveCardToAfter, moveCardToAfter,
@@ -48,6 +48,7 @@ export const useRecastKanbanGroupBy = () => {
// Add other type groupBy support // Add other type groupBy support
const supportedGroupBy = getProperties().filter( const supportedGroupBy = getProperties().filter(
prop => prop =>
prop.type === PropertyType.Status ||
prop.type === PropertyType.Select || prop.type === PropertyType.Select ||
prop.type === PropertyType.MultiSelect prop.type === PropertyType.MultiSelect
); );
@@ -88,7 +89,8 @@ export const useRecastKanbanGroupBy = () => {
// TODO: support other property type // TODO: support other property type
if ( if (
groupByProperty.type !== PropertyType.Select && groupByProperty.type !== PropertyType.Select &&
groupByProperty.type !== PropertyType.MultiSelect groupByProperty.type !== PropertyType.MultiSelect &&
groupByProperty.type !== PropertyType.Status
) { ) {
console.warn('Not support groupBy type', groupByProperty); console.warn('Not support groupBy type', groupByProperty);
@@ -134,7 +136,7 @@ export const useInitKanbanEffect = ():
} }
// 3. no group by, no properties // 3. no group by, no properties
// create a new property and set it as group by // create a new property and set it as group by
const prop = await createSelect(DEFAULT_GROUP_BY_PROPERTY); const prop = await createSelect(generateDefaultGroupByProperty());
await setGroupBy(prop.id); await setGroupBy(prop.id);
}; };
@@ -197,7 +199,12 @@ export const useRecastKanban = () => {
beforeBlock: string | null, beforeBlock: string | null,
afterBlock: string | null afterBlock: string | null
) => { ) => {
await moveCardToGroup(groupBy.id, child, kanbanMap[id]); await moveCardToGroup({
groupBy,
cardBlock: child,
group: kanbanMap[id],
recastBlock,
});
if (beforeBlock) { if (beforeBlock) {
const block = await editor.getBlockById( const block = await editor.getBlockById(
beforeBlock beforeBlock
@@ -286,7 +293,12 @@ export const useKanban = () => {
); );
if (isChangedGroup) { if (isChangedGroup) {
// 1.2 Move to the target group // 1.2 Move to the target group
await moveCardToGroup(groupBy.id, targetCard, targetGroup); await moveCardToGroup({
groupBy,
cardBlock: targetCard,
group: targetGroup,
recastBlock,
});
} }
// 2. Reorder the card // 2. Reorder the card
@@ -324,7 +336,12 @@ export const useKanban = () => {
} }
recastBlock.append(newBlock); recastBlock.append(newBlock);
const newCard = newBlock as unknown as RecastItem; const newCard = newBlock as unknown as RecastItem;
await moveCardToGroup(groupBy.id, newCard, group); await moveCardToGroup({
groupBy,
cardBlock: newCard,
group,
recastBlock,
});
}, },
[editor, groupBy.id, recastBlock] [editor, groupBy.id, recastBlock]
); );
@@ -46,7 +46,10 @@ export type DefaultGroup = KanbanGroupBase & {
type SelectGroup = KanbanGroupBase & type SelectGroup = KanbanGroupBase &
SelectOption & { SelectOption & {
type: PropertyType.Select | PropertyType.MultiSelect; type:
| PropertyType.Select
| PropertyType.MultiSelect
| PropertyType.Status;
}; };
type TextGroup = KanbanGroupBase & { type TextGroup = KanbanGroupBase & {
@@ -0,0 +1,84 @@
import { RecastPropertyId } from './types';
// TODO: The logic for keeping history should be supported by the network layer
type Props = {
recastBlockId: string;
blockId: string;
propertyId: RecastPropertyId;
};
type HistoryStorageMap = {
[recastBlockId: string]: {
[propertyId: RecastPropertyId]: string[];
};
};
const LOCAL_STORAGE_NAME = 'TEMPORARY_HISTORY_DATA';
const ensureLocalStorage = () => {
const data = localStorage.getItem(LOCAL_STORAGE_NAME);
if (!data) {
localStorage.setItem(LOCAL_STORAGE_NAME, JSON.stringify({}));
}
};
const ensureHistoryAtom = (
data: HistoryStorageMap,
recastBlockId: string,
propertyId: RecastPropertyId
): HistoryStorageMap => {
if (!data[recastBlockId]) {
data[recastBlockId] = {};
}
if (!data[recastBlockId][propertyId]) {
data[recastBlockId][propertyId] = [];
}
return data;
};
export const setHistory = ({ recastBlockId, blockId, propertyId }: Props) => {
ensureLocalStorage();
const data: HistoryStorageMap = JSON.parse(
localStorage.getItem(LOCAL_STORAGE_NAME) as string
);
ensureHistoryAtom(data, recastBlockId, propertyId);
const propertyHistory = data[recastBlockId][propertyId];
if (propertyHistory.includes(blockId)) {
const idIndex = propertyHistory.findIndex(id => id === blockId);
propertyHistory.splice(idIndex, 1);
}
propertyHistory.push(blockId);
localStorage.setItem(LOCAL_STORAGE_NAME, JSON.stringify(data));
};
export const getHistory = ({ recastBlockId }: { recastBlockId: string }) => {
ensureLocalStorage();
const data: HistoryStorageMap = JSON.parse(
localStorage.getItem(LOCAL_STORAGE_NAME) as string
);
return data[recastBlockId] ?? {};
};
export const removeHistory = ({
recastBlockId,
blockId,
propertyId,
}: Props) => {
ensureLocalStorage();
const data: HistoryStorageMap = JSON.parse(
localStorage.getItem(LOCAL_STORAGE_NAME) as string
);
ensureHistoryAtom(data, recastBlockId, propertyId);
const propertyHistory = data[recastBlockId][propertyId];
if (propertyHistory.includes(blockId)) {
const idIndex = propertyHistory.findIndex(id => id === blockId);
propertyHistory.splice(idIndex, 1);
}
localStorage.setItem(LOCAL_STORAGE_NAME, JSON.stringify(data));
};
@@ -15,6 +15,7 @@ import {
SelectProperty, SelectProperty,
TABLE_VALUES_KEY, TABLE_VALUES_KEY,
} from './types'; } from './types';
import { getHistory, removeHistory, setHistory } from './history';
/** /**
* Generate a unique id for a property * Generate a unique id for a property
@@ -240,7 +241,13 @@ export const getRecastItemValue = (block: RecastItem | AsyncBlock) => {
return props[id]; return props[id];
}; };
const setValue = (newValue: RecastBlockValue) => { const setValue = (newValue: RecastBlockValue, recastBlockId: string) => {
setHistory({
recastBlockId: recastBlockId,
blockId: block.id,
propertyId: newValue.id,
});
return recastItem.setProperty(TABLE_VALUES_KEY, { return recastItem.setProperty(TABLE_VALUES_KEY, {
...props, ...props,
[newValue.id]: newValue, [newValue.id]: newValue,
@@ -249,22 +256,30 @@ export const getRecastItemValue = (block: RecastItem | AsyncBlock) => {
const removeValue = (propertyId: RecastPropertyId) => { const removeValue = (propertyId: RecastPropertyId) => {
const { [propertyId]: omitted, ...restProps } = props; const { [propertyId]: omitted, ...restProps } = props;
removeHistory({
recastBlockId: block.id,
propertyId: propertyId,
blockId: block.id,
});
return recastItem.setProperty(TABLE_VALUES_KEY, restProps); return recastItem.setProperty(TABLE_VALUES_KEY, restProps);
}; };
return { getAllValue, getValue, setValue, removeValue };
const getValueHistory = getHistory;
return { getAllValue, getValue, setValue, removeValue, getValueHistory };
}; };
const isSelectLikeProperty = ( const isSelectLikeProperty = (
metaProperty?: RecastMetaProperty metaProperty?: RecastMetaProperty
): metaProperty is SelectProperty | MultiSelectProperty => { ): metaProperty is SelectProperty | MultiSelectProperty | StatusProperty => {
if ( return (
!metaProperty || metaProperty &&
(metaProperty.type !== PropertyType.Select && (metaProperty.type === PropertyType.Status ||
metaProperty.type !== PropertyType.MultiSelect) metaProperty.type === PropertyType.Select ||
) { metaProperty.type === PropertyType.MultiSelect)
return false; );
}
return true;
}; };
/** /**
@@ -312,7 +327,7 @@ export const useSelectProperty = () => {
}; };
const updateSelect = ( const updateSelect = (
selectProperty: SelectProperty | MultiSelectProperty selectProperty: StatusProperty | SelectProperty | MultiSelectProperty
) => { ) => {
// if (typeof selectProperty === 'string') { // if (typeof selectProperty === 'string') {
// const maybeSelectProperty = getProperty(selectProperty); // const maybeSelectProperty = getProperty(selectProperty);
@@ -64,7 +64,7 @@ const StyledContainerForAddCommentContainer = styled('div')(({ theme }) => {
zIndex: 1, zIndex: 1,
display: 'flex', display: 'flex',
borderRadius: theme.affine.shape.borderRadius, borderRadius: theme.affine.shape.borderRadius,
boxShadow: theme.affine.shadows.shadowSxDownLg, boxShadow: theme.affine.shadows.shadow1,
backgroundColor: theme.affine.palette.white, backgroundColor: theme.affine.palette.white,
}; };
}); });
@@ -31,7 +31,7 @@ const RootContainer = styled('div')(({ theme }) => {
width: 352, width: 352,
maxHeight: 525, maxHeight: 525,
borderRadius: '10px', borderRadius: '10px',
boxShadow: '0px 1px 10px rgba(152, 172, 189, 0.6)', boxShadow: theme.affine.shadows.shadow1,
backgroundColor: '#fff', backgroundColor: '#fff',
padding: '8px 4px', padding: '8px 4px',
}; };
@@ -75,13 +75,13 @@ export const InlineMenuContainer = ({ editor }: InlineMenuContainerProps) => {
) : null; ) : null;
}; };
const ToolbarContainer = styled('div')({ const ToolbarContainer = styled('div')(({ theme }) => ({
position: 'absolute', position: 'absolute',
zIndex: 1, zIndex: 1,
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',
padding: '0 12px', padding: '0 12px',
borderRadius: '10px', borderRadius: '10px',
boxShadow: '0px 1px 10px rgba(152, 172, 189, 0.6)', boxShadow: theme.affine.shadows.shadow1,
backgroundColor: '#fff', backgroundColor: '#fff',
}); }));
@@ -1,10 +1,19 @@
import { useState, useEffect, FC } from 'react'; import {
useState,
useEffect,
FC,
type MouseEvent,
type DragEvent,
type ReactNode,
type CSSProperties,
} from 'react';
import { import {
Virgo, Virgo,
BlockDomInfo, BlockDomInfo,
PluginHooks, PluginHooks,
BlockDropPlacement, BlockDropPlacement,
LINE_GAP,
} from '@toeverything/framework/virgo'; } from '@toeverything/framework/virgo';
import { Button } from '@toeverything/components/common'; import { Button } from '@toeverything/components/common';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
@@ -14,7 +23,7 @@ import { distinctUntilChanged, Subject } from 'rxjs';
import { HandleChildIcon } from '@toeverything/components/icons'; import { HandleChildIcon } from '@toeverything/components/icons';
import { MENU_WIDTH } from './menu-config'; import { MENU_WIDTH } from './menu-config';
const MENU_BUTTON_OFFSET = 12; const MENU_BUTTON_OFFSET = 4;
export type LineInfoSubject = Subject< export type LineInfoSubject = Subject<
| { | {
@@ -64,13 +73,13 @@ function Line(props: { lineInfo: LineInfo; rootRect: DOMRect }) {
}; };
const bottomLineStyle = { const bottomLineStyle = {
...horizontalLineStyle, ...horizontalLineStyle,
top: intersectionRect.bottom + 1 - rootRect.y, top: intersectionRect.bottom + 1 - rootRect.y - LINE_GAP,
}; };
const verticalLineStyle = { const verticalLineStyle = {
...lineStyle, ...lineStyle,
width: 2, width: 2,
height: intersectionRect.height, height: intersectionRect.height - LINE_GAP,
top: intersectionRect.y - rootRect.y, top: intersectionRect.y - rootRect.y,
}; };
const leftLineStyle = { const leftLineStyle = {
@@ -93,10 +102,10 @@ function Line(props: { lineInfo: LineInfo; rootRect: DOMRect }) {
} }
function DragComponent(props: { function DragComponent(props: {
children: React.ReactNode; children: ReactNode;
style: React.CSSProperties; style: CSSProperties;
onDragStart: (event: React.DragEvent<Element>) => void; onDragStart: (event: DragEvent<Element>) => void;
onDragEnd: (event: React.DragEvent<Element>) => void; onDragEnd: (event: DragEvent<Element>) => void;
}) { }) {
const { style, children, onDragStart, onDragEnd } = props; const { style, children, onDragStart, onDragEnd } = props;
return ( return (
@@ -122,7 +131,7 @@ export const LeftMenuDraggable: FC<LeftMenuProps> = props => {
const [block, setBlock] = useState<BlockDomInfo | undefined>(); const [block, setBlock] = useState<BlockDomInfo | undefined>();
const [line, setLine] = useState<LineInfo | undefined>(undefined); const [line, setLine] = useState<LineInfo | undefined>(undefined);
const handleDragStart = async (event: React.DragEvent<Element>) => { const handleDragStart = async (event: DragEvent<Element>) => {
event.stopPropagation(); event.stopPropagation();
setVisible(false); setVisible(false);
@@ -138,12 +147,12 @@ export const LeftMenuDraggable: FC<LeftMenuProps> = props => {
} }
}; };
const handleDragEnd = (event: React.DragEvent<Element>) => { const handleDragEnd = (event: DragEvent<Element>) => {
event.preventDefault(); event.preventDefault();
setLine(undefined); setLine(undefined);
}; };
const onClick = (event: React.MouseEvent) => { const onClick = (event: MouseEvent<Element>) => {
if (block == null) return; if (block == null) return;
const currentTarget = event.currentTarget; const currentTarget = event.currentTarget;
editor.selection.setSelectedNodesIds([block.blockId]); editor.selection.setSelectedNodesIds([block.blockId]);
@@ -200,11 +209,10 @@ export const LeftMenuDraggable: FC<LeftMenuProps> = props => {
style={{ style={{
position: 'absolute', position: 'absolute',
left: left:
Math.min(
block.rect.left - block.rect.left -
MENU_WIDTH - MENU_WIDTH -
MENU_BUTTON_OFFSET MENU_BUTTON_OFFSET -
) - rootRect.left, rootRect.left,
top: block.rect.top - rootRect.top, top: block.rect.top - rootRect.top,
opacity: visible ? 1 : 0, opacity: visible ? 1 : 0,
zIndex: 1, zIndex: 1,
@@ -240,7 +248,7 @@ const Draggable = styled(Button)({
justifyContent: 'center', justifyContent: 'center',
backgroundColor: 'transparent', backgroundColor: 'transparent',
width: '16px', width: '16px',
height: '20px', height: '22px',
'& svg': { '& svg': {
fontSize: '20px', fontSize: '20px',
marginLeft: '-2px', marginLeft: '-2px',
@@ -253,5 +261,5 @@ const Draggable = styled(Button)({
const LigoLeftMenu = styled('div')({ const LigoLeftMenu = styled('div')({
backgroundColor: 'transparent', backgroundColor: 'transparent',
marginRight: '4px', // marginRight: '4px',
}); });
@@ -1,5 +1,5 @@
import { BlockDomInfo, HookType } from '@toeverything/framework/virgo'; import { BlockDomInfo, HookType } from '@toeverything/framework/virgo';
import React, { StrictMode } from 'react'; import { StrictMode } from 'react';
import { BasePlugin } from '../../base-plugin'; import { BasePlugin } from '../../base-plugin';
import { ignoreBlockTypes } from './menu-config'; import { ignoreBlockTypes } from './menu-config';
import { LineInfoSubject, LeftMenuDraggable } from './LeftMenuDraggable'; import { LineInfoSubject, LeftMenuDraggable } from './LeftMenuDraggable';
@@ -37,7 +37,7 @@ export class LeftMenuPlugin extends BasePlugin {
); );
this.sub.add( this.sub.add(
this.hooks this.hooks
.get(HookType.AFTER_ON_NODE_DRAG_OVER) .get(HookType.ON_ROOTNODE_DRAG_OVER)
.subscribe(this._handleDragOverBlockNode) .subscribe(this._handleDragOverBlockNode)
); );
this.sub.add( this.sub.add(
@@ -65,24 +65,30 @@ export class LeftMenuPlugin extends BasePlugin {
private _onDrop = () => { private _onDrop = () => {
this._lineInfo.next(undefined); this._lineInfo.next(undefined);
}; };
private _handleDragOverBlockNode = async ([event, blockInfo]: [ private _handleDragOverBlockNode = async (
React.DragEvent<Element>, event: React.DragEvent<Element>
BlockDomInfo ) => {
]) => {
const { type, dom, blockId } = blockInfo;
event.preventDefault(); event.preventDefault();
if (this.editor.dragDropManager.isDragBlock(event)) { if (!this.editor.dragDropManager.isDragBlock(event)) return;
if (ignoreBlockTypes.includes(type)) { const block = await this.editor.getBlockByPoint(
return; new Point(event.clientX, event.clientY)
}
const direction =
await this.editor.dragDropManager.checkBlockDragTypes(
event,
dom,
blockId
); );
this._lineInfo.next({ direction, blockInfo }); if (block == null || ignoreBlockTypes.includes(block.type)) return;
} const direction = await this.editor.dragDropManager.checkBlockDragTypes(
event,
block.dom,
block.id
);
this._lineInfo.next({
direction,
blockInfo: {
blockId: block.id,
dom: block.dom,
rect: block.dom.getBoundingClientRect(),
type: block.type,
properties: block.getProperties(),
},
});
}; };
private _handleMouseMove = async ( private _handleMouseMove = async (
@@ -8,6 +8,7 @@ import {
commonListContainer, commonListContainer,
} from '@toeverything/components/common'; } from '@toeverything/components/common';
import { domToRect } from '@toeverything/utils'; import { domToRect } from '@toeverything/utils';
import { styled } from '@toeverything/components/ui';
import { QueryResult } from '../../search'; import { QueryResult } from '../../search';
@@ -152,13 +153,12 @@ export const ReferenceMenuContainer = ({
}, [hooks, handle_key_down]); }, [hooks, handle_key_down]);
return isShow ? ( return isShow ? (
<div <RootContainer
ref={menu_ref} ref={menu_ref}
className={styles('rootContainer')}
onKeyDownCapture={handle_key_down} onKeyDownCapture={handle_key_down}
style={style} style={style}
> >
<div className={styles('contentContainer')}> <ContentContainer>
<CommonList <CommonList
items={ items={
searchBlocks?.map( searchBlocks?.map(
@@ -169,24 +169,23 @@ export const ReferenceMenuContainer = ({
currentItem={current_item} currentItem={current_item}
setCurrentItem={set_current_item} setCurrentItem={set_current_item}
/> />
</div> </ContentContainer>
</div> </RootContainer>
) : null; ) : null;
}; };
const styles = style9.create({ const RootContainer = styled('div')(({ theme }) => ({
rootContainer: {
position: 'fixed', position: 'fixed',
zIndex: 1, zIndex: 1,
maxHeight: 525, maxHeight: '525px',
borderRadius: '10px', borderRadius: '10px',
boxShadow: '0px 1px 10px rgba(152, 172, 189, 0.6)', boxShadow: theme.affine.shadows.shadow1,
backgroundColor: '#fff', backgroundColor: '#fff',
padding: '8px 4px', padding: '8px 4px',
}, }));
contentContainer: {
const ContentContainer = styled('div')(({ theme }) => ({
display: 'flex', display: 'flex',
overflow: 'hidden', overflow: 'hidden',
maxHeight: 493, maxHeight: '493px',
}, }));
});
@@ -141,8 +141,7 @@ export const PlaceholderPanel = (props: PlaceholderPanelProps) => {
setOpen(false); setOpen(false);
props.onClickTips(); props.onClickTips();
}; };
const templateList: Array<TemplateMeta> = const templateList = TemplateFactory.defaultTemplateList;
TemplateFactory.defaultTemplateList;
const handleNewFromTemplate = async (template: TemplateMeta) => { const handleNewFromTemplate = async (template: TemplateMeta) => {
const pageId = await editor.getRootBlockId(); const pageId = await editor.getRootBlockId();
const newPage = await services.api.editorBlock.getBlock( const newPage = await services.api.editorBlock.getBlock(
@@ -162,7 +161,6 @@ export const PlaceholderPanel = (props: PlaceholderPanelProps) => {
setOpen(false); setOpen(false);
}; };
return ( return (
<>
<PlaceholderPanelContainer <PlaceholderPanelContainer
style={{ style={{
top: point.y + 'px', top: point.y + 'px',
@@ -171,8 +169,7 @@ export const PlaceholderPanel = (props: PlaceholderPanelProps) => {
}} }}
> >
<EmptyPageTipContainer onClick={handleClickEmptyPage}> <EmptyPageTipContainer onClick={handleClickEmptyPage}>
Press Enter to continue with an empty page, or pick a Press Enter to continue with an empty page, or pick a template
template
</EmptyPageTipContainer> </EmptyPageTipContainer>
<div style={{ marginTop: '4px', marginLeft: '-8px' }}> <div style={{ marginTop: '4px', marginLeft: '-8px' }}>
{templateList.map((template, index) => { {templateList.map((template, index) => {
@@ -189,6 +186,5 @@ export const PlaceholderPanel = (props: PlaceholderPanelProps) => {
})} })}
</div> </div>
</PlaceholderPanelContainer> </PlaceholderPanelContainer>
</>
); );
}; };
@@ -7,6 +7,7 @@ import {
TransitionsModal, TransitionsModal,
MuiBox as Box, MuiBox as Box,
MuiBox, MuiBox,
styled,
} from '@toeverything/components/ui'; } from '@toeverything/components/ui';
import { Virgo, BlockEditor } from '@toeverything/framework/virgo'; import { Virgo, BlockEditor } from '@toeverything/framework/virgo';
import { throttle } from '@toeverything/utils'; import { throttle } from '@toeverything/utils';
@@ -21,26 +22,6 @@ const styles = style9.create({
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
}, },
search: {
margin: '0.5em',
backgroundColor: 'white',
boxShadow: '0px 1px 10px rgb(152 172 189 / 60%)',
padding: '16px 32px',
borderRadius: '10px',
},
result: {
margin: '0.5em',
backgroundColor: 'white',
boxShadow: '0px 1px 10px rgb(152 172 189 / 60%)',
padding: '16px 32px',
borderRadius: '10px',
transitionProperty: 'max-height',
transitionDuration: '300ms',
transitionTimingFunction: 'cubic-bezier(0.4, 0, 0.2, 1)',
transitionDelay: '0ms',
overflowX: 'hidden',
overflowY: 'hidden',
},
resultItem: { resultItem: {
width: '100%', width: '100%',
}, },
@@ -96,15 +77,14 @@ export const Search = (props: SearchProps) => {
}} }}
> >
<Box className={styles('wrapper')}> <Box className={styles('wrapper')}>
<input <SearchInput
className={styles('search')}
autoFocus autoFocus
value={search} value={search}
onChange={e => set_search(e.target.value)} onChange={e => set_search(e.target.value)}
/> />
<MuiBox <ResultContainer
sx={{ maxHeight: `${result.length * 28 + 32 + 20}px` }} sx={{ maxHeight: `${result.length * 28 + 32 + 20}px` }}
className={styles('result', { className={styles({
resultHide: !result.length, resultHide: !result.length,
})} })}
> >
@@ -119,8 +99,30 @@ export const Search = (props: SearchProps) => {
}} }}
/> />
))} ))}
</MuiBox> </ResultContainer>
</Box> </Box>
</TransitionsModal> </TransitionsModal>
); );
}; };
const SearchInput = styled('input')(({ theme }) => ({
margin: '0.5em',
backgroundColor: 'white',
boxShadow: theme.affine.shadows.shadow1,
padding: '16px 32px',
borderRadius: '10px',
}));
const ResultContainer = styled(MuiBox)(({ theme }) => ({
margin: '0.5em',
backgroundColor: 'white',
boxShadow: theme.affine.shadows.shadow1,
padding: '16px 32px',
borderRadius: '10px',
transitionProperty: 'max-height',
transitionDuration: '300ms',
transitionTimingFunction: 'cubic-bezier(0.4, 0, 0.2, 1)',
transitionDelay: '0ms',
overflowX: 'hidden',
overflowY: 'hidden',
}));
@@ -20,7 +20,7 @@ const IconWrapper = styled('div')<Pick<StatusIconProps, 'mode'>>(
width: '20px', width: '20px',
height: '20px', height: '20px',
borderRadius: '5px', borderRadius: '5px',
boxShadow: '0px 1px 10px rgba(152, 172, 189, 0.6)', boxShadow: theme.affine.shadows.shadow1,
color: theme.affine.palette.primary, color: theme.affine.palette.primary,
cursor: 'pointer', cursor: 'pointer',
backgroundColor: theme.affine.palette.white, backgroundColor: theme.affine.palette.white,
@@ -94,7 +94,7 @@ const StyledContainerForCommentItem = styled('div', {
transition: 'left 150ms ease-in-out', transition: 'left 150ms ease-in-out',
backgroundColor: theme.affine.palette.white, backgroundColor: theme.affine.palette.white,
'&:hover': { '&:hover': {
boxShadow: theme.affine.shadows.shadowSxDownLg, boxShadow: theme.affine.shadows.shadow1,
}, },
}; };
}); });
@@ -12,17 +12,22 @@ import { useNavigate } from 'react-router';
import { formatDistanceToNow } from 'date-fns'; import { formatDistanceToNow } from 'date-fns';
const StyledWrapper = styled('div')({ const StyledWrapper = styled('div')({
margin: '0 16px 0 32px', paddingLeft: '12px',
span: { span: {
textOverflow: 'ellipsis', textOverflow: 'ellipsis',
overflow: 'hidden', overflow: 'hidden',
}, },
'.item': { '.item': {
height: '32px',
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',
ustifyContent: 'space-between', justifyContent: 'space-between',
padding: '7px 0px', paddingRight: '20px',
whiteSpace: 'nowrap', whiteSpace: 'nowrap',
'&:hover': {
background: '#f5f7f8',
borderRadius: '5px',
},
}, },
'.itemButton': { '.itemButton': {
padding: 0, padding: 0,
@@ -31,6 +36,7 @@ const StyledWrapper = styled('div')({
'.itemLeft': { '.itemLeft': {
color: '#4c6275', color: '#4c6275',
marginRight: '20px', marginRight: '20px',
cursor: 'pointer',
span: { span: {
fontSize: 14, fontSize: 14,
}, },
@@ -44,6 +50,14 @@ const StyledWrapper = styled('div')({
}, },
}); });
const StyledItemContent = styled('div')({
width: '100%',
height: '32px',
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
});
export const Activities = () => { export const Activities = () => {
const navigate = useNavigate(); const navigate = useNavigate();
const { user, currentSpaceId } = useUserAndSpaces(); const { user, currentSpaceId } = useUserAndSpaces();
@@ -51,34 +65,29 @@ export const Activities = () => {
const userId = user?.id; const userId = user?.id;
/* temporarily remove:show recently viewed documents */ /* temporarily remove:show recently viewed documents */
// const fetchRecentPages = useCallback(async () => { const fetchRecentPages = useCallback(async () => {
// if (!userId || !currentSpaceId) { if (!userId || !currentSpaceId) {
// return; return;
// } }
// const recent_pages = await services.api.userConfig.getRecentPages( const recent_pages = await services.api.userConfig.getRecentPages(
// currentSpaceId, currentSpaceId,
// userId userId
// ); );
// setRecentPages(recent_pages); setRecentPages(recent_pages);
// }, [userId, currentSpaceId]); }, [userId, currentSpaceId]);
// useEffect(() => { useEffect(() => {
// (async () => { (async () => {
// await fetchRecentPages(); await fetchRecentPages();
// })(); })();
// }, [fetchRecentPages]); }, [fetchRecentPages]);
/* show recently edit documents */
const getRecentEditPages = async (state, block) => {
console.log(state, await block.children());
};
useEffect(() => { useEffect(() => {
let unobserve: () => void; let unobserve: () => void;
const observe = async () => { const observe = async () => {
unobserve = await services.api.userConfig.observe( unobserve = await services.api.userConfig.observe(
{ workspace: currentSpaceId }, { workspace: currentSpaceId },
getRecentEditPages fetchRecentPages
); );
}; };
observe(); observe();
@@ -86,16 +95,15 @@ export const Activities = () => {
return () => { return () => {
unobserve?.(); unobserve?.();
}; };
}, [currentSpaceId, getRecentEditPages]); }, [currentSpaceId, fetchRecentPages]);
return ( return (
<StyledWrapper> <StyledWrapper>
<List> <List style={{ padding: '0px' }}>
{recentPages.map(({ id, title, lastOpenTime }) => { {recentPages.map(({ id, title, lastOpenTime }) => {
return ( return (
<ListItem className="item" key={id}> <ListItem className="item" key={id}>
<ListItemButton <StyledItemContent
className="itemButton"
onClick={() => { onClick={() => {
navigate(`/${currentSpaceId}/${id}`); navigate(`/${currentSpaceId}/${id}`);
}} }}
@@ -110,7 +118,7 @@ export const Activities = () => {
includeSeconds: true, includeSeconds: true,
})} })}
/> />
</ListItemButton> </StyledItemContent>
</ListItem> </ListItem>
); );
})} })}
@@ -44,7 +44,7 @@ export type DndTreeProps = {
*/ */
export function DndTree(props: DndTreeProps) { export function DndTree(props: DndTreeProps) {
const { const {
indentationWidth = 16, indentationWidth = 12,
collapsible, collapsible,
removable, removable,
showDragIndicator, showDragIndicator,
@@ -101,9 +101,6 @@ export const TreeItem = forwardRef<HTMLDivElement, TreeItemProps>(
<ArrowDropDownIcon /> <ArrowDropDownIcon />
))} ))}
</Action> </Action>
{/*<Action>*/}
{/* <DocumentIcon />*/}
{/*</Action>*/}
<div className={styles['ItemContent']}> <div className={styles['ItemContent']}>
<span <span
@@ -161,7 +158,6 @@ export function Action({
style={ style={
{ {
...style, ...style,
// cursor,
'--fill': active?.fill, '--fill': active?.fill,
'--background': active?.background, '--background': active?.background,
} as CSSProperties } as CSSProperties
@@ -4,6 +4,10 @@
list-style: none; list-style: none;
padding: 6px 0; padding: 6px 0;
font-size: 14px; font-size: 14px;
&:hover {
background: #f5f7f8;
border-radius: 5px;
}
&.clone { &.clone {
display: inline-block; display: inline-block;
@@ -43,7 +47,6 @@
height: 12px; height: 12px;
border-radius: 50%; border-radius: 50%;
border: 1px solid #2389ff; border: 1px solid #2389ff;
background-color: #ffffff;
} }
> * { > * {
@@ -69,7 +72,6 @@
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;
align-items: center; align-items: center;
background-color: #fff;
color: #4c6275; color: #4c6275;
} }
@@ -81,7 +83,6 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-around; justify-content: space-around;
background-color: #fff;
color: #4c6275; color: #4c6275;
padding-right: 0.5rem; padding-right: 0.5rem;
overflow: hidden; overflow: hidden;
@@ -96,11 +97,6 @@
display: block; display: block;
} }
} }
&:hover {
background: #f5f7f8;
border-radius: 5px;
}
} }
.Text { .Text {
@@ -167,14 +163,6 @@
background-color: transparent; background-color: transparent;
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
&:hover {
background-color: var(--action-background, rgba(0, 0, 0, 0.05));
svg {
fill: #6f7b88;
}
}
svg { svg {
flex: 0 0 auto; flex: 0 0 auto;
margin: auto; margin: auto;
+1 -1
View File
@@ -133,7 +133,7 @@ export function Cascader(props: CascaderProps) {
const MenuPaper = styled('div')(({ theme }) => ({ const MenuPaper = styled('div')(({ theme }) => ({
fontFamily: 'PingFang SC', fontFamily: 'PingFang SC',
background: '#FFF', background: '#FFF',
boxShadow: '0px 1px 10px rgba(152, 172, 189, 0.6)', boxShadow: theme.affine.shadows.shadow1,
borderRadius: '10px 0px 10px 10px', borderRadius: '10px 0px 10px 10px',
color: '#4C6275', color: '#4C6275',
fontWeight: '400', fontWeight: '400',
Loaded 100 of 122 files, more files were not shown because too many files have changed in this diff. Show more