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
merge branch develop into branch feat/doublelink220820
xiaodong zuo3a9aa99ee9c7
diff --cc libs/components/editor-core/src/editor/block/block-helper.tsindex 032f496050,b9e7c12af9..9e3090b527--- a/libs/components/editor-core/src/editor/block/block-helper.ts+++ b/libs/components/editor-core/src/editor/block/block-helper.ts@@@ -11,7 -10,9 +11,9 @@@ importPoint,Selection as SlateSelection,} from 'slate';-import { Editor } from '../editor';+ import { AsyncBlock } from '../block';+import { Editor } from '../editor';+ import { SelectBlock } from '../selection';type TextUtilsFunctions =| 'getString'@@@ -43,7 -44,8 +45,9 @@@| 'setSelection'| 'insertNodes'| 'getNodeByPath'- | 'wrapLink';++ | 'wrapLink'+ | 'getNodeByRange'+ | 'convertLeaf2Html';type ExtendedTextUtils = SlateUtils & {setLinkModalVisible: (visible: boolean) => void;@@@ -113,6 -152,70 +154,70 @@@ export class BlockHelperreturn '';}+ public async getEditableBlockPropertiesBySelectInfo(+ block: AsyncBlock,+ selectInfo?: SelectBlock+ ) {+ const properties = block.getProperties();+ if (properties.text.value.length === 0) {+ return properties;+ }- let text_value = properties.text.value;++ const text_value = properties.text.value;++ const {+ text: { value: originTextValue, ...otherTextProperties },+ ...otherProperties+ } = properties;++ // Use deepClone method will throw incomprehensible error+ let textValue = JSON.parse(JSON.stringify(originTextValue));++ if (selectInfo?.endInfo) {+ textValue = textValue.slice(0, selectInfo.endInfo.arrayIndex + 1);+ textValue[textValue.length - 1].text = text_value[+ textValue.length - 1+ ].text.substring(0, selectInfo.endInfo.offset);+ }+ if (selectInfo?.startInfo) {+ textValue = textValue.slice(selectInfo.startInfo.arrayIndex);+ textValue[0].text = textValue[0].text.substring(+ selectInfo.startInfo.offset+ );+ }+ return {+ ...otherProperties,+ text: {+ ...otherTextProperties,+ value: textValue,+ },+ };+ }++ // For editable blocks, the properties containing the selected text will be returned with the selection information+ public async getBlockPropertiesBySelectInfo(selectBlockInfo: SelectBlock) {+ const block = await this._editor.getBlockById(selectBlockInfo.blockId);+ const blockView = this._editor.getView(block.type);+ if (blockView.editable) {+ return this.getEditableBlockPropertiesBySelectInfo(+ block,+ selectBlockInfo+ );+ } else {+ return block?.getProperties();+ }+ }++ public convertTextValue2Html(blockId: string, textValue: any) {+ const text_utils = this._blockTextUtilsMap[blockId];+ if (!text_utils) {+ return '';+ }+ return textValue.reduce((html: string, textValueItem: any) => {+ const fragment = text_utils.convertLeaf2Html(textValueItem);+ return `${html}${fragment}`;+ }, '');+ }+public setBlockBlur(blockId: string) {const text_utils = this._blockTextUtilsMap[blockId];if (text_utils) {diff --cc libs/components/editor-core/src/editor/types.tsindex 25c37b5172,86c795b615..9fe247fc08--- a/libs/components/editor-core/src/editor/types.ts+++ b/libs/components/editor-core/src/editor/types.ts@@@ -9,7 -9,12 +9,10 @@@* 6. Dependencies between plugins are not supported for the time being*/import type { PatchNode } from '@toeverything/components/ui';- import type { BlockFlavors } from '@toeverything/datasource/db-service';+ import type {+ BlockFlavors,+ ReturnEditorBlock,+ } from '@toeverything/datasource/db-service';-import type { IdList, SelectionInfo, SelectionManager } from './selection';-import { Point } from '@toeverything/utils';import { Observable } from 'rxjs';import type { AsyncBlock } from './block';diff --cc libs/components/editor-core/src/editor/views/base-view.tsindex df110cf87c,d4867f2b59..87bd55ebbc--- a/libs/components/editor-core/src/editor/views/base-view.ts+++ b/libs/components/editor-core/src/editor/views/base-view.ts@@@ -7,13 -4,12 +4,12 @@@ importBlockDecoration,MapOperation,} from '@toeverything/datasource/jwt';- import { cloneDeep } from '@toeverything/utils';-import type { ComponentType, ReactElement } from 'react';+import { ComponentType, ReactElement } from 'react';import type { EventData } from '../block';import { AsyncBlock } from '../block';+ import { HTML2BlockResult } from '../clipboard';import type { Editor } from '../editor';import { SelectBlock } from '../selection';-export interface CreateView {block: AsyncBlock;editor: Editor;diff --cc libs/components/layout/src/header/LayoutHeader.tsxindex efef6116b1,9619c97c84..a0b8997f90--- a/libs/components/layout/src/header/LayoutHeader.tsx+++ b/libs/components/layout/src/header/LayoutHeader.tsx@@@ -10,7 -11,8 +10,8 @@@ importuseLocalTrigger,useShowSettingsSidebar,} from '@toeverything/datasource/state';-+import { useCallback, useMemo } from 'react';+ import { useTranslation } from 'react-i18next';import { EditorBoardSwitcher } from './EditorBoardSwitcher';import { FileSystem, fsApiSupported } from './FileSystem';import { CurrentPageTitle } from './Title';@@@ -22,22 -25,14 +24,22 @@@ export const LayoutHeader = () =>const warningTips = useMemo(() => {if (!fsApiSupported()) {- return 'Welcome to the AFFiNE demo. To begin saving changes you can SYNC DATA TO DISK with the latest version of Chromium based browser like Chrome/Edge';+ return t('WarningTips.IsNotfsApiSupported');} else if (!isLocalWorkspace) {- return 'Welcome to the AFFiNE demo. To begin saving changes you can SYNC TO DISK.';+ return t('WarningTips.IsNotLocalWorkspace');} else {- return 'AFFiNE is under active development and the current version is UNSTABLE. Please DO NOT store information or data';+ return t('WarningTips.DoNotStore');}- }, [isLocalWorkspace]);+ }, [isLocalWorkspace, t]);+ const { currentEditors } = useCurrentEditors();++ const handleSearch = useCallback(() => {+ for (const key in currentEditors || {}) {+ currentEditors[key].getHooks().onSearch();+ }+ }, [currentEditors]);+return (<StyledContainerForHeaderRoot><StyledHeaderRoot>