|
@@ -1,7 +1,7 @@
|
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
|
import { MagnifyingGlassIcon } from '@radix-ui/react-icons'
|
|
import { MagnifyingGlassIcon } from '@radix-ui/react-icons'
|
|
|
import { TLBoxShape, TLBoxShapeProps } from '@tldraw/core'
|
|
import { TLBoxShape, TLBoxShapeProps } from '@tldraw/core'
|
|
|
-import { HTMLContainer, TLComponentProps, useApp } from '@tldraw/react'
|
|
|
|
|
|
|
+import { HTMLContainer, TLComponentProps, TLContextBarProps, useApp } from '@tldraw/react'
|
|
|
import { makeObservable } from 'mobx'
|
|
import { makeObservable } from 'mobx'
|
|
|
import { observer } from 'mobx-react-lite'
|
|
import { observer } from 'mobx-react-lite'
|
|
|
import * as React from 'react'
|
|
import * as React from 'react'
|
|
@@ -93,7 +93,6 @@ const LogseqPortalShapeHeader = observer(
|
|
|
|
|
|
|
|
export class LogseqPortalShape extends TLBoxShape<LogseqPortalShapeProps> {
|
|
export class LogseqPortalShape extends TLBoxShape<LogseqPortalShapeProps> {
|
|
|
static id = 'logseq-portal'
|
|
static id = 'logseq-portal'
|
|
|
- static smart = true
|
|
|
|
|
|
|
|
|
|
static defaultProps: LogseqPortalShapeProps = {
|
|
static defaultProps: LogseqPortalShapeProps = {
|
|
|
id: 'logseq-portal',
|
|
id: 'logseq-portal',
|
|
@@ -133,6 +132,7 @@ export class LogseqPortalShape extends TLBoxShape<LogseqPortalShapeProps> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ReactContextBar = observer(() => {
|
|
ReactContextBar = observer(() => {
|
|
|
|
|
+ const app = useApp<Shape>()
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
<ColorInput
|
|
<ColorInput
|
|
@@ -142,6 +142,7 @@ export class LogseqPortalShape extends TLBoxShape<LogseqPortalShapeProps> {
|
|
|
this.update({
|
|
this.update({
|
|
|
fill: e.target.value,
|
|
fill: e.target.value,
|
|
|
})
|
|
})
|
|
|
|
|
+ app.persist(true)
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
<ColorInput
|
|
<ColorInput
|
|
@@ -151,6 +152,7 @@ export class LogseqPortalShape extends TLBoxShape<LogseqPortalShapeProps> {
|
|
|
this.update({
|
|
this.update({
|
|
|
stroke: e.target.value,
|
|
stroke: e.target.value,
|
|
|
})
|
|
})
|
|
|
|
|
+ app.persist(true)
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
<SwitchInput
|
|
<SwitchInput
|
|
@@ -164,6 +166,7 @@ export class LogseqPortalShape extends TLBoxShape<LogseqPortalShapeProps> {
|
|
|
size: [this.props.size[0], collapsing ? HEADER_HEIGHT : this.props.collapsedHeight],
|
|
size: [this.props.size[0], collapsing ? HEADER_HEIGHT : this.props.collapsedHeight],
|
|
|
collapsedHeight: collapsing ? originalHeight : this.props.collapsedHeight,
|
|
collapsedHeight: collapsing ? originalHeight : this.props.collapsedHeight,
|
|
|
})
|
|
})
|
|
|
|
|
+ app.persist()
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
</>
|
|
</>
|
|
@@ -180,7 +183,7 @@ export class LogseqPortalShape extends TLBoxShape<LogseqPortalShapeProps> {
|
|
|
const { Page } = React.useContext(LogseqContext)
|
|
const { Page } = React.useContext(LogseqContext)
|
|
|
const isSelected = app.selectedIds.has(this.id)
|
|
const isSelected = app.selectedIds.has(this.id)
|
|
|
const tlEventsEnabled =
|
|
const tlEventsEnabled =
|
|
|
- isMoving || (isSelected && !isEditing) || app.selectedTool.id !== 'select'
|
|
|
|
|
|
|
+ (isMoving || (isSelected && !isEditing) || app.selectedTool.id !== 'select') && !this.draft
|
|
|
const stop = React.useCallback(
|
|
const stop = React.useCallback(
|
|
|
e => {
|
|
e => {
|
|
|
if (!tlEventsEnabled) {
|
|
if (!tlEventsEnabled) {
|
|
@@ -210,14 +213,15 @@ export class LogseqPortalShape extends TLBoxShape<LogseqPortalShapeProps> {
|
|
|
}, [isEditing, this.props.collapsed])
|
|
}, [isEditing, this.props.collapsed])
|
|
|
|
|
|
|
|
const onPageNameChanged = React.useCallback((id: string) => {
|
|
const onPageNameChanged = React.useCallback((id: string) => {
|
|
|
|
|
+ app.history.resume()
|
|
|
app.wrapUpdate(() => {
|
|
app.wrapUpdate(() => {
|
|
|
|
|
+ this.setDraft(false)
|
|
|
this.update({
|
|
this.update({
|
|
|
pageId: id,
|
|
pageId: id,
|
|
|
size: [600, 320],
|
|
size: [600, 320],
|
|
|
blockType: 'P',
|
|
blockType: 'P',
|
|
|
})
|
|
})
|
|
|
- this.setDraft(false)
|
|
|
|
|
- app.clearEditingShape()
|
|
|
|
|
|
|
+ app.selectTool('select')
|
|
|
})
|
|
})
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
|