From 6bdb7b48762f3f700bf3f330ffb93b9473143834 Mon Sep 17 00:00:00 2001
From: lawvs <18554747+lawvs@users.noreply.github.com>
Date: Fri, 5 Aug 2022 18:55:30 +0800
Subject: [PATCH 01/10] chore: disable selection group plugin
---
libs/components/editor-plugins/src/index.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libs/components/editor-plugins/src/index.ts b/libs/components/editor-plugins/src/index.ts
index be7bb9bd97..ab657a9904 100644
--- a/libs/components/editor-plugins/src/index.ts
+++ b/libs/components/editor-plugins/src/index.ts
@@ -21,7 +21,7 @@ export const plugins: PluginCreator[] = [
CommandMenuPlugin,
ReferenceMenuPlugin,
TemplatePlugin,
- SelectionGroupPlugin,
+ // SelectionGroupPlugin,
AddCommentPlugin,
GroupMenuPlugin,
];
From 407ee4d8f0ca544580e407e76007410f1ea82725 Mon Sep 17 00:00:00 2001
From: lawvs <18554747+lawvs@users.noreply.github.com>
Date: Fri, 5 Aug 2022 18:56:25 +0800
Subject: [PATCH 02/10] feat: add kanban card mask
---
.../blocks/group/scene-kanban/CardItem.tsx | 63 ++++++++++++++++---
1 file changed, 53 insertions(+), 10 deletions(-)
diff --git a/libs/components/editor-blocks/src/blocks/group/scene-kanban/CardItem.tsx b/libs/components/editor-blocks/src/blocks/group/scene-kanban/CardItem.tsx
index 76220d7ff0..eba13f0db6 100644
--- a/libs/components/editor-blocks/src/blocks/group/scene-kanban/CardItem.tsx
+++ b/libs/components/editor-blocks/src/blocks/group/scene-kanban/CardItem.tsx
@@ -4,8 +4,14 @@ import {
useKanban,
useRefPage,
} from '@toeverything/components/editor-core';
-import { styled } from '@toeverything/components/ui';
+import { PenIcon } from '@toeverything/components/icons';
+import {
+ IconButton,
+ MuiClickAwayListener,
+ styled,
+} from '@toeverything/components/ui';
import { useFlag } from '@toeverything/datasource/feature-flags';
+import { useState } from 'react';
const CardContent = styled('div')({
margin: '20px',
@@ -23,6 +29,7 @@ const CardActions = styled('div')({
fontWeight: '300',
color: '#98ACBD',
transition: 'all ease-in 0.2s',
+ zIndex: 1,
':hover': {
background: '#F5F7F8',
@@ -39,11 +46,13 @@ const PlusIcon = styled('div')({
});
const CardContainer = styled('div')({
+ position: 'relative',
display: 'flex',
flexDirection: 'column',
backgroundColor: '#fff',
border: '1px solid #E2E7ED',
borderRadius: '5px',
+ overflow: 'hidden',
[CardActions.toString()]: {
opacity: '0',
@@ -55,6 +64,23 @@ const CardContainer = styled('div')({
},
});
+const Overlay = styled('div')({
+ position: 'absolute',
+ width: '100%',
+ height: '100%',
+ background: 'transparent',
+
+ '& > *': {
+ visibility: 'hidden',
+ position: 'absolute',
+ right: '24px',
+ top: '16px',
+ },
+ '&:hover > *': {
+ visibility: 'visible',
+ },
+});
+
export const CardItem = ({
id,
block,
@@ -64,8 +90,11 @@ export const CardItem = ({
}) => {
const { addSubItem } = useKanban();
const { openSubPage } = useRefPage();
+ const [editable, setEditable] = useState(false);
const showKanbanRefPageFlag = useFlag('ShowKanbanRefPage', false);
+
const onAddItem = async () => {
+ setEditable(true);
await addSubItem(block);
};
@@ -74,14 +103,28 @@ export const CardItem = ({
};
return (
-
-
-
-
-
-
- Add a sub-block
-
-
+ setEditable(false)}>
+
+
+
+
+ {!editable && (
+
+ {
+ e.stopPropagation();
+ setEditable(true);
+ }}
+ >
+
+
+
+ )}
+
+
+ Add a sub-block
+
+
+
);
};
From dcdc7f8862e3b5435c1ebfd0d9c6688b0de1efa7 Mon Sep 17 00:00:00 2001
From: lawvs <18554747+lawvs@users.noreply.github.com>
Date: Wed, 10 Aug 2022 17:41:13 +0800
Subject: [PATCH 03/10] refactor: ref page use AffineEditor
---
.../src/blocks/group/scene-kanban/CardItem.tsx | 7 ++-----
.../src/blocks/group/scene-kanban/RefPage.tsx} | 16 +++++++++++++---
libs/components/editor-core/src/index.ts | 2 +-
.../editor-core/src/recast-block/Context.tsx | 3 +--
.../components/editor-core/src/ref-page/index.ts | 1 -
5 files changed, 17 insertions(+), 12 deletions(-)
rename libs/components/{editor-core/src/ref-page/ModalPage.tsx => editor-blocks/src/blocks/group/scene-kanban/RefPage.tsx} (82%)
delete mode 100644 libs/components/editor-core/src/ref-page/index.ts
diff --git a/libs/components/editor-blocks/src/blocks/group/scene-kanban/CardItem.tsx b/libs/components/editor-blocks/src/blocks/group/scene-kanban/CardItem.tsx
index eba13f0db6..c1cc9f9a1c 100644
--- a/libs/components/editor-blocks/src/blocks/group/scene-kanban/CardItem.tsx
+++ b/libs/components/editor-blocks/src/blocks/group/scene-kanban/CardItem.tsx
@@ -1,9 +1,5 @@
import type { KanbanCard } from '@toeverything/components/editor-core';
-import {
- RenderBlock,
- useKanban,
- useRefPage,
-} from '@toeverything/components/editor-core';
+import { RenderBlock, useKanban } from '@toeverything/components/editor-core';
import { PenIcon } from '@toeverything/components/icons';
import {
IconButton,
@@ -12,6 +8,7 @@ import {
} from '@toeverything/components/ui';
import { useFlag } from '@toeverything/datasource/feature-flags';
import { useState } from 'react';
+import { useRefPage } from './RefPage';
const CardContent = styled('div')({
margin: '20px',
diff --git a/libs/components/editor-core/src/ref-page/ModalPage.tsx b/libs/components/editor-blocks/src/blocks/group/scene-kanban/RefPage.tsx
similarity index 82%
rename from libs/components/editor-core/src/ref-page/ModalPage.tsx
rename to libs/components/editor-blocks/src/blocks/group/scene-kanban/RefPage.tsx
index 52e1d6554f..cd3588162e 100644
--- a/libs/components/editor-core/src/ref-page/ModalPage.tsx
+++ b/libs/components/editor-blocks/src/blocks/group/scene-kanban/RefPage.tsx
@@ -1,7 +1,8 @@
+import { AffineEditor } from '@toeverything/components/affine-editor';
+import { useEditor } from '@toeverything/components/editor-core';
import { MuiBackdrop, styled, useTheme } from '@toeverything/components/ui';
import { createContext, ReactNode, useContext, useState } from 'react';
import { createPortal } from 'react-dom';
-import { RenderBlock } from '../render-block';
const Dialog = styled('div')({
flex: 1,
@@ -30,7 +31,7 @@ const Modal = ({ open, children }: { open: boolean; children?: ReactNode }) => {
onClick={closeSubPage}
>