@dosgato/templating 1.1.16 → 1.1.18

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.
@@ -175,8 +175,8 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
175
175
  * left open to protect overall page integrity, and fix header levels for accessibility.
176
176
  *
177
177
  * For instance, an editor supplies a title to be placed above some rich editor content. The
178
- * title uses an <h2>, so the headers inside the rich editor content should start at <h3> and
179
- * should not use <h1> or <h2>.
178
+ * title uses an `<h2>`, so the headers inside the rich editor content should start at `<h3>` and
179
+ * should not use `<h1>` or `<h2>`.
180
180
  *
181
181
  * Setting headerLevel: 3 instructs the renderRichText function to analyze and rebalance the header
182
182
  * structure of the content so that if it had an h2, it woud be replaced with an h3. Additionally,
@@ -557,7 +557,7 @@ export interface RenderComponentsOpts {
557
557
  skipContent?: boolean;
558
558
  /**
559
559
  * Provide a function that wraps each component, e.g.
560
- * ({ output }) => `<li>${output}</li>`
560
+ * `({ output }) => \`<li>${output}</li>\``
561
561
  *
562
562
  * Wrap receives a lot of optional paramaters so that you can customize the behavior. For
563
563
  * instance, you may want to wrap the content but not the edit bar, or vice versa. See
@@ -640,7 +640,7 @@ export declare abstract class Page<DataType extends PageData = any, FetchedType
640
640
  /**
641
641
  * This is a bunch of javascript and CSS and meta tags managed by the DosGato engine. It will
642
642
  * be filled by the rendering server and your render function for your page template
643
- * should place include it in the <head> element
643
+ * should place include it in the `<head>` element
644
644
  */
645
645
  headContent: string;
646
646
  /**
package/dist/component.js CHANGED
@@ -13,40 +13,6 @@ export class Component extends ResourceProvider {
13
13
  * Provide this when you create a template to identify what you are defining.
14
14
  */
15
15
  static templateKey;
16
- /**
17
- * The rendering server will provide an instance of the APIClient interface so that
18
- * you can run any API GraphQL query you like in your `fetch` function. There are also
19
- * some useful methods there like processRich to help you convert links in rich text
20
- * strings.
21
- *
22
- * Do NOT mutate data received from the API as it may be cached and given to other
23
- * Component instances that run the same type of query.
24
- */
25
- api;
26
- /**
27
- * This property will be set during page render and you may refer to it at any time to
28
- * determine whether you are doing your work in edit mode or regular rendering mode.
29
- * The editBar and newBar methods will automatically use it to blank out the editing UI.
30
- */
31
- editMode;
32
- /**
33
- * The extension of the variation currently being rendered.
34
- *
35
- * See 'renderVariation' and 'variationsToFetch' for more discussion of variations.
36
- */
37
- extension;
38
- /**
39
- * When hydrating an inherited component, the renderer will set this to the id of the page it
40
- * came from. You may use this information in any of the phases to alter your behavior if needed.
41
- *
42
- * For instance, you may decide that your fetch function needs some extra information from the
43
- * originating page instead of the page you're being inherited into (your `this.page` will
44
- * be the page currently being rendered, NOT the page the inheritable component came from).
45
- *
46
- * This property is also used to alter the edit bar. Inherited components may never be edited
47
- * except on their original page, so the edit bar will render with a link to the original page.
48
- */
49
- inheritedFrom;
50
16
  /**
51
17
  * The first phase of rendering a component is the fetch phase. Each component may
52
18
  * provide a fetch method that looks up data it needs from external sources. This step
@@ -89,17 +55,6 @@ export class Component extends ResourceProvider {
89
55
  * '.js.map', you should receive 'js.map'.
90
56
  */
91
57
  shouldFetchVariation(extension) { return extension === 'html'; }
92
- /**
93
- * Some components may be inheritable to subpages within the same site. For instance, a site's
94
- * social media links may appear on every page's footer. To accomplish this in your template,
95
- * you need to fetch ancestor page data in your fetch phase, identify the component data you want
96
- * to inherit, and then call this function within your fetch to let the renderer know it needs to
97
- * process those components (hydrate them, call their fetch functions, and include them in the render).
98
- *
99
- * The inherited components will be added to the appropriate area's array in the renderedAreas
100
- * parameter of your render function.
101
- */
102
- registerInherited;
103
58
  /**
104
59
  * Inherit components from another page with matching area
105
60
  *
@@ -134,44 +89,6 @@ export class Component extends ResourceProvider {
134
89
  setContext(renderCtxFromParent, areaName) {
135
90
  return renderCtxFromParent;
136
91
  }
137
- /**
138
- * This function will be provided by the rendering server and should be used inside your fetch
139
- * method to prepare editor-provided HTML for later rendering. It will do things like find and
140
- * resolve link definitions in the internal dosgato format.
141
- */
142
- fetchRichText;
143
- /**
144
- * This function will be provided by the rendering server and should be used during the render
145
- * phase to clean up editor-provided HTML. It will do things like clean up tags that were accidentally
146
- * left open to protect overall page integrity, and fix header levels for accessibility.
147
- *
148
- * For instance, an editor supplies a title to be placed above some rich editor content. The
149
- * title uses an <h2>, so the headers inside the rich editor content should start at <h3> and
150
- * should not use <h1> or <h2>.
151
- *
152
- * Setting headerLevel: 3 instructs the renderRichText function to analyze and rebalance the header
153
- * structure of the content so that if it had an h2, it woud be replaced with an h3. Additionally,
154
- * if the user skipped a header level (a WCAG violation) that situation will be repaired as well
155
- * as possible.
156
- *
157
- * If you do not provide a headerLevel, the one from `this.renderCtx` will be used. However, if you
158
- * provide a non-blank value for `advanceHeader`, the headerLevel from `this.renderCtx` + 1 will be used.
159
- *
160
- * This way you can easily render a piece of rich text in a component that has an optional title:
161
- *
162
- * this.renderRichText(this.data.richtext, { advanceHeader: this.data.title })
163
- *
164
- * If this.data.title is non-blank, the rich text will be balanced below it, but if it is blank,
165
- * it will be balanced at the level the title would have had.
166
- */
167
- renderRichText;
168
- /**
169
- * When we give editors the ability to enter raw HTML, we still need to minimally process it to
170
- * protect the rest of the page from unclosed tags and other syntax problems, but we don't want
171
- * to muck around with headers or links, so this function will be provided by the render server
172
- * and will only do the parsing and reconstruction part
173
- */
174
- renderRawHTML;
175
92
  /**
176
93
  * If you are rendering a variation for a component that has areas and children,
177
94
  * you can call Component.renderVariation(extension, this.renderedAreas) to help you easily
@@ -441,7 +358,7 @@ export class Page extends Component {
441
358
  /**
442
359
  * This is a bunch of javascript and CSS and meta tags managed by the DosGato engine. It will
443
360
  * be filled by the rendering server and your render function for your page template
444
- * should place include it in the <head> element
361
+ * should place include it in the `<head>` element
445
362
  */
446
363
  headContent;
447
364
  /**
package/dist/render.d.ts CHANGED
@@ -17,9 +17,9 @@ export interface PictureResize {
17
17
  src: string;
18
18
  }
19
19
  export interface PictureAttributes {
20
- /** string appropriate for the src attribute of the default <img> tag */
20
+ /** string appropriate for the src attribute of the default `<img>` tag */
21
21
  src: string;
22
- /** string appropriate for the srcset attribute of the default <img> tag, or use widths array to reconstruct */
22
+ /** string appropriate for the srcset attribute of the default `<img>` tag, or use widths array to reconstruct */
23
23
  srcset: string;
24
24
  /**
25
25
  * When an image link cannot be found, we still return the src and srcset with a non-working path so that the
@@ -36,11 +36,11 @@ export interface PictureAttributes {
36
36
  width: number;
37
37
  /** the original intrinsic height of the image uploaded by the editor */
38
38
  height: number;
39
- /** a list of alternate formats like AVIF or WEBP and their resizes, useful for creating <source> tags */
39
+ /** a list of alternate formats like AVIF or WEBP and their resizes, useful for creating `<source>` tags */
40
40
  alternates: {
41
- /** the mime type of this alternate source, useful for the type attribute on a <source> tag */
41
+ /** the mime type of this alternate source, useful for the type attribute on a `<source>` tag */
42
42
  mime: string;
43
- /** the full srcset for the <source> tag, or use widths array to reconstruct */
43
+ /** the full srcset for the `<source>` tag, or use widths array to reconstruct */
44
44
  srcset: string;
45
45
  /** a list of available widths in case you want to filter some out and recreate the srcset */
46
46
  widths: PictureResize[];
@@ -187,7 +187,7 @@ export interface APIClient {
187
187
  getAssetsByLink: (link: AssetLink | AssetFolderLink | string, recursive?: boolean) => Promise<AssetRecord[]>;
188
188
  /**
189
189
  * This function will retrieve information about an image to help you construct responsive HTML
190
- * for a <picture> element including the <img> and all <source> tags.
190
+ * for a `<picture>` element including the `<img>` and all `<source>` tags.
191
191
  *
192
192
  * The alt text it returns will be the default alternative text from the asset repository. Alt
193
193
  * text gathered from a template's dialog should generally take precedence (though the dialog may
@@ -43,7 +43,7 @@ export interface UITemplateBase {
43
43
  * during render. For instance, to set the id on an HTML element for reference by other
44
44
  * components or code.
45
45
  *
46
- * If your component has a dialog, dosgato-dialog has a <FieldIdentifier> component for this;
46
+ * If your component has a dialog, dosgato-dialog has a `<FieldIdentifier>` component for this;
47
47
  * it's invisible but either creates or maintains a random string.
48
48
  *
49
49
  * If your component has no dialog but still needs an identifier, you can name a property
@@ -326,7 +326,7 @@ export interface UIConfig {
326
326
  */
327
327
  environmentBackgroundColor?: (environmentConfig: any) => string | undefined;
328
328
  /**
329
- * Page title for the <head>
329
+ * Page title for the `<head>`
330
330
  */
331
331
  title?: string;
332
332
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {