Repository navigation
feat(ui): edit components and their props in the editor with a shared node view - #405
Conversation
… node view ComarkKit's component nodes drew as a bare div or span, so every host wrote its own view. componentView() from comark-ui/editor/vue draws a block's name and props in a bar, an inline component's tag, slots under their #name, and a props panel with typed fields from the host's schema, names and values otherwise, and a field hook for the host's own controls. The Vue bindings turn it on; ComarkKit takes it as componentView. It sets the props attribute through transactions only, so the schema and the written Markdown stay the same.
comark-annotate
comark-badge
comark-cards
comark-carousel
comark-cast
comark-charts
comark-chat
comark-chips
comark-cjk
comark-code
comark-code-notes
comark-colors
comark-comments
comark-critic
comark-deflist
comark-details
comark-diagrams
comark-diff
comark-embed
comark-fields
comark-figure
comark-file-tree
comark-footnotes
comark-github
comark-icon
comark-include
comark-keys
comark-links
comark-linter
comark-magic-move
comark-mark
markdown-it-to-comark
marked-to-comark
comark-mathml
comark-media
comark-metrics
migrate-to-comark
comark-outline
comark-properties
comark-qr
comark-quiz
comark-reading-time
remark-to-comark
comark-sources
comark-steps
comark-table
comark-tabs
comark-tests
comark-time
comark-ui
comark-xref
comark-zoom
commit: |
Latest result Pull request merged. Final answersSession Pull request merged. Session Waiting for GitHub merge request c0f8e12d-1371-4fe4-b929-76c7304eee12. Ready; no repair needed. Verified Pullfrog’s prior P1 bound-string decoding, JSON draft loss, and conditional-slot fallback fixes. All six hosted checks passed. Local vp fmt --check and git diff --check passed; vp lint exited 0 with one missing-build-type warning. Focused editor tests were blocked by missing workspace exports; the cached prerequisite build hit the prepare hook’s read-only .git/config error. Working tree is clean. Pushed 1b6e973, fixing Pullfrog P1 bound-string decoding, P1 JSON draft loss, and P1 conditional-slot fallback. All three threads resolved. From packages/ui, vp test run test/editor-view.test.ts test/editor-vue.test.ts passed all 15 tests. Changed-file lint, formatting, git diff --check, and the cached prerequisite build passed. Awaiting hosted checks. Session Marked the draft ready for review so it can merge. Session Marked the draft ready for review so it can merge. Session Marked the draft ready for review so it can merge. Session Marked the draft ready for review so it can merge. Session Marked the draft ready for review so it can merge. Session Marked the draft ready for review so it can merge. Verified the expected HEAD and inspected the diff and supplied feedback; no actionable defect found. git diff HEAD^ HEAD --check passed, and the working tree is clean. Dependency refresh timed out after 300 seconds; checkDependencies still reports the host’s shared install slot occupied. Focused tests and lint remain unverified. Awaiting hosted CI. |
There was a problem hiding this comment.
Important
Three supported editing paths need fixes: conditional field slots hide built-in controls, unrelated transactions discard JSON drafts, and bound string literals gain unwanted quote characters when edited.
Reviewed changes — Reviewed the shared Vue component node view, its public editor integration, prop serialization, playground, documentation, and tests.
- Shared component view. Block and inline components gain labeled chrome, editable content and slots, and a native props popover with typed and raw fields.
- Host integration.
ComarkKit,useComarkEditor, andComarkEditorexpose component metadata, custom field renderers, view overrides, and an opt-out without changing the schema. - Transaction handling. Prop edits preserve unrelated attributes, including when a retained host-field callback completes later, while parser options remain intact.
- Examples and verification. The playground and guide demonstrate the feature; both focused Vue suites pass all 10 tests and changed-file lint passes, but full workspace validation was blocked by the prepare hook error
could not lock config file .git/config: Read-only file system.
gpt-6.1-sol(xhigh) | 𝕏
There was a problem hiding this comment.
✅ No new issues found; no P0 or P1 findings remain.
Reviewed changes — Reviewed 1b6e973, the fixes added since the previous Pullfrog review at e5fb595.
- Restored conditional-slot fallbacks. Comment-only slots and empty fragments retain built-in fields, while real host controls still replace them.
- Preserved pending JSON edits. Valid and incomplete drafts survive unrelated content and prop transactions, and successful commits preserve intervening edits.
- Decoded bound strings. Text fields, selects, and host fields receive decoded values rather than serialized quote characters.
- Added regression coverage. All 15 focused editor tests passed, and lint on the changed implementation and tests reported zero errors or warnings.
gpt-6.1-sol(xhigh) | 𝕏

In comark-ui's editor,
::chart{type="stacked"},:::card{title="…"}and:badge[New]{color="success"}show up as an unlabeled div or span, with no way to see or edit their props. So the ViteHub Console, ViteHub Content's CMS and Drop each end up writing their own Tiptap node view.This adds one view to
comark-ui/editor/vue. A block shows its name and props in a bar above its content, an inline component gets a tag after its text, and slots stay editable in place under their#name. Clicking the props opens a panel with typed fields for the props the host describes, a name and value for every other prop, and a row to add one. The view only callsupdateAttributes({ props }), which is onesetNodeMarkuptransaction, so the schema and the Markdown the codec writes don't change and a room's server codec can leave the view out.The API:
ComarkKit.configure({ componentView })takes anyNodeViewRendererforcomarkBlockandcomarkInline.ComarkKitstays DOM-free.componentView({ components, field })fromcomark-ui/editor/vueis the view.componentsmaps a name to{ label?, icon?, props? }, and each prop is{ type?, label?, description?, default?, options? }.typeisstring,number,booleanorjson; any other name, likeimage, edits as text untilfielddraws it.field(ctx)returns the control for a prop, orundefinedfor the built-in one, andctx.update(value)writes it.useComarkEditorandComarkEditorturn the view on by default. They takecomponentsandfield(ComarkEditortakes it as a#fieldslot), andcomponents: falsegoes back to bare elements.Strings are written as
name="…"and every other value as:nameJSON text, which is what Comark parses back. An unchecked boolean drops the prop unless its default istrue.How the Console would adopt it: in
console-markdown-editor.vue, drop theaddExtensionsoverride that swaps in its own view forcomarkBlockandcomarkInline, and addcomponentView: componentView({ components, field })to the kit's existing.configure()besidestarterKit.componentsmaps straight fromConsoleDocumentComponent[](label, andpropswith the same type names anddefault).fielddraws the media picker forimageandfileprops, looking upstorefrom its own definitions bycomponentandname. Thenconsole-comark-component.vue,consoleComponentPropandconsoleComponentWithPropgo away. One difference: the Console writes numbers and booleans as raw values undername, and this writes them under:name.Before/after on Drop
packages/ui/test/editor-view.test.tsmounts the editor in happy-dom, added as a dev dependency. A doc with::card-group, two:::card(one with a#footerslot),::chartand:badgeround-trips byte for byte with the view drawn, and the schema is the same with and without it. Editingtype,titleandlabelsthrough the panel, adding and removing name/value props, a hostfield, and the#fieldslot all land in the written Markdown. In Chromium on the playground, typing in the panel (Backspace and Enter included), Escape, and typing in a slot all work, and the source pane follows.Not done: no rendered preview of data-only blocks like
::chart, since it would need comark-charts' Vega parse in the browser. I haven't tried it in a live collaborative room, only that the view edits through transactions and leaves the schema alone. I checked the playground withvp dev, not a docs build. main's playground has no dark scheme, so the dark capture has no before.