okno 1.0.0-beta.11 → 1.0.0-beta.13

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.
Files changed (44) hide show
  1. package/dist/boot.d.ts +1 -87
  2. package/dist/boot.d.ts.map +1 -1
  3. package/dist/dispatch-bnmIdH8E.js +759 -0
  4. package/dist/editor/index.js +11851 -11356
  5. package/dist/{core/content-encode.d.ts → engine/encode.d.ts} +7 -6
  6. package/dist/engine/encode.d.ts.map +1 -0
  7. package/dist/engine/fields.d.ts +29 -0
  8. package/dist/engine/fields.d.ts.map +1 -0
  9. package/dist/engine/index.d.ts +17 -0
  10. package/dist/engine/index.d.ts.map +1 -0
  11. package/dist/{core → engine}/order.d.ts +2 -0
  12. package/dist/engine/order.d.ts.map +1 -0
  13. package/dist/{core → engine}/parse.d.ts +4 -3
  14. package/dist/engine/parse.d.ts.map +1 -0
  15. package/dist/engine/schema.d.ts +69 -0
  16. package/dist/engine/schema.d.ts.map +1 -0
  17. package/dist/index.js +1 -1
  18. package/dist/local/disk.d.ts +57 -0
  19. package/dist/local/disk.d.ts.map +1 -0
  20. package/dist/local/dispatch.d.ts +27 -0
  21. package/dist/local/dispatch.d.ts.map +1 -0
  22. package/dist/local/self-written.d.ts +17 -0
  23. package/dist/local/self-written.d.ts.map +1 -0
  24. package/dist/mcp.js +1 -1
  25. package/dist/next/config.d.ts +13 -0
  26. package/dist/next/config.d.ts.map +1 -0
  27. package/dist/next/handler.d.ts +21 -0
  28. package/dist/next/handler.d.ts.map +1 -0
  29. package/dist/next/index.d.ts +14 -0
  30. package/dist/next/index.d.ts.map +1 -0
  31. package/dist/next/index.js +79 -0
  32. package/dist/plugin-DkXOrSVC.js +721 -0
  33. package/dist/runtime/wrap.d.ts.map +1 -1
  34. package/dist/runtime/wrap.js +146 -145
  35. package/dist/vite/index.js +1 -1
  36. package/dist/vite/local-engine.d.ts +11 -27
  37. package/dist/vite/local-engine.d.ts.map +1 -1
  38. package/package.json +5 -1
  39. package/src/runtime/wrap.ts +36 -28
  40. package/dist/core/content-encode.d.ts.map +0 -1
  41. package/dist/core/order.d.ts.map +0 -1
  42. package/dist/core/parse.d.ts.map +0 -1
  43. package/dist/plugin-D1AqM8JA.js +0 -1405
  44. /package/dist/{content-encode-DoojdsVU.js → encode-DoojdsVU.js} +0 -0
@@ -926,22 +926,41 @@ function collectGroups(list: string): ItemGroup[] {
926
926
  }))
927
927
  }
928
928
 
929
- /** Clear visible text in a cloned item's leaf content nodes (a fresh item has
930
- * no content yet). Only touches `data-okno` leaves with no element children
931
- * images / link spreads / richtext are left as-is (best-effort; they settle on
932
- * the next save+reload). */
929
+ /** Every `data-okno` content leaf in a cloned item, INCLUDING the root element
930
+ * itself. `querySelectorAll` only matches descendants, but for a primitive item
931
+ * the slot-boundary element IS the content leaf (`<span {...item.slot} data-okno>
932
+ * {value}</span>`), so the leaf is the clone root — miss it and a new item keeps
933
+ * the template's value. Blocks/refs carry their leaves nested, so both cases work. */
934
+ function contentLeaves(root: Element): Element[] {
935
+ const els = Array.from(root.querySelectorAll(`[${CONTENT_ATTR}]`))
936
+ if (root.hasAttribute(CONTENT_ATTR)) els.unshift(root)
937
+ return els
938
+ }
939
+
940
+ /** Clear visible content in a cloned item's leaf nodes (a fresh item has no
941
+ * content yet). Only touches `data-okno` leaves with no element children:
942
+ * clears the text, and — for a link leaf (`<a>`) — drops the template's stale
943
+ * `href`/`target`/`rel` so the new empty link doesn't point at the cloned one.
944
+ * Images / richtext (element children) are left as-is (best-effort; they settle
945
+ * on the next save+reload). */
933
946
  function clearLeaves(root: Element): void {
934
- root.querySelectorAll(`[${CONTENT_ATTR}]`).forEach((el) => {
935
- if (el.children.length === 0) el.textContent = ""
936
- })
947
+ for (const el of contentLeaves(root)) {
948
+ if (el.children.length > 0) continue
949
+ el.textContent = ""
950
+ if (el.tagName === "A") {
951
+ el.setAttribute("href", "")
952
+ el.removeAttribute("target")
953
+ el.removeAttribute("rel")
954
+ }
955
+ }
937
956
  }
