-
Notifications
You must be signed in to change notification settings - Fork 781
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3289 from udecode/sync
sync
- Loading branch information
Showing
36 changed files
with
787 additions
and
37 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-selection": patch | ||
--- | ||
|
||
Fix: can't close menu in production build |
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-caption": minor | ||
--- | ||
|
||
Add `showCaption` utils |
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-math": minor | ||
--- | ||
|
||
Add `inline-equation` toolbar button |
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-media": minor | ||
--- | ||
|
||
Add image preview |
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
148 changes: 148 additions & 0 deletions
148
apps/www/src/registry/default/plate-ui/image-preview.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,148 @@ | ||
import { cn, createPrimitiveComponent } from '@udecode/cn'; | ||
import { | ||
PreviewImage, | ||
useImagePreview, | ||
useImagePreviewState, | ||
useScaleInput, | ||
useScaleInputState, | ||
} from '@udecode/plate-media'; | ||
import { cva } from 'class-variance-authority'; | ||
|
||
import { Icons } from '@/components/icons'; | ||
|
||
const toolButtonVariants = cva('rounded bg-[rgba(0,0,0,0.5)] px-1', { | ||
defaultVariants: { | ||
variant: 'default', | ||
}, | ||
variants: { | ||
variant: { | ||
default: 'text-white', | ||
disabled: 'cursor-not-allowed text-gray-400', | ||
}, | ||
}, | ||
}); | ||
|
||
const ScaleInput = createPrimitiveComponent('input')({ | ||
propsHook: useScaleInput, | ||
stateHook: useScaleInputState, | ||
}); | ||
|
||
const SCROLL_SPEED = 4; | ||
|
||
export const ImagePreview = () => { | ||
const state = useImagePreviewState({ scrollSpeed: SCROLL_SPEED }); | ||
|
||
const { | ||
closeProps, | ||
currentUrlIndex, | ||
maskLayerProps, | ||
nextDisabled, | ||
nextProps, | ||
prevDisabled, | ||
prevProps, | ||
scaleTextProps, | ||
zommOutProps, | ||
zoomInDisabled, | ||
zoomInProps, | ||
zoomOutDisabled, | ||
} = useImagePreview(state); | ||
|
||
const { isOpen, scale } = state; | ||
|
||
return ( | ||
<div | ||
className={cn( | ||
'fixed left-0 top-0 z-50 h-screen w-screen', | ||
!isOpen && 'hidden' | ||
)} | ||
{...maskLayerProps} | ||
> | ||
<div className="absolute inset-0 size-full bg-black opacity-30"></div> | ||
<div className="absolute inset-0 size-full bg-black opacity-30"></div> | ||
<div className="absolute inset-0 flex items-center justify-center "> | ||
<div className="relative flex max-h-screen w-full items-center"> | ||
<PreviewImage | ||
className={cn( | ||
'mx-auto block max-h-[calc(100vh-4rem)] w-auto object-contain transition-transform' | ||
)} | ||
/> | ||
<div | ||
className="absolute bottom-0 left-1/2 z-40 flex w-fit -translate-x-1/2 justify-center gap-4 p-2 text-center text-white" | ||
onClick={(e) => e.stopPropagation()} | ||
> | ||
<div className="flex gap-1 "> | ||
<button | ||
{...prevProps} | ||
className={cn( | ||
toolButtonVariants({ | ||
variant: prevDisabled ? 'disabled' : 'default', | ||
}) | ||
)} | ||
type="button" | ||
> | ||
<Icons.arrowLeft className="size-5" /> | ||
</button> | ||
{(currentUrlIndex ?? 0) + 1} | ||
<button | ||
{...nextProps} | ||
className={cn( | ||
toolButtonVariants({ | ||
variant: nextDisabled ? 'disabled' : 'default', | ||
}) | ||
)} | ||
type="button" | ||
> | ||
<Icons.arrowRight className="size-5" /> | ||
</button> | ||
</div> | ||
<div className="flex "> | ||
<button | ||
className={cn( | ||
toolButtonVariants({ | ||
variant: zoomOutDisabled ? 'disabled' : 'default', | ||
}) | ||
)} | ||
{...zommOutProps} | ||
type="button" | ||
> | ||
<Icons.minus className="size-4" /> | ||
</button> | ||
<div className="mx-px"> | ||
{state.isEditingScale ? ( | ||
<> | ||
<ScaleInput className="w-10 rounded px-1 text-slate-500 outline" />{' '} | ||
<span>%</span> | ||
</> | ||
) : ( | ||
<span {...scaleTextProps}>{scale * 100 + '%'}</span> | ||
)} | ||
</div> | ||
<button | ||
className={cn( | ||
toolButtonVariants({ | ||
variant: zoomInDisabled ? 'disabled' : 'default', | ||
}) | ||
)} | ||
{...zoomInProps} | ||
type="button" | ||
> | ||
<Icons.add className="size-4" /> | ||
</button> | ||
</div> | ||
{/* TODO: downLoad the image */} | ||
<button className={cn(toolButtonVariants())} type="button"> | ||
<Icons.downLoad className="size-4" /> | ||
</button> | ||
<button | ||
{...closeProps} | ||
className={cn(toolButtonVariants())} | ||
type="button" | ||
> | ||
<Icons.close className="size-4" /> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
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,5 @@ | ||
/** | ||
* @file Automatically generated by barrelsby. | ||
*/ | ||
|
||
export * from './showCaption'; |
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,16 @@ | ||
import { | ||
type PlateEditor, | ||
type TElement, | ||
findNodePath, | ||
} from '@udecode/plate-common'; | ||
|
||
import { captionActions, captionGlobalStore } from '../captionGlobalStore'; | ||
|
||
export const showCaption = (editor: PlateEditor, element: TElement) => { | ||
const path = findNodePath(editor, element); | ||
captionActions.showCaptionId(element.id as string); | ||
|
||
setTimeout(() => { | ||
path && captionGlobalStore.set.focusEndCaptionPath(path); | ||
}, 0); | ||
}; |
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
22 changes: 22 additions & 0 deletions
22
packages/math/src/inline-equation/components/useInlineEquationToolbarButton.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,22 @@ | ||
import { getSelectionText, useEditorRef } from '@udecode/plate-common'; | ||
|
||
import { insertInlineEquation } from '../transforms'; | ||
|
||
export const useInlineToolbarButtonState = () => { | ||
const editor = useEditorRef(); | ||
|
||
return { editor }; | ||
}; | ||
|
||
export const useInlineToolbarButton = ({ | ||
editor, | ||
}: ReturnType<typeof useInlineToolbarButtonState>) => { | ||
return { | ||
props: { | ||
onClick: () => { | ||
const texExpression = getSelectionText(editor); | ||
insertInlineEquation(editor, texExpression); | ||
}, | ||
}, | ||
}; | ||
}; |
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
Oops, something went wrong.