@velocity-astro/cms-astro 0.1.0-beta.4 → 0.1.0-beta.6

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/index.d.ts CHANGED
@@ -10,6 +10,8 @@ export { registerSitePlugins } from './site-plugins.js';
10
10
  export { EditorNotSetUpError, editorOrigin, pagesOrigin, siteEditorHost, withEditor, type SiteEditorSettings } from './site-editor.js';
11
11
  export { cmsLiveLoader, entryTag, invalidateLiveContent, liveContentVersion, typeTag, type CmsCollectionFilter, type CmsEntryFilter, type CmsLiveLoaderOptions, } from './live-loader.js';
12
12
  export { isEditorPreview, isPreview } from './preview.js';
13
+ export { PREVIEW_BRIDGE_SCRIPT } from '@velocity-astro/cms-admin/page-bridge';
14
+ export { fieldMark, sectionMark, type PageMark } from './page-marks.js';
13
15
  export { pageHead, type DrawnPage } from './page-head.js';
14
16
  export { entryPage, entryPageAddresses, type EntryPage, type EntryPageOptions } from './entry-page.js';
15
17
  export { linkTo, type LinkTarget } from './link.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,KAAK,mBAAmB,EAAE,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9J,OAAO,EAAE,QAAQ,EAAE,KAAK,e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U,EACf,KAAK,WAAW,EAChB,KAAK,UAAU,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,mBAAmB,EAAE,KAAK,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAClK,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -11,6 +11,8 @@ export { registerSitePlugins } from './site-plugins.js';
11
11
  export { EditorNotSetUpError, editorOrigin, pagesOrigin, siteEditorHost, withEditor } from './site-editor.js';
12
12
  export { cmsLiveLoader, entryTag, invalidateLiveContent, liveContentVersion, typeTag, } from './live-loader.js';
13
13
  export { isEditorPreview, isPreview } from './preview.js';
14
+ export { PREVIEW_BRIDGE_SCRIPT } from '@velocity-astro/cms-admin/page-bridge';
15
+ export { fieldMark, sectionMark } from './page-marks.js';
14
16
  export { pageHead } from './page-head.js';
15
17
  export { entryPage, entryPageAddresses } from './entry-page.js';
16
18
  export { linkTo } from './link.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,O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EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,SAAS,EAAyB,MAAM,aAAa,CAAC;AAC/D,OAAO,EACL,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,WAAW,GAKZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,mBAAmB,EAAmC,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAA4B,MAAM,kBAAkB,CAAC;AAClK,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,EAAE,YAAY,EAAkB,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAsC,MAAM,aAAa,CAAC"}
