Skip to content

Commit 7291340

Browse files
committed
fix
1 parent 95f7ca9 commit 7291340

File tree

10 files changed

+39
-6
lines changed

10 files changed

+39
-6
lines changed

.changeset/cuddly-weeks-jam.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@udecode/plate-link': patch
3+
---
4+
5+
- Fix floating link insert
6+
- Hide floating link edit when clicking outside

.changeset/curly-dolls-laugh.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@udecode/plate-resizable': patch
3+
---
4+
5+
Hide ResizeHandle when read-only

.changeset/rare-lemons-smell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@udecode/plate-floating': patch
3+
---
4+
5+
Add `getDOMSelectionBoundingClientRect`

apps/www/content/docs/components/changelog.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ Use the [CLI](https://platejs.org/docs/components/cli) to install the latest ver
1414
### October 10 #15.3
1515

1616
- `dropdown-menu`(`DropdownMenuContent`): prevent default on `onCloseAutoFocus`
17-
- `floating-toolbar`(`FloatingToolbar`): remove portal, hide on click outside
17+
- `floating-toolbar`(`FloatingToolbar`): remove portal, hide on click outside, hide when floating link open
1818
- `turn-into-dropdown-menu`(`TurnIntoDropdownMenu`): add indent list items
19+
- `table-dropdown-menu`(`TableDropdownMenu`): select in `insertTable`
1920

2021
### October 4 #15.2
2122

apps/www/src/components/plate-ui/playground-insert-dropdown-menu.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,23 @@ export function PlaygroundInsertDropdownMenu(props: DropdownMenuProps) {
203203
break;
204204
}
205205
case CodeBlockPlugin.key: {
206-
insertEmptyCodeBlock(editor);
206+
insertEmptyCodeBlock(editor, {
207+
insertNodesOptions: { select: true },
208+
});
207209

208210
break;
209211
}
210212
case ImagePlugin.key: {
211-
await insertMedia(editor, { type: ImagePlugin.key });
213+
await insertMedia(editor, {
214+
select: true,
215+
type: ImagePlugin.key,
216+
});
212217

213218
break;
214219
}
215220
case MediaEmbedPlugin.key: {
216221
await insertMedia(editor, {
222+
select: true,
217223
type: MediaEmbedPlugin.key,
218224
});
219225

@@ -239,7 +245,7 @@ export function PlaygroundInsertDropdownMenu(props: DropdownMenuProps) {
239245
break;
240246
}
241247
case TablePlugin.key: {
242-
insertTable(editor);
248+
insertTable(editor, {}, { select: true });
243249

244250
break;
245251
}

apps/www/src/registry/default/plate-ui/floating-toolbar.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { cn, withRef } from '@udecode/cn';
66
import {
77
useComposedRef,
88
useEditorId,
9+
useEditorRef,
910
useEventEditorSelectors,
1011
} from '@udecode/plate-common/react';
1112
import {
@@ -15,6 +16,7 @@ import {
1516
useFloatingToolbar,
1617
useFloatingToolbarState,
1718
} from '@udecode/plate-floating';
19+
import { LinkPlugin } from '@udecode/plate-link/react';
1820

1921
import { Toolbar } from './toolbar';
2022

@@ -24,12 +26,15 @@ export const FloatingToolbar = withRef<
2426
state?: FloatingToolbarState;
2527
}
2628
>(({ children, state, ...props }, componentRef) => {
29+
const editor = useEditorRef();
2730
const editorId = useEditorId();
2831
const focusedEditorId = useEventEditorSelectors.focus();
32+
const isFloatingLinkOpen = !!editor.useOption(LinkPlugin, 'mode');
2933

3034
const floatingToolbarState = useFloatingToolbarState({
3135
editorId,
3236
focusedEditorId,
37+
hideToolbar: isFloatingLinkOpen,
3338
...state,
3439
floatingOptions: {
3540
middleware: [

apps/www/src/registry/default/plate-ui/table-dropdown-menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function TableDropdownMenu(props: DropdownMenuProps) {
6161
<DropdownMenuItem
6262
className="min-w-[180px]"
6363
onSelect={() => {
64-
insertTable(editor);
64+
insertTable(editor, {}, { select: true });
6565
focusEditor(editor);
6666
}}
6767
>

packages/floating/src/utils/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
export * from './createVirtualRef';
66
export * from './getBoundingClientRect';
7-
export * from './getDOMSelectionBoundingClientRect copy';
7+
export * from './getDOMSelectionBoundingClientRect';
88
export * from './getRangeBoundingClientRect';
99
export * from './getSelectionBoundingClientRect';
1010
export * from './makeClientRect';

packages/resizable/src/components/ResizeHandle.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
createAtomStore,
77
createPrimitiveComponent,
88
} from '@udecode/plate-common/react';
9+
import { useReadOnly } from 'slate-react';
910

1011
import type { ResizeDirection, ResizeEvent } from '../types';
1112

@@ -43,6 +44,7 @@ export const useResizeHandleState = ({
4344
onResize: onResizeProp,
4445
onTouchStart,
4546
}: ResizeHandleOptions) => {
47+
const readOnly = useReadOnly();
4648
const onResizeStore = useResizeHandleStore().get.onResize();
4749
const onResize = onResizeProp ?? onResizeStore;
4850

@@ -110,6 +112,7 @@ export const useResizeHandleState = ({
110112
initialSize,
111113
isHorizontal,
112114
isResizing,
115+
readOnly,
113116
setInitialPosition,
114117
setInitialSize,
115118
setIsResizing,
@@ -124,6 +127,7 @@ export const useResizeHandleState = ({
124127
export const useResizeHandle = ({
125128
isHorizontal,
126129
isResizing,
130+
readOnly,
127131
setInitialPosition,
128132
setInitialSize,
129133
setIsResizing,
@@ -167,6 +171,7 @@ export const useResizeHandle = ({
167171
};
168172

169173
return {
174+
hidden: readOnly,
170175
props: {
171176
onMouseDown: handleMouseDown,
172177
onMouseOut: handleMouseOut,

0 commit comments

Comments
 (0)