From 16072240e003ef81138afd8617f45fa641b4b567 Mon Sep 17 00:00:00 2001 From: DiamondThree Date: Mon, 15 Aug 2022 23:07:35 +0800 Subject: [PATCH 01/21] fix undo redo point err --- .../src/components/text-manage/TextManage.tsx | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/libs/components/editor-blocks/src/components/text-manage/TextManage.tsx b/libs/components/editor-blocks/src/components/text-manage/TextManage.tsx index f433c1fba9..6b4acfbb44 100644 --- a/libs/components/editor-blocks/src/components/text-manage/TextManage.tsx +++ b/libs/components/editor-blocks/src/components/text-manage/TextManage.tsx @@ -4,10 +4,7 @@ import { type SlateUtils, type TextProps, } from '@toeverything/components/common'; -import { - useOnSelectActive, - useOnSelectSetSelection, -} from '@toeverything/components/editor-core'; +import { useOnSelectActive } from '@toeverything/components/editor-core'; import { styled } from '@toeverything/components/ui'; import { ContentColumnValue } from '@toeverything/datasource/db-service'; import { @@ -119,13 +116,14 @@ export const TextManage = forwardRef( const properties = block.getProperties(); - const onTextViewSetSelection = (selection: Range | Point) => { - if (selection instanceof Point) { - //do some thing - } else { - textRef.current.setSelection(selection); - } - }; + // const onTextViewSetSelection = (selection: Range | Point) => { + // console.log('selection: ', selection); + // if (selection instanceof Point) { + // //do some thing + // } else { + // // textRef.current.setSelection(selection); + // } + // }; // block = await editor.commands.blockCommands.createNextBlock(block.id,) const onTextViewActive = useCallback( @@ -209,7 +207,8 @@ export const TextManage = forwardRef( ); useOnSelectActive(block.id, onTextViewActive); - useOnSelectSetSelection<'Range'>(block.id, onTextViewSetSelection); + // TODO undo dont reset selection + // useOnSelectSetSelection<'Range'>(block.id, onTextViewSetSelection); useEffect(() => { if (textRef.current) { From 81345ffcba7866abfc0d4499e5889231767c335d Mon Sep 17 00:00:00 2001 From: DiamondThree Date: Tue, 16 Aug 2022 10:59:13 +0800 Subject: [PATCH 02/21] fix lint --- .../src/components/text-manage/TextManage.tsx | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/libs/components/editor-blocks/src/components/text-manage/TextManage.tsx b/libs/components/editor-blocks/src/components/text-manage/TextManage.tsx index 6b4acfbb44..e42a85c5ed 100644 --- a/libs/components/editor-blocks/src/components/text-manage/TextManage.tsx +++ b/libs/components/editor-blocks/src/components/text-manage/TextManage.tsx @@ -116,16 +116,6 @@ export const TextManage = forwardRef( const properties = block.getProperties(); - // const onTextViewSetSelection = (selection: Range | Point) => { - // console.log('selection: ', selection); - // if (selection instanceof Point) { - // //do some thing - // } else { - // // textRef.current.setSelection(selection); - // } - // }; - - // block = await editor.commands.blockCommands.createNextBlock(block.id,) const onTextViewActive = useCallback( (point: CursorTypes) => { // TODO code to be optimized @@ -207,8 +197,6 @@ export const TextManage = forwardRef( ); useOnSelectActive(block.id, onTextViewActive); - // TODO undo dont reset selection - // useOnSelectSetSelection<'Range'>(block.id, onTextViewSetSelection); useEffect(() => { if (textRef.current) { From de0c53b1b213b4510a8238392d61daecd0977243 Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Mon, 15 Aug 2022 19:38:49 +0800 Subject: [PATCH 03/21] fix: filter empty string when getContentBetween --- .../common/src/lib/text/slate-utils.ts | 62 +++++++++++++++---- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/libs/components/common/src/lib/text/slate-utils.ts b/libs/components/common/src/lib/text/slate-utils.ts index 1783d79cab..43a47ad85f 100644 --- a/libs/components/common/src/lib/text/slate-utils.ts +++ b/libs/components/common/src/lib/text/slate-utils.ts @@ -2,28 +2,28 @@ import { Descendant, Editor, + Location, + Node as SlateNode, + Path, Point, - Transforms, Range, Text, - Location, - Path, - Node as SlateNode, + Transforms, } from 'slate'; import { ReactEditor } from 'slate-react'; -import { - getCommentsIdsOnTextNode, - getEditorMarkForCommentId, - MARKDOWN_STYLE_MAP, - MatchRes, -} from './utils'; import { fontBgColorPalette, fontColorPalette, type TextAlignOptions, type TextStyleMark, } from './constants'; +import { + getCommentsIdsOnTextNode, + getEditorMarkForCommentId, + MARKDOWN_STYLE_MAP, + MatchRes, +} from './utils'; function isInlineAndVoid(editor: Editor, el: any) { return editor.isInline(el) && editor.isVoid(el); @@ -567,8 +567,46 @@ class SlateUtils { anchor: point1, focus: point2, }); - // @ts-ignore - return fragment[0].children; + if (!fragment.length) { + console.error('Debug information:', point1, point2, fragment); + throw new Error('Failed to get content between!'); + } + + if (fragment.length > 1) { + console.warn( + 'Fragment length is greater than one, ' + + 'please be careful if there is missing content!\n' + + 'Debug information:', + point1, + point2, + fragment + ); + } + + const firstFragment = fragment[0]; + if (!('type' in firstFragment)) { + console.error('Debug information:', point1, point2, fragment); + throw new Error( + 'Failed to get content between! type of firstFragment not found!' + ); + } + + const fragmentChildren = firstFragment.children; + + const textChildren: Text[] = []; + for (const child of fragmentChildren) { + if (!('text' in child)) { + console.error('Debug information:', point1, point2, fragment); + throw new Error('Fragment exists nested!'); + } + // Filter empty string + if (child.text === '') { + continue; + } + textChildren.push(child); + } + + return textChildren; } public getSplitContentsBySelection() { From 6884451324b348a1cfb47613142c89e41eb69b11 Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Mon, 15 Aug 2022 14:53:03 +0800 Subject: [PATCH 04/21] fix: backspace with root id --- .../editor-blocks/src/blocks/text/TextView.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libs/components/editor-blocks/src/blocks/text/TextView.tsx b/libs/components/editor-blocks/src/blocks/text/TextView.tsx index 2a9d77d577..e2ee5bba8d 100644 --- a/libs/components/editor-blocks/src/blocks/text/TextView.tsx +++ b/libs/components/editor-blocks/src/blocks/text/TextView.tsx @@ -2,13 +2,11 @@ import { useState } from 'react'; import { CustomText, TextProps } from '@toeverything/components/common'; import { - mergeGroup, + BlockPendantProvider, RenderBlockChildren, splitGroup, supportChildren, - unwrapGroup, useOnSelect, - BlockPendantProvider, } from '@toeverything/components/editor-core'; import { styled } from '@toeverything/components/ui'; import { Protocol } from '@toeverything/datasource/db-service'; @@ -95,13 +93,21 @@ export const TextView = ({ await block.setType('text'); return true; } + if (editor.getRootBlockId() === block.id) { + // Can not delete + return false; + } const parentBlock = await block.parent(); if (!parentBlock) { return false; } + const preParent = await parentBlock.previousSibling(); - if (Protocol.Block.Type.group === parentBlock.type) { + if ( + Protocol.Block.Type.group === parentBlock.type || + editor.getRootBlockId() === parentBlock.id + ) { const children = await block.children(); const preNode = await block.physicallyPerviousSibling(); // FIXME support children do not means has textBlock From 6e58dff08835d11a3bff85da26bd9fb697638c04 Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Mon, 15 Aug 2022 17:04:42 +0800 Subject: [PATCH 05/21] refactor: batch api --- .../src/blocks/text/TextView.tsx | 11 ++- .../editor-core/src/editor/editor.ts | 83 ++++++++++++------- 2 files changed, 58 insertions(+), 36 deletions(-) diff --git a/libs/components/editor-blocks/src/blocks/text/TextView.tsx b/libs/components/editor-blocks/src/blocks/text/TextView.tsx index e2ee5bba8d..04411b386b 100644 --- a/libs/components/editor-blocks/src/blocks/text/TextView.tsx +++ b/libs/components/editor-blocks/src/blocks/text/TextView.tsx @@ -83,8 +83,8 @@ export const TextView = ({ return true; }; - const onBackspace: TextProps['handleBackSpace'] = async props => { - return await editor.withSuspend(async () => { + const onBackspace: TextProps['handleBackSpace'] = editor.withBatch( + async props => { const { isCollAndStart } = props; if (!isCollAndStart) { return false; @@ -114,7 +114,6 @@ export const TextView = ({ // TODO: abstract this part of code if (preNode) { if (supportChildren(preNode)) { - editor.suspend(true); await editor.selectionManager.activePreviousNode( block.id, 'end' @@ -133,7 +132,6 @@ export const TextView = ({ } await preNode.append(...children); await block.remove(); - editor.suspend(false); } else { // TODO: point does not clear await editor.selectionManager.activePreviousNode( @@ -200,8 +198,9 @@ export const TextView = ({ ); } return true; - }); - }; + } + ); + const handleConvert = async ( toType: string, options?: Record diff --git a/libs/components/editor-core/src/editor/editor.ts b/libs/components/editor-core/src/editor/editor.ts index 24854735f4..16cca74950 100644 --- a/libs/components/editor-core/src/editor/editor.ts +++ b/libs/components/editor-core/src/editor/editor.ts @@ -2,40 +2,40 @@ import HotKeys from 'hotkeys-js'; import LRUCache from 'lru-cache'; -import { services } from '@toeverything/datasource/db-service'; +import type { PatchNode } from '@toeverything/components/ui'; import type { BlockFlavors, ReturnEditorBlock, UpdateEditorBlock, } from '@toeverything/datasource/db-service'; -import type { PatchNode } from '@toeverything/components/ui'; +import { services } from '@toeverything/datasource/db-service'; -import { AsyncBlock } from './block'; -import type { WorkspaceAndBlockId } from './block'; -import type { BaseView } from './views/base-view'; -import { SelectionManager } from './selection'; -import { Hooks, PluginManager } from './plugin'; -import { EditorCommands } from './commands'; -import { - Virgo, - HooksRunner, - PluginHooks, - PluginCreator, - StorageManager, - VirgoSelection, - PluginManagerInterface, -} from './types'; -import { KeyboardManager } from './keyboard'; -import { MouseManager } from './mouse'; -import { ScrollManager } from './scroll'; -import assert from 'assert'; -import { domToRect, last, Point, sleep } from '@toeverything/utils'; import { Commands } from '@toeverything/datasource/commands'; +import { domToRect, last, Point, sleep } from '@toeverything/utils'; +import assert from 'assert'; +import type { WorkspaceAndBlockId } from './block'; +import { AsyncBlock } from './block'; +import { BlockHelper } from './block/block-helper'; import { BrowserClipboard } from './clipboard/browser-clipboard'; import { ClipboardPopulator } from './clipboard/clipboard-populator'; -import { BlockHelper } from './block/block-helper'; -import { DragDropManager } from './drag-drop'; +import { EditorCommands } from './commands'; import { EditorConfig } from './config'; +import { DragDropManager } from './drag-drop'; +import { KeyboardManager } from './keyboard'; +import { MouseManager } from './mouse'; +import { Hooks, PluginManager } from './plugin'; +import { ScrollManager } from './scroll'; +import { SelectionManager } from './selection'; +import { + HooksRunner, + PluginCreator, + PluginHooks, + PluginManagerInterface, + StorageManager, + Virgo, + VirgoSelection, +} from './types'; +import type { BaseView } from './views/base-view'; export interface EditorCtorProps { workspace: string; @@ -148,18 +148,41 @@ export class Editor implements Virgo { public get container() { return this.ui_container; } - // preference to use withSuspend + + /** + * Use it discreetly. + * Preference to use {@link withBatch} + */ public suspend(flag: boolean) { services.api.editorBlock.suspend(this.workspace, flag); } - public async withSuspend any>( + // TODO support suspend recursion + private _isSuspend = false; + public withBatch Promise>(fn: T): T { + return (async (...args) => { + if (this._isSuspend) { + console.warn( + 'The editor currently has suspend! Please do not call batch method repeatedly!' + ); + } + this._isSuspend = true; + services.api.editorBlock.suspend(this.workspace, true); + const result = await fn(...args); + services.api.editorBlock.suspend(this.workspace, false); + this._isSuspend = false; + return result; + }) as T; + } + + /** + * Use it discreetly. + * Preference to use {@link withBatch} + */ + public async batch any>( fn: T ): Promise>> { - services.api.editorBlock.suspend(this.workspace, true); - const result = await fn(); - services.api.editorBlock.suspend(this.workspace, false); - return result; + return this.withBatch(fn)(); } public setReactRenderRoot(props: { From cc3dc1716d0c6bb467219ef9c8356678846c38ec Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Mon, 15 Aug 2022 17:07:18 +0800 Subject: [PATCH 06/21] fix: text enter with root id --- .../src/blocks/text/TextView.tsx | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/libs/components/editor-blocks/src/blocks/text/TextView.tsx b/libs/components/editor-blocks/src/blocks/text/TextView.tsx index 04411b386b..79912ebd02 100644 --- a/libs/components/editor-blocks/src/blocks/text/TextView.tsx +++ b/libs/components/editor-blocks/src/blocks/text/TextView.tsx @@ -67,19 +67,31 @@ export const TextView = ({ const { contentBeforeSelection, contentAfterSelection } = splitContents; const before = [...contentBeforeSelection.content]; const after = [...contentAfterSelection.content]; - const _nextBlockChildren = await block.children(); - const _nextBlock = await editor.createBlock('text'); - await _nextBlock.setProperty('text', { + const nextBlockChildren = await block.children(); + const nextBlock = await editor.createBlock('text'); + if (!nextBlock) { + throw new Error('Failed to create text block'); + } + await nextBlock.setProperty('text', { value: after as CustomText[], }); - _nextBlock.append(..._nextBlockChildren); - block.removeChildren(); await block.setProperty('text', { value: before as CustomText[], }); - await block.after(_nextBlock); - editor.selectionManager.activeNodeByNodeId(_nextBlock.id); + if (editor.getRootBlockId() === block.id) { + // If the block is the root block, + // new block can not append as next sibling, + // all new blocks should be append as children. + await block.insert(0, [nextBlock]); + editor.selectionManager.activeNodeByNodeId(nextBlock.id); + return true; + } + await nextBlock.append(...nextBlockChildren); + await block.removeChildren(); + await block.after(nextBlock); + + editor.selectionManager.activeNodeByNodeId(nextBlock.id); return true; }; From 42f02aed5c0ed46fa0514098505ca42ea401b0ba Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Fri, 12 Aug 2022 16:58:54 +0800 Subject: [PATCH 07/21] fix: handle root block when indent --- .../src/blocks/bullet/BulletView.tsx | 2 +- .../src/blocks/numbered/NumberedView.tsx | 2 +- .../src/blocks/text/TextView.tsx | 2 +- .../src/blocks/todo/TodoView.tsx | 2 +- .../editor-blocks/src/utils/indent.ts | 34 +++++++++++++------ 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/libs/components/editor-blocks/src/blocks/bullet/BulletView.tsx b/libs/components/editor-blocks/src/blocks/bullet/BulletView.tsx index 5a15a78554..9f77eda6cb 100644 --- a/libs/components/editor-blocks/src/blocks/bullet/BulletView.tsx +++ b/libs/components/editor-blocks/src/blocks/bullet/BulletView.tsx @@ -173,7 +173,7 @@ export const BulletView = ({ block, editor }: CreateView) => { } return true; } else { - return tabBlock(block, isShiftKey); + return tabBlock(editor, block, isShiftKey); } }; diff --git a/libs/components/editor-blocks/src/blocks/numbered/NumberedView.tsx b/libs/components/editor-blocks/src/blocks/numbered/NumberedView.tsx index ec0d690c96..38dac6fc75 100644 --- a/libs/components/editor-blocks/src/blocks/numbered/NumberedView.tsx +++ b/libs/components/editor-blocks/src/blocks/numbered/NumberedView.tsx @@ -167,7 +167,7 @@ export const NumberedView = ({ block, editor }: CreateView) => { } return true; } else { - tabBlock(block, isShiftKey); + tabBlock(editor, block, isShiftKey); return false; } }; diff --git a/libs/components/editor-blocks/src/blocks/text/TextView.tsx b/libs/components/editor-blocks/src/blocks/text/TextView.tsx index 2a9d77d577..e319f9e863 100644 --- a/libs/components/editor-blocks/src/blocks/text/TextView.tsx +++ b/libs/components/editor-blocks/src/blocks/text/TextView.tsx @@ -211,7 +211,7 @@ export const TextView = ({ block.firstCreateFlag = true; }; const onTab: TextProps['handleTab'] = async ({ isShiftKey }) => { - await tabBlock(block, isShiftKey); + await tabBlock(editor, block, isShiftKey); return true; }; diff --git a/libs/components/editor-blocks/src/blocks/todo/TodoView.tsx b/libs/components/editor-blocks/src/blocks/todo/TodoView.tsx index 961aa92735..8982f4695e 100644 --- a/libs/components/editor-blocks/src/blocks/todo/TodoView.tsx +++ b/libs/components/editor-blocks/src/blocks/todo/TodoView.tsx @@ -100,7 +100,7 @@ export const TodoView = ({ block, editor }: CreateView) => { }; const on_tab: TextProps['handleTab'] = async ({ isShiftKey }) => { - await tabBlock(block, isShiftKey); + await tabBlock(editor, block, isShiftKey); return true; }; diff --git a/libs/components/editor-blocks/src/utils/indent.ts b/libs/components/editor-blocks/src/utils/indent.ts index a68dd5b2db..7f0a2bad08 100644 --- a/libs/components/editor-blocks/src/utils/indent.ts +++ b/libs/components/editor-blocks/src/utils/indent.ts @@ -1,4 +1,7 @@ -import { supportChildren } from '@toeverything/components/editor-core'; +import { + type BlockEditor, + supportChildren, +} from '@toeverything/components/editor-core'; import { Protocol } from '@toeverything/datasource/db-service'; import { AsyncBlock } from '@toeverything/framework/virgo'; import type { TodoAsyncBlock } from '../blocks/todo/types'; @@ -6,14 +9,19 @@ import type { TodoAsyncBlock } from '../blocks/todo/types'; /** * Is the block in top level */ -export const isTopLevelBlock = (parentBlock: AsyncBlock): boolean => { +export const isTopLevelBlock = ( + editor: BlockEditor, + block: AsyncBlock +): boolean => { return ( - parentBlock.type === Protocol.Block.Type.group || - parentBlock.type === Protocol.Block.Type.page + editor.getRootBlockId() === block.id || + block.type === Protocol.Block.Type.group || + block.type === Protocol.Block.Type.page ); }; /** + * Move down * @returns true if indent is success * @example * ``` @@ -31,7 +39,6 @@ export const isTopLevelBlock = (parentBlock: AsyncBlock): boolean => { * ``` */ const indentBlock = async (block: TodoAsyncBlock) => { - // Move down const previousBlock = await block.previousSibling(); if (!previousBlock || !supportChildren(previousBlock)) { @@ -57,6 +64,7 @@ const indentBlock = async (block: TodoAsyncBlock) => { }; /** + * Move up * @returns true if dedent is success * @example * ``` @@ -73,13 +81,15 @@ const indentBlock = async (block: TodoAsyncBlock) => { * └─ [ ] * ``` */ -const dedentBlock = async (block: AsyncBlock) => { - // Move up +const dedentBlock = async (editor: BlockEditor, block: AsyncBlock) => { + if (editor.getRootBlockId() === block.id) { + return false; + } let parentBlock = await block.parent(); if (!parentBlock) { throw new Error('Failed to dedent block! Parent block not found!'); } - if (isTopLevelBlock(parentBlock)) { + if (isTopLevelBlock(editor, parentBlock)) { // Top, do nothing return false; } @@ -111,9 +121,13 @@ const dedentBlock = async (block: AsyncBlock) => { return true; }; -export const tabBlock = async (block: AsyncBlock, isShiftKey: boolean) => { +export const tabBlock = async ( + editor: BlockEditor, + block: AsyncBlock, + isShiftKey: boolean +) => { if (isShiftKey) { - return await dedentBlock(block); + return await dedentBlock(editor, block); } else { return await indentBlock(block); } From 64952806b91826bcc6e18eaafb7c43ee464e74b4 Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Tue, 16 Aug 2022 13:21:46 +0800 Subject: [PATCH 08/21] fix: slate cannot get the start point in the node at path [0] --- libs/components/common/src/lib/text/slate-utils.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/components/common/src/lib/text/slate-utils.ts b/libs/components/common/src/lib/text/slate-utils.ts index 43a47ad85f..ec7e219810 100644 --- a/libs/components/common/src/lib/text/slate-utils.ts +++ b/libs/components/common/src/lib/text/slate-utils.ts @@ -605,6 +605,11 @@ class SlateUtils { } textChildren.push(child); } + // If nothing, should preserve empty string + // Fix Slate Cannot get the start point in the node at path [0] because it has no start text node. + if (!textChildren.length) { + textChildren.push({ text: '' }); + } return textChildren; } From b682e55596a563a739b01852463740ca17d04e10 Mon Sep 17 00:00:00 2001 From: Qi <474021214@qq.com> Date: Tue, 16 Aug 2022 17:46:53 +0800 Subject: [PATCH 09/21] fix: the pendant popover is blocked by the container in kanban mode (#268) --- .../editor-core/src/block-pendant/BlockPendantProvider.tsx | 2 +- .../block-pendant/pendant-history-panel/PendantHistoryPanel.tsx | 2 +- .../src/block-pendant/pendant-render/PandentRender.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/components/editor-core/src/block-pendant/BlockPendantProvider.tsx b/libs/components/editor-core/src/block-pendant/BlockPendantProvider.tsx index 955cbc5b9f..6d099d8ae4 100644 --- a/libs/components/editor-core/src/block-pendant/BlockPendantProvider.tsx +++ b/libs/components/editor-core/src/block-pendant/BlockPendantProvider.tsx @@ -31,7 +31,7 @@ export const BlockPendantProvider = ({ diff --git a/libs/components/editor-core/src/block-pendant/pendant-history-panel/PendantHistoryPanel.tsx b/libs/components/editor-core/src/block-pendant/pendant-history-panel/PendantHistoryPanel.tsx index 3efc36721f..d66aa0a706 100644 --- a/libs/components/editor-core/src/block-pendant/pendant-history-panel/PendantHistoryPanel.tsx +++ b/libs/components/editor-core/src/block-pendant/pendant-history-panel/PendantHistoryPanel.tsx @@ -117,7 +117,7 @@ export const PendantHistoryPanel = ({ /> } trigger="click" - container={historyPanelRef.current} + // container={historyPanelRef.current} > { popperHandlerRef={ref => { popoverHandlerRef.current[id] = ref; }} - container={blockRenderContainerRef.current} + // container={blockRenderContainerRef.current} key={id} trigger="click" placement="bottom-start" From 02613e08b8050278fbd233ddc579a65c22ef48aa Mon Sep 17 00:00:00 2001 From: alt0 Date: Tue, 16 Aug 2022 18:41:04 +0800 Subject: [PATCH 10/21] fix: whiteboard -> edgeless --- .cz-config.js | 2 +- .../{Whiteboard.tsx => Edgeless.tsx} | 4 +- apps/ligo-virgo/src/pages/workspace/Home.tsx | 2 +- .../pages/workspace/WorkspaceContainer.tsx | 6 +- apps/ligo-virgo/webpack.config.js | 4 +- libs/components/affine-editor/src/Editor.tsx | 18 +++--- .../affine-editor/src/create-editor.ts | 4 +- .../src/editor-util/EditorUtil.tsx | 2 +- .../src/blocks/group/GroupView.tsx | 2 +- .../source-view/format-url/affine.ts | 2 +- .../components/editor-core/src/RenderRoot.tsx | 28 ++++------ .../editor-core/src/editor/editor.ts | 56 +++++++++---------- .../editor-core/src/editor/types.ts | 2 +- .../src/recast-block/types/view.ts | 1 - .../src/menu/group-menu/Plugin.tsx | 2 +- .../header/EditorBoardSwitcher/Switcher.tsx | 6 +- libs/components/layout/src/header/Header.tsx | 22 ++++---- .../db-service/src/protocol/index.ts | 1 - .../utils/column/default-config.ts | 1 - libs/datasource/jwt/src/types/block.ts | 1 - 20 files changed, 76 insertions(+), 90 deletions(-) rename apps/ligo-virgo/src/pages/workspace/{Whiteboard.tsx => Edgeless.tsx} (92%) diff --git a/.cz-config.js b/.cz-config.js index e282d831ee..a0608d5afa 100644 --- a/.cz-config.js +++ b/.cz-config.js @@ -26,7 +26,7 @@ module.exports = { ], scopes: [ { name: 'selection' }, - { name: 'whiteboard' }, + { name: 'edgeless' }, { name: 'point' }, { name: 'group' }, { name: 'page' }, diff --git a/apps/ligo-virgo/src/pages/workspace/Whiteboard.tsx b/apps/ligo-virgo/src/pages/workspace/Edgeless.tsx similarity index 92% rename from apps/ligo-virgo/src/pages/workspace/Whiteboard.tsx rename to apps/ligo-virgo/src/pages/workspace/Edgeless.tsx index 7059a264c3..c84ceda481 100644 --- a/apps/ligo-virgo/src/pages/workspace/Whiteboard.tsx +++ b/apps/ligo-virgo/src/pages/workspace/Edgeless.tsx @@ -9,11 +9,11 @@ const MemoAffineBoard = memo(AffineBoard, (prev, next) => { return prev.rootBlockId === next.rootBlockId; }); -type WhiteboardProps = { +type EdgelessProps = { workspace: string; }; -export const Whiteboard = (props: WhiteboardProps) => { +export const Edgeless = (props: EdgelessProps) => { const { page_id } = useParams(); const { user } = useUserAndSpaces(); diff --git a/apps/ligo-virgo/src/pages/workspace/Home.tsx b/apps/ligo-virgo/src/pages/workspace/Home.tsx index 31de316209..d0ac1f3872 100644 --- a/apps/ligo-virgo/src/pages/workspace/Home.tsx +++ b/apps/ligo-virgo/src/pages/workspace/Home.tsx @@ -22,7 +22,7 @@ export function WorkspaceHome() { workspace_id, user_initial_page_id, TemplateFactory.generatePageTemplateByGroupKeys({ - name: '👋 Get Started with AFFINE', + name: '👋 Get Started with AFFiNE', groupKeys: [ 'getStartedGroup0', 'getStartedGroup1', diff --git a/apps/ligo-virgo/src/pages/workspace/WorkspaceContainer.tsx b/apps/ligo-virgo/src/pages/workspace/WorkspaceContainer.tsx index f8cdb7a242..8e83c601a0 100644 --- a/apps/ligo-virgo/src/pages/workspace/WorkspaceContainer.tsx +++ b/apps/ligo-virgo/src/pages/workspace/WorkspaceContainer.tsx @@ -4,10 +4,10 @@ import { useUserAndSpaces } from '@toeverything/datasource/state'; import { WorkspaceRootContainer } from './Container'; import { Page } from './docs'; +import { Edgeless } from './Edgeless'; import { WorkspaceHome } from './Home'; import Labels from './labels'; import Pages from './pages'; -import { Whiteboard } from './Whiteboard'; export function WorkspaceContainer() { const { workspace_id } = useParams(); @@ -26,8 +26,8 @@ export function WorkspaceContainer() { } /> } /> } + path="/:page_id/edgeless" + element={} /> (null); const { setCurrentEditors } = useCurrentEditors(); ref.current ??= { - data: createEditor(workspace, rootBlockId, isWhiteboard), + data: createEditor(workspace, rootBlockId, isEdgeless), onInit: true, }; @@ -42,18 +42,14 @@ function _useConstantWithDispose( if (ref.current.onInit) { ref.current.onInit = false; } else { - ref.current.data = createEditor( - workspace, - rootBlockId, - isWhiteboard - ); + ref.current.data = createEditor(workspace, rootBlockId, isEdgeless); } setCurrentEditors(prev => ({ ...prev, [rootBlockId]: ref.current.data, })); return () => ref.current.data.dispose(); - }, [workspace, rootBlockId, isWhiteboard, setCurrentEditors]); + }, [workspace, rootBlockId, isEdgeless, setCurrentEditors]); return ref.current.data; } @@ -64,7 +60,7 @@ export const AffineEditor = forwardRef( workspace, rootBlockId, scrollBlank = true, - isWhiteboard, + isEdgeless, scrollController, scrollContainer, }, @@ -73,7 +69,7 @@ export const AffineEditor = forwardRef( const editor = _useConstantWithDispose( workspace, rootBlockId, - isWhiteboard + isEdgeless ); useEffect(() => { diff --git a/libs/components/affine-editor/src/create-editor.ts b/libs/components/affine-editor/src/create-editor.ts index c976c9ef46..6075e7a9af 100644 --- a/libs/components/affine-editor/src/create-editor.ts +++ b/libs/components/affine-editor/src/create-editor.ts @@ -30,7 +30,7 @@ import { BlockEditor } from '@toeverything/framework/virgo'; export const createEditor = ( workspace: string, rootBlockId: string, - isWhiteboard?: boolean + isEdgeless?: boolean ) => { const blockEditor = new BlockEditor({ workspace, @@ -61,7 +61,7 @@ export const createEditor = ( [Protocol.Block.Type.groupDivider]: new GroupDividerBlock(), }, plugins, - isWhiteboard, + isEdgeless, }); return blockEditor; diff --git a/libs/components/board-shapes/src/editor-util/EditorUtil.tsx b/libs/components/board-shapes/src/editor-util/EditorUtil.tsx index f8b032dc17..6e6f123a72 100644 --- a/libs/components/board-shapes/src/editor-util/EditorUtil.tsx +++ b/libs/components/board-shapes/src/editor-util/EditorUtil.tsx @@ -148,7 +148,7 @@ export class EditorUtil extends TDShapeUtil { workspace={workspace} rootBlockId={rootBlockId} scrollBlank={false} - isWhiteboard + isEdgeless /> {editingText ? null : } diff --git a/libs/components/editor-blocks/src/blocks/group/GroupView.tsx b/libs/components/editor-blocks/src/blocks/group/GroupView.tsx index 826a81cad7..791059e36c 100644 --- a/libs/components/editor-blocks/src/blocks/group/GroupView.tsx +++ b/libs/components/editor-blocks/src/blocks/group/GroupView.tsx @@ -103,7 +103,7 @@ export const GroupView = (props: CreateView) => { - {editor.isWhiteboard ? null : ( + {editor.isEdgeless ? null : ( )} diff --git a/libs/components/editor-blocks/src/components/source-view/format-url/affine.ts b/libs/components/editor-blocks/src/components/source-view/format-url/affine.ts index e31e1759cc..33974553cf 100644 --- a/libs/components/editor-blocks/src/components/source-view/format-url/affine.ts +++ b/libs/components/editor-blocks/src/components/source-view/format-url/affine.ts @@ -1,5 +1,5 @@ const _regex = - /^(https?:\/\/(localhost:4200|(nightly|app)\.affine\.pro|.*?\.ligo-virgo\.pages\.dev)\/\w{28}\/)?(affine\w{16})(\/whiteboard)?$/; + /^(https?:\/\/(localhost:4200|(nightly|app)\.affine\.pro|.*?\.ligo-virgo\.pages\.dev)\/\w{28}\/)?(affine\w{16})(\/edgeless)?$/; export const isAffineUrl = (url?: string) => { if (!url) return false; diff --git a/libs/components/editor-core/src/RenderRoot.tsx b/libs/components/editor-core/src/RenderRoot.tsx index 93ae57a6f0..cbafd3ea75 100644 --- a/libs/components/editor-core/src/RenderRoot.tsx +++ b/libs/components/editor-core/src/RenderRoot.tsx @@ -1,16 +1,16 @@ -import type { BlockEditor } from './editor'; import { styled, usePatchNodes } from '@toeverything/components/ui'; -import type { PropsWithChildren } from 'react'; -import React, { useEffect, useRef, useState, useCallback } from 'react'; -import { EditorProvider } from './Contexts'; -import { SelectionRect, SelectionRef } from './Selection'; import { Protocol, services, type ReturnUnobserve, } from '@toeverything/datasource/db-service'; -import { addNewGroup, appendNewGroup } from './recast-block'; +import type { PropsWithChildren } from 'react'; +import React, { useCallback, useEffect, useRef, useState } from 'react'; +import { EditorProvider } from './Contexts'; +import type { BlockEditor } from './editor'; import { useIsOnDrag } from './hooks'; +import { addNewGroup, appendNewGroup } from './recast-block'; +import { SelectionRect, SelectionRef } from './Selection'; interface RenderRootProps { editor: BlockEditor; @@ -160,7 +160,7 @@ export const RenderRoot = ({ return ( { if (ref != null && ref !== editor.container) { editor.container = ref; @@ -188,7 +188,7 @@ export const RenderRoot = ({ {/** TODO: remove selectionManager insert */} {editor && } - {editor.isWhiteboard ? null : } + {editor.isEdgeless ? null : } {patchedNodes} @@ -262,16 +262,10 @@ function ScrollBlank({ editor }: { editor: BlockEditor }) { const PADDING_X = 150; const Container = styled('div')( - ({ - isWhiteboard, - isOnDrag, - }: { - isWhiteboard: boolean; - isOnDrag: boolean; - }) => ({ + ({ isEdgeless, isOnDrag }: { isEdgeless: boolean; isOnDrag: boolean }) => ({ width: '100%', - padding: isWhiteboard ? 0 : `72px ${PADDING_X}px 0 ${PADDING_X}px`, - minWidth: isWhiteboard ? 'unset' : '940px', + padding: isEdgeless ? 0 : `72px ${PADDING_X}px 0 ${PADDING_X}px`, + minWidth: isEdgeless ? 'unset' : '940px', position: 'relative', ...(isOnDrag && { cursor: 'grabbing', diff --git a/libs/components/editor-core/src/editor/editor.ts b/libs/components/editor-core/src/editor/editor.ts index 24854735f4..8643421241 100644 --- a/libs/components/editor-core/src/editor/editor.ts +++ b/libs/components/editor-core/src/editor/editor.ts @@ -2,47 +2,47 @@ import HotKeys from 'hotkeys-js'; import LRUCache from 'lru-cache'; -import { services } from '@toeverything/datasource/db-service'; +import type { PatchNode } from '@toeverything/components/ui'; import type { BlockFlavors, ReturnEditorBlock, UpdateEditorBlock, } from '@toeverything/datasource/db-service'; -import type { PatchNode } from '@toeverything/components/ui'; +import { services } from '@toeverything/datasource/db-service'; -import { AsyncBlock } from './block'; -import type { WorkspaceAndBlockId } from './block'; -import type { BaseView } from './views/base-view'; -import { SelectionManager } from './selection'; -import { Hooks, PluginManager } from './plugin'; -import { EditorCommands } from './commands'; -import { - Virgo, - HooksRunner, - PluginHooks, - PluginCreator, - StorageManager, - VirgoSelection, - PluginManagerInterface, -} from './types'; -import { KeyboardManager } from './keyboard'; -import { MouseManager } from './mouse'; -import { ScrollManager } from './scroll'; -import assert from 'assert'; -import { domToRect, last, Point, sleep } from '@toeverything/utils'; import { Commands } from '@toeverything/datasource/commands'; +import { domToRect, last, Point, sleep } from '@toeverything/utils'; +import assert from 'assert'; +import type { WorkspaceAndBlockId } from './block'; +import { AsyncBlock } from './block'; +import { BlockHelper } from './block/block-helper'; import { BrowserClipboard } from './clipboard/browser-clipboard'; import { ClipboardPopulator } from './clipboard/clipboard-populator'; -import { BlockHelper } from './block/block-helper'; -import { DragDropManager } from './drag-drop'; +import { EditorCommands } from './commands'; import { EditorConfig } from './config'; +import { DragDropManager } from './drag-drop'; +import { KeyboardManager } from './keyboard'; +import { MouseManager } from './mouse'; +import { Hooks, PluginManager } from './plugin'; +import { ScrollManager } from './scroll'; +import { SelectionManager } from './selection'; +import { + HooksRunner, + PluginCreator, + PluginHooks, + PluginManagerInterface, + StorageManager, + Virgo, + VirgoSelection, +} from './types'; +import type { BaseView } from './views/base-view'; export interface EditorCtorProps { workspace: string; views: Partial>; plugins: PluginCreator[]; rootBlockId: string; - isWhiteboard?: boolean; + isEdgeless?: boolean; } export class Editor implements Virgo { @@ -75,7 +75,7 @@ export class Editor implements Virgo { render: PatchNode; has: (key: string) => boolean; }; - public isWhiteboard = false; + public isEdgeless = false; private _isDisposed = false; constructor(props: EditorCtorProps) { @@ -85,8 +85,8 @@ export class Editor implements Virgo { this.hooks = new Hooks(); this.plugin_manager = new PluginManager(this, this.hooks); this.plugin_manager.registerAll(props.plugins); - if (props.isWhiteboard) { - this.isWhiteboard = true; + if (props.isEdgeless) { + this.isEdgeless = true; } for (const [name, block] of Object.entries(props.views)) { services.api.editorBlock.registerContentExporter( diff --git a/libs/components/editor-core/src/editor/types.ts b/libs/components/editor-core/src/editor/types.ts index 44befc97c6..1b97cf0f86 100644 --- a/libs/components/editor-core/src/editor/types.ts +++ b/libs/components/editor-core/src/editor/types.ts @@ -107,7 +107,7 @@ export interface Virgo { getBlockDomById: (id: string) => Promise; getBlockByPoint: (point: Point) => Promise; getGroupBlockByPoint: (point: Point) => Promise; - isWhiteboard: boolean; + isEdgeless: boolean; mouseManager: MouseManager; } diff --git a/libs/components/editor-core/src/recast-block/types/view.ts b/libs/components/editor-core/src/recast-block/types/view.ts index 3f03187bce..fa30c07861 100644 --- a/libs/components/editor-core/src/recast-block/types/view.ts +++ b/libs/components/editor-core/src/recast-block/types/view.ts @@ -7,7 +7,6 @@ export enum RecastScene { Page = 'page', Kanban = 'kanban', Table = 'table', - // Whiteboard = 'whiteboard', } export type RecastViewId = string & { diff --git a/libs/components/editor-plugins/src/menu/group-menu/Plugin.tsx b/libs/components/editor-plugins/src/menu/group-menu/Plugin.tsx index 115e754202..6d4561d667 100644 --- a/libs/components/editor-plugins/src/menu/group-menu/Plugin.tsx +++ b/libs/components/editor-plugins/src/menu/group-menu/Plugin.tsx @@ -14,7 +14,7 @@ export class GroupMenuPlugin extends BasePlugin { } protected override _onRender(): void { - if (this.editor.isWhiteboard) return; + if (this.editor.isEdgeless) return; this.root = new PluginRenderRoot({ name: PLUGIN_NAME, render: this.editor.reactRenderRoot.render, diff --git a/libs/components/layout/src/header/EditorBoardSwitcher/Switcher.tsx b/libs/components/layout/src/header/EditorBoardSwitcher/Switcher.tsx index 78239dac9e..6c8ab70372 100644 --- a/libs/components/layout/src/header/EditorBoardSwitcher/Switcher.tsx +++ b/libs/components/layout/src/header/EditorBoardSwitcher/Switcher.tsx @@ -4,7 +4,7 @@ import { StatusText } from './StatusText'; import { StatusTrack } from './StatusTrack'; import { DocMode } from './type'; -const isBoard = (pathname: string): boolean => pathname.endsWith('/whiteboard'); +const isBoard = (pathname: string): boolean => pathname.endsWith('/edgeless'); export const Switcher = () => { const navigate = useNavigate(); @@ -20,11 +20,11 @@ export const Switcher = () => { /** * There are two possible modes: * Page mode: /{workspaceId}/{pageId} - * Board mode: /{workspaceId}/{pageId}/whiteboard + * Board mode: /{workspaceId}/{pageId}/edgeless */ const pageId = params['*'].split('/')[0]; const targetUrl = `/${workspaceId}/${pageId}${ - targetViewMode === DocMode.board ? '/whiteboard' : '' + targetViewMode === DocMode.board ? '/edgeless' : '' }`; navigate(targetUrl); }; diff --git a/libs/components/layout/src/header/Header.tsx b/libs/components/layout/src/header/Header.tsx index 36c82f7361..0f9028b9ae 100644 --- a/libs/components/layout/src/header/Header.tsx +++ b/libs/components/layout/src/header/Header.tsx @@ -26,7 +26,7 @@ function hideAffineHeader(pathname: string): boolean { } type HeaderIconProps = { - isWhiteboardView?: boolean; + isEdgelessView?: boolean; }; export const AffineHeader = () => { @@ -38,7 +38,7 @@ export const AffineHeader = () => { const { toggleSettingsSidebar: toggleInfoSidebar } = useShowSettingsSidebar(); const theme = useTheme(); - const isWhiteboardView = pathname.endsWith('/whiteboard'); + const isEdgelessView = pathname.endsWith('/edgeless'); const pageHistoryPortalFlag = useFlag('BooleanPageHistoryPortal', false); const pageSettingPortalFlag = useFlag('PageSettingPortal', false); const BooleanPageSharePortal = useFlag('BooleanPageSharePortal', false); @@ -77,9 +77,9 @@ export const AffineHeader = () => { - isWhiteboardView + isEdgelessView ? navigate( `/${ params['workspace_id'] || @@ -100,17 +100,17 @@ export const AffineHeader = () => { - + - isWhiteboardView + isEdgelessView ? null : navigate( `/${ params['workspace_id'] || 'space' - }/${params['*']}` + '/whiteboard' + }/${params['*']}` + '/edgeless' ) } > @@ -166,14 +166,14 @@ const StyledHeaderRight = styled('div')` `; const HeaderIcon = styled(IconButton, { - shouldForwardProp: (prop: string) => prop !== 'isWhiteboardView', -})(({ isWhiteboardView = false }) => ({ + shouldForwardProp: (prop: string) => prop !== 'isEdgelessView', +})(({ isEdgelessView = false }) => ({ color: '#98ACBD', minWidth: 48, width: 48, height: 36, borderRadius: '8px', - ...(isWhiteboardView && { + ...(isEdgelessView && { color: '#fff', backgroundColor: '#3E6FDB', '&:hover': { diff --git a/libs/datasource/db-service/src/protocol/index.ts b/libs/datasource/db-service/src/protocol/index.ts index 606988c683..328cc03bc3 100644 --- a/libs/datasource/db-service/src/protocol/index.ts +++ b/libs/datasource/db-service/src/protocol/index.ts @@ -22,7 +22,6 @@ const Protocol = { quote: 'quote', toc: 'toc', database: 'database', - whiteboard: 'whiteboard', template: 'template', discussion: 'discussion', comment: 'comment', diff --git a/libs/datasource/db-service/src/services/editor-block/utils/column/default-config.ts b/libs/datasource/db-service/src/services/editor-block/utils/column/default-config.ts index 13c5e6e4c2..f2d1c861b6 100644 --- a/libs/datasource/db-service/src/services/editor-block/utils/column/default-config.ts +++ b/libs/datasource/db-service/src/services/editor-block/utils/column/default-config.ts @@ -16,7 +16,6 @@ export enum GroupScene { page = 'page', table = 'table', kanban = 'kanban', - whiteboard = 'whiteboard', } /** diff --git a/libs/datasource/jwt/src/types/block.ts b/libs/datasource/jwt/src/types/block.ts index cd0300e5a1..3b04dc7830 100644 --- a/libs/datasource/jwt/src/types/block.ts +++ b/libs/datasource/jwt/src/types/block.ts @@ -37,7 +37,6 @@ export const BlockFlavors = { quote: 'quote' as const, // quote toc: 'toc' as const, //directory database: 'database' as const, //Multidimensional table - whiteboard: 'whiteboard' as const, // whiteboard template: 'template' as const, // template discussion: 'discussion' as const, // comment header comment: 'comment' as const, // comment details From 84cf334c54dd528c471358e362a18b36d60c2953 Mon Sep 17 00:00:00 2001 From: alt0 Date: Tue, 16 Aug 2022 18:46:13 +0800 Subject: [PATCH 11/21] fix: whiteboard -> edgeless e2e --- apps/ligo-virgo-e2e/src/integration/app.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/ligo-virgo-e2e/src/integration/app.spec.ts b/apps/ligo-virgo-e2e/src/integration/app.spec.ts index 9ef8947047..520bd9ada3 100644 --- a/apps/ligo-virgo-e2e/src/integration/app.spec.ts +++ b/apps/ligo-virgo-e2e/src/integration/app.spec.ts @@ -4,7 +4,7 @@ describe('ligo-virgo', () => { beforeEach(() => cy.visit('/')); it('basic load check', () => { - getTitle().contains('👋 Get Started with AFFINE'); + getTitle().contains('👋 Get Started with AFFiNE'); cy.get('.block_container').contains('The Essentials'); From ecbd7f37c024d2fe63314663a84fc17ac69676b3 Mon Sep 17 00:00:00 2001 From: DarkSky Date: Tue, 16 Aug 2022 18:53:48 +0800 Subject: [PATCH 12/21] chore: cleanup e2e useless code --- apps/ligo-virgo-e2e/src/support/commands.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/ligo-virgo-e2e/src/support/commands.ts b/apps/ligo-virgo-e2e/src/support/commands.ts index 4200179bac..395bb4a20f 100644 --- a/apps/ligo-virgo-e2e/src/support/commands.ts +++ b/apps/ligo-virgo-e2e/src/support/commands.ts @@ -12,14 +12,14 @@ declare namespace Cypress { // eslint-disable-next-line @typescript-eslint/no-unused-vars interface Chainable { - login(email: string, password: string): void; + // login(email: string, password: string): void; } } // // -- This is a parent command -- -Cypress.Commands.add('login', (email, password) => { - console.log('Custom command example: Login', email, password); -}); +// Cypress.Commands.add('login', (email, password) => { +// console.log('Custom command example: Login', email, password); +// }); // // -- This is a child command -- // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) From 3964ac7a3856d39f7b5544bde92594cc3264ff72 Mon Sep 17 00:00:00 2001 From: DarkSky Date: Wed, 17 Aug 2022 02:24:34 +0800 Subject: [PATCH 13/21] chore: cleanup deps --- .vscode/settings.json | 1 + apps/ligo-virgo-e2e/package.json | 11 + .../source-view/format-url/affine.ts | 4 +- package.json | 5 - pnpm-lock.yaml | 556 +----------------- 5 files changed, 32 insertions(+), 545 deletions(-) create mode 100644 apps/ligo-virgo-e2e/package.json diff --git a/.vscode/settings.json b/.vscode/settings.json index 8d06279b15..e69da8bc93 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -25,6 +25,7 @@ "Kanban", "keyval", "ligo", + "livedemo", "lozad", "mastersthesis", "nrwl", diff --git a/apps/ligo-virgo-e2e/package.json b/apps/ligo-virgo-e2e/package.json new file mode 100644 index 0000000000..03d495c5a1 --- /dev/null +++ b/apps/ligo-virgo-e2e/package.json @@ -0,0 +1,11 @@ +{ + "name": "ligo-virgo-e2e", + "version": "1.0.0", + "license": "MIT", + "description": "", + "author": "AFFiNE ", + "dependencies": {}, + "devDependencies": { + "cypress": "^10.4.0" + } +} diff --git a/libs/components/editor-blocks/src/components/source-view/format-url/affine.ts b/libs/components/editor-blocks/src/components/source-view/format-url/affine.ts index 33974553cf..37e0c1dcb6 100644 --- a/libs/components/editor-blocks/src/components/source-view/format-url/affine.ts +++ b/libs/components/editor-blocks/src/components/source-view/format-url/affine.ts @@ -1,5 +1,5 @@ const _regex = - /^(https?:\/\/(localhost:4200|(nightly|app)\.affine\.pro|.*?\.ligo-virgo\.pages\.dev)\/\w{28}\/)?(affine\w{16})(\/edgeless)?$/; + /^(https?:\/\/(localhost:4200|(nightly|app|livedemo)\.affine\.pro|.*?\.ligo-virgo\.pages\.dev)\/(\w{28}|AFFiNE)\/)?(affine[\w\-_]{16})(\/edgeless)?$/; export const isAffineUrl = (url?: string) => { if (!url) return false; @@ -7,5 +7,5 @@ export const isAffineUrl = (url?: string) => { }; export const toAffineEmbedUrl = (url: string) => { - return _regex.exec(url)?.[4]; + return _regex.exec(url)?.[5]; }; diff --git a/package.json b/package.json index 0e8a1863c0..a0e060199e 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,6 @@ "got": "^12.1.0", "level": "^8.0.0", "level-read-stream": "1.1.0", - "next": "12.2.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router": "^6.3.0", @@ -91,8 +90,6 @@ "@nrwl/jest": "^14.4.0", "@nrwl/js": "^14.4.0", "@nrwl/linter": "^14.4.0", - "@nrwl/nest": "^14.4.0", - "@nrwl/next": "^14.4.0", "@nrwl/node": "^14.4.0", "@nrwl/nx-cloud": "^14.2.0", "@nrwl/react": "^14.4.0", @@ -120,11 +117,9 @@ "compression-webpack-plugin": "^10.0.0", "cross-env": "^7.0.3", "css-minimizer-webpack-plugin": "^4.0.0", - "cypress": "^10.4.0", "cz-customizable": "^5.3.0", "env-cmd": "^10.1.0", "eslint": "^8.19.0", - "eslint-config-next": "12.2.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-cypress": "^2.10.3", "eslint-plugin-filename-rules": "^1.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 33707fa0f2..d2d0c70750 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,8 +17,6 @@ importers: '@nrwl/jest': ^14.4.0 '@nrwl/js': ^14.4.0 '@nrwl/linter': ^14.4.0 - '@nrwl/nest': ^14.4.0 - '@nrwl/next': ^14.4.0 '@nrwl/node': ^14.4.0 '@nrwl/nx-cloud': ^14.2.0 '@nrwl/react': ^14.4.0 @@ -49,11 +47,9 @@ importers: core-js: ^3.23.3 cross-env: ^7.0.3 css-minimizer-webpack-plugin: ^4.0.0 - cypress: ^10.4.0 cz-customizable: ^5.3.0 env-cmd: ^10.1.0 eslint: ^8.19.0 - eslint-config-next: 12.2.0 eslint-config-prettier: ^8.5.0 eslint-plugin-cypress: ^2.10.3 eslint-plugin-filename-rules: ^1.2.0 @@ -71,7 +67,6 @@ importers: level: ^8.0.0 level-read-stream: 1.1.0 lint-staged: ^13.0.3 - next: 12.2.0 nx: ^14.4.0 prettier: ^2.7.1 react: ^18.2.0 @@ -101,7 +96,6 @@ importers: got: 12.1.0 level: 8.0.0 level-read-stream: 1.1.0 - next: 12.2.0_beenoklgwfttvph5dgxj7na7aq react: 18.2.0 react-dom: 18.2.0_react@18.2.0 react-router: 6.3.0_react@18.2.0 @@ -115,18 +109,16 @@ importers: '@headlessui/react': 1.6.5_biqbaboplfbrettd7655fr4n2y '@heroicons/react': 1.0.6_react@18.2.0 '@nrwl/cli': 14.4.2_@swc+core@1.2.210 - '@nrwl/cypress': 14.4.2_3xokhr63pvhsh24r6gmwyvbcfi + '@nrwl/cypress': 14.4.2_gtbxvtmh5ipj3piki3xg57n5fe '@nrwl/eslint-plugin-nx': 14.4.2_afsbewstkdex5d4fc6xnpjlnau '@nrwl/jest': 14.4.2_dltevkctzdxkrvyldbyepwbdle '@nrwl/js': 14.4.2_gtbxvtmh5ipj3piki3xg57n5fe '@nrwl/linter': 14.4.2_jqnzvbaca4rx3byobgjku3onji - '@nrwl/nest': 14.4.2_e6qtqvxbhokjbvzxuqyvhc6pli - '@nrwl/next': 14.4.2_tij6xbouytihgovru6qahme53a '@nrwl/node': 14.4.2_ehspof47b5bphcyk4536mwaw4u '@nrwl/nx-cloud': 14.2.0 - '@nrwl/react': 14.4.2_uzkaey7ewjmyys5ezff4uhptsm + '@nrwl/react': 14.4.2_46t6z7wulh2zjyi5wmxujdm57y '@nrwl/tao': 14.4.2_@swc+core@1.2.210 - '@nrwl/web': 14.4.2_hikps3f6ih4xnq3f4csrxvfvzu + '@nrwl/web': 14.4.2_7ggz7ibmlwrqtwusxeq53zzcym '@nrwl/workspace': 14.4.2_a22ftc74wzukohhtmp6cnnvzoq '@portabletext/react': 1.0.6_react@18.2.0 '@svgr/core': 6.2.1 @@ -149,11 +141,9 @@ importers: compression-webpack-plugin: 10.0.0_webpack@5.74.0 cross-env: 7.0.3 css-minimizer-webpack-plugin: 4.0.0_webpack@5.74.0 - cypress: 10.4.0 cz-customizable: 5.10.0 env-cmd: 10.1.0 eslint: 8.19.0 - eslint-config-next: 12.2.0_4x5o4skxv6sl53vpwefgt23khm eslint-config-prettier: 8.5.0_eslint@8.19.0 eslint-plugin-cypress: 2.12.1_eslint@8.19.0 eslint-plugin-filename-rules: 1.2.0 @@ -219,6 +209,12 @@ importers: mini-css-extract-plugin: 2.6.1_webpack@5.74.0 webpack: 5.74.0 + apps/ligo-virgo-e2e: + specifiers: + cypress: ^10.4.0 + devDependencies: + cypress: 10.4.0 + apps/venus: specifiers: '@emotion/react': ^11.10.0 @@ -681,36 +677,6 @@ packages: '@jridgewell/gen-mapping': 0.1.1 '@jridgewell/trace-mapping': 0.3.14 - /@angular-devkit/core/13.3.5: - resolution: {integrity: sha512-w7vzK4VoYP9rLgxJ2SwEfrkpKybdD+QgQZlsDBzT0C6Ebp7b4gkNcNVFo8EiZvfDl6Yplw2IAP7g7fs3STn0hQ==} - engines: {node: ^12.20.0 || ^14.15.0 || >=16.10.0, npm: ^6.11.0 || ^7.5.6 || >=8.0.0, yarn: '>= 1.13.0'} - peerDependencies: - chokidar: ^3.5.2 - peerDependenciesMeta: - chokidar: - optional: true - dependencies: - ajv: 8.9.0 - ajv-formats: 2.1.1 - fast-json-stable-stringify: 2.1.0 - magic-string: 0.25.7 - rxjs: 6.6.7 - source-map: 0.7.3 - dev: true - - /@angular-devkit/schematics/13.3.5: - resolution: {integrity: sha512-0N/kL/Vfx0yVAEwa3HYxNx9wYb+G9r1JrLjJQQzDp+z9LtcojNf7j3oey6NXrDUs1WjVZOa/AIdRl3/DuaoG5w==} - engines: {node: ^12.20.0 || ^14.15.0 || >=16.10.0, npm: ^6.11.0 || ^7.5.6 || >=8.0.0, yarn: '>= 1.13.0'} - dependencies: - '@angular-devkit/core': 13.3.5 - jsonc-parser: 3.0.0 - magic-string: 0.25.7 - ora: 5.4.1 - rxjs: 6.6.7 - transitivePeerDependencies: - - chokidar - dev: true - /@babel/code-frame/7.18.6: resolution: {integrity: sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==} engines: {node: '>=6.9.0'} @@ -4952,134 +4918,6 @@ packages: yargs: 17.5.1 dev: false - /@nestjs/schematics/8.0.11_typescript@4.7.4: - resolution: {integrity: sha512-W/WzaxgH5aE01AiIErE9QrQJ73VR/M/8p8pq0LZmjmNcjZqU5kQyOWUxZg13WYfSpJdOa62t6TZRtFDmgZPoIg==} - peerDependencies: - typescript: ^3.4.5 || ^4.3.5 - dependencies: - '@angular-devkit/core': 13.3.5 - '@angular-devkit/schematics': 13.3.5 - fs-extra: 10.1.0 - jsonc-parser: 3.0.0 - pluralize: 8.0.0 - typescript: 4.7.4 - transitivePeerDependencies: - - chokidar - dev: true - - /@next/env/12.2.0: - resolution: {integrity: sha512-/FCkDpL/8SodJEXvx/DYNlOD5ijTtkozf4PPulYPtkPOJaMPpBSOkzmsta4fnrnbdH6eZjbwbiXFdr6gSQCV4w==} - - /@next/eslint-plugin-next/12.2.0: - resolution: {integrity: sha512-nIj5xV/z3dOfeBnE7qFAjUQZAi4pTlIMuusRM6s/T6lOz8x7mjY5s1ZkTUBmcjPVCb2VIv3CrMH0WZL6xfjZZg==} - dependencies: - glob: 7.1.7 - dev: true - - /@next/swc-android-arm-eabi/12.2.0: - resolution: {integrity: sha512-hbneH8DNRB2x0Nf5fPCYoL8a0osvdTCe4pvOc9Rv5CpDsoOlf8BWBs2OWpeP0U2BktGvIsuUhmISmdYYGyrvTw==} - engines: {node: '>= 10'} - cpu: [arm] - os: [android] - requiresBuild: true - optional: true - - /@next/swc-android-arm64/12.2.0: - resolution: {integrity: sha512-1eEk91JHjczcJomxJ8X0XaUeNcp5Lx1U2Ic7j15ouJ83oRX+3GIslOuabW2oPkSgXbHkThMClhirKpvG98kwZg==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [android] - requiresBuild: true - optional: true - - /@next/swc-darwin-arm64/12.2.0: - resolution: {integrity: sha512-x5U5gJd7ZvrEtTFnBld9O2bUlX8opu7mIQUqRzj7KeWzBwPhrIzTTsQXAiNqsaMuaRPvyHBVW/5d/6g6+89Y8g==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [darwin] - requiresBuild: true - optional: true - - /@next/swc-darwin-x64/12.2.0: - resolution: {integrity: sha512-iwMNFsrAPjfedjKDv9AXPAV16PWIomP3qw/FfPaxkDVRbUls7BNdofBLzkQmqxqWh93WrawLwaqyXpJuAaiwJA==} - engines: {node: '>= 10'} - cpu: [x64] - os: [darwin] - requiresBuild: true - optional: true - - /@next/swc-freebsd-x64/12.2.0: - resolution: {integrity: sha512-gRiAw8g3Akf6niTDLEm1Emfa7jXDjvaAj/crDO8hKASKA4Y1fS4kbi/tyWw5VtoFI4mUzRmCPmZ8eL0tBSG58A==} - engines: {node: '>= 10'} - cpu: [x64] - os: [freebsd] - requiresBuild: true - optional: true - - /@next/swc-linux-arm-gnueabihf/12.2.0: - resolution: {integrity: sha512-/TJZkxaIpeEwnXh6A40trgwd40C5+LJroLUOEQwMOJdavLl62PjCA6dGl1pgooWLCIb5YdBQ0EG4ylzvLwS2+Q==} - engines: {node: '>= 10'} - cpu: [arm] - os: [linux] - requiresBuild: true - optional: true - - /@next/swc-linux-arm64-gnu/12.2.0: - resolution: {integrity: sha512-++WAB4ElXCSOKG9H8r4ENF8EaV+w0QkrpjehmryFkQXmt5juVXz+nKDVlCRMwJU7A1O0Mie82XyEoOrf6Np1pA==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [linux] - requiresBuild: true - optional: true - - /@next/swc-linux-arm64-musl/12.2.0: - resolution: {integrity: sha512-XrqkHi/VglEn5zs2CYK6ofJGQySrd+Lr4YdmfJ7IhsCnMKkQY1ma9Hv5THwhZVof3e+6oFHrQ9bWrw9K4WTjFA==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [linux] - requiresBuild: true - optional: true - - /@next/swc-linux-x64-gnu/12.2.0: - resolution: {integrity: sha512-MyhHbAKVjpn065WzRbqpLu2krj4kHLi6RITQdD1ee+uxq9r2yg5Qe02l24NxKW+1/lkmpusl4Y5Lks7rBiJn4w==} - engines: {node: '>= 10'} - cpu: [x64] - os: [linux] - requiresBuild: true - optional: true - - /@next/swc-linux-x64-musl/12.2.0: - resolution: {integrity: sha512-Tz1tJZ5egE0S/UqCd5V6ZPJsdSzv/8aa7FkwFmIJ9neLS8/00za+OY5pq470iZQbPrkTwpKzmfTTIPRVD5iqDg==} - engines: {node: '>= 10'} - cpu: [x64] - os: [linux] - requiresBuild: true - optional: true - - /@next/swc-win32-arm64-msvc/12.2.0: - resolution: {integrity: sha512-0iRO/CPMCdCYUzuH6wXLnsfJX1ykBX4emOOvH0qIgtiZM0nVYbF8lkEyY2ph4XcsurpinS+ziWuYCXVqrOSqiw==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [win32] - requiresBuild: true - optional: true - - /@next/swc-win32-ia32-msvc/12.2.0: - resolution: {integrity: sha512-8A26RJVcJHwIKm8xo/qk2ePRquJ6WCI2keV2qOW/Qm+ZXrPXHMIWPYABae/nKN243YFBNyPiHytjX37VrcpUhg==} - engines: {node: '>= 10'} - cpu: [ia32] - os: [win32] - requiresBuild: true - optional: true - - /@next/swc-win32-x64-msvc/12.2.0: - resolution: {integrity: sha512-OI14ozFLThEV3ey6jE47zrzSTV/6eIMsvbwozo+XfdWqOPwQ7X00YkRx4GVMKMC0rM44oGS2gmwMKYpe4EblnA==} - engines: {node: '>= 10'} - cpu: [x64] - os: [win32] - requiresBuild: true - optional: true - /@nodelib/fs.scandir/2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -5116,7 +4954,7 @@ packages: - '@swc/core' dev: true - /@nrwl/cypress/14.4.2_3xokhr63pvhsh24r6gmwyvbcfi: + /@nrwl/cypress/14.4.2_gtbxvtmh5ipj3piki3xg57n5fe: resolution: {integrity: sha512-vek4tJYzaJwnLgeJLAJKWuCmtE+XWCq6IgmCl/4G/lWxTWGzlJ19ZK8MoCEiJqbnNYeoHZPxoaAGwyBAbVuO3w==} peerDependencies: cypress: '>= 3 < 10' @@ -5132,7 +4970,6 @@ packages: '@nrwl/workspace': 14.4.2_a22ftc74wzukohhtmp6cnnvzoq babel-loader: 8.2.5_m3opitmgss2x7fiy6klia7uvaa chalk: 4.1.0 - cypress: 10.4.0 enhanced-resolve: 5.10.0 fork-ts-checker-webpack-plugin: 6.2.10_wln64xm7gyszy6wbwhdijmigya rxjs: 6.6.7 @@ -5290,101 +5127,6 @@ packages: - utf-8-validate dev: true - /@nrwl/nest/14.4.2_e6qtqvxbhokjbvzxuqyvhc6pli: - resolution: {integrity: sha512-TVlY7UbWQLMjQyCwkos8IkLzhKz/58IPUqoE3Jr9syf8KJ+JCkVxndEcUSPMlEJWtfxdEjchNrOwZH5bWpZPBw==} - dependencies: - '@nestjs/schematics': 8.0.11_typescript@4.7.4 - '@nrwl/devkit': 14.4.2_nx@14.4.2 - '@nrwl/jest': 14.4.2_dltevkctzdxkrvyldbyepwbdle - '@nrwl/js': 14.4.2_gtbxvtmh5ipj3piki3xg57n5fe - '@nrwl/linter': 14.4.2_jqnzvbaca4rx3byobgjku3onji - '@nrwl/node': 14.4.2_ehspof47b5bphcyk4536mwaw4u - transitivePeerDependencies: - - '@swc-node/register' - - '@swc/core' - - '@swc/wasm' - - '@types/node' - - bufferutil - - canvas - - chokidar - - esbuild - - eslint - - node-notifier - - nx - - prettier - - supports-color - - ts-node - - typescript - - uglify-js - - utf-8-validate - - vue-template-compiler - - webpack-cli - dev: true - - /@nrwl/next/14.4.2_tij6xbouytihgovru6qahme53a: - resolution: {integrity: sha512-T8F8Fy7jJ7dNhLET14FhslD9lGzpUrzOQQfES5mb8LK0Y3kNyumGfCetAuFwkUEp/7aC5FxsZSc/32l4b6dxZA==} - peerDependencies: - next: ^12.1.0 - dependencies: - '@babel/plugin-proposal-decorators': 7.18.6_@babel+core@7.18.6 - '@nrwl/cypress': 14.4.2_3xokhr63pvhsh24r6gmwyvbcfi - '@nrwl/devkit': 14.4.2_nx@14.4.2 - '@nrwl/jest': 14.4.2_dltevkctzdxkrvyldbyepwbdle - '@nrwl/linter': 14.4.2_jqnzvbaca4rx3byobgjku3onji - '@nrwl/react': 14.4.2_uzkaey7ewjmyys5ezff4uhptsm - '@nrwl/web': 14.4.2_hikps3f6ih4xnq3f4csrxvfvzu - '@nrwl/workspace': 14.4.2_a22ftc74wzukohhtmp6cnnvzoq - '@svgr/webpack': 6.2.1 - chalk: 4.1.0 - eslint-config-next: 12.2.0_4x5o4skxv6sl53vpwefgt23khm - fs-extra: 10.1.0 - next: 12.2.0_beenoklgwfttvph5dgxj7na7aq - ts-node: 10.8.2_y42jqzo3jkzuv3kp7opavo2xbi - tsconfig-paths: 3.14.1 - url-loader: 4.1.1_webpack@5.74.0 - webpack-merge: 5.8.0 - transitivePeerDependencies: - - '@babel/core' - - '@parcel/css' - - '@swc-node/register' - - '@swc/core' - - '@swc/wasm' - - '@types/babel__core' - - '@types/node' - - '@types/webpack' - - '@typescript-eslint/parser' - - bufferutil - - canvas - - clean-css - - csso - - cypress - - debug - - esbuild - - eslint - - eslint-import-resolver-typescript - - eslint-import-resolver-webpack - - fibers - - file-loader - - html-webpack-plugin - - node-notifier - - node-sass - - nx - - prettier - - sass-embedded - - sockjs-client - - supports-color - - type-fest - - typescript - - uglify-js - - utf-8-validate - - vue-template-compiler - - webpack - - webpack-cli - - webpack-dev-server - - webpack-hot-middleware - - webpack-plugin-serve - dev: true - /@nrwl/node/14.4.2_ehspof47b5bphcyk4536mwaw4u: resolution: {integrity: sha512-YMolQH3R/DTyPap3fQFWXvBaKJQG6l+msAUqzHp5OML3lPDg+zBYGW2kD1IsXpYq/ccpaot1ePS5K0JDpbZ8zQ==} dependencies: @@ -5446,18 +5188,18 @@ packages: - debug dev: true - /@nrwl/react/14.4.2_uzkaey7ewjmyys5ezff4uhptsm: + /@nrwl/react/14.4.2_46t6z7wulh2zjyi5wmxujdm57y: resolution: {integrity: sha512-5OlTpa5wRgADkNuP55Ii0myZLqzcefwR+lMRSBFquwOzxQ5VEU9JCyZVeO4pBdVr1ibbIJoj1EfO+NnVpCtELg==} dependencies: '@babel/core': 7.18.6 '@babel/preset-react': 7.18.6_@babel+core@7.18.6 - '@nrwl/cypress': 14.4.2_3xokhr63pvhsh24r6gmwyvbcfi + '@nrwl/cypress': 14.4.2_gtbxvtmh5ipj3piki3xg57n5fe '@nrwl/devkit': 14.4.2_nx@14.4.2 '@nrwl/jest': 14.4.2_dltevkctzdxkrvyldbyepwbdle '@nrwl/js': 14.4.2_gtbxvtmh5ipj3piki3xg57n5fe '@nrwl/linter': 14.4.2_jqnzvbaca4rx3byobgjku3onji - '@nrwl/storybook': 14.4.2_yflzlx5dxniwxy53i7vvsdpbmy - '@nrwl/web': 14.4.2_hikps3f6ih4xnq3f4csrxvfvzu + '@nrwl/storybook': 14.4.2_brofqo76x5gdh2qufyuyzjmfne + '@nrwl/web': 14.4.2_7ggz7ibmlwrqtwusxeq53zzcym '@nrwl/workspace': 14.4.2_a22ftc74wzukohhtmp6cnnvzoq '@pmmmwh/react-refresh-webpack-plugin': 0.5.7_bgbvhssx5jbdjtmrq4m55itcsu '@storybook/node-logger': 6.1.20 @@ -5513,10 +5255,10 @@ packages: - webpack-plugin-serve dev: true - /@nrwl/storybook/14.4.2_yflzlx5dxniwxy53i7vvsdpbmy: + /@nrwl/storybook/14.4.2_brofqo76x5gdh2qufyuyzjmfne: resolution: {integrity: sha512-G6h3jQT+pIY0RAEbeclguEFSAIXsToRVKEeRyq1bk6fWJHy7y//bCeJrINL9xPf9zk12cWyKkjJvwsOcy0Z1Mw==} dependencies: - '@nrwl/cypress': 14.4.2_3xokhr63pvhsh24r6gmwyvbcfi + '@nrwl/cypress': 14.4.2_gtbxvtmh5ipj3piki3xg57n5fe '@nrwl/devkit': 14.4.2_nx@14.4.2 '@nrwl/linter': 14.4.2_jqnzvbaca4rx3byobgjku3onji '@nrwl/workspace': 14.4.2_a22ftc74wzukohhtmp6cnnvzoq @@ -5555,7 +5297,7 @@ packages: - '@swc/core' dev: true - /@nrwl/web/14.4.2_hikps3f6ih4xnq3f4csrxvfvzu: + /@nrwl/web/14.4.2_7ggz7ibmlwrqtwusxeq53zzcym: resolution: {integrity: sha512-x00dE67yDRC3zmVEdO1HdtIbPezZ5gSKmNmEL2++PrA6AUz3a+f7/Ahhs4ALxnEPx1oDRLzM5OxRb5w6kLmGfw==} dependencies: '@babel/core': 7.18.6 @@ -5566,7 +5308,7 @@ packages: '@babel/preset-env': 7.18.6_@babel+core@7.18.6 '@babel/preset-typescript': 7.18.6_@babel+core@7.18.6 '@babel/runtime': 7.18.6 - '@nrwl/cypress': 14.4.2_3xokhr63pvhsh24r6gmwyvbcfi + '@nrwl/cypress': 14.4.2_gtbxvtmh5ipj3piki3xg57n5fe '@nrwl/devkit': 14.4.2_nx@14.4.2 '@nrwl/jest': 14.4.2_dltevkctzdxkrvyldbyepwbdle '@nrwl/js': 14.4.2_gtbxvtmh5ipj3piki3xg57n5fe @@ -6011,10 +5753,6 @@ packages: picomatch: 2.3.1 dev: true - /@rushstack/eslint-patch/1.1.4: - resolution: {integrity: sha512-LwzQKA4vzIct1zNZzBmRKI9QuNpLgTQMEjsQLf3BXuGYb3QPTP4Yjf6mkdX+X1mYttZ808QpOwAzZjv28kq7DA==} - dev: true - /@sinclair/typebox/0.23.5: resolution: {integrity: sha512-AFBVi/iT4g20DHoujvMH1aEDn8fGJh4xsRGCP6d8RpLPMqsNPvW01Jcn0QysXTsg++/xj25NmJsGyH9xug/wKg==} dev: true @@ -6376,11 +6114,6 @@ packages: '@swc/core-win32-ia32-msvc': 1.2.210 '@swc/core-win32-x64-msvc': 1.2.210 - /@swc/helpers/0.4.2: - resolution: {integrity: sha512-556Az0VX7WR6UdoTn4htt/l3zPQ7bsQWK+HqdG4swV7beUCxo/BqmvbOpUkTIm/9ih86LIf1qsUnywNL3obGHw==} - dependencies: - tslib: 2.4.0 - /@swc/helpers/0.4.3: resolution: {integrity: sha512-6JrF+fdUK2zbGpJIlN7G3v966PQjyx/dPt1T9km2wj+EUBqgrxCk3uX4Kct16MIm9gGxfKRcfax2hVf5jvlTzA==} dependencies: @@ -7365,15 +7098,6 @@ packages: uri-js: 4.4.1 dev: true - /ajv/8.9.0: - resolution: {integrity: sha512-qOKJyNj/h+OWx7s5DePL6Zu1KeM9jPZhwBqs+7DzP6bGOvqzVCSf0xueYmVuaC/oQ/VtS2zLMLHdQFbkka+XDQ==} - dependencies: - fast-deep-equal: 3.1.3 - json-schema-traverse: 1.0.0 - require-from-string: 2.0.2 - uri-js: 4.4.1 - dev: true - /ansi-colors/4.1.3: resolution: {integrity: sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==} engines: {node: '>=6'} @@ -8501,11 +8225,6 @@ packages: dependencies: mimic-response: 1.0.1 - /clone/1.0.4: - resolution: {integrity: sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==} - engines: {node: '>=0.8'} - dev: true - /clsx/1.2.0: resolution: {integrity: sha512-EPRP7XJsM1y0iCU3Z7C7jFKdQboXSeHgEfzQUTlz7m5NP3hDrlz48aUsmNGp4pC+JOW9WA3vIRqlYuo/bl4Drw==} engines: {node: '>=6'} @@ -9332,12 +9051,6 @@ packages: execa: 5.1.1 dev: true - /defaults/1.0.3: - resolution: {integrity: sha512-s82itHOnYrN0Ib8r+z7laQz3sdE+4FP3d9Q7VLO7U+KRT+CR0GsWuyHxzdAY82I7cXv0G/twrqomTJLOssO5HA==} - dependencies: - clone: 1.0.4 - dev: true - /defer-to-connect/2.0.1: resolution: {integrity: sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==} engines: {node: '>=10'} @@ -9782,31 +9495,6 @@ packages: source-map: 0.6.1 dev: true - /eslint-config-next/12.2.0_4x5o4skxv6sl53vpwefgt23khm: - resolution: {integrity: sha512-QWzNegadFXjQ0h3hixnLacRM9Kot85vQefyNsA8IeOnERZMz0Gvays1W6DMCjSxJbnCwuWaMXj9DCpar5IahRA==} - peerDependencies: - eslint: ^7.23.0 || ^8.0.0 - typescript: '>=3.3.1' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@next/eslint-plugin-next': 12.2.0 - '@rushstack/eslint-patch': 1.1.4 - '@typescript-eslint/parser': 5.30.5_4x5o4skxv6sl53vpwefgt23khm - eslint: 8.19.0 - eslint-import-resolver-node: 0.3.6 - eslint-import-resolver-typescript: 2.7.1_q2xwze32dd33a2fc2qubwr4ie4 - eslint-plugin-import: 2.26.0_6o2fuefo7gfpbr7nbqwgu7w4mq - eslint-plugin-jsx-a11y: 6.6.0_eslint@8.19.0 - eslint-plugin-react: 7.30.1_eslint@8.19.0 - eslint-plugin-react-hooks: 4.6.0_eslint@8.19.0 - typescript: 4.7.4 - transitivePeerDependencies: - - eslint-import-resolver-webpack - - supports-color - dev: true - /eslint-config-prettier/8.5.0_eslint@8.19.0: resolution: {integrity: sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==} hasBin: true @@ -9825,24 +9513,6 @@ packages: - supports-color dev: true - /eslint-import-resolver-typescript/2.7.1_q2xwze32dd33a2fc2qubwr4ie4: - resolution: {integrity: sha512-00UbgGwV8bSgUv34igBDbTOtKhqoRMy9bFjNehT40bXg6585PNIct8HhXZ0SybqB9rWtXj9crcku8ndDn/gIqQ==} - engines: {node: '>=4'} - peerDependencies: - eslint: '*' - eslint-plugin-import: '*' - dependencies: - debug: 4.3.4 - eslint: 8.19.0 - eslint-plugin-import: 2.26.0_6o2fuefo7gfpbr7nbqwgu7w4mq - glob: 7.2.3 - is-glob: 4.0.3 - resolve: 1.22.1 - tsconfig-paths: 3.14.1 - transitivePeerDependencies: - - supports-color - dev: true - /eslint-module-utils/2.7.3_ea34krk32wbcqzxapvwr7rsjs4: resolution: {integrity: sha512-088JEC7O3lDZM9xGe0RerkOMd0EjFl+Yvd1jPWIkMT5u3H9+HC34mWWPnqPrN13gieT9pBOO+Qt07Nb/6TresQ==} engines: {node: '>=4'} @@ -9869,33 +9539,6 @@ packages: - supports-color dev: true - /eslint-module-utils/2.7.3_ngc5pgxzrdnldt43xbcfncn6si: - resolution: {integrity: sha512-088JEC7O3lDZM9xGe0RerkOMd0EjFl+Yvd1jPWIkMT5u3H9+HC34mWWPnqPrN13gieT9pBOO+Qt07Nb/6TresQ==} - engines: {node: '>=4'} - peerDependencies: - '@typescript-eslint/parser': '*' - eslint-import-resolver-node: '*' - eslint-import-resolver-typescript: '*' - eslint-import-resolver-webpack: '*' - peerDependenciesMeta: - '@typescript-eslint/parser': - optional: true - eslint-import-resolver-node: - optional: true - eslint-import-resolver-typescript: - optional: true - eslint-import-resolver-webpack: - optional: true - dependencies: - '@typescript-eslint/parser': 5.30.5_4x5o4skxv6sl53vpwefgt23khm - debug: 3.2.7 - eslint-import-resolver-node: 0.3.6 - eslint-import-resolver-typescript: 2.7.1_q2xwze32dd33a2fc2qubwr4ie4 - find-up: 2.1.0 - transitivePeerDependencies: - - supports-color - dev: true - /eslint-plugin-cypress/2.12.1_eslint@8.19.0: resolution: {integrity: sha512-c2W/uPADl5kospNDihgiLc7n87t5XhUbFDoTl6CfVkmG+kDAb5Ux10V9PoLPu9N+r7znpc+iQlcmAqT1A/89HA==} peerDependencies: @@ -9910,37 +9553,6 @@ packages: engines: {node: '>=6.0.0'} dev: true - /eslint-plugin-import/2.26.0_6o2fuefo7gfpbr7nbqwgu7w4mq: - resolution: {integrity: sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==} - engines: {node: '>=4'} - peerDependencies: - '@typescript-eslint/parser': '*' - eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 - peerDependenciesMeta: - '@typescript-eslint/parser': - optional: true - dependencies: - '@typescript-eslint/parser': 5.30.5_4x5o4skxv6sl53vpwefgt23khm - array-includes: 3.1.5 - array.prototype.flat: 1.3.0 - debug: 2.6.9 - doctrine: 2.1.0 - eslint: 8.19.0 - eslint-import-resolver-node: 0.3.6 - eslint-module-utils: 2.7.3_ngc5pgxzrdnldt43xbcfncn6si - has: 1.0.3 - is-core-module: 2.9.0 - is-glob: 4.0.3 - minimatch: 3.1.2 - object.values: 1.1.5 - resolve: 1.22.1 - tsconfig-paths: 3.14.1 - transitivePeerDependencies: - - eslint-import-resolver-typescript - - eslint-import-resolver-webpack - - supports-color - dev: true - /eslint-plugin-import/2.26.0_iom7pm3yknyiblqpw2vvqvxs5i: resolution: {integrity: sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==} engines: {node: '>=4'} @@ -11129,17 +10741,6 @@ packages: path-is-absolute: 1.0.1 dev: true - /glob/7.1.7: - resolution: {integrity: sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==} - dependencies: - fs.realpath: 1.0.0 - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 3.1.2 - once: 1.4.0 - path-is-absolute: 1.0.1 - dev: true - /glob/7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} dependencies: @@ -12072,11 +11673,6 @@ packages: is-path-inside: 3.0.3 dev: true - /is-interactive/1.0.0: - resolution: {integrity: sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==} - engines: {node: '>=8'} - dev: true - /is-module/1.0.0: resolution: {integrity: sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==} dev: true @@ -13942,12 +13538,6 @@ packages: hasBin: true dev: true - /magic-string/0.25.7: - resolution: {integrity: sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==} - dependencies: - sourcemap-codec: 1.4.8 - dev: true - /magic-string/0.25.9: resolution: {integrity: sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==} dependencies: @@ -14284,54 +13874,6 @@ packages: /neo-async/2.6.2: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} - /next/12.2.0_beenoklgwfttvph5dgxj7na7aq: - resolution: {integrity: sha512-B4j7D3SHYopLYx6/Ark0fenwIar9tEaZZFAaxmKjgcMMexhVJzB3jt7X+6wcdXPPMeUD6r09weUtnDpjox/vIA==} - engines: {node: '>=12.22.0'} - hasBin: true - peerDependencies: - fibers: '>= 3.1.0' - node-sass: ^6.0.0 || ^7.0.0 - react: ^17.0.2 || ^18.0.0-0 - react-dom: ^17.0.2 || ^18.0.0-0 - sass: ^1.3.0 - peerDependenciesMeta: - fibers: - optional: true - node-sass: - optional: true - react: - optional: true - react-dom: - optional: true - sass: - optional: true - dependencies: - '@next/env': 12.2.0 - '@swc/helpers': 0.4.2 - caniuse-lite: 1.0.30001363 - postcss: 8.4.5 - react: 18.2.0 - react-dom: 18.2.0_react@18.2.0 - styled-jsx: 5.0.2_2sb3a56iojvze2npkgcccbebf4 - use-sync-external-store: 1.1.0_react@18.2.0 - optionalDependencies: - '@next/swc-android-arm-eabi': 12.2.0 - '@next/swc-android-arm64': 12.2.0 - '@next/swc-darwin-arm64': 12.2.0 - '@next/swc-darwin-x64': 12.2.0 - '@next/swc-freebsd-x64': 12.2.0 - '@next/swc-linux-arm-gnueabihf': 12.2.0 - '@next/swc-linux-arm64-gnu': 12.2.0 - '@next/swc-linux-arm64-musl': 12.2.0 - '@next/swc-linux-x64-gnu': 12.2.0 - '@next/swc-linux-x64-musl': 12.2.0 - '@next/swc-win32-arm64-msvc': 12.2.0 - '@next/swc-win32-ia32-msvc': 12.2.0 - '@next/swc-win32-x64-msvc': 12.2.0 - transitivePeerDependencies: - - '@babel/core' - - babel-plugin-macros - /nice-try/1.0.5: resolution: {integrity: sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==} dev: true @@ -14684,21 +14226,6 @@ packages: bin-wrapper: 4.1.0 dev: true - /ora/5.4.1: - resolution: {integrity: sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==} - engines: {node: '>=10'} - dependencies: - bl: 4.1.0 - chalk: 4.1.2 - cli-cursor: 3.1.0 - cli-spinners: 2.6.1 - is-interactive: 1.0.0 - is-unicode-supported: 0.1.0 - log-symbols: 4.1.0 - strip-ansi: 6.0.1 - wcwidth: 1.0.1 - dev: true - /os-filter-obj/2.0.0: resolution: {integrity: sha512-uksVLsqG3pVdzzPvmAHpBK0wKxYItuzZr7SziusRPoz67tGV8rL1szZ6IdeUrbqLjGDwApBtN29eEE3IqGHOjg==} engines: {node: '>=4'} @@ -15071,11 +14598,6 @@ packages: find-up: 5.0.0 dev: true - /pluralize/8.0.0: - resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} - engines: {node: '>=4'} - dev: true - /portfinder/1.0.28: resolution: {integrity: sha512-Se+2isanIcEqf2XMHjyUKskczxbPH7dQnlMjXX6+dybayyHvAf/TCgyMRlzf/B6QDhAEFOGes0pzRo3by4AbMA==} engines: {node: '>= 0.12.0'} @@ -15491,14 +15013,6 @@ packages: picocolors: 1.0.0 source-map-js: 1.0.2 - /postcss/8.4.5: - resolution: {integrity: sha512-jBDboWM8qpaqwkMwItqTQTiFikhs/67OYVvblFFTM7MrZjt6yMKd6r2kgXizEbTTljacm4NldIlZnhbjr84QYg==} - engines: {node: ^10 || ^12 || >=14} - dependencies: - nanoid: 3.3.4 - picocolors: 1.0.0 - source-map-js: 1.0.2 - /prelude-ls/1.1.2: resolution: {integrity: sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==} engines: {node: '>= 0.8.0'} @@ -17267,24 +16781,6 @@ packages: - webpack dev: false - /styled-jsx/5.0.2_2sb3a56iojvze2npkgcccbebf4: - resolution: {integrity: sha512-LqPQrbBh3egD57NBcHET4qcgshPks+yblyhPlH2GY8oaDgKs8SK4C3dBh3oSJjgzJ3G5t1SYEZGHkP+QEpX9EQ==} - engines: {node: '>= 12.0.0'} - peerDependencies: - '@babel/core': '*' - babel-plugin-macros: '*' - react: '>= 16.8.0 || 17.x.x || ^18.0.0-0' - peerDependenciesMeta: - '@babel/core': - optional: true - babel-plugin-macros: - optional: true - react: - optional: true - dependencies: - '@babel/core': 7.18.6 - react: 18.2.0 - /stylehacks/5.1.0_postcss@8.4.14: resolution: {integrity: sha512-SzLmvHQTrIWfSgljkQCw2++C9+Ne91d/6Sp92I8c5uHTcy/PgeHamwITIbBW9wnFTY/3ZfSXR9HIL6Ikqmcu6Q==} engines: {node: ^10 || ^12 || >=14.0} @@ -18019,16 +17515,6 @@ packages: querystring: 0.2.0 dev: false - /use-sync-external-store/1.1.0_react@18.2.0: - resolution: {integrity: sha512-SEnieB2FPKEVne66NpXPd1Np4R1lTNKfjuy3XdIoPQKYBAFdzbzSZlSn1KJZUiihQLQC5Znot4SBz1EOTBwQAQ==} - peerDependencies: - react: ^16.8.0 || ^17.0.0 || ^18.0.0 - peerDependenciesMeta: - react: - optional: true - dependencies: - react: 18.2.0 - /user-home/2.0.0: resolution: {integrity: sha512-KMWqdlOcjCYdtIJpicDSFBQ8nFwS2i9sslAd6f4+CBGcU4gist2REnr2fxj2YocvJFxSF3ZOHLYLVZnUxv4BZQ==} engines: {node: '>=0.10.0'} @@ -18150,12 +17636,6 @@ packages: minimalistic-assert: 1.0.1 dev: true - /wcwidth/1.0.1: - resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} - dependencies: - defaults: 1.0.3 - dev: true - /webidl-conversions/3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} From f54274442cea935a28ac1c6a8fc318addd8424b4 Mon Sep 17 00:00:00 2001 From: tzhangchi Date: Wed, 17 Aug 2022 10:03:00 +0800 Subject: [PATCH 14/21] feat(weakSql): deal with Incomplete string escaping or encoding --- .../src/blocks/group/utils/weak-sql/weakSqlCreator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/components/editor-blocks/src/blocks/group/utils/weak-sql/weakSqlCreator.ts b/libs/components/editor-blocks/src/blocks/group/utils/weak-sql/weakSqlCreator.ts index 47debf2175..6d980155fa 100644 --- a/libs/components/editor-blocks/src/blocks/group/utils/weak-sql/weakSqlCreator.ts +++ b/libs/components/editor-blocks/src/blocks/group/utils/weak-sql/weakSqlCreator.ts @@ -49,7 +49,7 @@ const weakSqlCreator = (weak_sql_express = ''): Promise => { constraints.push({ field: field.trim(), relation: relation.trim() as Relation, - value: pickValue(value.replace(/&&|&|;/, '').trim()), + value: pickValue(value.replace(/&&|&|;/g, '').trim()), }); /* meaningless return value */ From 88645938822bba231323df2dac2ab170ce50e81e Mon Sep 17 00:00:00 2001 From: tzhangchi Date: Wed, 17 Aug 2022 10:14:34 +0800 Subject: [PATCH 15/21] fix(youtube): Incomplete URL substring sanitization --- .../src/components/source-view/format-url/youtube.ts | 3 ++- ! | 0 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 ! diff --git a/libs/components/editor-blocks/src/components/source-view/format-url/youtube.ts b/libs/components/editor-blocks/src/components/source-view/format-url/youtube.ts index ebc0c70be0..202f0dc968 100644 --- a/libs/components/editor-blocks/src/components/source-view/format-url/youtube.ts +++ b/libs/components/editor-blocks/src/components/source-view/format-url/youtube.ts @@ -1,5 +1,6 @@ export const isYoutubeUrl = (url?: string): boolean => { - return url.includes('youtu.be') || url.includes('youtube.com'); + const allowedHosts = ['youtu.be', 'youtube.com']; + return allowedHosts.includes(url); }; const _regexp = /.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#&?]*).*/; diff --git a/! b/! new file mode 100644 index 0000000000..e69de29bb2 From a17ec1c5f9a6f2c5cf3e967c22a77c878b74bb19 Mon Sep 17 00:00:00 2001 From: tzhangchi Date: Wed, 17 Aug 2022 10:18:02 +0800 Subject: [PATCH 16/21] fix(youtube): Incomplete URL substring sanitization --- libs/components/editor-blocks/src/blocks/youtube/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/components/editor-blocks/src/blocks/youtube/index.ts b/libs/components/editor-blocks/src/blocks/youtube/index.ts index 363e7d78a9..26e4117961 100644 --- a/libs/components/editor-blocks/src/blocks/youtube/index.ts +++ b/libs/components/editor-blocks/src/blocks/youtube/index.ts @@ -19,7 +19,9 @@ export class YoutubeBlock extends BaseView { const tag_name = el.tagName; if (tag_name === 'A' && el.parentElement?.childElementCount === 1) { const href = el.getAttribute('href'); - if (href.indexOf('.youtube.com') !== -1) { + const allowedHosts = ['.youtube.com']; + + if (allowedHosts.includes(href)) { return [ { type: this.type, From fd9ed2862f1da7a145ec0d729001a8b1b4c549d8 Mon Sep 17 00:00:00 2001 From: tzhangchi Date: Wed, 17 Aug 2022 10:35:12 +0800 Subject: [PATCH 17/21] fix(youtube): Incomplete URL substring sanitization --- libs/components/editor-blocks/src/blocks/youtube/index.ts | 7 ++++--- .../src/components/source-view/format-url/youtube.ts | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libs/components/editor-blocks/src/blocks/youtube/index.ts b/libs/components/editor-blocks/src/blocks/youtube/index.ts index 26e4117961..42f22bcda4 100644 --- a/libs/components/editor-blocks/src/blocks/youtube/index.ts +++ b/libs/components/editor-blocks/src/blocks/youtube/index.ts @@ -1,9 +1,9 @@ +import { Protocol } from '@toeverything/datasource/db-service'; import { AsyncBlock, BaseView, SelectBlock, } from '@toeverything/framework/virgo'; -import { Protocol } from '@toeverything/datasource/db-service'; import { YoutubeView } from './YoutubeView'; export class YoutubeBlock extends BaseView { @@ -19,9 +19,10 @@ export class YoutubeBlock extends BaseView { const tag_name = el.tagName; if (tag_name === 'A' && el.parentElement?.childElementCount === 1) { const href = el.getAttribute('href'); - const allowedHosts = ['.youtube.com']; + const allowedHosts = ['www.youtu.be', 'www.youtube.com']; + const host = new URL(href).host; - if (allowedHosts.includes(href)) { + if (allowedHosts.includes(host)) { return [ { type: this.type, diff --git a/libs/components/editor-blocks/src/components/source-view/format-url/youtube.ts b/libs/components/editor-blocks/src/components/source-view/format-url/youtube.ts index 202f0dc968..56f165a515 100644 --- a/libs/components/editor-blocks/src/components/source-view/format-url/youtube.ts +++ b/libs/components/editor-blocks/src/components/source-view/format-url/youtube.ts @@ -1,6 +1,7 @@ export const isYoutubeUrl = (url?: string): boolean => { - const allowedHosts = ['youtu.be', 'youtube.com']; - return allowedHosts.includes(url); + const allowedHosts = ['www.youtu.be', 'www.youtube.com']; + const host = new URL(url).host; + return allowedHosts.includes(host); }; const _regexp = /.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#&?]*).*/; From 2f17534394b3c69700fb60e467cf54e6231e5c5e Mon Sep 17 00:00:00 2001 From: tzhangchi Date: Wed, 17 Aug 2022 10:37:04 +0800 Subject: [PATCH 18/21] fix(figma): Incomplete URL substring sanitization --- libs/components/editor-blocks/src/blocks/figma/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/components/editor-blocks/src/blocks/figma/index.ts b/libs/components/editor-blocks/src/blocks/figma/index.ts index b3e0b76b8d..3ed44c9c85 100644 --- a/libs/components/editor-blocks/src/blocks/figma/index.ts +++ b/libs/components/editor-blocks/src/blocks/figma/index.ts @@ -1,9 +1,9 @@ +import { Protocol } from '@toeverything/datasource/db-service'; import { AsyncBlock, BaseView, SelectBlock, } from '@toeverything/framework/virgo'; -import { Protocol, services } from '@toeverything/datasource/db-service'; import { FigmaView } from './FigmaView'; export class FigmaBlock extends BaseView { @@ -19,7 +19,10 @@ export class FigmaBlock extends BaseView { const tag_name = el.tagName; if (tag_name === 'A' && el.parentElement?.childElementCount === 1) { const href = el.getAttribute('href'); - if (href.indexOf('.figma.com') !== -1) { + const allowedHosts = ['www.figma.com']; + const host = new URL(href).host; + + if (allowedHosts.includes(host)) { return [ { type: this.type, From 137f48c33879f6237f761fd8514d8556ef2755b4 Mon Sep 17 00:00:00 2001 From: Whitewater Date: Wed, 17 Aug 2022 11:01:41 +0800 Subject: [PATCH 19/21] chore: remove unused file --- ! | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 ! diff --git a/! b/! deleted file mode 100644 index e69de29bb2..0000000000 From bb9495e69c523b6966d422a2655cacc6713e4164 Mon Sep 17 00:00:00 2001 From: DiamondThree Date: Wed, 17 Aug 2022 17:01:59 +0800 Subject: [PATCH 20/21] fix delete Regex --- libs/components/board-state/src/tldraw-app.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/libs/components/board-state/src/tldraw-app.ts b/libs/components/board-state/src/tldraw-app.ts index 366b7c67f5..32e170e668 100644 --- a/libs/components/board-state/src/tldraw-app.ts +++ b/libs/components/board-state/src/tldraw-app.ts @@ -15,13 +15,13 @@ import { TLPointerEventHandler, TLShapeCloneHandler, TLWheelEventHandler, - Utils, + Utils } from '@tldraw/core'; import { Vec } from '@tldraw/vec'; import { clearPrevSize, defaultStyle, - shapeUtils, + shapeUtils } from '@toeverything/components/board-shapes'; import { AlignType, @@ -54,7 +54,7 @@ import { TDUser, TldrawCommand, USER_COLORS, - VIDEO_EXTENSIONS, + VIDEO_EXTENSIONS } from '@toeverything/components/board-types'; import { MIN_PAGE_WIDTH } from '@toeverything/components/editor-core'; import { @@ -67,7 +67,7 @@ import { migrate, openAssetFromFileSystem, openFromFileSystem, - saveToFileSystem, + saveToFileSystem } from './data'; import { getClipboard, setClipboard } from './idb-clipboard'; import { StateManager } from './manager/state-manager'; @@ -3779,7 +3779,7 @@ export class TldrawApp extends StateManager { const svgString = await fileToText(file); const viewBoxAttribute = this.get_viewbox_from_svg(svgString); - + if (viewBoxAttribute) { viewBox = viewBoxAttribute.split(' '); size[0] = parseFloat(viewBox[2]); @@ -3840,12 +3840,10 @@ export class TldrawApp extends StateManager { }; private get_viewbox_from_svg = (svgStr: string | ArrayBuffer | null) => { - const viewBoxRegex = - /.*?viewBox=["'](-?[\d.]+[, ]+-?[\d.]+[, ][\d.]+[, ][\d.]+)["']/; - + if (typeof svgStr === 'string') { - const matches = svgStr.match(viewBoxRegex); - return matches && matches.length >= 2 ? matches[1] : null; + let viewBox = (new DOMParser()).parseFromString(svgStr, "text/xml") + return viewBox.children[0].getAttribute('viewBox') } console.warn('could not get viewbox from svg string'); From eb20ce01b9a1118889440ba2f27e6d013b7a8278 Mon Sep 17 00:00:00 2001 From: DiamondThree Date: Wed, 17 Aug 2022 17:06:32 +0800 Subject: [PATCH 21/21] fix delete Regex --- libs/components/board-state/src/tldraw-app.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libs/components/board-state/src/tldraw-app.ts b/libs/components/board-state/src/tldraw-app.ts index 32e170e668..e4b7a8a34f 100644 --- a/libs/components/board-state/src/tldraw-app.ts +++ b/libs/components/board-state/src/tldraw-app.ts @@ -15,13 +15,13 @@ import { TLPointerEventHandler, TLShapeCloneHandler, TLWheelEventHandler, - Utils + Utils, } from '@tldraw/core'; import { Vec } from '@tldraw/vec'; import { clearPrevSize, defaultStyle, - shapeUtils + shapeUtils, } from '@toeverything/components/board-shapes'; import { AlignType, @@ -54,7 +54,7 @@ import { TDUser, TldrawCommand, USER_COLORS, - VIDEO_EXTENSIONS + VIDEO_EXTENSIONS, } from '@toeverything/components/board-types'; import { MIN_PAGE_WIDTH } from '@toeverything/components/editor-core'; import { @@ -67,7 +67,7 @@ import { migrate, openAssetFromFileSystem, openFromFileSystem, - saveToFileSystem + saveToFileSystem, } from './data'; import { getClipboard, setClipboard } from './idb-clipboard'; import { StateManager } from './manager/state-manager'; @@ -3779,7 +3779,7 @@ export class TldrawApp extends StateManager { const svgString = await fileToText(file); const viewBoxAttribute = this.get_viewbox_from_svg(svgString); - + if (viewBoxAttribute) { viewBox = viewBoxAttribute.split(' '); size[0] = parseFloat(viewBox[2]); @@ -3840,10 +3840,9 @@ export class TldrawApp extends StateManager { }; private get_viewbox_from_svg = (svgStr: string | ArrayBuffer | null) => { - if (typeof svgStr === 'string') { - let viewBox = (new DOMParser()).parseFromString(svgStr, "text/xml") - return viewBox.children[0].getAttribute('viewBox') + let viewBox = new DOMParser().parseFromString(svgStr, 'text/xml'); + return viewBox.children[0].getAttribute('viewBox'); } console.warn('could not get viewbox from svg string');