There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(core): block sharing link cannot be created when selecting inline (#7090)
JimmFly412b919ec65e
diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor-container.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor-container.tsxindex b72f7366e8..693db046ad 100644--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor-container.tsx+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor-container.tsx@@ -1,5 +1,9 @@import { ViewService } from '@affine/core/modules/workbench/services/view';-import type { BaseSelection, BlockElement } from '@blocksuite/block-std';+import type {+ BaseSelection,+ BlockElement,+ TextSelection,+} from '@blocksuite/block-std';import type { Disposable } from '@blocksuite/global/utils';import type {AffineEditorContainer,@@ -102,6 +106,7 @@ export const BlocksuiteEditorContainer = forwardRef<ref) {const scrolledRef = useRef(false);+ const hashChangedRef = useRef(false);const rootRef = useRef<HTMLDivElement>(null);const docRef = useRef<PageEditor>(null);const edgelessRef = useRef<EdgelessEditor>(null);@@ -231,7 +236,12 @@ export const BlocksuiteEditorContainer = forwardRef<};affineEditorContainerProxy.updateComplete.then(() => {- if (blockElement && !scrolledRef.current && !canceled) {+ if (+ blockElement &&+ !scrolledRef.current &&+ !canceled &&+ !hashChangedRef.current+ ) {handleScrollToBlock(blockElement);scrolledRef.current = true;}@@ -258,14 +268,24 @@ export const BlocksuiteEditorContainer = forwardRef<) {return;}- if (selection[0]?.type !== 'block') {+ if (mode === 'edgeless') {if (locationHash) {- // Clear the hash if no block is selectedcurrentView.replace(currentPath);}return;}+ if (selection[0]?.type === 'text') {+ const textSelection = selection[0] as TextSelection;+ if (textSelection.from.length === 0) {+ // Clear the hash if no block is selected+ if (locationHash) {+ currentView.replace(currentPath);+ }+ return;+ }+ }+const selectedId = selection[0]?.blockId;if (!selectedId) {return;@@ -274,9 +294,11 @@ export const BlocksuiteEditorContainer = forwardRef<// Only update the hash if it has changedif (locationHash !== newHash) {+ hashChangedRef.current = true;currentView.replace(currentPath + newHash);}};+affineEditorContainerProxy.updateComplete.then(() => {const selectManager = affineEditorContainerProxy.host?.selection;@@ -290,7 +312,7 @@ export const BlocksuiteEditorContainer = forwardRef<canceled = true;disposable?.dispose();};- }, [affineEditorContainerProxy, currentView]);+ }, [affineEditorContainerProxy, currentView, mode]);return (<div