-
-
Notifications
You must be signed in to change notification settings - Fork 757
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/npm_and_yarn/npm_and_yarn-securit…
…y-group-29ffd4c3ca
- Loading branch information
Showing
29 changed files
with
470 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@udecode/plate-serializer-html": patch | ||
--- | ||
|
||
Fixes "The `useSlateStatic` hook must be used inside the <Slate> component's context." error in `serializeHtml` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@udecode/plate-indent-list": minor | ||
"@udecode/plate-indent": minor | ||
--- | ||
|
||
Feature: todo lists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
apps/www/src/registry/default/plate-ui/indent-todo-marker-component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { IMarkerComponentProps } from '@udecode/plate-indent-list'; | ||
|
||
import { Checkbox } from './checkbox'; | ||
|
||
export const TodoMarker = (props: IMarkerComponentProps) => { | ||
const { onChange, checked } = props; | ||
return ( | ||
<Checkbox | ||
style={{ left: -24, top: 4, position: 'absolute' }} | ||
onCheckedChange={onChange} | ||
checked={checked} | ||
/> | ||
); | ||
}; |
22 changes: 22 additions & 0 deletions
22
apps/www/src/registry/default/plate-ui/indent-todo-toolbar-button.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { | ||
useIndentTodoToolBarButton, | ||
useIndentTodoToolBarButtonState, | ||
} from '@udecode/plate-indent-list'; | ||
import { withRef } from '@udecode/react-utils'; | ||
|
||
import { Icons } from '@/components/icons'; | ||
|
||
import { ToolbarButton } from './toolbar'; | ||
|
||
export const IndentTodoToolbarButton = withRef<typeof ToolbarButton>( | ||
(rest, ref) => { | ||
const state = useIndentTodoToolBarButtonState({ nodeType: 'todo' }); | ||
const { props } = useIndentTodoToolBarButton(state); | ||
|
||
return ( | ||
<ToolbarButton ref={ref} tooltip="Todo" {...props} {...rest}> | ||
<Icons.todo /> | ||
</ToolbarButton> | ||
); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/indent-list/src/delete-backward/deleteBackwardIndentList.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { | ||
getAboveNode, | ||
getNodeString, | ||
isCollapsed, | ||
isDefined, | ||
PlateEditor, | ||
Value, | ||
} from '@udecode/plate-common'; | ||
import { TextUnit } from 'slate'; | ||
|
||
import { KEY_LIST_STYLE_TYPE } from '../createIndentListPlugin'; | ||
import { outdentList } from '../transforms'; | ||
|
||
export const deleteBackwardIndentList = <V extends Value>( | ||
editor: PlateEditor<V> | ||
) => { | ||
const { deleteBackward } = editor; | ||
|
||
return function (unit: TextUnit) { | ||
deleteBackwardHelper(editor); | ||
deleteBackward(unit); | ||
}; | ||
}; | ||
|
||
function deleteBackwardHelper<V extends Value>(editor: PlateEditor<V>) { | ||
if (isCollapsed(editor.selection)) { | ||
const str = getNodeString(editor); | ||
if (str) return; | ||
const entry = getAboveNode(editor); | ||
if (!entry) return; | ||
const node = entry[0]; | ||
if (isDefined(node[KEY_LIST_STYLE_TYPE])) { | ||
outdentList(editor); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { PlateEditor, someNode, Value } from '@udecode/plate-common'; | ||
|
||
import { | ||
KEY_LIST_CHECKED, | ||
KEY_LIST_STYLE_TYPE, | ||
KEY_TODO_STYLE_TYPE, | ||
} from '../index'; | ||
|
||
export const someIndentTodo = <V extends Value>( | ||
editor: PlateEditor<V>, | ||
type: string | ||
) => { | ||
return someNode(editor, { | ||
at: editor.selection!, | ||
match: (n) => { | ||
const list = n[KEY_LIST_STYLE_TYPE]; | ||
const isHasProperty = n.hasOwnProperty(KEY_LIST_CHECKED); | ||
return n.type === 'p' && isHasProperty && list === KEY_TODO_STYLE_TYPE; | ||
}, | ||
}); | ||
}; |
37 changes: 37 additions & 0 deletions
37
packages/indent-list/src/hooks/useIndentTodoToolbarButton.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { useEditorRef, useEditorSelector } from '@udecode/plate-common'; | ||
|
||
import { ListStyleType, toggleIndentList } from '../index'; | ||
import { someIndentTodo } from './someIndentTodo'; | ||
|
||
export const useIndentTodoToolBarButtonState = ({ | ||
nodeType = ListStyleType.Disc, | ||
}: { nodeType?: string } = {}) => { | ||
const pressed = useEditorSelector( | ||
(editor) => someIndentTodo(editor, nodeType), | ||
[nodeType] | ||
); | ||
return { | ||
pressed, | ||
nodeType, | ||
}; | ||
}; | ||
|
||
export const useIndentTodoToolBarButton = ({ | ||
nodeType, | ||
pressed, | ||
}: ReturnType<typeof useIndentTodoToolBarButtonState>) => { | ||
const editor = useEditorRef(); | ||
return { | ||
props: { | ||
pressed, | ||
onMouseDown: (e: React.MouseEvent<HTMLButtonElement>) => { | ||
e.preventDefault(); | ||
}, | ||
onClick: () => { | ||
toggleIndentList(editor, { | ||
listStyleType: nodeType, | ||
}); | ||
}, | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.