@digital-gravy/etch-connector 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +30 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -437,7 +437,23 @@ changes and training data may be stale):
|
|
|
437
437
|
Manual fallback https://docs.etchwp.com/public-api (window.etch.*)
|
|
438
438
|
https://docs.etchwp.com (everything else)
|
|
439
439
|
|
|
440
|
-
Building Etch pages (AGENT: conventions
|
|
440
|
+
Building Etch pages (AGENT: conventions — follow these or the builder won't
|
|
441
|
+
render what you author):
|
|
442
|
+
Images. ALWAYS use the Dynamic Image element (etch/dynamic-image, <etch:img>),
|
|
443
|
+
NEVER a plain etch/element with tag "img". Bind it by WP media ID, not a URL:
|
|
444
|
+
attributes: { mediaId: "{props.image}", useSrcSet: "true", alt: "{props.name}" }
|
|
445
|
+
The backing prop must be a Media prop, not a text prop:
|
|
446
|
+
type: { primitive: "string", specialized: "wpMediaId" }
|
|
447
|
+
(specialized "image" is the URL-based picker — NOT for mediaId.) Instances
|
|
448
|
+
then pass the numeric media ID, e.g. image: "10" — not the file URL.
|
|
449
|
+
|
|
450
|
+
Classes. A block's classes ARE its read-only \`styles\` array, not an HTML
|
|
451
|
+
attribute. Setting attributes.class in authored JSON is silently dropped, and
|
|
452
|
+
\`styles\` is rejected on authoring. Assign classes with etch.blocks.addClass()
|
|
453
|
+
— for component blocks, inside enterComponentEditMode() →
|
|
454
|
+
saveComponentEditModeAsync() → exitComponentEditMode(). An existing class
|
|
455
|
+
name re-links to its style record automatically (styling is preserved).
|
|
456
|
+
|
|
441
457
|
Sections. When you create a top-level section, always tag it
|
|
442
458
|
data-etch-element="section" and nest ONE container inside it as its inner —
|
|
443
459
|
a div block with data-etch-element="container" — and put the section's
|
|
@@ -453,6 +469,19 @@ Building Etch pages (AGENT: conventions for structuring content):
|
|
|
453
469
|
side padding, or inter-section margins — the pair already handles layout
|
|
454
470
|
structure, spacing, and content width.
|
|
455
471
|
|
|
472
|
+
Gotchas.
|
|
473
|
+
• NEVER call etch.*.saveAsync (or otherwise persist) unless the user
|
|
474
|
+
explicitly asks to save — authored changes stay in the builder until then.
|
|
475
|
+
• Component instance props are attributes: set them at create()/replace()
|
|
476
|
+
time, or update an existing instance in place with
|
|
477
|
+
etch.blocks.update(instanceId, { attributes: { image: "10" } })
|
|
478
|
+
• updateAsync({ blocks }) requires styles:[] on every element block
|
|
479
|
+
(validation differs from blocks.create(), which omits styles entirely).
|
|
480
|
+
• No etch.media API. Resolve a URL → media ID via the WP REST API:
|
|
481
|
+
curl 'http://<site>/?rest_route=/wp/v2/media&per_page=100&_fields=id,source_url'
|
|
482
|
+
(rest_route form works on plain permalinks; /wp-json/wp/v2/media on pretty
|
|
483
|
+
ones.)
|
|
484
|
+
|
|
456
485
|
See AGENTS.md for project conventions.`);
|
|
457
486
|
}
|
|
458
487
|
async function main() {
|