Преглед изворни кода

fix: editing ux enhancement

Peng Xiao пре 3 година
родитељ
комит
530140db91

+ 11 - 2
tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx

@@ -78,8 +78,16 @@ const EditAction = observer(() => {
       type="button"
       onClick={() => {
         app.api.editShape(shape)
+        app.api.zoomToSelection()
         if (shape.props.type === 'logseq-portal') {
-          window.logseq?.api?.edit_block?.(shape.props.pageId)
+          let uuid = shape.props.pageId
+          if (shape.props.blockType === 'P') {
+            const firstNonePropertyBlock = window.logseq?.api
+              ?.get_page_blocks_tree?.(shape.props.pageId)
+              .find(b => !('propertiesOrder' in b))
+            uuid = firstNonePropertyBlock.uuid
+          }
+          window.logseq?.api?.edit_block?.(uuid)
         }
       }}
     >
@@ -258,7 +266,8 @@ const SwatchAction = observer(() => {
     })
   }, [])
 
-  return <ColorInput value={shapes[0].props.fill} onChange={handleChange} />
+  const value = shapes[0].props.noFill ? shapes[0].props.stroke : shapes[0].props.fill
+  return <ColorInput value={value} onChange={handleChange} />
 })
 
 const StrokeTypeAction = observer(() => {

+ 1 - 1
tldraw/apps/tldraw-logseq/src/lib/shapes/LineShape.tsx

@@ -32,7 +32,7 @@ export class LineShape extends TLLineShape<LineShapeProps> {
     },
     stroke: 'var(--ls-primary-text-color, #000)',
     fill: '#ffffff',
-    noFill: false,
+    noFill: true,
     strokeType: 'line',
     strokeWidth: 1,
     opacity: 1,

+ 1 - 0
tldraw/apps/tldraw-logseq/src/lib/shapes/index.ts

@@ -63,6 +63,7 @@ declare global {
     logseq?: {
       api?: {
         make_asset_url?: (url: string) => string
+        get_page_blocks_tree?: (pageName: string) => any[]
         edit_block?: (uuid: string) => void
         set_blocks_id?: (uuids: string[]) => void
         open_external_link?: (url: string) => void