@@ -0,0 +1,34 @@
1
+ /** Attributes a template spreads on an element of a page. Nothing at all, except beside the editor's form. */
2
+ export type PageMark = Readonly<Record<string, string>>;
3
+ /**
4
+ * Says which section of a page an element is, for the page beside the editor's form: a click on
5
+ * it there finds the section in the form. A template spreads it on the element that wraps the
6
+ * section:
7
+ *
8
+ * ```astro
9
+ * <div {...sectionMark(section.id, section.data)}><Block {...section.data} /></div>
10
+ * ```
11
+ *
12
+ * Given what the section holds, the mark also says which words belong to which field
13
+ * (`data-cms-values`), and the page beside the form finds each field by the words it shows, so a
14
+ * click on a heading opens the heading's field with no mark on the heading. Where that is not
15
+ * enough (a value the block changes before it shows it), the block says so with `fieldMark`.
16
+ *
17
+ * A visitor's page gets no attribute, so nothing about the editor reaches the site.
18
+ */
19
+ export declare function sectionMark(id: string, data?: unknown): PageMark;
20
+ /**
21
+ * Says which field of its section an element shows, by the field's key, so a click on it beside
22
+ * the editor's form opens that field and not only the section:
23
+ *
24
+ * ```astro
25
+ * <h1 {...fieldMark('title')}>{title}</h1>
26
+ * {items.map((item, at) => <li {...fieldMark('items', at, 'text')}>{item.text}</li>)}
27
+ * ```
28
+ *
29
+ * The parts are joined with dots: a field inside a list is the list's key, the item's place and
30
+ * the field's own key. A mark written this way comes before what `sectionMark` finds by itself, and
31
+ * a field with no mark is still edited in the form.
32
+ */
33
+ export declare function fieldMark(...path: readonly (string | number)[]): PageMark;
34
+ //# sourceMappingURL=page-marks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-marks.d.ts","sourceRoot":"","sources":["../src/page-marks.ts"],"names":[],"mappings":"AAEA,8GAA8G;AAC9G,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AA2BxD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAKhE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,GAAG,IAAI,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,QAAQ,CAEzE"}
@@ -0,0 +1,68 @@
1
+ import { isEditorPreview } from './preview.js';
2
+ const NONE = Object.freeze({});
3
+ /** How deep a section's values are looked into for words, which is deeper than a list in a list goes. */
4
+ const DEPTH = 6;
5
+ /** What a section holds that a page can show, each with its place: `['items.0.text', 'Open daily']`. */
6
+ function shown(data, path, into) {
7
+ if (typeof data === 'string') {
8
+ if (data.trim() !== '' && path.length > 0)
9
+ into.push([path.join('.'), data]);
10
+ return;
11
+ }
12
+ if (typeof data !== 'object' || data === null || path.length >= DEPTH)
13
+ return;
14
+ if (Array.isArray(data)) {
15
+ data.forEach((item, at) => shown(item, [...path, at], into));
16
+ return;
17
+ }
18
+ const html = data.html;
19
+ // Text shaped in the editor is one field, found by its words and not its markup.
20
+ if (typeof html === 'string' && path.length > 0) {
21
+ if (html.trim() !== '')
22
+ into.push([path.join('.'), html, 'html']);
23
+ return;
24
+ }
25
+ for (const [key, value] of Object.entries(data))
26
+ shown(value, [...path, key], into);
27
+ }
28
+ /**
29
+ * Says which section of a page an element is, for the page beside the editor's form: a click on
30
+ * it there finds the section in the form. A template spreads it on the element that wraps the
31
+ * section:
32
+ *
33
+ * ```astro
34
+ * <div {...sectionMark(section.id, section.data)}><Block {...section.data} /></div>
35
+ * ```
36
+ *
37
+ * Given what the section holds, the mark also says which words belong to which field
38
+ * (`data-cms-values`), and the page beside the form finds each field by the words it shows, so a
39
+ * click on a heading opens the heading's field with no mark on the heading. Where that is not
40
+ * enough (a value the block changes before it shows it), the block says so with `fieldMark`.
41
+ *
42
+ * A visitor's page gets no attribute, so nothing about the editor reaches the site.
43
+ */
44
+ export function sectionMark(id, data) {
45
+ if (!isEditorPreview())
46
+ return NONE;
47
+ const values = [];
48
+ if (data !== undefined)
49
+ shown(data, [], values);
50
+ return values.length > 0 ? { 'data-cms-section': id, 'data-cms-values': JSON.stringify(values) } : { 'data-cms-section': id };
51
+ }
52
+ /**
53
+ * Says which field of its section an element shows, by the field's key, so a click on it beside
54
+ * the editor's form opens that field and not only the section:
55
+ *
56
+ * ```astro
57
+ * <h1 {...fieldMark('title')}>{title}</h1>
58
+ * {items.map((item, at) => <li {...fieldMark('items', at, 'text')}>{item.text}</li>)}
59
+ * ```
60
+ *
61
+ * The parts are joined with dots: a field inside a list is the list's key, the item's place and
62
+ * the field's own key. A mark written this way comes before what `sectionMark` finds by itself, and
63
+ * a field with no mark is still edited in the form.
64
+ */
65
+ export function fieldMark(...path) {
66
+ return path.length > 0 && isEditorPreview() ? { 'data-cms-field': path.join('.') } : NONE;
67
+ }
68
+ //# sourceMappingURL=page-marks.js.map
@@ -0,0 +1 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C,CAAC;QAClE,OAAO;IACT,CAAC;IACD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,KAAK,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;AACtF,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,WAAW,CAAC,EAAU,EAAE,IAAc;IACpD,IAAI,CAAC,eAAe,EAAE;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,MAAM,GAA0B,EAAE,CAAC;IACzC,IAAI,IAAI,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IAChD,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,EAAE,EAAE,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,EAAE,EAAE,CAAC;AAChI,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,SAAS,CAAC,GAAG,IAAkC;IAC7D,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5F,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velocity-astro/cms-astro",
3
- "version": "0.1.0-beta.4",
3
+ "version": "0.1.0-beta.6",
4
4
  "description": "The Astro side of Velocity CMS: a live loader for pages rendered on demand, a Content Layer loader for static builds, and the integration.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,12 +34,12 @@
34
34
  "!dist/**/*.test.*"
35
35
  ],
