mirror of
https://github.com/penxio/penx.git
synced 2026-04-19 03:03:06 -04:00
fix: fix add node
This commit is contained in:
@@ -21,7 +21,7 @@ export function AddCreationButton({ className }: Props) {
|
||||
className,
|
||||
)}
|
||||
onClick={() => {
|
||||
addCreation({ type: StructType.PAGE })
|
||||
addCreation({ type: StructType.PAGE, isAddPanel: true })
|
||||
}}
|
||||
>
|
||||
<PlusIcon size={20} className="" />
|
||||
|
||||
@@ -111,7 +111,7 @@ export function Creation({ panel, className, ref, editorFooter }: Props) {
|
||||
|
||||
<div
|
||||
className={cn(
|
||||
'creation-container relative z-0 flex-1 flex-col overflow-y-auto overflow-x-hidden px-3 pb-40 md:px-8',
|
||||
'creation-container relative z-0 flex-1 flex-col overflow-y-auto overflow-x-hidden px-3 pb-40 pt-14 md:px-8',
|
||||
isMobileApp && 'px-3 pt-0',
|
||||
className,
|
||||
)}
|
||||
@@ -125,7 +125,7 @@ export function Creation({ panel, className, ref, editorFooter }: Props) {
|
||||
{!hideTitle && (
|
||||
<div className="mb-2 flex flex-col space-y-3 md:mb-5">
|
||||
<div className="relative">
|
||||
{!isImage && !isMobileApp && (
|
||||
{/* {!isImage && !isMobileApp && (
|
||||
<CoverUpload
|
||||
creation={creation}
|
||||
isCover={isCover}
|
||||
@@ -135,7 +135,7 @@ export function Creation({ panel, className, ref, editorFooter }: Props) {
|
||||
})
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
)} */}
|
||||
<div className="flex items-center gap-2">
|
||||
{struct?.type === StructType.TASK && (
|
||||
<Checkbox
|
||||
|
||||
@@ -95,6 +95,7 @@ export function JournalQuickInput({
|
||||
onKeyDown={(event) => {
|
||||
if (
|
||||
event.key === 'Enter' &&
|
||||
(event.ctrlKey || event.metaKey) &&
|
||||
!event.shiftKey &&
|
||||
!event.nativeEvent.isComposing
|
||||
) {
|
||||
|
||||
@@ -194,7 +194,8 @@ export const WidgetItem = forwardRef<HTMLDivElement, Props>(
|
||||
appEmitter.emit('ROUTE_TO_STRUCT')
|
||||
store.panels.openStruct(struct.id)
|
||||
} else {
|
||||
setVisible(!visible)
|
||||
// setVisible(!visible)
|
||||
store.panels.openStruct(struct.id)
|
||||
}
|
||||
setStruct(struct)
|
||||
}}
|
||||
|
||||
@@ -28,7 +28,7 @@ export function StructList({ onSelect }: Props) {
|
||||
>
|
||||
<div>{struct.name}</div>
|
||||
|
||||
<TooltipProvider>
|
||||
{/* <TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
@@ -48,7 +48,7 @@ export function StructList({ onSelect }: Props) {
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>Open in new panel</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
</TooltipProvider> */}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -12,7 +12,7 @@ export const ViewToolBar = () => {
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-1">
|
||||
<HideField />
|
||||
{/* <HideField /> */}
|
||||
{/* <FilterField /> */}
|
||||
{/* <SortField /> */}
|
||||
{/* <GroupField /> */}
|
||||
|
||||
@@ -51,14 +51,6 @@ export function NoteGalleryView({ struct }: PostListProps) {
|
||||
>
|
||||
<NoteList />
|
||||
</div>
|
||||
|
||||
{!isMobileApp && (
|
||||
<div className="px-6 pb-2">
|
||||
<div className="mx-auto flex w-full max-w-2xl flex-col gap-2">
|
||||
<NoteInput />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -29,7 +29,7 @@ export function TasksList({ struct }: PostListProps) {
|
||||
<div className="relative flex-1">
|
||||
<div className="absolute bottom-0 left-0 right-0 top-0 flex h-full flex-1 flex-col">
|
||||
{!tasks.length && (
|
||||
<div className="text-foreground/60">
|
||||
<div className="text-foreground/60 px-3">
|
||||
<Trans id="No task yet."></Trans>
|
||||
</div>
|
||||
)}
|
||||
@@ -40,11 +40,6 @@ export function TasksList({ struct }: PostListProps) {
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
<div className="px-6 pb-2">
|
||||
<div className="sticky bottom-0 mx-auto flex w-full max-w-2xl flex-col gap-2">
|
||||
<TaskInput />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
"@penx/uikit": "workspace:*",
|
||||
"@penx/libs": "workspace:*",
|
||||
"@penx/editor-plugins": "workspace:*",
|
||||
"@penx/novel-editor": "workspace:*",
|
||||
"@penx/editor-custom-plugins": "workspace:*",
|
||||
"@penx/unique-id": "workspace:*",
|
||||
"@penx/trpc-client": "workspace:*",
|
||||
|
||||
@@ -8,17 +8,10 @@ import {
|
||||
import Image from 'next/image'
|
||||
import { BaseBidirectionalLinkPlugin } from '@penx/editor-custom-plugins/bidirectional-link/lib/BaseBidirectionalLinkPlugin'
|
||||
import { BaseProductPlugin } from '@penx/editor-custom-plugins/product/lib/BaseProductPlugin'
|
||||
import { NovelEditor } from '@penx/novel-editor/NovelEditor'
|
||||
import { cn, getUrl } from '@penx/utils'
|
||||
import { BidirectionalLinkElementStatic } from './bidirectional-link/bidirectional-link-static'
|
||||
import { components } from './components'
|
||||
import { serverSideComponents, serverSideEditor } from './server-side-editor'
|
||||
import { SlateContent } from './SlateContent'
|
||||
|
||||
interface Element {
|
||||
type: string
|
||||
id: string
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
interface Props {
|
||||
content: any
|
||||
@@ -40,23 +33,5 @@ export function ContentRender({ content, className }: Props) {
|
||||
)
|
||||
}
|
||||
|
||||
// console.log('========:>>content:', content)
|
||||
|
||||
const value: Element[] = Array.isArray(content)
|
||||
? content
|
||||
: JSON.parse(content)
|
||||
|
||||
return (
|
||||
<PlateStatic
|
||||
editor={serverSideEditor}
|
||||
components={{
|
||||
...serverSideComponents,
|
||||
[BaseBidirectionalLinkPlugin.key]: BidirectionalLinkElementStatic,
|
||||
}}
|
||||
// editor={editor}
|
||||
// components={components}
|
||||
value={value.map(({ id, ...rest }) => rest) as any}
|
||||
className={cn('break-all text-base', className)}
|
||||
/>
|
||||
)
|
||||
return <NovelEditor className="px-3" value={content} />
|
||||
}
|
||||
|
||||
@@ -97,6 +97,8 @@ export function useAddCreation() {
|
||||
if (isMobileApp && !input.content) {
|
||||
appEmitter.emit('ROUTE_TO_CREATION', newCreation)
|
||||
} else {
|
||||
console.log('add panellse......')
|
||||
|
||||
store.panels.addPanel({
|
||||
id: uniqueId(),
|
||||
type: PanelType.CREATION,
|
||||
|
||||
@@ -45,7 +45,9 @@ export function useJournal(date?: string) {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryKey: getQueryKey(),
|
||||
queryFn: async () => {
|
||||
return getOrCreateJournal(date ? new Date(date) : new Date())
|
||||
const journal = getOrCreateJournal(date ? new Date(date) : new Date())
|
||||
|
||||
return journal
|
||||
},
|
||||
})
|
||||
return { data, ...rest }
|
||||
@@ -55,8 +57,12 @@ export function getJournal() {
|
||||
return queryClient.getQueryData(getQueryKey()) as IJournalNode
|
||||
}
|
||||
|
||||
export function addCreationToJournal(creationId: string) {
|
||||
const journal = getJournal()
|
||||
export async function addCreationToJournal(creationId: string, date = '') {
|
||||
let journal = getJournal()
|
||||
if (!journal) {
|
||||
journal = await getOrCreateJournal(date ? new Date(date) : new Date())
|
||||
}
|
||||
|
||||
const newJournal = produce(journal, (draft) => {
|
||||
draft.props.children.unshift(creationId)
|
||||
})
|
||||
|
||||
17
packages/novel-editor/src/components/FocusHelper.tsx
Normal file
17
packages/novel-editor/src/components/FocusHelper.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useEffect } from 'react'
|
||||
import { Editor, useCurrentEditor } from '@tiptap/react'
|
||||
import { appEmitter } from '@penx/emitter'
|
||||
|
||||
export function FocusHelper() {
|
||||
const { editor } = useCurrentEditor()
|
||||
useEffect(() => {
|
||||
const handleFocus = () => {
|
||||
editor?.chain().focus().run()
|
||||
}
|
||||
appEmitter.on('FOCUS_EDITOR', handleFocus)
|
||||
return () => {
|
||||
appEmitter.off('FOCUS_EDITOR', handleFocus)
|
||||
}
|
||||
}, [])
|
||||
return null
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import { defaultEditorContent } from '@penx/constants'
|
||||
import { Separator } from '@penx/uikit/ui/separator'
|
||||
import { cn } from '@penx/utils'
|
||||
import { defaultExtensions } from './extensions'
|
||||
import { FocusHelper } from './FocusHelper'
|
||||
import GenerativeMenuSwitch from './generative/generative-menu-switch'
|
||||
import { uploadFn } from './image-upload'
|
||||
import { ColorSelector } from './selectors/color-selector'
|
||||
@@ -151,6 +152,7 @@ export const NovelEditor = ({
|
||||
<Separator orientation="vertical" />
|
||||
<ColorSelector open={openColor} onOpenChange={setOpenColor} />
|
||||
</GenerativeMenuSwitch>
|
||||
<FocusHelper />
|
||||
{children}
|
||||
</EditorContent>
|
||||
</EditorRoot>
|
||||
|
||||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@@ -1864,6 +1864,9 @@ importers:
|
||||
'@penx/libs':
|
||||
specifier: workspace:*
|
||||
version: link:../libs
|
||||
'@penx/novel-editor':
|
||||
specifier: workspace:*
|
||||
version: link:../novel-editor
|
||||
'@penx/session':
|
||||
specifier: workspace:*
|
||||
version: link:../session
|
||||
|
||||
Reference in New Issue
Block a user