Repository navigation
fix(export): Text property values in exports and the Markdown mirror; no repeated blocks in selected-block EDN - #13887
yuxi-liu-wired wants to merge 5 commits into
Conversation
Exporting a selected block as Text dropped everything nested under a Text property's value. For a property whose value block had children, the output kept only `Property:: value`, and the child and grandchild blocks were missing with no warning. The property exporter only writes Text values as nested blocks when :export-default-property-values-as-blocks? is set. Markdown mirror sets it, but the selection export config (get-content-config) does not, so that path always wrote the inline form. When the flag is not set, a Text property now switches to the nested block form if any of its values has children. Values without children keep the inline `Property:: value` form, and the output when the flag is set (markdown mirror) is unchanged. Added export-blocks-as-markdown-keeps-text-property-value-children, which exports a block through the Text export path and checks that the value's child and grandchild are present. It fails without the change. Fixes logseq/db-test#1390
The Markdown mirror wrote every Text property as a list, even when "Multiple values" was off, so `myprop:: some value` became `myprop::` followed by a `- some value` child bullet. The exporter wrote Text values as nested blocks for all Text properties whenever the markdown mirror asked for block output, without looking at the property's cardinality. Text values are now written as nested blocks only when the property allows multiple values, or when a value has children (which would otherwise be dropped). A single value without children stays on the property line. Updated the mirror tests that pinned the list form for single-value properties and added page-mirror-exports-single-value-text-property-on-one-line-test, which checks a single-value and a multiple-value property side by side. It fails without the change. Fixes logseq/db-test#1218
Importing a Selected-block EDN export moved a block that another selected block refers to behind its siblings. With the blocks `order alpha`, `order beta [[order alpha]]` and `order gamma`, the import produced beta, gamma, alpha. The export lists the referenced block once as a selected block and again as a referenced one, and merge-export-maps joined the two :blocks vectors without looking at :block/uuid. The importer then placed the repeated block after the other siblings. merge-export-maps now keeps one block per :block/uuid in a page's :blocks, at the position of its first occurrence, and merges the repeated occurrences. Blocks without a :block/uuid are kept as they are. Added merge-export-maps-keeps-one-block-per-uuid, and import-selected-nodes-keeps-order-of-referenced-sibling, which exports and imports the three blocks above and checks their order. Both fail without the change. Fixes logseq/db-test#1389
| (into {} (map (fn [[block-uuid same-uuid-blocks]] | ||
| [block-uuid (apply merge same-uuid-blocks)]))))] |
There was a problem hiding this comment.
🔴 Referenced descendants lose properties on import
When selected blocks reference a parent and its child, merge-blocks-with-same-uuid replaces the parent's full children with shallow copies. Import loses the child's properties and tags.
Learn more
Selected-node export builds the full selected tree before build-uuid-block-export adds shallow copies of referenced blocks. When both a selected parent and its child are referenced, build-blocks-export nests the child in both copies. The later shallow parent overwrites the full parent's :build/children during the map merge, discarding the child's full properties and tags before import.
Example: Select parent P with child C carrying :build/properties, and select a separate block referencing both P and C. The referenced export contains shallow P with shallow C; importing the merged export creates C without its properties.
Recommended fix: Merge :build/children by child UUID recursively, retaining the full child over its shallow counterpart. Add a selected-nodes round-trip test with both parent and child referenced and a property on the child.
Was this helpful? React with 👍 or 👎 to provide feedback.
| (or (property-value-has-children? db value) | ||
| (and (:export-default-property-values-as-blocks? context) | ||
| (db-property/many? property))))) |
There was a problem hiding this comment.
🔴 Single-value Text metadata disappears from mirror
When a single-value Text value has its own properties but no children, default-property-values-as-blocks? exports it inline. The Markdown mirror loses those nested properties, which the former block form included.
Learn more
A Text property value can itself be a block with properties, independently of whether it has children. default-property-value-block-content emits those properties when exporting the value as a block. The Markdown mirror enables :export-default-property-values-as-blocks?, but this guard now chooses inline output for single-value Text properties without children, even if the value block has properties. Inline property-value->string only emits its title, so the value's properties disappear from the mirrored file.
Example: A single-value notes Text property holds the value Draft with a nested rating:: 5 property and no children. The mirror now contains only notes:: Draft, whereas its previous block output included rating:: 5.
Recommended fix: Detect nested properties on value entities in addition to children before selecting inline output; preserve block form for any value with nested data. Add a mirror test for a single-value Text property whose value has its own property but no children.
Was this helpful? React with 👍 or 👎 to provide feedback.
When one selected block referred to both a selected parent and its child, importing the Selected-block EDN export created the child without its properties and tags. The export holds the parent twice: in full as a selected block, and as a shallow copy made for the reference. merge-blocks-with-same-uuid merged the two with a plain map merge, so the shallow copy's :build/children replaced the full ones. The :build/children of the two copies are now merged by child uuid, recursively, so the child exported in full is kept. Added merge-export-maps-keeps-fuller-child-of-block-exported-twice and import-selected-nodes-keeps-child-properties-when-parent-and-child-are-referenced, an export and import round trip that checks the child's property and tag. Both fail without the change. Refs logseq/db-test#1389
The previous change wrote a single-value Text property on one line unless its value had children. A value that has properties of its own but no children, such as `notes` = `Draft` with `rating:: 5`, was then written inline and lost `rating:: 5`. The nested block form is now also used when a value has properties of its own that the export writes, in addition to children and multiple values. Added page-mirror-exports-properties-of-single-text-property-value-test, which fails without the change. Refs logseq/db-test#1218
|
|
Combined into #13869 with the other PRs of this theme, to keep the number of open PRs down; the commits are unchanged there. |
Fixes logseq/db-test#1390.
Fixes logseq/db-test#1218.
Fixes logseq/db-test#1389.
Three export bugs, each fixed in its own commit.
What the user sees
Property:: valuewas written; the value's child and grandchild blocks were missing, with no warning.myprop::followed by a- some valuebullet, instead ofmyprop:: some value.order alpha,order beta [[order alpha]],order gammacame back as beta, gamma, alpha.Cause
block-properties-content(logseq.common.export.file). Text property values are written as nested blocks only when:export-default-property-values-as-blocks?is set. Markdown mirror sets it, so it wrote every Text property as blocks whatever the cardinality (点击标签,含有此标签的节点能被筛选出来(多标签搜索) #1218). The selection export config (get-content-config) does not set it, so children of the value were dropped (github pull到本地文件夹后,用logseq打开后属性全部被展开 #1390).merge-export-mapsjoined the two:blocksvectors without looking at:block/uuid, and the importer put the repeated block after the other siblings.Change
Property:: valueform in the selection export, so its existing output is unchanged.notes=Draftwithrating:: 5lostrating:: 5.merge-export-mapskeeps one block per:block/uuidin a page's:blocks, at the position of its first occurrence, and merges the repeats. Blocks without a:block/uuidare kept as they are. A follow-up commit merges the:build/childrenof the repeats by child uuid, recursively, so a child exported in full is not replaced by the shallow copy made for a reference (otherwise the child was imported without its properties and tags when a selected block referred to both the selected parent and its child).Tests
export-blocks-as-markdown-keeps-text-property-value-children(frontend.handler.export-test) exports a block through the Text export path and checks the value's child and grandchild are present. Fails without the change (2 assertions); with it the namespace passes, and the whole unit suite passed except adb-worker-node"Worker request timeout" that passed when the namespace was rerun alone.page-mirror-exports-single-value-text-property-on-one-line-test(frontend.worker.markdown-mirror-test) checks a single-value and a multiple-value property side by side. Three existing mirror tests that pinned the list form for single-value properties now expect the one-line form;property-value-lines-do-not-render-db-id-comments-testnow uses a multiple-value property so it still covers the bullet form. Without the change the namespace fails 4 tests; with it the namespace and the whole unit suite pass.page-mirror-exports-properties-of-single-text-property-value-testcovers a single value with properties of its own and no children (rating:: 5undernotes=Draft); it fails without the follow-up commit and passes with it, and the whole unit suite passes at the branch head. Changing those three tests changes pinned output on purpose, as the issue asks; if the list form is wanted (for example for round-tripping the mirror), the 点击标签,含有此标签的节点能被筛选出来(多标签搜索) #1218 commit can be dropped on its own and the other two fixes stand.merge-export-maps-keeps-one-block-per-uuidandimport-selected-nodes-keeps-order-of-referenced-sibling(logseq.db.sqlite.export-test,deps/db) fail without the change and pass with it. For the follow-up,merge-export-maps-keeps-fuller-child-of-block-exported-twiceandimport-selected-nodes-keeps-child-properties-when-parent-and-child-are-referenced(a round trip where one selected block refers to both the selected parent and its child, checking the child's property and tag) fail without the change (3 failed assertions) and pass with it. Thedeps/dbsuite and the whole main-bundle unit suite pass at the branch head.