36
36
  "dependencies": {
37
- "@velocity-astro/cms-admin": "0.1.0-beta.4",
38
- "@velocity-astro/cms-api": "0.1.0-beta.4",
39
- "@velocity-astro/cms-auth": "0.1.0-beta.4",
40
- "@velocity-astro/cms-core": "0.1.0-beta.4",
41
- "@velocity-astro/cms-db": "0.1.0-beta.4",
42
- "@velocity-astro/cms-plugins": "0.1.0-beta.4"
37
+ "@velocity-astro/cms-admin": "0.1.0-beta.6",
38
+ "@velocity-astro/cms-api": "0.1.0-beta.6",
39
+ "@velocity-astro/cms-auth": "0.1.0-beta.6",
40
+ "@velocity-astro/cms-core": "0.1.0-beta.6",
41
+ "@velocity-astro/cms-db": "0.1.0-beta.6",
42
+ "@velocity-astro/cms-plugins": "0.1.0-beta.6"
43
43
  },
44
44
  "optionalDependencies": {
45
45
  "sharp": "^0.35.4"
@@ -1,63 +1,13 @@
1
1
  import type { APIRoute } from 'astro';
2
+ import { PREVIEW_BRIDGE_SCRIPT } from '@velocity-astro/cms-astro';
2
3
 
3
4
  export const prerender = false;
4
5
 
5
6
  /**
6
- * What the page beside the editor's form runs. The preview adds it to that page only, and it
7
- * does nothing unless the page is in a frame of the same site.
8
- *
9
- * It tells the editor which section was clicked, shows the section the editor asks for, and
10
- * keeps the page where it was scrolled to when it is drawn again. It marks a section by setting
11
- * its style from script, which a page's content rules allow where a style written into the page
12
- * would not be.
7
+ * What the page beside the editor's form runs (`src/preview-bridge.ts`). The preview adds it to
8
+ * that page only, and it does nothing unless the page is in a frame of the same site. A browser
9
+ * asks for it each time: it is small, only an editor loads it, and a copy kept from before an
10
+ * upgrade would not know what the editor now says to it.
13
11
  */
14
- const SCRIPT = `
15
- if (window.parent !== window) {
16
- const origin = location.origin;
17
- const say = (message) => window.parent.postMessage({ source: 'velocity-cms', ...message }, origin);
18
- const sectionOf = (target) => (target instanceof Element ? target.closest('[data-cms-section]') : null);
19
-
20
- let marked = null;
21
- const mark = (section) => {
22
- if (marked === section) return;
23
- if (marked) marked.style.outline = marked.style.outlineOffset = marked.style.cursor = '';
24
- marked = section;
25
- if (!section) return;
26
- section.style.outline = '2px solid Highlight';
27
- section.style.outlineOffset = '-2px';
28
- section.style.cursor = 'pointer';
29
- };
30
- document.addEventListener('mouseover', (event) => mark(sectionOf(event.target)));
31
- document.documentElement.addEventListener('mouseleave', () => mark(null));
32
-
33
- // Nothing on the page goes anywhere: a click chooses the section it is in.
34
- document.addEventListener('click', (event) => {
35
- event.preventDefault();
36
- const section = sectionOf(event.target);
37
- if (section) say({ type: 'section', id: section.dataset.cmsSection });
38
- }, true);
39
- document.addEventListener('submit', (event) => event.preventDefault(), true);
40
-
41
- addEventListener('message', (event) => {
42
- if (event.origin !== origin || event.source !== window.parent || event.data?.source !== 'velocity-cms') return;
43
- if (event.data.type !== 'show') return;
44
- const section = [...document.querySelectorAll('[data-cms-section]')].find((candidate) => candidate.dataset.cmsSection === event.data.id);
45
- if (!section) return;
46
- // Room for a header that stays at the top of the page.
47
- section.style.scrollMarginTop = '6rem';
48
- section.scrollIntoView({ block: 'start' });
49
- });
50
-
51
- const key = 'velocity-cms:scroll:' + location.pathname;
52
- try {
53
- const kept = Number(sessionStorage.getItem(key));
54
- if (kept > 0) scrollTo({ top: kept, behavior: 'instant' });
55
- addEventListener('pagehide', () => sessionStorage.setItem(key, String(scrollY)));
56
- } catch {}
57
-
58
- say({ type: 'ready' });
59
- }
60
- `;
61
-
62
12
  export const GET: APIRoute = () =>
63
- new Response(SCRIPT, { headers: { 'Content-Type': 'text/javascript; charset=utf-8', 'Cache-Control': 'public, max-age=3600' } });
13
+ new Response(PREVIEW_BRIDGE_SCRIPT, { headers: { 'Content-Type': 'text/javascript; charset=utf-8', 'Cache-Control': 'no-cache' } });