From ecc708017968e4beca2c62979c257ef53cfd5b02 Mon Sep 17 00:00:00 2001 From: DarkSky Date: Fri, 5 Aug 2022 22:06:31 +0800 Subject: [PATCH 01/20] Revert "Merge pull request #42 from toeverything/feat/sub-page" This reverts commit cf6491fb0c7cf0b031f0b87b145ca3a98c687c88, reversing changes made to e12deb302f74cb5bbc42f16f9b848fa93bb58d85. --- .../blocks/group/scene-kanban/CardContext.tsx | 2 +- .../blocks/group/scene-kanban/CardItem.tsx | 17 +--- .../components/editor-core/src/RenderRoot.tsx | 6 +- .../src/{Contexts.tsx => contexts.tsx} | 18 +++- libs/components/editor-core/src/hooks.ts | 20 ++--- libs/components/editor-core/src/index.ts | 3 +- .../editor-core/src/kanban/kanban.ts | 2 +- .../editor-core/src/recast-block/Context.tsx | 5 +- .../editor-core/src/recast-block/README.md | 19 ++++ .../editor-core/src/recast-block/group.ts | 4 +- .../editor-core/src/ref-page/ModalPage.tsx | 90 ------------------- .../editor-core/src/ref-page/index.ts | 1 - .../src/render-block/RenderBlock.tsx | 8 +- libs/components/ui/src/mui.ts | 5 -- libs/datasource/feature-flags/README.md | 13 +-- libs/datasource/feature-flags/src/config.ts | 14 --- 16 files changed, 63 insertions(+), 164 deletions(-) rename libs/components/editor-core/src/{Contexts.tsx => contexts.tsx} (70%) delete mode 100644 libs/components/editor-core/src/ref-page/ModalPage.tsx delete mode 100644 libs/components/editor-core/src/ref-page/index.ts diff --git a/libs/components/editor-blocks/src/blocks/group/scene-kanban/CardContext.tsx b/libs/components/editor-blocks/src/blocks/group/scene-kanban/CardContext.tsx index f7f05b37d4..cb313d14ee 100644 --- a/libs/components/editor-blocks/src/blocks/group/scene-kanban/CardContext.tsx +++ b/libs/components/editor-blocks/src/blocks/group/scene-kanban/CardContext.tsx @@ -25,7 +25,7 @@ const AddCard = ({ group }: { group: KanbanGroup }) => { const { addCard } = useKanban(); const handleClick = useCallback(async () => { await addCard(group); - }, [addCard, group]); + }, [addCard]); return +; }; 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..f26374e4c3 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,11 +1,6 @@ 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 { styled } from '@toeverything/components/ui'; -import { useFlag } from '@toeverything/datasource/feature-flags'; const CardContent = styled('div')({ margin: '20px', @@ -63,24 +58,18 @@ export const CardItem = ({ block: KanbanCard['block']; }) => { const { addSubItem } = useKanban(); - const { openSubPage } = useRefPage(); - const showKanbanRefPageFlag = useFlag('ShowKanbanRefPage', false); const onAddItem = async () => { await addSubItem(block); }; - const onClickCard = async () => { - showKanbanRefPageFlag && openSubPage(id); - }; - return ( - + - Add a sub-block + Add item ); diff --git a/libs/components/editor-core/src/RenderRoot.tsx b/libs/components/editor-core/src/RenderRoot.tsx index e4534b813d..1d08db0b16 100644 --- a/libs/components/editor-core/src/RenderRoot.tsx +++ b/libs/components/editor-core/src/RenderRoot.tsx @@ -2,7 +2,7 @@ import type { BlockEditor } from './editor'; import { styled, usePatchNodes } from '@toeverything/components/ui'; import type { FC, PropsWithChildren } from 'react'; import React, { useEffect, useRef, useState, useCallback } from 'react'; -import { EditorProvider } from './Contexts'; +import { RootContext } from './contexts'; import { SelectionRect, SelectionRef } from './Selection'; import { Protocol, @@ -151,7 +151,7 @@ export const RenderRoot: FC> = ({ }; return ( - + { @@ -183,7 +183,7 @@ export const RenderRoot: FC> = ({ {editor.isWhiteboard ? null : } {patchedNodes} - + ); }; diff --git a/libs/components/editor-core/src/Contexts.tsx b/libs/components/editor-core/src/contexts.tsx similarity index 70% rename from libs/components/editor-core/src/Contexts.tsx rename to libs/components/editor-core/src/contexts.tsx index 418fe0e8b4..cdd4dbf305 100644 --- a/libs/components/editor-core/src/Contexts.tsx +++ b/libs/components/editor-core/src/contexts.tsx @@ -1,8 +1,9 @@ import { createContext, useContext } from 'react'; import type { BlockEditor, AsyncBlock } from './editor'; +import type { Column } from '@toeverything/datasource/db-service'; import { genErrorObj } from '@toeverything/utils'; -const RootContext = createContext<{ +export const RootContext = createContext<{ editor: BlockEditor; // TODO: Temporary fix, dependencies in the new architecture are bottom-up, editors do not need to be passed down from the top editorElement: () => JSX.Element; @@ -13,8 +14,6 @@ const RootContext = createContext<{ ) as any ); -export const EditorProvider = RootContext.Provider; - export const useEditor = () => { return useContext(RootContext); }; @@ -23,3 +22,16 @@ export const useEditor = () => { * @deprecated */ export const BlockContext = createContext(null as any); + +/** + * Context of column information + * + * @deprecated + */ +export const ColumnsContext = createContext<{ + fromId: string; + columns: Column[]; +}>({ + fromId: '', + columns: [], +}); diff --git a/libs/components/editor-core/src/hooks.ts b/libs/components/editor-core/src/hooks.ts index f0af8a0f87..d7d1a00cef 100644 --- a/libs/components/editor-core/src/hooks.ts +++ b/libs/components/editor-core/src/hooks.ts @@ -1,6 +1,3 @@ -import { noop, Point } from '@toeverything/utils'; -import { useCallback, useEffect, useRef, useState } from 'react'; -import { useEditor } from './Contexts'; import { AsyncBlock, BlockEditor, @@ -8,6 +5,9 @@ import { SelectionInfo, SelectionSettingsMap, } from './editor'; +import { noop, Point } from '@toeverything/utils'; +import { useCallback, useContext, useEffect, useRef, useState } from 'react'; +import { RootContext } from './contexts'; function useRequestReRender() { const [, setUpdateCounter] = useState(0); @@ -56,7 +56,7 @@ function useRequestReRender() { export const useBlock = (blockId: string) => { const [block, setBlock] = useState(); const requestReRender = useRequestReRender(); - const { editor } = useEditor(); + const { editor } = useContext(RootContext); useEffect(() => { if (!blockId) { return undefined; @@ -95,7 +95,7 @@ export const useOnSelect = ( blockId: string, cb: (isSelect: boolean) => void ) => { - const { editor } = useEditor(); + const { editor } = useContext(RootContext); useEffect(() => { editor.selectionManager.observe(blockId, SelectEventTypes.onSelect, cb); return () => { @@ -117,7 +117,7 @@ export const useOnSelectActive = ( blockId: string, cb: (position: Point | undefined) => void ) => { - const { editor } = useEditor(); + const { editor } = useContext(RootContext); useEffect(() => { editor.selectionManager.observe(blockId, SelectEventTypes.active, cb); return () => { @@ -139,7 +139,7 @@ export const useOnSelectSetSelection = ( blockId: string, cb: (args: SelectionSettingsMap[T]) => void ) => { - const { editor } = useEditor(); + const { editor } = useContext(RootContext); useEffect(() => { editor.selectionManager.observe( blockId, @@ -162,7 +162,7 @@ export const useOnSelectSetSelection = ( * @export */ export const useOnSelectChange = (cb: (info: SelectionInfo) => void) => { - const { editor } = useEditor(); + const { editor } = useContext(RootContext); useEffect(() => { editor.selectionManager.onSelectionChange(cb); return () => { @@ -177,7 +177,7 @@ export const useOnSelectChange = (cb: (info: SelectionInfo) => void) => { * @export */ export const useOnSelectEnd = (cb: (info: SelectionInfo) => void) => { - const { editor } = useEditor(); + const { editor } = useContext(RootContext); useEffect(() => { editor.selectionManager.onSelectEnd(cb); return () => { @@ -195,7 +195,7 @@ export const useOnSelectStartWith = ( blockId: string, cb: (args: MouseEvent) => void ) => { - const { editor } = useEditor(); + const { editor } = useContext(RootContext); useEffect(() => { editor.mouseManager.onSelectStartWith(blockId, cb); return () => { diff --git a/libs/components/editor-core/src/index.ts b/libs/components/editor-core/src/index.ts index bea2fed3a0..6cdd358058 100644 --- a/libs/components/editor-core/src/index.ts +++ b/libs/components/editor-core/src/index.ts @@ -1,3 +1,4 @@ +export { ColumnsContext, RootContext } from './contexts'; export { RenderRoot, MIN_PAGE_WIDTH } from './RenderRoot'; export * from './render-block'; export * from './hooks'; @@ -15,5 +16,3 @@ export * from './kanban/types'; export * from './utils'; export * from './editor'; - -export { RefPageProvider, useRefPage } from './ref-page'; diff --git a/libs/components/editor-core/src/kanban/kanban.ts b/libs/components/editor-core/src/kanban/kanban.ts index 218476ac44..ff33b17f1d 100644 --- a/libs/components/editor-core/src/kanban/kanban.ts +++ b/libs/components/editor-core/src/kanban/kanban.ts @@ -1,6 +1,6 @@ import { Protocol } from '@toeverything/datasource/db-service'; import { useCallback, useContext, useEffect, useState } from 'react'; -import { useEditor } from '../Contexts'; +import { useEditor } from '../contexts'; import { AsyncBlock } from '../editor'; import { useRecastView } from '../recast-block'; import { useRecastBlock } from '../recast-block/Context'; diff --git a/libs/components/editor-core/src/recast-block/Context.tsx b/libs/components/editor-core/src/recast-block/Context.tsx index 47ec6cfcdb..55d334039b 100644 --- a/libs/components/editor-core/src/recast-block/Context.tsx +++ b/libs/components/editor-core/src/recast-block/Context.tsx @@ -2,7 +2,6 @@ import { Protocol } from '@toeverything/datasource/db-service'; import { AsyncBlock } from '../editor'; import { ComponentType, createContext, ReactNode, useContext } from 'react'; import { RecastBlock } from './types'; -import { RefPageProvider } from '../ref-page'; /** * Determine whether the block supports RecastBlock @@ -48,7 +47,7 @@ export const RecastBlockProvider = ({ return ( - {children} + {children} ); }; @@ -61,7 +60,7 @@ export const useRecastBlock = () => { const recastBlock = useContext(RecastBlockContext); if (!recastBlock) { throw new Error( - 'Failed to find recastBlock! Please use the hook under `RecastBlockProvider`.' + 'Failed to find recastBlock! Please use the hook under `RecastTableProvider`.' ); } return recastBlock; diff --git a/libs/components/editor-core/src/recast-block/README.md b/libs/components/editor-core/src/recast-block/README.md index 489412eab3..59aed91be7 100644 --- a/libs/components/editor-core/src/recast-block/README.md +++ b/libs/components/editor-core/src/recast-block/README.md @@ -49,3 +49,22 @@ const SomeBlock = () => { return
...
; }; ``` + +## Scene + +**Notice: The scene API will refactor at next version.** + +```tsx +const SomeBlock = () => { + const { scene, setScene, setPage, setTable, setKanban } = + useRecastBlockScene(); + + return ( + <> +
Scene: {scene}
+ + + + ); +}; +``` diff --git a/libs/components/editor-core/src/recast-block/group.ts b/libs/components/editor-core/src/recast-block/group.ts index 9879ba43df..ae846fc238 100644 --- a/libs/components/editor-core/src/recast-block/group.ts +++ b/libs/components/editor-core/src/recast-block/group.ts @@ -32,7 +32,7 @@ export const mergeGroup = async (...groups: AsyncBlock[]) => { ); } - await mergeGroupProperties(...(groups as unknown as RecastBlock[])); + await mergeGroupProperties(...(groups as RecastBlock[])); const [headGroup, ...restGroups] = groups; // Add all children to the head group @@ -174,7 +174,7 @@ export const splitGroup = async ( } splitGroupProperties( - group as unknown as RecastBlock, + group as RecastBlock, newGroupBlock as unknown as RecastBlock ); await group.after(newGroupBlock); diff --git a/libs/components/editor-core/src/ref-page/ModalPage.tsx b/libs/components/editor-core/src/ref-page/ModalPage.tsx deleted file mode 100644 index 276d5984d6..0000000000 --- a/libs/components/editor-core/src/ref-page/ModalPage.tsx +++ /dev/null @@ -1,90 +0,0 @@ -import { MuiBackdrop, styled, useTheme } from '@toeverything/components/ui'; -import { createContext, ReactNode, useContext, useState } from 'react'; -import { createPortal } from 'react-dom'; -import { useEditor } from '../Contexts'; -import { RenderBlock } from '../render-block'; - -const Dialog = styled('div')({ - flex: 1, - width: '880px', - margin: '72px auto', - background: '#fff', - boxShadow: '0px 1px 10px rgba(152, 172, 189, 0.6)', - borderRadius: '10px', - padding: '72px 120px', - overflow: 'scroll', -}); - -const Modal = ({ open, children }: { open: boolean; children?: ReactNode }) => { - const theme = useTheme(); - const { closeSubPage } = useRefPage(); - - return createPortal( - - { - e.stopPropagation(); - }} - > - {children} - - , - - document.body - ); -}; - -const ModalPage = ({ blockId }: { blockId: string | null }) => { - const { editor } = useEditor(); - - return ( - - {blockId && } - - ); -}; - -const RefPageContext = createContext< - ReturnType> | undefined ->(undefined); - -export const RefPageProvider = ({ children }: { children: ReactNode }) => { - const state = useState(); - const [blockId, setBlockId] = state; - - return ( - - {children} - - - ); -}; - -export const useRefPage = () => { - const context = useContext(RefPageContext); - if (!context) { - throw new Error( - 'Wrap your app inside of a `SubPageProvider` to have access to the hook context!' - ); - } - const [blockId, setBlockId] = context; - const openSubPage = (blockId: string) => { - setBlockId(blockId); - }; - const closeSubPage = () => { - setBlockId(null); - }; - - return { blockId, open: !!blockId, openSubPage, closeSubPage }; -}; - -// export const openSubPage = () => {}; diff --git a/libs/components/editor-core/src/ref-page/index.ts b/libs/components/editor-core/src/ref-page/index.ts deleted file mode 100644 index 4b06310a5c..0000000000 --- a/libs/components/editor-core/src/ref-page/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { useRefPage, RefPageProvider } from './ModalPage'; diff --git a/libs/components/editor-core/src/render-block/RenderBlock.tsx b/libs/components/editor-core/src/render-block/RenderBlock.tsx index 74f6c659cf..46f068af2b 100644 --- a/libs/components/editor-core/src/render-block/RenderBlock.tsx +++ b/libs/components/editor-core/src/render-block/RenderBlock.tsx @@ -1,8 +1,8 @@ -import { styled } from '@toeverything/components/ui'; -import { FC, useLayoutEffect, useMemo, useRef } from 'react'; +import { styled, Theme } from '@toeverything/components/ui'; +import { FC, useContext, useLayoutEffect, useMemo, useRef } from 'react'; // import { RenderChildren } from './RenderChildren'; -import { useEditor } from '../Contexts'; +import { RootContext } from '../contexts'; import { useBlock } from '../hooks'; interface RenderBlockProps { @@ -14,7 +14,7 @@ export const RenderBlock: FC = ({ blockId, hasContainer = true, }) => { - const { editor, editorElement } = useEditor(); + const { editor, editorElement } = useContext(RootContext); const { block } = useBlock(blockId); const blockRef = useRef(null); diff --git a/libs/components/ui/src/mui.ts b/libs/components/ui/src/mui.ts index 47588ce5e6..b0658ad526 100644 --- a/libs/components/ui/src/mui.ts +++ b/libs/components/ui/src/mui.ts @@ -13,7 +13,6 @@ import type { } from '@mui/material'; import { Avatar, - Backdrop, Box, Button, Checkbox, @@ -244,7 +243,3 @@ export const MuiFade = Fade; * @deprecated It is not recommended to use Mui directly, because the design will not refer to Mui's interaction logic. */ export const MuiRadio = Radio; -/** - * @deprecated It is not recommended to use Mui directly, because the design will not refer to Mui's interaction logic. - */ -export const MuiBackdrop = Backdrop; diff --git a/libs/datasource/feature-flags/README.md b/libs/datasource/feature-flags/README.md index 7a04209c5d..f5c59f4e13 100644 --- a/libs/datasource/feature-flags/README.md +++ b/libs/datasource/feature-flags/README.md @@ -2,15 +2,7 @@ ## Usage -- Set token at environment variable - - The key can be obtained from the [Feature Flag Portal](https://portal.featureflag.co/account-settings/projects) - -```shell -# .env.local -AFFINE_FEATURE_FLAG_TOKEN=XXXXXXX -``` - -- Set provider +- set provider ```tsx import { FeatureFlagsProvider } from '@toeverything/datasource/feature-flags'; @@ -50,8 +42,7 @@ const App = () => { **When entering development mode feature flag will NOT be updated in real time** -- `activateFfcDevMode(PASSWORD)` play with feature flags locally - - The `devModePassword` can be obtained from `src/config.ts` +- `activateFfcDevMode()` play with feature flags locally - `quitFfcDevMode()` quit dev mode ## Running unit tests diff --git a/libs/datasource/feature-flags/src/config.ts b/libs/datasource/feature-flags/src/config.ts index 5295dae995..7f3360d6db 100644 --- a/libs/datasource/feature-flags/src/config.ts +++ b/libs/datasource/feature-flags/src/config.ts @@ -8,18 +8,4 @@ export const config: IOption = { // id: 'the user's unique identifier' // } devModePassword: '-', - enableDataSync: !!process.env['AFFINE_FEATURE_FLAG_TOKEN'], - // bootstrap: [ - // { - // // the feature flag key - // id: 'flag', - // // the feature flag value - // variation: false, - // // the variation data type, string is used if not provided - // variationType: VariationDataType.boolean, - // variationOptions: [], - // timestamp: 0, - // sendToExperiment: false, - // }, - // ], }; From d86247d6271f3e1e755fa3612fa8c8346ecb23fb Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Fri, 5 Aug 2022 22:44:01 +0800 Subject: [PATCH 02/20] Revert "Revert "Merge pull request #42 from toeverything/feat/sub-page"" This reverts commit ecc708017968e4beca2c62979c257ef53cfd5b02. --- .../blocks/group/scene-kanban/CardContext.tsx | 2 +- .../blocks/group/scene-kanban/CardItem.tsx | 17 +++- .../src/{contexts.tsx => Contexts.tsx} | 18 +--- .../components/editor-core/src/RenderRoot.tsx | 6 +- libs/components/editor-core/src/hooks.ts | 20 ++--- libs/components/editor-core/src/index.ts | 3 +- .../editor-core/src/kanban/kanban.ts | 2 +- .../editor-core/src/recast-block/Context.tsx | 5 +- .../editor-core/src/recast-block/README.md | 19 ---- .../editor-core/src/recast-block/group.ts | 4 +- .../editor-core/src/ref-page/ModalPage.tsx | 90 +++++++++++++++++++ .../editor-core/src/ref-page/index.ts | 1 + .../src/render-block/RenderBlock.tsx | 8 +- libs/components/ui/src/mui.ts | 5 ++ libs/datasource/feature-flags/README.md | 13 ++- libs/datasource/feature-flags/src/config.ts | 14 +++ 16 files changed, 164 insertions(+), 63 deletions(-) rename libs/components/editor-core/src/{contexts.tsx => Contexts.tsx} (70%) create mode 100644 libs/components/editor-core/src/ref-page/ModalPage.tsx create mode 100644 libs/components/editor-core/src/ref-page/index.ts diff --git a/libs/components/editor-blocks/src/blocks/group/scene-kanban/CardContext.tsx b/libs/components/editor-blocks/src/blocks/group/scene-kanban/CardContext.tsx index cb313d14ee..f7f05b37d4 100644 --- a/libs/components/editor-blocks/src/blocks/group/scene-kanban/CardContext.tsx +++ b/libs/components/editor-blocks/src/blocks/group/scene-kanban/CardContext.tsx @@ -25,7 +25,7 @@ const AddCard = ({ group }: { group: KanbanGroup }) => { const { addCard } = useKanban(); const handleClick = useCallback(async () => { await addCard(group); - }, [addCard]); + }, [addCard, group]); return +; }; 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 f26374e4c3..76220d7ff0 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,6 +1,11 @@ import type { KanbanCard } from '@toeverything/components/editor-core'; -import { RenderBlock, useKanban } from '@toeverything/components/editor-core'; +import { + RenderBlock, + useKanban, + useRefPage, +} from '@toeverything/components/editor-core'; import { styled } from '@toeverything/components/ui'; +import { useFlag } from '@toeverything/datasource/feature-flags'; const CardContent = styled('div')({ margin: '20px', @@ -58,18 +63,24 @@ export const CardItem = ({ block: KanbanCard['block']; }) => { const { addSubItem } = useKanban(); + const { openSubPage } = useRefPage(); + const showKanbanRefPageFlag = useFlag('ShowKanbanRefPage', false); const onAddItem = async () => { await addSubItem(block); }; + const onClickCard = async () => { + showKanbanRefPageFlag && openSubPage(id); + }; + return ( - + - Add item + Add a sub-block ); diff --git a/libs/components/editor-core/src/contexts.tsx b/libs/components/editor-core/src/Contexts.tsx similarity index 70% rename from libs/components/editor-core/src/contexts.tsx rename to libs/components/editor-core/src/Contexts.tsx index cdd4dbf305..418fe0e8b4 100644 --- a/libs/components/editor-core/src/contexts.tsx +++ b/libs/components/editor-core/src/Contexts.tsx @@ -1,9 +1,8 @@ import { createContext, useContext } from 'react'; import type { BlockEditor, AsyncBlock } from './editor'; -import type { Column } from '@toeverything/datasource/db-service'; import { genErrorObj } from '@toeverything/utils'; -export const RootContext = createContext<{ +const RootContext = createContext<{ editor: BlockEditor; // TODO: Temporary fix, dependencies in the new architecture are bottom-up, editors do not need to be passed down from the top editorElement: () => JSX.Element; @@ -14,6 +13,8 @@ export const RootContext = createContext<{ ) as any ); +export const EditorProvider = RootContext.Provider; + export const useEditor = () => { return useContext(RootContext); }; @@ -22,16 +23,3 @@ export const useEditor = () => { * @deprecated */ export const BlockContext = createContext(null as any); - -/** - * Context of column information - * - * @deprecated - */ -export const ColumnsContext = createContext<{ - fromId: string; - columns: Column[]; -}>({ - fromId: '', - columns: [], -}); diff --git a/libs/components/editor-core/src/RenderRoot.tsx b/libs/components/editor-core/src/RenderRoot.tsx index 1d08db0b16..e4534b813d 100644 --- a/libs/components/editor-core/src/RenderRoot.tsx +++ b/libs/components/editor-core/src/RenderRoot.tsx @@ -2,7 +2,7 @@ import type { BlockEditor } from './editor'; import { styled, usePatchNodes } from '@toeverything/components/ui'; import type { FC, PropsWithChildren } from 'react'; import React, { useEffect, useRef, useState, useCallback } from 'react'; -import { RootContext } from './contexts'; +import { EditorProvider } from './Contexts'; import { SelectionRect, SelectionRef } from './Selection'; import { Protocol, @@ -151,7 +151,7 @@ export const RenderRoot: FC> = ({ }; return ( - + { @@ -183,7 +183,7 @@ export const RenderRoot: FC> = ({ {editor.isWhiteboard ? null : } {patchedNodes} - + ); }; diff --git a/libs/components/editor-core/src/hooks.ts b/libs/components/editor-core/src/hooks.ts index d7d1a00cef..f0af8a0f87 100644 --- a/libs/components/editor-core/src/hooks.ts +++ b/libs/components/editor-core/src/hooks.ts @@ -1,3 +1,6 @@ +import { noop, Point } from '@toeverything/utils'; +import { useCallback, useEffect, useRef, useState } from 'react'; +import { useEditor } from './Contexts'; import { AsyncBlock, BlockEditor, @@ -5,9 +8,6 @@ import { SelectionInfo, SelectionSettingsMap, } from './editor'; -import { noop, Point } from '@toeverything/utils'; -import { useCallback, useContext, useEffect, useRef, useState } from 'react'; -import { RootContext } from './contexts'; function useRequestReRender() { const [, setUpdateCounter] = useState(0); @@ -56,7 +56,7 @@ function useRequestReRender() { export const useBlock = (blockId: string) => { const [block, setBlock] = useState(); const requestReRender = useRequestReRender(); - const { editor } = useContext(RootContext); + const { editor } = useEditor(); useEffect(() => { if (!blockId) { return undefined; @@ -95,7 +95,7 @@ export const useOnSelect = ( blockId: string, cb: (isSelect: boolean) => void ) => { - const { editor } = useContext(RootContext); + const { editor } = useEditor(); useEffect(() => { editor.selectionManager.observe(blockId, SelectEventTypes.onSelect, cb); return () => { @@ -117,7 +117,7 @@ export const useOnSelectActive = ( blockId: string, cb: (position: Point | undefined) => void ) => { - const { editor } = useContext(RootContext); + const { editor } = useEditor(); useEffect(() => { editor.selectionManager.observe(blockId, SelectEventTypes.active, cb); return () => { @@ -139,7 +139,7 @@ export const useOnSelectSetSelection = ( blockId: string, cb: (args: SelectionSettingsMap[T]) => void ) => { - const { editor } = useContext(RootContext); + const { editor } = useEditor(); useEffect(() => { editor.selectionManager.observe( blockId, @@ -162,7 +162,7 @@ export const useOnSelectSetSelection = ( * @export */ export const useOnSelectChange = (cb: (info: SelectionInfo) => void) => { - const { editor } = useContext(RootContext); + const { editor } = useEditor(); useEffect(() => { editor.selectionManager.onSelectionChange(cb); return () => { @@ -177,7 +177,7 @@ export const useOnSelectChange = (cb: (info: SelectionInfo) => void) => { * @export */ export const useOnSelectEnd = (cb: (info: SelectionInfo) => void) => { - const { editor } = useContext(RootContext); + const { editor } = useEditor(); useEffect(() => { editor.selectionManager.onSelectEnd(cb); return () => { @@ -195,7 +195,7 @@ export const useOnSelectStartWith = ( blockId: string, cb: (args: MouseEvent) => void ) => { - const { editor } = useContext(RootContext); + const { editor } = useEditor(); useEffect(() => { editor.mouseManager.onSelectStartWith(blockId, cb); return () => { diff --git a/libs/components/editor-core/src/index.ts b/libs/components/editor-core/src/index.ts index 6cdd358058..bea2fed3a0 100644 --- a/libs/components/editor-core/src/index.ts +++ b/libs/components/editor-core/src/index.ts @@ -1,4 +1,3 @@ -export { ColumnsContext, RootContext } from './contexts'; export { RenderRoot, MIN_PAGE_WIDTH } from './RenderRoot'; export * from './render-block'; export * from './hooks'; @@ -16,3 +15,5 @@ export * from './kanban/types'; export * from './utils'; export * from './editor'; + +export { RefPageProvider, useRefPage } from './ref-page'; diff --git a/libs/components/editor-core/src/kanban/kanban.ts b/libs/components/editor-core/src/kanban/kanban.ts index ff33b17f1d..218476ac44 100644 --- a/libs/components/editor-core/src/kanban/kanban.ts +++ b/libs/components/editor-core/src/kanban/kanban.ts @@ -1,6 +1,6 @@ import { Protocol } from '@toeverything/datasource/db-service'; import { useCallback, useContext, useEffect, useState } from 'react'; -import { useEditor } from '../contexts'; +import { useEditor } from '../Contexts'; import { AsyncBlock } from '../editor'; import { useRecastView } from '../recast-block'; import { useRecastBlock } from '../recast-block/Context'; diff --git a/libs/components/editor-core/src/recast-block/Context.tsx b/libs/components/editor-core/src/recast-block/Context.tsx index 55d334039b..47ec6cfcdb 100644 --- a/libs/components/editor-core/src/recast-block/Context.tsx +++ b/libs/components/editor-core/src/recast-block/Context.tsx @@ -2,6 +2,7 @@ import { Protocol } from '@toeverything/datasource/db-service'; import { AsyncBlock } from '../editor'; import { ComponentType, createContext, ReactNode, useContext } from 'react'; import { RecastBlock } from './types'; +import { RefPageProvider } from '../ref-page'; /** * Determine whether the block supports RecastBlock @@ -47,7 +48,7 @@ export const RecastBlockProvider = ({ return ( - {children} + {children} ); }; @@ -60,7 +61,7 @@ export const useRecastBlock = () => { const recastBlock = useContext(RecastBlockContext); if (!recastBlock) { throw new Error( - 'Failed to find recastBlock! Please use the hook under `RecastTableProvider`.' + 'Failed to find recastBlock! Please use the hook under `RecastBlockProvider`.' ); } return recastBlock; diff --git a/libs/components/editor-core/src/recast-block/README.md b/libs/components/editor-core/src/recast-block/README.md index 59aed91be7..489412eab3 100644 --- a/libs/components/editor-core/src/recast-block/README.md +++ b/libs/components/editor-core/src/recast-block/README.md @@ -49,22 +49,3 @@ const SomeBlock = () => { return
...
; }; ``` - -## Scene - -**Notice: The scene API will refactor at next version.** - -```tsx -const SomeBlock = () => { - const { scene, setScene, setPage, setTable, setKanban } = - useRecastBlockScene(); - - return ( - <> -
Scene: {scene}
- - - - ); -}; -``` diff --git a/libs/components/editor-core/src/recast-block/group.ts b/libs/components/editor-core/src/recast-block/group.ts index ae846fc238..9879ba43df 100644 --- a/libs/components/editor-core/src/recast-block/group.ts +++ b/libs/components/editor-core/src/recast-block/group.ts @@ -32,7 +32,7 @@ export const mergeGroup = async (...groups: AsyncBlock[]) => { ); } - await mergeGroupProperties(...(groups as RecastBlock[])); + await mergeGroupProperties(...(groups as unknown as RecastBlock[])); const [headGroup, ...restGroups] = groups; // Add all children to the head group @@ -174,7 +174,7 @@ export const splitGroup = async ( } splitGroupProperties( - group as RecastBlock, + group as unknown as RecastBlock, newGroupBlock as unknown as RecastBlock ); await group.after(newGroupBlock); diff --git a/libs/components/editor-core/src/ref-page/ModalPage.tsx b/libs/components/editor-core/src/ref-page/ModalPage.tsx new file mode 100644 index 0000000000..276d5984d6 --- /dev/null +++ b/libs/components/editor-core/src/ref-page/ModalPage.tsx @@ -0,0 +1,90 @@ +import { MuiBackdrop, styled, useTheme } from '@toeverything/components/ui'; +import { createContext, ReactNode, useContext, useState } from 'react'; +import { createPortal } from 'react-dom'; +import { useEditor } from '../Contexts'; +import { RenderBlock } from '../render-block'; + +const Dialog = styled('div')({ + flex: 1, + width: '880px', + margin: '72px auto', + background: '#fff', + boxShadow: '0px 1px 10px rgba(152, 172, 189, 0.6)', + borderRadius: '10px', + padding: '72px 120px', + overflow: 'scroll', +}); + +const Modal = ({ open, children }: { open: boolean; children?: ReactNode }) => { + const theme = useTheme(); + const { closeSubPage } = useRefPage(); + + return createPortal( + + { + e.stopPropagation(); + }} + > + {children} + + , + + document.body + ); +}; + +const ModalPage = ({ blockId }: { blockId: string | null }) => { + const { editor } = useEditor(); + + return ( + + {blockId && } + + ); +}; + +const RefPageContext = createContext< + ReturnType> | undefined +>(undefined); + +export const RefPageProvider = ({ children }: { children: ReactNode }) => { + const state = useState(); + const [blockId, setBlockId] = state; + + return ( + + {children} + + + ); +}; + +export const useRefPage = () => { + const context = useContext(RefPageContext); + if (!context) { + throw new Error( + 'Wrap your app inside of a `SubPageProvider` to have access to the hook context!' + ); + } + const [blockId, setBlockId] = context; + const openSubPage = (blockId: string) => { + setBlockId(blockId); + }; + const closeSubPage = () => { + setBlockId(null); + }; + + return { blockId, open: !!blockId, openSubPage, closeSubPage }; +}; + +// export const openSubPage = () => {}; diff --git a/libs/components/editor-core/src/ref-page/index.ts b/libs/components/editor-core/src/ref-page/index.ts new file mode 100644 index 0000000000..4b06310a5c --- /dev/null +++ b/libs/components/editor-core/src/ref-page/index.ts @@ -0,0 +1 @@ +export { useRefPage, RefPageProvider } from './ModalPage'; diff --git a/libs/components/editor-core/src/render-block/RenderBlock.tsx b/libs/components/editor-core/src/render-block/RenderBlock.tsx index 46f068af2b..74f6c659cf 100644 --- a/libs/components/editor-core/src/render-block/RenderBlock.tsx +++ b/libs/components/editor-core/src/render-block/RenderBlock.tsx @@ -1,8 +1,8 @@ -import { styled, Theme } from '@toeverything/components/ui'; -import { FC, useContext, useLayoutEffect, useMemo, useRef } from 'react'; +import { styled } from '@toeverything/components/ui'; +import { FC, useLayoutEffect, useMemo, useRef } from 'react'; // import { RenderChildren } from './RenderChildren'; -import { RootContext } from '../contexts'; +import { useEditor } from '../Contexts'; import { useBlock } from '../hooks'; interface RenderBlockProps { @@ -14,7 +14,7 @@ export const RenderBlock: FC = ({ blockId, hasContainer = true, }) => { - const { editor, editorElement } = useContext(RootContext); + const { editor, editorElement } = useEditor(); const { block } = useBlock(blockId); const blockRef = useRef(null); diff --git a/libs/components/ui/src/mui.ts b/libs/components/ui/src/mui.ts index b0658ad526..47588ce5e6 100644 --- a/libs/components/ui/src/mui.ts +++ b/libs/components/ui/src/mui.ts @@ -13,6 +13,7 @@ import type { } from '@mui/material'; import { Avatar, + Backdrop, Box, Button, Checkbox, @@ -243,3 +244,7 @@ export const MuiFade = Fade; * @deprecated It is not recommended to use Mui directly, because the design will not refer to Mui's interaction logic. */ export const MuiRadio = Radio; +/** + * @deprecated It is not recommended to use Mui directly, because the design will not refer to Mui's interaction logic. + */ +export const MuiBackdrop = Backdrop; diff --git a/libs/datasource/feature-flags/README.md b/libs/datasource/feature-flags/README.md index f5c59f4e13..7a04209c5d 100644 --- a/libs/datasource/feature-flags/README.md +++ b/libs/datasource/feature-flags/README.md @@ -2,7 +2,15 @@ ## Usage -- set provider +- Set token at environment variable + - The key can be obtained from the [Feature Flag Portal](https://portal.featureflag.co/account-settings/projects) + +```shell +# .env.local +AFFINE_FEATURE_FLAG_TOKEN=XXXXXXX +``` + +- Set provider ```tsx import { FeatureFlagsProvider } from '@toeverything/datasource/feature-flags'; @@ -42,7 +50,8 @@ const App = () => { **When entering development mode feature flag will NOT be updated in real time** -- `activateFfcDevMode()` play with feature flags locally +- `activateFfcDevMode(PASSWORD)` play with feature flags locally + - The `devModePassword` can be obtained from `src/config.ts` - `quitFfcDevMode()` quit dev mode ## Running unit tests diff --git a/libs/datasource/feature-flags/src/config.ts b/libs/datasource/feature-flags/src/config.ts index 7f3360d6db..5295dae995 100644 --- a/libs/datasource/feature-flags/src/config.ts +++ b/libs/datasource/feature-flags/src/config.ts @@ -8,4 +8,18 @@ export const config: IOption = { // id: 'the user's unique identifier' // } devModePassword: '-', + enableDataSync: !!process.env['AFFINE_FEATURE_FLAG_TOKEN'], + // bootstrap: [ + // { + // // the feature flag key + // id: 'flag', + // // the feature flag value + // variation: false, + // // the variation data type, string is used if not provided + // variationType: VariationDataType.boolean, + // variationOptions: [], + // timestamp: 0, + // sendToExperiment: false, + // }, + // ], }; From 833fcae1165733affc4111707408968747100523 Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Fri, 5 Aug 2022 22:41:21 +0800 Subject: [PATCH 03/20] fix: context not found --- libs/components/editor-core/src/ref-page/ModalPage.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/libs/components/editor-core/src/ref-page/ModalPage.tsx b/libs/components/editor-core/src/ref-page/ModalPage.tsx index 276d5984d6..52e1d6554f 100644 --- a/libs/components/editor-core/src/ref-page/ModalPage.tsx +++ b/libs/components/editor-core/src/ref-page/ModalPage.tsx @@ -1,7 +1,6 @@ import { MuiBackdrop, styled, useTheme } from '@toeverything/components/ui'; import { createContext, ReactNode, useContext, useState } from 'react'; import { createPortal } from 'react-dom'; -import { useEditor } from '../Contexts'; import { RenderBlock } from '../render-block'; const Dialog = styled('div')({ @@ -44,8 +43,6 @@ const Modal = ({ open, children }: { open: boolean; children?: ReactNode }) => { }; const ModalPage = ({ blockId }: { blockId: string | null }) => { - const { editor } = useEditor(); - return ( {blockId && } From 78ef250ee1d85486c3bff778a5b68f4588d67ebf Mon Sep 17 00:00:00 2001 From: "biqing.hu" Date: Fri, 5 Aug 2022 23:24:42 +0800 Subject: [PATCH 04/20] feat: page-tree code style --- .../src/services/workspace/page-tree.ts | 158 +++++++++--------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/libs/datasource/db-service/src/services/workspace/page-tree.ts b/libs/datasource/db-service/src/services/workspace/page-tree.ts index 89e85b9998..db7edb73ff 100644 --- a/libs/datasource/db-service/src/services/workspace/page-tree.ts +++ b/libs/datasource/db-service/src/services/workspace/page-tree.ts @@ -7,22 +7,22 @@ import { TreeItem } from './types'; export type ObserveCallback = () => void; export class PageTree extends ServiceBaseClass { - private async fetch_page_tree(workspace: string) { - const workspace_db_block = await this.getWorkspaceDbBlock(workspace); - const page_tree_config = - workspace_db_block.getDecoration(PAGE_TREE); - return page_tree_config; + private async fetchPageTree(workspace: string) { + const workspaceDbBlock = await this.getWorkspaceDbBlock(workspace); + const PAGE_TREEConfig = + workspaceDbBlock.getDecoration(PAGE_TREE); + return PAGE_TREEConfig; } async getPageTree(workspace: string): Promise { try { - const page_tree = await this.fetch_page_tree(workspace); - if (page_tree && page_tree.length) { + const PAGE_TREE = await this.fetchPageTree(workspace); + if (PAGE_TREE && PAGE_TREE.length) { const db = await this.database.getDatabase(workspace); - const pages = await update_tree_items_title( + const pages = await updateTreeItemsTitle( db, - page_tree as [], + PAGE_TREE as [], {} ); return pages; @@ -36,8 +36,8 @@ export class PageTree extends ServiceBaseClass { /** @deprecated should implement more fine-grained crud methods instead of replacing each time with a new array */ async setPageTree(workspace: string, treeData: TreeItem[]) { - const workspace_db_block = await this.getWorkspaceDbBlock(workspace); - workspace_db_block.setDecoration(PAGE_TREE, treeData); + const workspaceDbBlock = await this.getWorkspaceDbBlock(workspace); + workspaceDbBlock.setDecoration(PAGE_TREE, treeData); } async addPage(workspace: string, treeData: TreeItem[] | string) { @@ -52,109 +52,109 @@ export class PageTree extends ServiceBaseClass { } async addPageToWorkspacee( - target_workspace_id: string, - new_page_id: string + targetWorkspaceId: string, + newPageId: string ) { - const items = await this.getPageTree(target_workspace_id); - await this.setPageTree(target_workspace_id, [ - { id: new_page_id, children: [] }, + const items = await this.getPageTree(targetWorkspaceId); + await this.setPageTree(targetWorkspaceId, [ + { id: newPageId, children: [] }, ...items, ]); } async addChildPageToWorkspace( - target_workspace_id: string, - parent_page_id: string, - new_page_id: string + targetWorkspaceId: string, + parentPageId: string, + newPageId: string ) { - const pages = await this.getPageTree(target_workspace_id); - this.build_items_for_child_page(parent_page_id, new_page_id, pages); + const pages = await this.getPageTree(targetWorkspaceId); + this.buildItemsForChildPage(parentPageId, newPageId, pages); - await this.setPageTree(target_workspace_id, [...pages]); + await this.setPageTree(targetWorkspaceId, [...pages]); } async addPrevPageToWorkspace( - target_workspace_id: string, - parent_page_id: string, - new_page_id: string + targetWorkspaceId: string, + parentPageId: string, + newPageId: string ) { - const pages = await this.getPageTree(target_workspace_id); - this.build_items_for_prev_page(parent_page_id, new_page_id, pages); - await this.setPageTree(target_workspace_id, [...pages]); + const pages = await this.getPageTree(targetWorkspaceId); + this.buildItemsForPrevPage(parentPageId, newPageId, pages); + await this.setPageTree(targetWorkspaceId, [...pages]); } async addNextPageToWorkspace( - target_workspace_id: string, - parent_page_id: string, - new_page_id: string + targetWorkspaceId: string, + parentPageId: string, + newPageId: string ) { - const pages = await this.getPageTree(target_workspace_id); - this.build_items_for_next_page(parent_page_id, new_page_id, pages); - await this.setPageTree(target_workspace_id, [...pages]); + const pages = await this.getPageTree(targetWorkspaceId); + this.buildItemsForNextPage(parentPageId, newPageId, pages); + await this.setPageTree(targetWorkspaceId, [...pages]); } - private build_items_for_next_page( - parent_page_id: string, - new_page_id: string, + private buildItemsForNextPage( + parentPageId: string, + newPageId: string, children: TreeItem[] ) { for (let i = 0; i < children.length; i++) { - const child_page = children[i]; - if (child_page.id === parent_page_id) { - const new_page = { - id: new_page_id, + const childPage = children[i]; + if (childPage.id === parentPageId) { + const newPage = { + id: newPageId, title: 'Untitled', children: [] as TreeItem[], }; - children = children.splice(i + 1, 0, new_page); - } else if (child_page.children && child_page.children.length) { - this.build_items_for_next_page( - parent_page_id, - new_page_id, - child_page.children + children = children.splice(i + 1, 0, newPage); + } else if (childPage.children && childPage.children.length) { + this.buildItemsForNextPage( + parentPageId, + newPageId, + childPage.children ); } } } - private build_items_for_prev_page( - parent_page_id: string, - new_page_id: string, + private buildItemsForPrevPage( + parentPageId: string, + newPageId: string, children: TreeItem[] ) { for (let i = 0; i < children.length; i++) { - const child_page = children[i]; - if (child_page.id === parent_page_id) { - const new_page = { - id: new_page_id, + const childPage = children[i]; + if (childPage.id === parentPageId) { + const newPage = { + id: newPageId, title: 'Untitled', children: [] as TreeItem[], }; - children = children.splice(i - 1, 0, new_page); - } else if (child_page.children && child_page.children.length) { - this.build_items_for_prev_page( - parent_page_id, - new_page_id, - child_page.children + children = children.splice(i - 1, 0, newPage); + } else if (childPage.children && childPage.children.length) { + this.buildItemsForPrevPage( + parentPageId, + newPageId, + childPage.children ); } } } - private build_items_for_child_page( - parent_page_id: string, - new_page_id: string, + private buildItemsForChildPage( + parentPageId: string, + newPageId: string, children: TreeItem[] ) { for (let i = 0; i < children.length; i++) { - const child_page = children[i]; - if (child_page.id === parent_page_id) { - child_page.children = child_page.children || []; - child_page.children.push({ - id: new_page_id, + const childPage = children[i]; + if (childPage.id === parentPageId) { + childPage.children = childPage.children || []; + childPage.children.push({ + id: newPageId, title: 'Untitled', children: [], }); - } else if (child_page.children && child_page.children.length) { - this.build_items_for_child_page( - parent_page_id, - new_page_id, - child_page.children + } else if (childPage.children && childPage.children.length) { + this.buildItemsForChildPage( + parentPageId, + newPageId, + childPage.children ); } } @@ -164,10 +164,10 @@ export class PageTree extends ServiceBaseClass { { workspace, page }: { workspace: string; page: string }, callback: ObserveCallback ): Promise { - const workspace_db_block = await this.getWorkspaceDbBlock(workspace); + const workspaceDbBlock = await this.getWorkspaceDbBlock(workspace); const unobserveWorkspace = await this._observe( workspace, - workspace_db_block.id, + workspaceDbBlock.id, (states, block) => { callback(); } @@ -187,12 +187,12 @@ export class PageTree extends ServiceBaseClass { } async unobserve({ workspace }: { workspace: string }) { - const workspace_db_block = await this.getWorkspaceDbBlock(workspace); - await this._unobserve(workspace, workspace_db_block.id); + const workspaceDbBlock = await this.getWorkspaceDbBlock(workspace); + await this._unobserve(workspace, workspaceDbBlock.id); } } -async function update_tree_items_title< +async function updateTreeItemsTitle< TreeItem extends { id: string; title: string; children: TreeItem[] } >( db: BlockClientInstance, @@ -213,7 +213,7 @@ async function update_tree_items_title< } if (item.children.length) { - item.children = await update_tree_items_title( + item.children = await updateTreeItemsTitle( db, item.children, cache From 93c460f6a519e8e22d287b779683796216b651a6 Mon Sep 17 00:00:00 2001 From: "biqing.hu" Date: Fri, 5 Aug 2022 23:34:31 +0800 Subject: [PATCH 05/20] feat: pageTreeName --- .../src/services/workspace/page-tree.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libs/datasource/db-service/src/services/workspace/page-tree.ts b/libs/datasource/db-service/src/services/workspace/page-tree.ts index db7edb73ff..baf3d080f1 100644 --- a/libs/datasource/db-service/src/services/workspace/page-tree.ts +++ b/libs/datasource/db-service/src/services/workspace/page-tree.ts @@ -1,5 +1,5 @@ import type { BlockClientInstance } from '@toeverything/datasource/jwt'; -import { PAGE_TREE } from '../../utils'; +import { PAGE_TREE as pageTreeName } from '../../utils'; import type { ReturnUnobserve } from '../database/observer'; import { ServiceBaseClass } from '../base'; import { TreeItem } from './types'; @@ -9,20 +9,20 @@ export type ObserveCallback = () => void; export class PageTree extends ServiceBaseClass { private async fetchPageTree(workspace: string) { const workspaceDbBlock = await this.getWorkspaceDbBlock(workspace); - const PAGE_TREEConfig = - workspaceDbBlock.getDecoration(PAGE_TREE); - return PAGE_TREEConfig; + const pageTreeConfig = + workspaceDbBlock.getDecoration(pageTreeName); + return pageTreeConfig; } async getPageTree(workspace: string): Promise { try { - const PAGE_TREE = await this.fetchPageTree(workspace); - if (PAGE_TREE && PAGE_TREE.length) { + const pageTree = await this.fetchPageTree(workspace); + if (pageTree && pageTree.length) { const db = await this.database.getDatabase(workspace); const pages = await updateTreeItemsTitle( db, - PAGE_TREE as [], + pageTree as [], {} ); return pages; @@ -37,7 +37,7 @@ export class PageTree extends ServiceBaseClass { /** @deprecated should implement more fine-grained crud methods instead of replacing each time with a new array */ async setPageTree(workspace: string, treeData: TreeItem[]) { const workspaceDbBlock = await this.getWorkspaceDbBlock(workspace); - workspaceDbBlock.setDecoration(PAGE_TREE, treeData); + workspaceDbBlock.setDecoration(pageTreeName, treeData); } async addPage(workspace: string, treeData: TreeItem[] | string) { From 15d908626e53677710890f93c29f8487ca52118f Mon Sep 17 00:00:00 2001 From: QiShaoXuan Date: Fri, 5 Aug 2022 23:52:16 +0800 Subject: [PATCH 06/20] fix: scrollManager can not get scrollcontainer after create new page --- .../src/pages/workspace/docs/Page.tsx | 26 ++++++++---------- libs/components/affine-editor/src/Editor.tsx | 27 ++++++++++++++++++- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/apps/ligo-virgo/src/pages/workspace/docs/Page.tsx b/apps/ligo-virgo/src/pages/workspace/docs/Page.tsx index eb6c334803..76c48efeb6 100644 --- a/apps/ligo-virgo/src/pages/workspace/docs/Page.tsx +++ b/apps/ligo-virgo/src/pages/workspace/docs/Page.tsx @@ -93,38 +93,29 @@ const EditorContainer = ({ workspace: string; }) => { const [lockScroll, setLockScroll] = useState(false); - const scrollContainerRef = useRef(); + const [scrollContainer, setScrollContainer] = useState(); const editorRef = useRef(); + const onScroll = (event: UIEvent) => { editorRef.current.getHooks().onRootNodeScroll(event); editorRef.current.scrollManager.emitScrollEvent(event); }; - useEffect(() => { - editorRef.current.scrollManager.scrollContainer = - scrollContainerRef.current; - - editorRef.current.scrollManager.scrollController = { - lockScroll: () => setLockScroll(true), - unLockScroll: () => setLockScroll(false), - }; - }, []); - const { setPageClientWidth } = usePageClientWidth(); useEffect(() => { - if (scrollContainerRef.current) { + if (scrollContainer) { const obv = new ResizeObserver(e => { setPageClientWidth(e[0].contentRect.width); }); - obv.observe(scrollContainerRef.current); + obv.observe(scrollContainer); return () => obv.disconnect(); } - }, [setPageClientWidth]); + }, [setPageClientWidth, scrollContainer]); return ( setScrollContainer(ref)} onScroll={onScroll} > {pageId ? ( @@ -132,6 +123,11 @@ const EditorContainer = ({ workspace={workspace} rootBlockId={pageId} ref={editorRef} + scrollContainer={scrollContainer} + scrollController={{ + lockScroll: () => setLockScroll(true), + unLockScroll: () => setLockScroll(false), + }} /> ) : ( void; + unLockScroll: () => void; + }; } function _useConstantWithDispose( @@ -53,13 +59,32 @@ function _useConstantWithDispose( } export const AffineEditor = forwardRef( - ({ workspace, rootBlockId, scrollBlank = true, isWhiteboard }, ref) => { + ( + { + workspace, + rootBlockId, + scrollBlank = true, + isWhiteboard, + scrollController, + scrollContainer, + }, + ref + ) => { const editor = _useConstantWithDispose( workspace, rootBlockId, isWhiteboard ); + useEffect(() => { + if (scrollContainer) { + editor.scrollManager.scrollContainer = scrollContainer; + } + if (scrollController) { + editor.scrollManager.scrollController = scrollController; + } + }, [editor, scrollContainer, scrollController]); + useImperativeHandle(ref, () => editor); return ( From b183506c134beb49bf6318a7e61d53c0235786c9 Mon Sep 17 00:00:00 2001 From: Caleb OLeary Date: Fri, 5 Aug 2022 23:14:10 -0500 Subject: [PATCH 07/20] feat(component): add support for elixir highlighting in code block --- libs/components/editor-blocks/package.json | 1 + .../editor-blocks/src/blocks/code/CodeView.tsx | 2 ++ pnpm-lock.yaml | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libs/components/editor-blocks/package.json b/libs/components/editor-blocks/package.json index d497e04e0f..d558743117 100644 --- a/libs/components/editor-blocks/package.json +++ b/libs/components/editor-blocks/package.json @@ -31,6 +31,7 @@ "@mui/system": "^5.8.6", "code-example": "^3.3.6", "codemirror": "6.0.1", + "codemirror-lang-elixir": "^3.0.0", "keymap": "link:@codemirror/next/keymap", "nanoid": "^4.0.0", "react-resizable": "^3.0.4", diff --git a/libs/components/editor-blocks/src/blocks/code/CodeView.tsx b/libs/components/editor-blocks/src/blocks/code/CodeView.tsx index 3b64cc3b1a..0ef732cd54 100644 --- a/libs/components/editor-blocks/src/blocks/code/CodeView.tsx +++ b/libs/components/editor-blocks/src/blocks/code/CodeView.tsx @@ -32,6 +32,7 @@ import { powerShell } from '@codemirror/legacy-modes/mode/powershell'; import { brainfuck } from '@codemirror/legacy-modes/mode/brainfuck'; import { stylus } from '@codemirror/legacy-modes/mode/stylus'; import { erlang } from '@codemirror/legacy-modes/mode/erlang'; +import { elixir } from 'codemirror-lang-elixir'; import { nginx } from '@codemirror/legacy-modes/mode/nginx'; import { perl } from '@codemirror/legacy-modes/mode/perl'; import { pascal } from '@codemirror/legacy-modes/mode/pascal'; @@ -87,6 +88,7 @@ const langs: Record = { brainfuck: () => StreamLanguage.define(brainfuck), stylus: () => StreamLanguage.define(stylus), erlang: () => StreamLanguage.define(erlang), + elixir: () => StreamLanguage.define(elixir), nginx: () => StreamLanguage.define(nginx), perl: () => StreamLanguage.define(perl), ruby: () => StreamLanguage.define(ruby), diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 852beb66c2..27172f8157 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -401,6 +401,7 @@ importers: '@types/react-window': ^1.8.5 code-example: ^3.3.6 codemirror: 6.0.1 + codemirror-lang-elixir: ^3.0.0 keymap: link:@codemirror/next/keymap nanoid: ^4.0.0 react-resizable: ^3.0.4 @@ -437,6 +438,7 @@ importers: '@mui/system': 5.8.7_d6menda4vqwq6peqnkbe7mkj4i code-example: 3.3.6 codemirror: 6.0.1 + codemirror-lang-elixir: 3.0.0_@codemirror+language@6.2.0 keymap: link:@codemirror/next/keymap nanoid: 4.0.0 react-resizable: 3.0.4 @@ -4578,8 +4580,8 @@ packages: dependencies: '@babel/runtime': 7.18.6 '@emotion/cache': 11.9.3 - '@emotion/react': 11.9.3 - '@emotion/styled': 11.9.3_@emotion+react@11.9.3 + '@emotion/react': 11.9.3_@babel+core@7.18.6 + '@emotion/styled': 11.9.3_dc5dh2wp562rsjxvguwi2i3yzq csstype: 3.1.0 prop-types: 15.8.1 dev: false @@ -8518,6 +8520,14 @@ packages: engines: {node: '>=0.10.0'} dev: true + /codemirror-lang-elixir/3.0.0_@codemirror+language@6.2.0: + resolution: {integrity: sha512-Liy5MDxf+xw7aFqNfhLfntSK6vsRkI0lSlyytw23P1hWSrb0Bw5WunEB3iKJ49iUu8Kj2dx+vvMqD8I5ms7rSQ==} + peerDependencies: + '@codemirror/language': ^6.2.1 + dependencies: + '@codemirror/language': 6.2.0 + dev: false + /codemirror/6.0.1: resolution: {integrity: sha512-J8j+nZ+CdWmIeFIGXEFbFPtpiYacFMDR8GlHK3IyHQJMCaVRfGx9NT+Hxivv1ckLWPvNdZqndbr/7lVhrf/Svg==} dependencies: From 9e9b8f78f0f240792df7b91d50e171f2cf391c5b Mon Sep 17 00:00:00 2001 From: Federico Leiva Date: Sat, 6 Aug 2022 01:43:43 -0300 Subject: [PATCH 08/20] fix: forward isActive prop in tab --- .../workspace/docs/components/tabs/Tabs.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/ligo-virgo/src/pages/workspace/docs/components/tabs/Tabs.tsx b/apps/ligo-virgo/src/pages/workspace/docs/components/tabs/Tabs.tsx index 3722c5e162..fc06d826bc 100644 --- a/apps/ligo-virgo/src/pages/workspace/docs/components/tabs/Tabs.tsx +++ b/apps/ligo-virgo/src/pages/workspace/docs/components/tabs/Tabs.tsx @@ -11,15 +11,15 @@ const StyledTabs = styled('div')({ cursor: 'pointer', }); -const StyledDivider = styled(Divider)<{ isActive?: boolean }>( - ({ isActive }) => { - return { - flex: 1, - backgroundColor: isActive ? '#3E6FDB' : '#ECF1FB', - borderWidth: '2px', - }; - } -); +const StyledDivider = styled(Divider, { + shouldForwardProp: (prop: string) => !['isActive'].includes(prop), +})<{ isActive?: boolean }>(({ isActive }) => { + return { + flex: 1, + backgroundColor: isActive ? '#3E6FDB' : '#ECF1FB', + borderWidth: '2px', + }; +}); const TAB_TITLE = { PAGES: 'pages', From 78b497e5512cdf2acbaffb1e1ab2d2a4b1a95755 Mon Sep 17 00:00:00 2001 From: Federico Leiva Date: Sat, 6 Aug 2022 01:45:34 -0300 Subject: [PATCH 09/20] fix: changed prop format to camelCase --- .../src/pages/workspace/docs/components/logo/Logo.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/ligo-virgo/src/pages/workspace/docs/components/logo/Logo.tsx b/apps/ligo-virgo/src/pages/workspace/docs/components/logo/Logo.tsx index 8b33a276c4..d4926a57e5 100644 --- a/apps/ligo-virgo/src/pages/workspace/docs/components/logo/Logo.tsx +++ b/apps/ligo-virgo/src/pages/workspace/docs/components/logo/Logo.tsx @@ -9,8 +9,8 @@ export const Logo = ({ color, style, ...props }) => { > From 16756e770eee4f942da779d4ba027f9da797dd8a Mon Sep 17 00:00:00 2001 From: "biqing.hu" Date: Sat, 6 Aug 2022 18:35:23 +0800 Subject: [PATCH 10/20] feat: add underscore --- .../src/services/workspace/page-tree.ts | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/libs/datasource/db-service/src/services/workspace/page-tree.ts b/libs/datasource/db-service/src/services/workspace/page-tree.ts index baf3d080f1..9b4a348c2f 100644 --- a/libs/datasource/db-service/src/services/workspace/page-tree.ts +++ b/libs/datasource/db-service/src/services/workspace/page-tree.ts @@ -7,7 +7,7 @@ import { TreeItem } from './types'; export type ObserveCallback = () => void; export class PageTree extends ServiceBaseClass { - private async fetchPageTree(workspace: string) { + private async _fetchPageTree(workspace: string) { const workspaceDbBlock = await this.getWorkspaceDbBlock(workspace); const pageTreeConfig = workspaceDbBlock.getDecoration(pageTreeName); @@ -16,11 +16,11 @@ export class PageTree extends ServiceBaseClass { async getPageTree(workspace: string): Promise { try { - const pageTree = await this.fetchPageTree(workspace); + const pageTree = await this._fetchPageTree(workspace); if (pageTree && pageTree.length) { const db = await this.database.getDatabase(workspace); - const pages = await updateTreeItemsTitle( + const pages = await _updateTreeItemsTitle( db, pageTree as [], {} @@ -51,10 +51,7 @@ export class PageTree extends ServiceBaseClass { await dbBlock?.remove(); } - async addPageToWorkspacee( - targetWorkspaceId: string, - newPageId: string - ) { + async addPageToWorkspacee(targetWorkspaceId: string, newPageId: string) { const items = await this.getPageTree(targetWorkspaceId); await this.setPageTree(targetWorkspaceId, [ { id: newPageId, children: [] }, @@ -68,7 +65,7 @@ export class PageTree extends ServiceBaseClass { newPageId: string ) { const pages = await this.getPageTree(targetWorkspaceId); - this.buildItemsForChildPage(parentPageId, newPageId, pages); + this._buildItemsForChildPage(parentPageId, newPageId, pages); await this.setPageTree(targetWorkspaceId, [...pages]); } @@ -78,7 +75,7 @@ export class PageTree extends ServiceBaseClass { newPageId: string ) { const pages = await this.getPageTree(targetWorkspaceId); - this.buildItemsForPrevPage(parentPageId, newPageId, pages); + this._buildItemsForPrevPage(parentPageId, newPageId, pages); await this.setPageTree(targetWorkspaceId, [...pages]); } async addNextPageToWorkspace( @@ -87,10 +84,10 @@ export class PageTree extends ServiceBaseClass { newPageId: string ) { const pages = await this.getPageTree(targetWorkspaceId); - this.buildItemsForNextPage(parentPageId, newPageId, pages); + this._buildItemsForNextPage(parentPageId, newPageId, pages); await this.setPageTree(targetWorkspaceId, [...pages]); } - private buildItemsForNextPage( + private _buildItemsForNextPage( parentPageId: string, newPageId: string, children: TreeItem[] @@ -105,7 +102,7 @@ export class PageTree extends ServiceBaseClass { }; children = children.splice(i + 1, 0, newPage); } else if (childPage.children && childPage.children.length) { - this.buildItemsForNextPage( + this._buildItemsForNextPage( parentPageId, newPageId, childPage.children @@ -113,7 +110,7 @@ export class PageTree extends ServiceBaseClass { } } } - private buildItemsForPrevPage( + private _buildItemsForPrevPage( parentPageId: string, newPageId: string, children: TreeItem[] @@ -128,7 +125,7 @@ export class PageTree extends ServiceBaseClass { }; children = children.splice(i - 1, 0, newPage); } else if (childPage.children && childPage.children.length) { - this.buildItemsForPrevPage( + this._buildItemsForPrevPage( parentPageId, newPageId, childPage.children @@ -136,7 +133,7 @@ export class PageTree extends ServiceBaseClass { } } } - private buildItemsForChildPage( + private _buildItemsForChildPage( parentPageId: string, newPageId: string, children: TreeItem[] @@ -151,7 +148,7 @@ export class PageTree extends ServiceBaseClass { children: [], }); } else if (childPage.children && childPage.children.length) { - this.buildItemsForChildPage( + this._buildItemsForChildPage( parentPageId, newPageId, childPage.children @@ -192,7 +189,7 @@ export class PageTree extends ServiceBaseClass { } } -async function updateTreeItemsTitle< +async function _updateTreeItemsTitle< TreeItem extends { id: string; title: string; children: TreeItem[] } >( db: BlockClientInstance, @@ -213,7 +210,7 @@ async function updateTreeItemsTitle< } if (item.children.length) { - item.children = await updateTreeItemsTitle( + item.children = await _updateTreeItemsTitle( db, item.children, cache From 1ee53790220816524bf58c86f1400d4c03a21d4b Mon Sep 17 00:00:00 2001 From: CarlosZoft Date: Sat, 6 Aug 2022 09:54:18 -0300 Subject: [PATCH 11/20] refactor : remove redundant if --- apps/ligo-virgo/webpack.config.js | 6 +----- apps/venus/webpack.config.js | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/apps/ligo-virgo/webpack.config.js b/apps/ligo-virgo/webpack.config.js index edb5305b2b..fffec29165 100644 --- a/apps/ligo-virgo/webpack.config.js +++ b/apps/ligo-virgo/webpack.config.js @@ -34,11 +34,6 @@ module.exports = function (webpackConfig) { if (isProd) { config.module.rules.unshift(style9); - } else { - config.module.rules.push(style9); - } - - if (isProd) { config.entry = { main: [...config.entry.main, ...config.entry.polyfills], }; @@ -133,6 +128,7 @@ module.exports = function (webpackConfig) { }); config.module.rules.splice(6); } else { + config.module.rules.push(style9); config.output = { ...config.output, publicPath: '/', diff --git a/apps/venus/webpack.config.js b/apps/venus/webpack.config.js index 9b5aba0eef..c325851149 100644 --- a/apps/venus/webpack.config.js +++ b/apps/venus/webpack.config.js @@ -35,11 +35,6 @@ module.exports = function (webpackConfig) { if (isProd) { config.module.rules.unshift(style9); - } else { - config.module.rules.push(style9); - } - - if (isProd) { config.entry = { main: [...config.entry.main, ...config.entry.polyfills], }; @@ -124,6 +119,7 @@ module.exports = function (webpackConfig) { }); config.module.rules.splice(6); } else { + config.module.rules.push(style9); config.output = { ...config.output, publicPath: '/', From 998025104bf154db4675378d3e88c8394020909a Mon Sep 17 00:00:00 2001 From: CarlosZoft Date: Sat, 6 Aug 2022 13:50:38 -0300 Subject: [PATCH 12/20] refactor : improving code clarity and removing unnecessary else --- apps/keck/src/index.ts | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/apps/keck/src/index.ts b/apps/keck/src/index.ts index d76df31b53..6436dd9315 100644 --- a/apps/keck/src/index.ts +++ b/apps/keck/src/index.ts @@ -34,27 +34,24 @@ const _checkAuth = async ( response: http.ServerResponse, callback: (response: http.OutgoingMessage, workspace: string) => boolean ) => { + const url = new URL(request.url, `http://${request.headers.host}`); + const workspace = _getWorkspace(url.pathname); if (process.env.NODE_ENV === 'development') { - const url = new URL(request.url, `http://${request.headers.host}`); - const workspace = _getWorkspace(url.pathname); if (workspace) return callback(response, workspace); return false; - } else { - try { - const decodedToken = await firebaseAuth - .getAuth() - .verifyIdToken(request.headers.token as string); - const allowWorkspace = [AFFINE_COMMON_WORKSPACE, decodedToken.uid]; - const url = new URL(request.url, `http://${request.headers.host}`); - const workspace = _getWorkspace(url.pathname); - if (allowWorkspace.includes(workspace)) { - return callback(response, workspace); - } - } catch (error) { - console.log(error); - } - return false; } + try { + const decodedToken = await firebaseAuth + .getAuth() + .verifyIdToken(request.headers.token as string); + const allowWorkspace = [AFFINE_COMMON_WORKSPACE, decodedToken.uid]; + if (allowWorkspace.includes(workspace)) { + return callback(response, workspace); + } + } catch (error) { + console.log(error); + } + return false; }; const HOST = process.env.HOST || 'localhost'; From fb81d1f8ff5fb18ec7037b549fd70dc9d093ad81 Mon Sep 17 00:00:00 2001 From: CarlosZoft Date: Sat, 6 Aug 2022 13:59:50 -0300 Subject: [PATCH 13/20] fix : broken magic number --- apps/keck/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/keck/src/index.ts b/apps/keck/src/index.ts index 6436dd9315..31dadb7893 100644 --- a/apps/keck/src/index.ts +++ b/apps/keck/src/index.ts @@ -58,7 +58,7 @@ const HOST = process.env.HOST || 'localhost'; const PORT = process.env.PORT || 3000; const _tokens = new LRUCache({ - max: 10240, + max: 1024 * 10, ttl: 1000 * 60 * 5, }); From 7042a04212c049087168b2cab0ec5111062b4d42 Mon Sep 17 00:00:00 2001 From: Caleb OLeary Date: Sat, 6 Aug 2022 12:15:54 -0500 Subject: [PATCH 14/20] fix(component): fixes codeblock so lang selection persists across refresh --- .../editor-blocks/src/blocks/code/CodeView.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libs/components/editor-blocks/src/blocks/code/CodeView.tsx b/libs/components/editor-blocks/src/blocks/code/CodeView.tsx index 0ef732cd54..964c11b294 100644 --- a/libs/components/editor-blocks/src/blocks/code/CodeView.tsx +++ b/libs/components/editor-blocks/src/blocks/code/CodeView.tsx @@ -105,7 +105,7 @@ const langs: Record = { // clike: () => StreamLanguage.define(clike), // clike: () => clike({ }), }; - +const DEFAULT_LANG = 'javascript'; const CodeBlock = styled('div')(({ theme }) => ({ backgroundColor: '#F2F5F9', padding: '8px 24px', @@ -132,8 +132,7 @@ const CodeBlock = styled('div')(({ theme }) => ({ })); export const CodeView: FC = ({ block, editor }) => { const initValue: string = block.getProperty('text')?.value?.[0]?.text; - const langType: string = block.getProperty('lang')?.value?.[0]?.text; - const [mode, setMode] = useState('javascript'); + const langType: string = block.getProperty('lang'); const [extensions, setExtensions] = useState(); const codeMirror = useRef(); useOnSelect(block.id, (is_select: boolean) => { @@ -147,14 +146,14 @@ export const CodeView: FC = ({ block, editor }) => { value: [{ text: value }], }); }; - useEffect(() => { - handleLangChange(langType ? langType : 'javascript'); - }, []); function handleLangChange(lang: string) { block.setProperty('lang', lang); - setMode(lang); setExtensions([langs[lang]()]); } + useEffect(() => { + handleLangChange(langType ? langType : DEFAULT_LANG); + }, []); + const copyCode = () => { copyToClipboard(initValue); }; @@ -182,7 +181,7 @@ export const CodeView: FC = ({ block, editor }) => { handleLangChange(evn.target.value)} - /> */}
-
+
Copy - {/* */}
From 574fb6d393e15383454c0c069998edb8a19c73d3 Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sun, 7 Aug 2022 19:06:14 +0800 Subject: [PATCH 17/20] chore: try lighter ci --- .github/workflows/affine.yml | 4 ++-- .github/workflows/check.yml | 25 +++++++++++++++++++++++++ .github/workflows/keck.yml | 12 ++++++------ .github/workflows/lint.yml | 4 ++-- .github/workflows/lisa.yml | 4 ++-- .github/workflows/venus.yml | 10 +++++----- 6 files changed, 42 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/check.yml diff --git a/.github/workflows/affine.yml b/.github/workflows/affine.yml index 28ca2d429b..a5c0eafe70 100644 --- a/.github/workflows/affine.yml +++ b/.github/workflows/affine.yml @@ -3,8 +3,8 @@ name: Build AFFiNE-Local on: push: branches: [master] - pull_request: - 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 diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000000..6e0e25560b --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,25 @@ +name: standard check + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + main: + name: Nx Cloud - Main Job + uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.5 + with: + number-of-agents: 3 + parallel-commands: | + pnpm exec nx-cloud record -- pnpm exec nx format:check + parallel-commands-on-agents: | + pnpm exec nx affected --target=lint --parallel=3 --exclude=components-common,keck,theme + pnpm exec nx affected --target=build --parallel=3 + + agents: + name: Nx Cloud - Agents + uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.5 + with: + number-of-agents: 3 diff --git a/.github/workflows/keck.yml b/.github/workflows/keck.yml index a09d790455..32e1d56058 100644 --- a/.github/workflows/keck.yml +++ b/.github/workflows/keck.yml @@ -8,12 +8,12 @@ on: - 'apps/keck/**' - '.github/deployment' - '.github/workflows/keck.yml' - pull_request: - branches: [master] - paths: - - 'apps/keck/**' - - '.github/deployment' - - '.github/workflows/keck.yml' + # pull_request: + # branches: [master] + # paths: + # - 'apps/keck/**' + # - '.github/deployment' + # - '.github/workflows/keck.yml' # Cancels all previous workflow runs for pull requests that have not completed. # See https://docs.github.com/en/actions/using-jobs/using-concurrency diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8266d460df..8efce5cbd4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,8 +3,8 @@ name: Lint on: push: branches: [master] - pull_request: - 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 diff --git a/.github/workflows/lisa.yml b/.github/workflows/lisa.yml index ead4c8fff2..f548ddeeed 100644 --- a/.github/workflows/lisa.yml +++ b/.github/workflows/lisa.yml @@ -3,8 +3,8 @@ name: Build Lisa on: push: branches: [master] - pull_request: - 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 diff --git a/.github/workflows/venus.yml b/.github/workflows/venus.yml index 8b8841404c..699cf44dd3 100644 --- a/.github/workflows/venus.yml +++ b/.github/workflows/venus.yml @@ -7,11 +7,11 @@ on: - 'apps/venus/**' - '.github/deployment' - '.github/workflows/venus.yml' - pull_request: - branches: [master] - paths: - - 'apps/venus/**' - - '.github/workflows/venus.yml' + # pull_request: + # branches: [master] + # paths: + # - 'apps/venus/**' + # - '.github/workflows/venus.yml' # Cancels all previous workflow runs for pull requests that have not completed. # See https://docs.github.com/en/actions/using-jobs/using-concurrency From af40927b0a770d5fd55afdad446a85219a031fc7 Mon Sep 17 00:00:00 2001 From: DarkSky <25152247+darkskygit@users.noreply.github.com> Date: Sun, 7 Aug 2022 19:47:19 +0800 Subject: [PATCH 18/20] Update check.yml --- .github/workflows/check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 6e0e25560b..b17f387f69 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -11,6 +11,7 @@ jobs: name: Nx Cloud - Main Job uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.5 with: + main-branch-name: master number-of-agents: 3 parallel-commands: | pnpm exec nx-cloud record -- pnpm exec nx format:check From 450a54bcb92522599f080201a245ec1af7c8926f Mon Sep 17 00:00:00 2001 From: tzhangchi Date: Sun, 7 Aug 2022 19:24:39 +0800 Subject: [PATCH 19/20] fix(Reference): add robust judgment --- .../editor-plugins/src/menu/reference-menu/ReferenceMenu.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/components/editor-plugins/src/menu/reference-menu/ReferenceMenu.tsx b/libs/components/editor-plugins/src/menu/reference-menu/ReferenceMenu.tsx index cbd443927a..accd73849b 100644 --- a/libs/components/editor-plugins/src/menu/reference-menu/ReferenceMenu.tsx +++ b/libs/components/editor-plugins/src/menu/reference-menu/ReferenceMenu.tsx @@ -116,7 +116,7 @@ export const ReferenceMenu = ({ editor, hooks, style }: ReferenceMenuProps) => { }; const handle_close = () => { - editor.blockHelper.removeSearchSlash(block_id); + block_id && editor.blockHelper.removeSearchSlash(block_id); }; return ( From 5c26c4094d50978acf76ef3103fe686617c1a36b Mon Sep 17 00:00:00 2001 From: DarkSky <25152247+darkskygit@users.noreply.github.com> Date: Sun, 7 Aug 2022 21:46:56 +0800 Subject: [PATCH 20/20] Update check.yml --- .github/workflows/check.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index b17f387f69..e1a982e4f1 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -9,7 +9,8 @@ on: jobs: main: name: Nx Cloud - Main Job - uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.5 + uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.6 + secrets: inherit with: main-branch-name: master number-of-agents: 3 @@ -21,6 +22,7 @@ jobs: agents: name: Nx Cloud - Agents - uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.5 + uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.6 + secrets: inherit with: number-of-agents: 3