938
957
 
939
958
  /** Fill a cloned item's text leaves from absolute-path → value pairs. */
940
959
  function fillLeaves(root: Element, values: Record<string, string>): void {
941
- root.querySelectorAll(`[${CONTENT_ATTR}]`).forEach((el) => {
960
+ for (const el of contentLeaves(root)) {
942
961
  const path = el.getAttribute(CONTENT_ATTR)
943
962
  if (path && path in values && el.children.length === 0) el.textContent = values[path] ?? ""
944
- })
963
+ }
945
964
  }
946
965
 
947
966
  function prefersReducedMotion(): boolean {
@@ -1002,24 +1021,14 @@ export function __oknoApplyStructure(detail: OknoStructureDetail): void {
1002
1021
  const docEl = document.documentElement
1003
1022
  docEl.classList.add("okno-vt-active")
1004
1023
 
1005
- // Keep the editor above the animation. View-transition snapshots render in the
1006
- // browser TOP LAYER (above every z-index), so the moving page items would
1007
- // otherwise sweep OVER the editor window. Give the editor host its own group
1008
- // (`view-transition-name: okno-editor`) so it's captured and being the last
1009
- // child of <body> composited on top. The host is normally a 0-size box (its
1010
- // UI is `position:fixed` inside the shadow), which would snapshot empty, so we
1011
- // give it a real viewport box for the transition only and restore it after — no
1012
- // permanent layout/pointer-events change. The editor doesn't move, so its
1013
- // crossfade is suppressed in CSS (`::view-transition-*(okno-editor)`); it shows
1014
- // a frozen snapshot, so the temporary box never actually paints. Tradeoff: its
1015
- // backdrop-filter blur can't sample across snapshot groups, so the glass goes
1016
- // flat for the transition's duration (a View Transitions limitation).
1017
- const editorHost = document.getElementById("okno-shadow-root")
1018
- const prevHostCss = editorHost instanceof HTMLElement ? editorHost.style.cssText : null
1019
- if (editorHost instanceof HTMLElement) {
1020
- editorHost.style.cssText = `${prevHostCss};position:fixed;inset:0;pointer-events:none;view-transition-name:okno-editor`
1021
- }
1022
-
1024
+ // NOTE: the editor host (`#okno-shadow-root`) is intentionally NOT given its own
1025
+ // `view-transition-name`. Its UI is `position:fixed` inside the shadow root,
1026
+ // which a named group snapshots EMPTY so the old attempt to isolate + freeze it
1027
+ // captured nothing and the whole editor window blinked out for the transition.
1028
+ // Left unnamed, it rides the `root` snapshot; since the editor doesn't change, its
1029
+ // old→new crossfade is between identical pixels (invisible). Only the tagged item
1030
+ // wrappers animate. A moving item can briefly composite over the editor panel if
1031
+ // they overlap on screen a minor cosmetic cost vs. the window vanishing.
1023
1032
  const mutate = () => {
1024
1033
  for (const g of groups) {
1025
1034
  if (op === "reorder") applyReorder(g, list, detail.from!, detail.to!)
@@ -1031,7 +1040,6 @@ export function __oknoApplyStructure(detail: OknoStructureDetail): void {
1031
1040
  withTransition(mutate).finally(() => {
1032
1041
  for (const w of tagged) w.style.viewTransitionName = ""
1033
1042
  docEl.classList.remove("okno-vt-active")
1034
- if (editorHost instanceof HTMLElement && prevHostCss !== null) editorHost.style.cssText = prevHostCss
1035
1043
  })
1036
1044
  }
1037
1045
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-encode.d.ts","sourceRoot":"","sources":["../../src/core/content-encode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,KAAK;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,KAAK,CAAA;CAAE,GACpD,MAAM,CAIR;AAED;;;;GAIG;AAGH,wBAAgB,YAAY,CAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,SAA2C,GAC/C,MAAM,CAER;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEhD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../src/core/order.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EAAE,EACV,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,SAAS,EACxC,KAAK,CAAC,EAAE,MAAM,EAAE,GACd,CAAC,EAAE,CAaL;AAED;kFACkF;AAClF,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAGnF;AACD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAEhF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/core/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAqDH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAyBvE"}