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: #547
DiamondThree3fc70a7aade9
diff --git a/libs/components/editor-blocks/src/blocks/bullet/BulletView.tsx b/libs/components/editor-blocks/src/blocks/bullet/BulletView.tsxindex 94ba655006..143bebc0e2 100644--- a/libs/components/editor-blocks/src/blocks/bullet/BulletView.tsx+++ b/libs/components/editor-blocks/src/blocks/bullet/BulletView.tsx@@ -46,24 +46,24 @@ const BulletLeft = styled('div')(() => ({export const BulletView: FC<CreateView> = ({ block, editor }) => {// block.remove();const properties = { ...defaultBulletProps, ...block.getProperties() };- const text_ref = useRef<ExtendedTextUtils>(null);+ const textRef = useRef<ExtendedTextUtils>(null);// const [type, set_type] = useState('type-1');const [isSelect, setIsSelect] = useState<boolean>();useOnSelect(block.id, (is_select: boolean) => {setIsSelect(is_select);});- const turn_into_text_block = async () => {+ const turnIntoTextBlock = async () => {// Convert to text blockawait block.setType('text');await reset_todo_state(block);- if (!text_ref.current) {+ if (!textRef.current) {throw new Error('Failed to set cursor position! text_ref is not exist!');}- const currentSelection = text_ref.current.getStartSelection();+ const currentSelection = textRef.current.getStartSelection();if (!currentSelection) {throw new Error('Failed to get cursor selection! currentSelection is not exist!'@@ -82,28 +82,35 @@ export const BulletView: FC<CreateView> = ({ block, editor }) => {};const i = 0;const listChange = async () => {- const preBlock = await block.previousSiblings();- const parent_block = await block.parent();- let parent_number_type = parent_block.getProperty('numberType');- if (- !parent_number_type &&- parent_block.type === Protocol.Block.Type.bullet- ) {- parent_number_type = NumberType.type1;- parent_block.setProperty('numberType', parent_number_type);+ try {+ const parentBlock = await block.parent();+ if (!parentBlock) {+ return;+ }+ let parentNumberType = parentBlock.getProperty('numberType');+ if (+ !parentNumberType &&+ parentBlock.type === Protocol.Block.Type.bullet+ ) {+ parentNumberType = NumberType.type1;+ parentBlock.setProperty('numberType', parentNumberType);+ }+ block.setProperty('numberType', getChildrenType(parentNumberType));+ } catch (e) {+ // TODO+ console.log('undo redo bugfix');}- block.setProperty('numberType', getChildrenType(parent_number_type));};useEffect(() => {listChange();let obj: any;const parentChange = async () => {- const parent_block = await block.parent();+ const parentBlock = await block.parent();obj = await services.api.editorBlock.observe({workspace: editor.workspace,- id: parent_block.id,+ id: parentBlock.id,},listChange);@@ -115,16 +122,16 @@ export const BulletView: FC<CreateView> = ({ block, editor }) => {// console.log('_parent_block: ', _parent_block);}, []);- const on_text_enter: TextProps['handleEnter'] = async props => {+ const onTextEnter: TextProps['handleEnter'] = async props => {const { splitContents, isShiftKey } = props;if (isShiftKey) {return false;}const { contentBeforeSelection, contentAfterSelection } = splitContents;- const before = [...contentBeforeSelection.content];- const after = [...contentAfterSelection.content];+ const before = [...(contentBeforeSelection.content ?? '')];+ const after = [...(contentAfterSelection.content ?? '')];if (todoIsEmpty({ value: before } as ContentColumnValue)) {- await turn_into_text_block();+ await turnIntoTextBlock();return true;}@@ -149,15 +156,15 @@ export const BulletView: FC<CreateView> = ({ block, editor }) => {return true;};- const on_tab: TextProps['handleTab'] = async ({ isShiftKey }) => {+ const onTab: TextProps['handleTab'] = async ({ isShiftKey }) => {if (!isShiftKey) {const preSiblingBlock = await block.previousSibling();if (preSiblingBlock && supportChildren(preSiblingBlock)) {- const copy_block = block;+ const copyBlock = block;block.remove();block.removeChildren();- const block_children = await copy_block.children();- preSiblingBlock.append(copy_block, ...block_children);+ const blockChildren = await copyBlock.children();+ preSiblingBlock.append(copyBlock, ...blockChildren);}return true;} else {@@ -165,13 +172,13 @@ export const BulletView: FC<CreateView> = ({ block, editor }) => {}};- const on_backspace: TextProps['handleBackSpace'] = async ({+ const onBackspace: TextProps['handleBackSpace'] = async ({isCollAndStart,}) => {if (!isCollAndStart) {return false;}- await turn_into_text_block();+ await turnIntoTextBlock();return true;};@@ -184,14 +191,14 @@ export const BulletView: FC<CreateView> = ({ block, editor }) => {</BulletLeft><div className={'textContainer'}><TextManage- ref={text_ref}+ ref={textRef}editor={editor}block={block}supportMarkdownplaceholder="/Bullet list"- handleEnter={on_text_enter}- handleBackSpace={on_backspace}- handleTab={on_tab}+ handleEnter={onTextEnter}+ handleBackSpace={onBackspace}+ handleTab={onTab}/></div></List>