@dosgato/templating 0.0.84 → 0.0.85

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/render.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ContextBase, DataData, PageData, PageRecord, PageRecordOptionalData } from './component.js';
2
2
  import { AssetLink, DataFolderLink, DataLink, LinkDefinition, PageLink } from './links.js';
3
- export declare function printHeader(ctx: ContextBase, content: string): string;
4
- export declare function advanceHeader(ctx: ContextBase, content?: string): {
3
+ export declare function printHeader(ctx: ContextBase, content: string | undefined | null, attributes?: Record<string, string>): string;
4
+ export declare function advanceHeader(ctx: ContextBase, content: string | undefined | null): {
5
5
  headerLevel: number;
6
6
  };
7
7
  export interface PictureResize {
package/dist/render.js CHANGED
@@ -1,13 +1,14 @@
1
- import { isBlank } from 'txstate-utils';
2
- export function printHeader(ctx, content) {
1
+ import { htmlEncode, isBlank } from 'txstate-utils';
2
+ export function printHeader(ctx, content, attributes) {
3
3
  if (isBlank(content))
4
4
  return '';
5
5
  const level = (ctx.headerLevel ?? 0) + 1;
6
+ const attr = attributes ? ' ' + Object.entries(attributes).map(([key, val]) => `${key}="${htmlEncode(val)}"`).join(' ') : '';
6
7
  if (level < 1)
7
- return `<h1>${content}</h1>`;
8
+ return `<h1${attr}>${content}</h1>`;
8
9
  if (level > 6)
9
- return `<h6>${content}</h6>`;
10
- return `<h${level}>${content}</h${level}>`;
10
+ return `<h6${attr}>${content}</h6>`;
11
+ return `<h${level}${attr}>${content}</h${level}>`;
11
12
  }
12
13
  export function advanceHeader(ctx, content) {
13
14
  const ret = { ...ctx };
@@ -27,10 +27,15 @@ export interface UITemplate {
27
27
  * - data: ComponentData, the current data on the page, should not be mutated during editing,
28
28
  * undefined when creating
29
29
  * - page: DialogPageProp, the current page so that you can reference the full page data or
30
- * make a further graphql query based on its id/path.
30
+ * make a further graphql query based on its id/path. Component dialogs only, page and data
31
+ * dialogs do not receive this prop
31
32
  * - templateProperties: the template properties for the current page template, so you can make
32
- * things like color pickers that visually match the colors of the current page template
33
+ * things like color pickers that visually match the colors of the current page template.
34
+ * Data dialogs do not receive this.
33
35
  * - environmentConfig: base URLs in case you need to generate a link to the API or something
36
+ *
37
+ * In addition to the props, you may import the `dialogQuery` function (see below) to send
38
+ * requests to the API.
34
39
  */
35
40
  dialog?: new (...args: any[]) => any;
36
41
  /**
@@ -64,7 +69,7 @@ export interface UITemplate {
64
69
  }
65
70
  /**
66
71
  * This is a type for the data that will be passed to dialog Svelte components as
67
- * the `page` prop.
72
+ * the `page` prop. Note that page template dialogs do NOT receive this prop.
68
73
  */
69
74
  export interface DialogPageProp {
70
75
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.84",
3
+ "version": "0.0.85",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {