@enonic/nextjs-adapter 6.0.0-beta.5 → 6.0.0-beta.7
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/README.md +56 -13
- package/dist/guillotine/combineMultipleQueries.js +2 -2
- package/dist/guillotine/combineMultipleQueries.js.map +1 -1
- package/dist/guillotine/fetchContentData.js +1 -1
- package/dist/guillotine/fetchContentData.js.map +1 -1
- package/dist/guillotine/fetchContentPathsForLocale.js +1 -1
- package/dist/guillotine/fetchContentPathsForLocale.js.map +1 -1
- package/dist/guillotine/fetchMetaData.js +1 -1
- package/dist/guillotine/fetchMetaData.js.map +1 -1
- package/dist/guillotine/getMetaData.js +5 -4
- package/dist/guillotine/getMetaData.js.map +1 -1
- package/dist/guillotine/getQueryAndVariables.js +1 -1
- package/dist/guillotine/getQueryAndVariables.js.map +1 -1
- package/dist/guillotine/metadata/richTextQuery.d.ts +2 -1
- package/dist/guillotine/metadata/richTextQuery.js +14 -10
- package/dist/guillotine/metadata/richTextQuery.js.map +1 -1
- package/dist/guillotine/urlQueries.d.ts +5 -1
- package/dist/guillotine/urlQueries.js +4 -4
- package/dist/guillotine/urlQueries.js.map +1 -1
- package/dist/guillotine/urls.js +1 -1
- package/dist/guillotine/urls.js.map +1 -1
- package/dist/types/component.d.ts +11 -7
- package/dist/types/componentProps.d.ts +2 -2
- package/dist/types/guillotine.d.ts +14 -10
- package/dist/types/urls.d.ts +1 -3
- package/dist/views/RichTextView.jsx +25 -17
- package/dist/views/RichTextView.jsx.map +1 -1
- package/dist/views/macros/DefaultMacro.d.ts +1 -2
- package/dist/views/macros/DefaultMacro.jsx +1 -1
- package/dist/views/macros/DefaultMacro.jsx.map +1 -1
- package/dist/views/macros/DisableMacro.d.ts +1 -1
- package/dist/views/macros/DisableMacro.jsx +1 -1
- package/dist/views/macros/DisableMacro.jsx.map +1 -1
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
> NextJS adapter with Guillotine support and basic views
|
|
4
4
|
|
|
5
|
+
Requires Enonic XP 8.1+ with Guillotine 9.
|
|
6
|
+
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
9
|
```bash
|
|
@@ -99,7 +101,7 @@ Usage:
|
|
|
99
101
|
```tsx
|
|
100
102
|
import {fetchGuillotine} from '@enonic/nextjs-adapter/server';
|
|
101
103
|
|
|
102
|
-
const apiUrl = 'http://domain:
|
|
104
|
+
const apiUrl = 'http://domain:8080/api/com.enonic.app.guillotine:graphql';
|
|
103
105
|
|
|
104
106
|
const body = {
|
|
105
107
|
query: 'qraphql query as string',
|
|
@@ -115,7 +117,7 @@ const headers = {
|
|
|
115
117
|
const opts = {
|
|
116
118
|
body,
|
|
117
119
|
headers,
|
|
118
|
-
method: '
|
|
120
|
+
method: 'POST',
|
|
119
121
|
next: {
|
|
120
122
|
revalidate: 60,
|
|
121
123
|
tags: ['tag1', 'tag2'],
|
|
@@ -315,10 +317,10 @@ turns the returned object into the final URL string.
|
|
|
315
317
|
| `attachmentUrl` | `attachmentUrlQuery(args?: MediaUrlArgs)` | `attachmentUrl(data)` |
|
|
316
318
|
| `pageUrl` | `pageUrlQuery(args?: PageUrlArgs)` | `pageUrl(data, meta)` |
|
|
317
319
|
|
|
318
|
-
The query builders accept the same arguments as the Guillotine field (`scale`, `quality`, `background`, `format`, `filter
|
|
319
|
-
`imageUrl`; `download
|
|
320
|
-
`
|
|
321
|
-
(`pageUrl` has `
|
|
320
|
+
The query builders accept the same arguments as the Guillotine field (`scale`, `quality`, `background`, `format`, `filter` for
|
|
321
|
+
`imageUrl`; `download` for `mediaUrl`/`attachmentUrl`; `params` for `pageUrl`) and select every field of the returned object:
|
|
322
|
+
`path`, `queryString`, `context`, `id`, `fingerprint`, `name`, plus `scale` for images and `intent` for media and attachments
|
|
323
|
+
(`pageUrl` has `baseUrl`, `path` and `queryString`).
|
|
322
324
|
Media functions return absolute URLs pointing at the XP media API (`ENONIC_MEDIA_CDN`, defaulting to `ENONIC_API`). `pageUrl` returns a
|
|
323
325
|
relative path for the Next.js router, prefixed with the locale unless it is the default locale (`meta.locale` vs `meta.defaultLocale`);
|
|
324
326
|
`meta` is the runtime data returned by [fetchContent](#fetch-content). Pass `{locale}` alone to always prefix, e.g. for `revalidatePath`.
|
|
@@ -350,7 +352,7 @@ mapping's locale unless it is the default one, leaving sources untouched.
|
|
|
350
352
|
|
|
351
353
|
<br/>
|
|
352
354
|
|
|
353
|
-
#### <a id="rich-text-query"></a>`richTextQuery(fieldName: string) => string`
|
|
355
|
+
#### <a id="rich-text-query"></a>`richTextQuery(fieldName: string, options?: RichTextQueryOptions) => string`
|
|
354
356
|
|
|
355
357
|
This is a utility function for querying for `RichTextData` needed for [RichTextView](#rich-text-view). It creates a graphql query string for
|
|
356
358
|
HTML area input type with given field name.
|
|
@@ -369,14 +371,41 @@ through `withRichTextFragments(query)`.
|
|
|
369
371
|
| Argument | Description |
|
|
370
372
|
|-------------|----------------------|
|
|
371
373
|
| `fieldName` | HTML area field name |
|
|
374
|
+
| `options` | Optional per-field image settings passed to Guillotine's `processHtml` input. Each omitted setting independently retains its current behavior. |
|
|
375
|
+
|
|
376
|
+
`RichTextQueryOptions` is exported by the adapter:
|
|
377
|
+
|
|
378
|
+
| Option | Type | Default when omitted |
|
|
379
|
+
|--------|------|----------------------|
|
|
380
|
+
| `imageWidths` | `number[]` | `[400, 800, 1200]` for responsive `srcset` candidates. |
|
|
381
|
+
| `imageSizes` | `string` | `"(max-width: 400px) 400px, (max-width: 800px) 800px, 1200px"` for the HTML `sizes` attribute. |
|
|
382
|
+
| `imageSrcWidth` | `number` | Not sent; Guillotine retains its default primary image width of 768px. |
|
|
383
|
+
|
|
384
|
+
Passing an empty array or string is an explicit override, not an omitted option.
|
|
385
|
+
These settings apply at query time, not as rendering props. Different fields in the same document can use different settings
|
|
386
|
+
while sharing the same fragment definitions.
|
|
387
|
+
|
|
388
|
+
```ts
|
|
389
|
+
import {richTextQuery, type RichTextQueryOptions} from '@enonic/nextjs-adapter';
|
|
390
|
+
|
|
391
|
+
// Only the primary source width changes; responsive widths and sizes keep their defaults.
|
|
392
|
+
const bioQuery = richTextQuery('bio', {imageSrcWidth: 640});
|
|
393
|
+
|
|
394
|
+
const imageOptions: RichTextQueryOptions = {
|
|
395
|
+
imageWidths: [320, 640, 960],
|
|
396
|
+
imageSizes: '(max-width: 640px) 100vw, 640px',
|
|
397
|
+
imageSrcWidth: 640
|
|
398
|
+
};
|
|
399
|
+
const textQuery = richTextQuery('text', imageOptions);
|
|
400
|
+
```
|
|
372
401
|
|
|
373
402
|
Usage:
|
|
374
403
|
|
|
375
404
|
```tsx
|
|
376
405
|
import {richTextQuery} from '@enonic/nextjs-adapter';
|
|
377
406
|
|
|
378
|
-
const query = `query($path:ID
|
|
379
|
-
guillotine {
|
|
407
|
+
const query = `query($path:ID!, $scopeKey:String, $project:String, $branch:String){
|
|
408
|
+
guillotine(scopeKey: $scopeKey, project: $project, branch: $branch) {
|
|
380
409
|
get(key:$path) {
|
|
381
410
|
_path
|
|
382
411
|
type
|
|
@@ -500,10 +529,10 @@ import {ComponentRegistry} from '@enonic/nextjs-adapter';
|
|
|
500
529
|
|
|
501
530
|
const query = {
|
|
502
531
|
query: 'graphql query',
|
|
503
|
-
variables: ({path,
|
|
532
|
+
variables: ({path, scopeKey, branch, project}, context, config) => {
|
|
504
533
|
return {
|
|
505
534
|
path: path + '/some/processing',
|
|
506
|
-
|
|
535
|
+
scopeKey,
|
|
507
536
|
branch,
|
|
508
537
|
project,
|
|
509
538
|
};
|
|
@@ -524,7 +553,7 @@ Gets the common query definition.
|
|
|
524
553
|
```tsx
|
|
525
554
|
interface GlobalVariables {
|
|
526
555
|
path: string;
|
|
527
|
-
|
|
556
|
+
scopeKey: string;
|
|
528
557
|
branch: string;
|
|
529
558
|
project: string;
|
|
530
559
|
}
|
|
@@ -1013,13 +1042,17 @@ Requires `transpilePackages: ['@enonic/nextjs-adapter']` in `next.config.js` so
|
|
|
1013
1042
|
|
|
1014
1043
|
Tag for displaying contents of html area input types. Takes care of processing macros, URLs and images inside.
|
|
1015
1044
|
|
|
1045
|
+
`RichTextData`, `LinkData`, `ImageData`, `MacroData`, and `MacroConfig` are shared with and re-exported from
|
|
1046
|
+
`@enonic/react-components`. Rich-text URL values can be strings (used unchanged) or URL parts (resolved by the adapter using its
|
|
1047
|
+
locale and media configuration). The adapter renders the original reference entries without rewriting their data.
|
|
1048
|
+
|
|
1016
1049
|
| Argument | Type | Description |
|
|
1017
1050
|
|------------------|----------------|---------------------------------------------------------------------------------------------------|
|
|
1018
1051
|
| `data` | `RichTextData` | Rich text data |
|
|
1019
1052
|
| `meta` | `MetaData` | Runtime data returned by fetchContent method. |
|
|
1020
1053
|
| `customReplacer` | `Replacer` | Function to do custom element processing. Not invoked for image, link and macro nodes. _Optional_ |
|
|
1021
1054
|
| `className` | `String` | Class name to add to the root html element. _Optional_ |
|
|
1022
|
-
| `tag = '
|
|
1055
|
+
| `tag = 'section'` | `ElementType` | Element to use as a root. An html tag name, a component, or `Fragment` to render no root element at all. _Optional_ |
|
|
1023
1056
|
|
|
1024
1057
|
> **TIP!** There is a utility function [richTextQuery(fieldName)](#rich-text-query) generating part of the graphql query to
|
|
1025
1058
|
> obtain `RichTextData` for html area input types.
|
|
@@ -1032,6 +1065,16 @@ import RichTextView from '@enonic/nextjs-adapter/views/RichTextView';
|
|
|
1032
1065
|
<RichTextView data={richTextData} meta={meta} tag="section" className="rich-text-view"></RichTextView>
|
|
1033
1066
|
```
|
|
1034
1067
|
|
|
1068
|
+
To render the rich text without any wrapping element, pass `Fragment` as the tag. Note that `className` has
|
|
1069
|
+
nowhere to go in that case and is ignored, so apply styling to a surrounding element instead.
|
|
1070
|
+
|
|
1071
|
+
```tsx
|
|
1072
|
+
import {Fragment} from 'react';
|
|
1073
|
+
import RichTextView from '@enonic/nextjs-adapter/views/RichTextView';
|
|
1074
|
+
|
|
1075
|
+
<RichTextView data={richTextData} meta={meta} tag={Fragment}></RichTextView>
|
|
1076
|
+
```
|
|
1077
|
+
|
|
1035
1078
|
<br/>
|
|
1036
1079
|
|
|
1037
1080
|
#### `<Regions page={page} meta={meta} name="main" common={common}>`
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const ALIAS_PREFIX = 'request';
|
|
2
2
|
const GRAPHQL_FRAGMENTS_REGEXP = /fragment\s+.+\s+on\s+.+\s*{[\s\w{}().,:"'`]+}/;
|
|
3
3
|
// const GUILLOTINE_QUERY_REGEXP = /^\s*query\s*(?:\((.*)*\))?\s*{\s*guillotine\s*{((?:.|\s)+)}\s*}\s*$/;
|
|
4
|
-
const GUILLOTINE_QUERY_REGEXP = /^\s*query\s*(?:\(([^)]*)\))?\s*{\s*((?:.|\s)+)\s*}\s*$/;
|
|
5
|
-
const GLOBAL_PARAMS = [{ key: 'path', type: 'ID!' }, { key: '
|
|
4
|
+
const GUILLOTINE_QUERY_REGEXP = /^\s*query(?:\s+[_A-Za-z]\w*)?\s*(?:\(([^)]*)\))?\s*{\s*((?:.|\s)+)\s*}\s*$/;
|
|
5
|
+
const GLOBAL_PARAMS = [{ key: 'path', type: 'ID!' }, { key: 'scopeKey', type: 'String' }, { key: 'project', type: 'String' },
|
|
6
6
|
{ key: 'branch', type: 'String' }];
|
|
7
7
|
export function combineMultipleQueries(queriesWithVars) {
|
|
8
8
|
const queries = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combineMultipleQueries.js","sourceRoot":"","sources":["../../src/guillotine/combineMultipleQueries.ts"],"names":[],"mappings":"AAGA,MAAM,YAAY,GAAG,SAAS,CAAC;AAE/B,MAAM,wBAAwB,GAAG,+CAA+C,CAAC;AAEjF,yGAAyG;AACzG,MAAM,uBAAuB,GAAG,
|
|
1
|
+
{"version":3,"file":"combineMultipleQueries.js","sourceRoot":"","sources":["../../src/guillotine/combineMultipleQueries.ts"],"names":[],"mappings":"AAGA,MAAM,YAAY,GAAG,SAAS,C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AAO,CAAC,IAAI,CAAC,GAAG,YAAY,IAAI,KAAK,EAAE,CAAC,CAAC;YAEzC,mEAAmE;YACnE,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAC1B,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;gBAC1C,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBAClE,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC1B,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,0BAA0B;IAC1B,MAAM,UAAU,GAAG,SAAS,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;UAC7E,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;;MAEtB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;KACrB,CAAC;IAEF,OAAO;QACH,KAAK,EAAE,UAAU;QACjB,SAAS,EAAE,SAAS;KACvB,CAAC;AACN,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchContentData.js","sourceRoot":"","sources":["../../src/guillotine/fetchContentData.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EACjC,aAAqB,EACrB,WAAmB,EACnB,OAAsB,EACtB,MAAc,EACd,KAAa,EACb,SAAuC,EACvC,OAAkC,EACZ,EAAE;IACxB,MAAM,IAAI,GAAuB;QAC7B,KAAK;QACL,SAAS,EAAE;YACP,IAAI,EAAE,WAAW;YACjB,
|
|
1
|
+
{"version":3,"file":"fetchContentData.js","sourceRoot":"","sources":["../../src/guillotine/fetchContentData.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EACjC,aAAqB,EACrB,WAAmB,EACnB,OAAsB,EACtB,MAAc,EACd,KAAa,EACb,SAAuC,EACvC,OAAkC,EACZ,EAAE;IACxB,MAAM,IAAI,GAAuB;QAC7B,KAAK;QACL,SAAS,EAAE;YACP,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,OAAO,CAAC,IAAI;YACtB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,MAAM;SACT;KACJ,CAAC;IACF,IAAI,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjD,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC9D,CAAC;IACD,MAAM,cAAc,GAAG,MAAM,eAAe,CAAyB,aAAa,EAAE;QAChF,IAAI;QACJ,OAAO;KACV,CAAC,CAAC;IAEH,IAAI,cAAc,CAAC,KAAK,EAAE,CAAC;QACvB,OAAO,cAAc,CAAC;IAC1B,CAAC;SAAM,CAAC;QACJ,OAAO;YACH,qCAAqC;YACrC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;SAC1C,CAAC;IACN,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchContentPathsForLocale.js","sourceRoot":"","sources":["../../src/guillotine/fetchContentPathsForLocale.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,sBAAsB,EAAC,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAA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AAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CACtC,IAAuB,EACvB,KAAU,EACZ,EAAE;;YACA,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,CAAA,MAAA,KAAK,CAAC,IAAI,0CAAE,KAAK,EAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACnF,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACpD,IAAI,CAAC,IAAI,CAAC;gBACN,WAAW,EAAE,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC;gBACnC,MAAM,EAAE,OAAO,CAAC,MAAM;aACzB,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QAChB,CAAC,EAAE,EAAE,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchMetaData.js","sourceRoot":"","sources":["../../src/guillotine/fetchMetaData.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,YAAY,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAC9B,aAAqB,EACrB,WAAmB,EACnB,OAAsB,EACtB,MAAc,EACd,OAAkC,EACf,EAAE;;IACrB,MAAM,IAAI,GAAuB;QAC7B,KAAK,EAAE,YAAY,CAAC,iBAAiB,EAAE,CAAC;QACxC,SAAS,EAAE;YACP,IAAI,EAAE,WAAW;YACjB,
|
|
1
|
+
{"version":3,"file":"fetchMetaData.js","sourceRoot":"","sources":["../../src/guillotine/fetchMetaData.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,YAAY,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAC9B,aAAqB,EACrB,WAAmB,EACnB,OAAsB,EACtB,MAAc,EACd,OAAkC,EACf,EAAE;;IACrB,MAAM,IAAI,GAAuB;QAC7B,KAAK,EAAE,YAAY,CAAC,iBAAiB,EAAE,CAAC;QACxC,SAAS,EAAE;YACP,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,OAAO,CAAC,IAAI;YACtB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,MAAM;SACT;KACJ,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,eAAe,CAAa,aAAa,EAAE;QAChE,IAAI;QACJ,OAAO;KACV,CAAC,CAAC;IACH,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;QACnB,OAAO,UAAU,CAAC;IACtB,CAAC;SAAM,CAAC;QACJ,OAAO;YACH,IAAI,EAAE,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,UAAU,0CAAE,GAAG;SACpC,CAAC;IACN,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -37,8 +37,9 @@ ${indent(partConfigQuery(), 4)}
|
|
|
37
37
|
image {
|
|
38
38
|
caption
|
|
39
39
|
image {
|
|
40
|
-
imageUrl(scale: "width
|
|
41
|
-
|
|
40
|
+
imageUrl(scale: "width(768)") {
|
|
41
|
+
path
|
|
42
|
+
queryString
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
}`;
|
|
@@ -64,8 +65,8 @@ ${indent(pageFragment || '', 4)}
|
|
|
64
65
|
}
|
|
65
66
|
export function queryGuillotine(query, args) {
|
|
66
67
|
const argsString = args && Object.entries(args).map(([name, type]) => `${name}: ${type}`);
|
|
67
|
-
return `query($
|
|
68
|
-
guillotine(
|
|
68
|
+
return `query($scopeKey: String, $project: String, $branch: String${argsString ? ', ' + argsString.join(', ') : ''}) {
|
|
69
|
+
guillotine(scopeKey: $scopeKey, project: $project, branch: $branch) {
|
|
69
70
|
${query}
|
|
70
71
|
}
|
|
71
72
|
}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMetaData.js","sourceRoot":"","sources":["../../src/guillotine/getMetaData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAGvC,MAAM,eAAe,GAAG,GAAW,EAAE;IACjC,OAAO,WAAW,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC,CAAC;AACrD,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,GAAW,EAAE;IACnC,OAAO,WAAW,CAAC,iBAAiB,CAAC,UAAU,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,GAAW,EAAE;IACjC,OAAO,WAAW,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC,CAAC;AACrD,CAAC,CAAC;AAGF;;GAEG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC;;;;EAI5B,MAAM,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;;;;;;;EAO5B,MAAM,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;;;EAG9B,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;;;;EAIjC,MAAM,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC
|
|
1
|
+
{"version":3,"file":"getMetaData.js","sourceRoot":"","sources":["../../src/guillotine/getMetaData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAC,aAAa,EAAC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,CAAC;QACpE,MAAM,KAAK,CAAC,0BAA0B,IAAI,yCAAyC,OAAO,KAAK,EAAE,CAAC,CAAC;IACvG,CAAC;IAED,IAAI,SAAS,GAAoB;QAC7B,IAAI;QACJ,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,QAAQ,EAAE,OAAO,CAAC,IAAI;QACtB,MAAM;KACT,CAAC;IAEF,IAAI,YAAY,EAAE,CAAC;QACf,SAAS,GAAG,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAC9B,KAAK,GAAG,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,KAAK,EAAE,CAAC;QACR,OAAO;YACH,KAAK;YACL,SAAS;SACZ,CAAC;IACN,CAAC;AACL,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { RichTextQueryOptions } from '../../types';
|
|
1
2
|
export declare const RICH_TEXT_MACROS_FRAGMENT = "RichTextMacros";
|
|
2
3
|
export declare const RICH_TEXT_LINKS_FRAGMENT = "RichTextLinks";
|
|
3
4
|
export declare const RICH_TEXT_IMAGES_FRAGMENT = "RichTextImages";
|
|
4
|
-
export declare const richTextQuery: (fieldName: string) => string;
|
|
5
|
+
export declare const richTextQuery: (fieldName: string, options?: RichTextQueryOptions) => string;
|
|
5
6
|
/** The fragment definitions behind richTextQuery(); evaluated when called, so the registered macros are included */
|
|
6
7
|
export declare const richTextFragments: () => string;
|
|
7
8
|
/** Appends the definitions of the rich text fragments a document spreads but does not define (fetchGuillotine does this) */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentRegistry } from '../../common/ComponentRegistry';
|
|
2
2
|
import { configQuery } from './configQuery';
|
|
3
3
|
import { indent } from '../../utils/indent';
|
|
4
|
-
import { imageUrlQuery, mediaUrlQuery, pageUrlQuery } from '../urlQueries';
|
|
4
|
+
import { IMAGE_URL_FIELDS, imageUrlQuery, mediaUrlQuery, pageUrlQuery, toGraphqlLiteral } from '../urlQueries';
|
|
5
5
|
// Fragments on Guillotine's rich text member types: spread by every rich text field, defined once per document
|
|
6
6
|
export const RICH_TEXT_MACROS_FRAGMENT = 'RichTextMacros';
|
|
7
7
|
export const RICH_TEXT_LINKS_FRAGMENT = 'RichTextLinks';
|
|
@@ -9,8 +9,10 @@ export const RICH_TEXT_IMAGES_FRAGMENT = 'RichTextImages';
|
|
|
9
9
|
const macroConfigQuery = () => {
|
|
10
10
|
return configQuery(ComponentRegistry.getMacros(), false, false);
|
|
11
11
|
};
|
|
12
|
-
export const richTextQuery = (fieldName) => {
|
|
13
|
-
|
|
12
|
+
export const richTextQuery = (fieldName, options = {}) => {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const processHtml = Object.assign({ imageWidths: (_a = options.imageWidths) !== null && _a !== void 0 ? _a : [400, 800, 1200], imageSizes: (_b = options.imageSizes) !== null && _b !== void 0 ? _b : '(max-width: 400px) 400px, (max-width: 800px) 800px, 1200px' }, (options.imageSrcWidth !== undefined ? { imageSrcWidth: options.imageSrcWidth } : {}));
|
|
15
|
+
return `${fieldName}(processHtml:${toGraphqlLiteral(processHtml)}) {
|
|
14
16
|
processedHtml
|
|
15
17
|
macros {
|
|
16
18
|
...${RICH_TEXT_MACROS_FRAGMENT}
|
|
@@ -32,30 +34,32 @@ const fragmentDefinitions = () => [
|
|
|
32
34
|
[RICH_TEXT_LINKS_FRAGMENT, `fragment ${RICH_TEXT_LINKS_FRAGMENT} on Link {
|
|
33
35
|
ref
|
|
34
36
|
uri
|
|
37
|
+
fragment
|
|
38
|
+
${pageUrlQuery()}
|
|
35
39
|
content {
|
|
36
40
|
_path
|
|
37
41
|
_id
|
|
38
|
-
${pageUrlQuery()}
|
|
39
42
|
}
|
|
40
43
|
media {
|
|
44
|
+
${mediaUrlQuery()}
|
|
41
45
|
content {
|
|
42
46
|
_id
|
|
43
|
-
... on media_Image {
|
|
44
|
-
${mediaUrlQuery()}
|
|
45
|
-
}
|
|
46
47
|
}
|
|
47
48
|
intent
|
|
48
49
|
}
|
|
49
50
|
}`],
|
|
50
51
|
[RICH_TEXT_IMAGES_FRAGMENT, `fragment ${RICH_TEXT_IMAGES_FRAGMENT} on Image {
|
|
51
52
|
ref
|
|
53
|
+
src ${IMAGE_URL_FIELDS}
|
|
54
|
+
srcset {
|
|
55
|
+
width
|
|
56
|
+
${imageUrlQuery()}
|
|
57
|
+
}
|
|
52
58
|
image {
|
|
53
59
|
_id
|
|
54
|
-
... on media_Image {
|
|
55
|
-
${imageUrlQuery({ scale: 'width(768)' })}
|
|
56
|
-
}
|
|
57
60
|
}
|
|
58
61
|
style {
|
|
62
|
+
application
|
|
59
63
|
name
|
|
60
64
|
aspectRatio
|
|
61
65
|
filter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"richTextQuery.js","sourceRoot":"","sources":["../../../src/guillotine/metadata/richTextQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAE,aAAa,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"richTextQuery.js","sourceRoot":"","sources":["../../../src/guillotine/metadata/richTextQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAC,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAI7G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AAoH;AACpH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAW,EAAE;IAC1C,OAAO,mBAAmB,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChF,CAAC,CAAC;AAEF,4HAA4H;AAC5H,MAAM,UAAU,qBAAqB,CAAC,KAAa;IAC/C,MAAM,OAAO,GAAG,mBAAmB,EAAE;SAChC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,IAAI,GAAG,CAAC,CAAC;SACxF,GAAG,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC;IAEzC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AACtE,CAAC"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { ImageUrlArgs, MediaUrlArgs, PageUrlArgs } from '../types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const IMAGE_URL_FIELDS = "{ path queryString context id fingerprint scale name }";
|
|
3
|
+
export declare const ATTACHMENT_URL_FIELDS = "{ path queryString context id fingerprint name intent }";
|
|
4
|
+
export declare const PAGE_URL_FIELDS = "{ baseUrl path queryString }";
|
|
5
|
+
export declare const imageUrlQuery: (args?: ImageUrlArgs) => string;
|
|
3
6
|
export declare const mediaUrlQuery: (args?: MediaUrlArgs) => string;
|
|
4
7
|
export declare const attachmentUrlQuery: (args?: MediaUrlArgs) => string;
|
|
5
8
|
export declare const pageUrlQuery: (args?: PageUrlArgs) => string;
|
|
9
|
+
export declare function toGraphqlLiteral(value: unknown): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Every field of the Guillotine 9 result types, so callers can build their own URLs from the parts
|
|
2
|
-
const IMAGE_URL_FIELDS = '{
|
|
3
|
-
const ATTACHMENT_URL_FIELDS = '{
|
|
4
|
-
const PAGE_URL_FIELDS = '{
|
|
2
|
+
export const IMAGE_URL_FIELDS = '{ path queryString context id fingerprint scale name }';
|
|
3
|
+
export const ATTACHMENT_URL_FIELDS = '{ path queryString context id fingerprint name intent }';
|
|
4
|
+
export const PAGE_URL_FIELDS = '{ baseUrl path queryString }';
|
|
5
5
|
export const imageUrlQuery = (args) => `imageUrl${toGraphqlArgs(args)} ${IMAGE_URL_FIELDS}`;
|
|
6
6
|
export const mediaUrlQuery = (args) => `mediaUrl${toGraphqlArgs(args)} ${ATTACHMENT_URL_FIELDS}`;
|
|
7
7
|
export const attachmentUrlQuery = (args) => `attachmentUrl${toGraphqlArgs(args)} ${ATTACHMENT_URL_FIELDS}`;
|
|
@@ -10,7 +10,7 @@ function toGraphqlArgs(args = {}) {
|
|
|
10
10
|
const entries = Object.entries(args).filter(([, value]) => value !== undefined && value !== null);
|
|
11
11
|
return entries.length ? `(${entries.map(([key, value]) => `${key}: ${toGraphqlLiteral(value)}`).join(', ')})` : '';
|
|
12
12
|
}
|
|
13
|
-
function toGraphqlLiteral(value) {
|
|
13
|
+
export function toGraphqlLiteral(value) {
|
|
14
14
|
if (Array.isArray(value)) {
|
|
15
15
|
return `[${value.map(toGraphqlLiteral).join(', ')}]`;
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlQueries.js","sourceRoot":"","sources":["../../src/guillotine/urlQueries.ts"],"names":[],"mappings":"AAEA,mGAAmG;AACnG,MAAM,gBAAgB,GAAG,
|
|
1
|
+
{"version":3,"file":"urlQueries.js","sourceRoot":"","sources":["../../src/guillotine/urlQueries.ts"],"names":[],"mappings":"AAEA,mGAAmG;AACnG,MAAM,CAAC,MAAM,g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I,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IACzD,CAAC;IACD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9C,0DAA0D;QAC1D,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IAC3G,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC"}
|
package/dist/guillotine/urls.js
CHANGED
|
@@ -10,7 +10,7 @@ export function attachmentUrl(data) {
|
|
|
10
10
|
return toMediaUrl(data);
|
|
11
11
|
}
|
|
12
12
|
export function pageUrl(data, meta) {
|
|
13
|
-
return data ? getPageUrl(data.path + (data.queryString || '')
|
|
13
|
+
return data ? getPageUrl(data.path, meta) + (data.queryString || '') : undefined;
|
|
14
14
|
}
|
|
15
15
|
function toMediaUrl(data) {
|
|
16
16
|
return data ? getMediaUrl(data.path + (data.queryString || '')) : undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urls.js","sourceRoot":"","sources":["../../src/guillotine/urls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAI/C,MAAM,UAAU,QAAQ,CAAC,IAAgC;IACrD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAID,MAAM,UAAU,QAAQ,CAAC,IAAqC;IAC1D,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAID,MAAM,UAAU,aAAa,CAAC,IAAqC;IAC/D,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAMD,MAAM,UAAU,OAAO,CAAC,IAA0C,EAAE,IAAiB;IACjF,OAAO,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"urls.js","sourceRoot":"","sources":["../../src/guillotine/urls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAI/C,MAAM,UAAU,QAAQ,CAAC,IAAgC;IACrD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAID,MAAM,UAAU,QAAQ,CAAC,IAAqC;IAC1D,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAID,MAAM,UAAU,aAAa,CAAC,IAAqC;IAC/D,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAMD,MAAM,UAAU,OAAO,CAAC,IAA0C,EAAE,IAAiB;IACjF,OAAO,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACrF,CAAC;AAED,SAAS,UAAU,CAAC,IAAsC;IACtD,OAAO,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { XP_COMPONENT_TYPE } from '../common/constants';
|
|
2
2
|
import type { Context } from './next';
|
|
3
|
-
import type { RichTextData
|
|
3
|
+
import type { RichTextData } from '@enonic/react-components';
|
|
4
|
+
export type { RichTextData, LinkData, ImageData, MacroData, MacroConfig } from '@enonic/react-components';
|
|
4
5
|
export interface ComponentDefinitionParams {
|
|
5
6
|
query?: SelectedQueryMaybeVariablesFunc;
|
|
6
7
|
configQuery?: string;
|
|
@@ -33,15 +34,11 @@ export interface FragmentData {
|
|
|
33
34
|
components: PageComponent[];
|
|
34
35
|
};
|
|
35
36
|
}
|
|
36
|
-
export type ImageData = CompsImageData;
|
|
37
37
|
export interface LayoutData {
|
|
38
38
|
descriptor: string;
|
|
39
39
|
config?: any;
|
|
40
40
|
[customKeysFromQuery: string]: any;
|
|
41
41
|
}
|
|
42
|
-
export type LinkData = CompsLinkData;
|
|
43
|
-
export type MacroConfig = Record<string, any>;
|
|
44
|
-
export type MacroData = CompsMacroData;
|
|
45
42
|
export interface PageComponent {
|
|
46
43
|
[key: string]: any;
|
|
47
44
|
type: XP_COMPONENT_TYPE;
|
|
@@ -75,9 +72,17 @@ export interface QueryAndVariables {
|
|
|
75
72
|
query: string;
|
|
76
73
|
variables?: Record<string, any>;
|
|
77
74
|
}
|
|
75
|
+
export interface RichTextQueryOptions {
|
|
76
|
+
/** Responsive image widths. Defaults to [400, 800, 1200]. */
|
|
77
|
+
imageWidths?: number[];
|
|
78
|
+
/** HTML sizes expression. Defaults to the adapter's 400/800/1200px breakpoints. */
|
|
79
|
+
imageSizes?: string;
|
|
80
|
+
/** Primary image width. Omitted by default, preserving Guillotine's default of 768px. */
|
|
81
|
+
imageSrcWidth?: number;
|
|
82
|
+
}
|
|
78
83
|
export interface GlobalVariables {
|
|
79
84
|
path: string;
|
|
80
|
-
|
|
85
|
+
scopeKey: string;
|
|
81
86
|
branch: string;
|
|
82
87
|
project: string;
|
|
83
88
|
}
|
|
@@ -87,7 +92,6 @@ export type SelectedQueryMaybeVariablesFunc = string | QueryGetter | {
|
|
|
87
92
|
variables: VariablesGetter;
|
|
88
93
|
} | [string | QueryGetter, VariablesGetter];
|
|
89
94
|
export type RegionTree = Record<string, PageRegion>;
|
|
90
|
-
export type RichTextData = CompsRichTextData;
|
|
91
95
|
export interface TextData {
|
|
92
96
|
value: RichTextData;
|
|
93
97
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DOMNode } from 'html-react-parser';
|
|
2
2
|
import type { RENDER_MODE, XP_REQUEST_TYPE } from '../common/constants';
|
|
3
3
|
import type { FragmentData, LayoutData, MacroConfig, MacroData, PageComponent, PageData, PartData, RichTextData, RegionTree } from './component';
|
|
4
|
-
import type { ReactNode, ReactElement } from 'react';
|
|
4
|
+
import type { ReactNode, ReactElement, ElementType } from 'react';
|
|
5
5
|
export interface BaseComponentProps {
|
|
6
6
|
component: PageComponent;
|
|
7
7
|
meta: MetaData;
|
|
@@ -102,6 +102,6 @@ export interface RichTextViewProps {
|
|
|
102
102
|
data: RichTextData;
|
|
103
103
|
meta: MetaData;
|
|
104
104
|
className?: string;
|
|
105
|
-
tag?:
|
|
105
|
+
tag?: ElementType;
|
|
106
106
|
customReplacer?: Replacer;
|
|
107
107
|
}
|
|
@@ -70,7 +70,7 @@ interface Attachment {
|
|
|
70
70
|
label: string;
|
|
71
71
|
size: number;
|
|
72
72
|
mimeType: string;
|
|
73
|
-
attachmentUrl:
|
|
73
|
+
attachmentUrl: AttachmentUrl;
|
|
74
74
|
}
|
|
75
75
|
type DateTime = string;
|
|
76
76
|
export interface Component {
|
|
@@ -85,7 +85,7 @@ export interface Component {
|
|
|
85
85
|
}
|
|
86
86
|
type ComponentType = 'page' | 'layout' | 'image' | 'part' | 'text' | 'fragment';
|
|
87
87
|
export interface PageUrl {
|
|
88
|
-
|
|
88
|
+
baseUrl: string;
|
|
89
89
|
path: string;
|
|
90
90
|
queryString: string;
|
|
91
91
|
}
|
|
@@ -132,7 +132,7 @@ interface ContentEdge {
|
|
|
132
132
|
}
|
|
133
133
|
interface ContentType {
|
|
134
134
|
name: string;
|
|
135
|
-
|
|
135
|
+
title: string;
|
|
136
136
|
description: string;
|
|
137
137
|
superType: string;
|
|
138
138
|
abstract: boolean;
|
|
@@ -173,8 +173,6 @@ export interface HeadlessCms {
|
|
|
173
173
|
getSite?: portal_Site;
|
|
174
174
|
getType?: ContentType;
|
|
175
175
|
getTypes?: ContentType[];
|
|
176
|
-
query?: Content[];
|
|
177
|
-
queryConnection?: QueryContentConnection;
|
|
178
176
|
queryDsl?: Content[];
|
|
179
177
|
queryDslConnection?: QueryDSLContentConnection;
|
|
180
178
|
}
|
|
@@ -186,6 +184,12 @@ interface Image {
|
|
|
186
184
|
image: Content;
|
|
187
185
|
ref: string;
|
|
188
186
|
style: ImageStyle;
|
|
187
|
+
src: ImageUrl | null;
|
|
188
|
+
srcset: ImageSource[];
|
|
189
|
+
}
|
|
190
|
+
interface ImageSource {
|
|
191
|
+
width: number;
|
|
192
|
+
imageUrl: ImageUrl;
|
|
189
193
|
}
|
|
190
194
|
interface ImageComponentData {
|
|
191
195
|
id: string;
|
|
@@ -193,6 +197,7 @@ interface ImageComponentData {
|
|
|
193
197
|
image: media_Image;
|
|
194
198
|
}
|
|
195
199
|
interface ImageStyle {
|
|
200
|
+
application: string;
|
|
196
201
|
name: string;
|
|
197
202
|
aspectRatio: string;
|
|
198
203
|
filter: string;
|
|
@@ -206,6 +211,8 @@ interface LayoutComponentData {
|
|
|
206
211
|
interface Link {
|
|
207
212
|
ref: string;
|
|
208
213
|
uri: string;
|
|
214
|
+
pageUrl: PageUrl | null;
|
|
215
|
+
fragment: string;
|
|
209
216
|
media: Media;
|
|
210
217
|
content: Content;
|
|
211
218
|
}
|
|
@@ -229,10 +236,10 @@ interface MacroConfig {
|
|
|
229
236
|
interface Media {
|
|
230
237
|
content: Content;
|
|
231
238
|
intent: MediaIntentType;
|
|
239
|
+
mediaUrl: AttachmentUrl | null;
|
|
232
240
|
}
|
|
233
241
|
type MediaIntentType = 'download' | 'inline';
|
|
234
242
|
export interface AttachmentUrl {
|
|
235
|
-
url: string;
|
|
236
243
|
path: string;
|
|
237
244
|
queryString: string;
|
|
238
245
|
context: string;
|
|
@@ -242,7 +249,6 @@ export interface AttachmentUrl {
|
|
|
242
249
|
intent: MediaIntentType;
|
|
243
250
|
}
|
|
244
251
|
export interface ImageUrl {
|
|
245
|
-
url: string;
|
|
246
252
|
path: string;
|
|
247
253
|
queryString: string;
|
|
248
254
|
context: string;
|
|
@@ -306,10 +312,8 @@ interface PrincipalKey {
|
|
|
306
312
|
idProvider: string;
|
|
307
313
|
principalId: string;
|
|
308
314
|
}
|
|
309
|
-
interface
|
|
315
|
+
interface QueryDSLContentConnection extends ContentConnection {
|
|
310
316
|
aggregationsAsJson: JSON;
|
|
311
|
-
}
|
|
312
|
-
interface QueryDSLContentConnection extends QueryContentConnection {
|
|
313
317
|
highlightAsJson: JSON;
|
|
314
318
|
}
|
|
315
319
|
interface RichText {
|
package/dist/types/urls.d.ts
CHANGED
|
@@ -2,16 +2,14 @@ import type { MetaData } from './componentProps';
|
|
|
2
2
|
import type { AttachmentUrl, ImageUrl, PageUrl } from './guillotine';
|
|
3
3
|
export type GraphqlJson = Record<string, unknown>;
|
|
4
4
|
export interface ImageUrlArgs {
|
|
5
|
-
scale
|
|
5
|
+
scale?: string;
|
|
6
6
|
quality?: number;
|
|
7
7
|
background?: string;
|
|
8
8
|
format?: string;
|
|
9
9
|
filter?: string;
|
|
10
|
-
params?: GraphqlJson;
|
|
11
10
|
}
|
|
12
11
|
export interface MediaUrlArgs {
|
|
13
12
|
download?: boolean;
|
|
14
|
-
params?: GraphqlJson;
|
|
15
13
|
}
|
|
16
14
|
export interface PageUrlArgs {
|
|
17
15
|
params?: GraphqlJson;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import BaseMacro from './BaseMacro';
|
|
2
2
|
import Link from 'next/link';
|
|
3
|
-
import { pageUrl } from '../guillotine/urls';
|
|
4
|
-
import { getMediaSrcSet, getMediaUrl } from '../utils/getMediaUrl';
|
|
3
|
+
import { mediaUrl, pageUrl } from '../guillotine/urls';
|
|
5
4
|
import { useMemo } from 'react';
|
|
6
5
|
import { RichText } from '@enonic/react-components';
|
|
7
6
|
const RichTextView = (props) => {
|
|
@@ -10,21 +9,17 @@ const RichTextView = (props) => {
|
|
|
10
9
|
path: props.meta.path,
|
|
11
10
|
text: props.data.processedHtml
|
|
12
11
|
}), [props.meta.path, props.data.processedHtml]);
|
|
13
|
-
return <RichText data={wrapData(props.data)} meta={toRichTextMetaData(props.meta)} nextMeta={props.meta} component={component} className={props.className} tag={props.tag} replacer={wrapReplacer(props.customReplacer, props.meta)} Macro={MacroAdapter} Link={LinkAdapter} Image={ImageAdapter}/>;
|
|
12
|
+
return <RichText data={wrapData(props.data)} meta={toRichTextMetaData(props.meta)} nextMeta={props.meta} component={component} className={props.className} tag={props.tag} replacer={wrapReplacer(props.customReplacer, props.meta, props.data)} Macro={MacroAdapter} Link={LinkAdapter} Image={ImageAdapter}/>;
|
|
14
13
|
};
|
|
15
|
-
function wrapReplacer(nextReplacer, meta) {
|
|
14
|
+
function wrapReplacer(nextReplacer, meta, data) {
|
|
16
15
|
if (!nextReplacer) {
|
|
17
16
|
return null;
|
|
18
17
|
}
|
|
19
|
-
return ({ el
|
|
20
|
-
return nextReplacer(el, data, meta);
|
|
21
|
-
};
|
|
18
|
+
return ({ el }) => nextReplacer(el, data, meta);
|
|
22
19
|
}
|
|
23
20
|
function wrapData(data) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
const macroComponents = data.macros.map((macroData) => {
|
|
21
|
+
var _a;
|
|
22
|
+
const macroComponents = (_a = data.macros) === null || _a === void 0 ? void 0 : _a.map((macroData) => {
|
|
28
23
|
return {
|
|
29
24
|
component: {
|
|
30
25
|
type: 'macro',
|
|
@@ -47,16 +42,29 @@ function MacroAdapter(props) {
|
|
|
47
42
|
}
|
|
48
43
|
function LinkAdapter(props) {
|
|
49
44
|
var _a, _b;
|
|
50
|
-
const
|
|
45
|
+
const { data } = props;
|
|
46
|
+
const contentUrl = typeof (data === null || data === void 0 ? void 0 : data.pageUrl) === 'string' ? data.pageUrl : pageUrl(data === null || data === void 0 ? void 0 : data.pageUrl, props.nextMeta);
|
|
51
47
|
if (contentUrl) {
|
|
52
|
-
return <Link href={contentUrl} data-content-path={(
|
|
48
|
+
return <Link href={contentUrl + (data.fragment || '')} data-content-path={(_a = data.content) === null || _a === void 0 ? void 0 : _a._path} target={props.target} title={props.title}>{props.children}</Link>;
|
|
53
49
|
}
|
|
54
|
-
//
|
|
55
|
-
|
|
50
|
+
// Referenced HTML URLs are placeholders, including when the reference cannot be resolved.
|
|
51
|
+
const href = data ? resolveMediaUrl((_b = data.media) === null || _b === void 0 ? void 0 : _b.mediaUrl) : props.href;
|
|
52
|
+
return <a href={href} target={props.target} title={props.title}>{props.children}</a>;
|
|
56
53
|
}
|
|
57
54
|
function ImageAdapter(props) {
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
var _a, _b;
|
|
56
|
+
const src = resolveMediaUrl((_a = props.data) === null || _a === void 0 ? void 0 : _a.src);
|
|
57
|
+
if (!src) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
const srcSet = (_b = props.data.srcset) === null || _b === void 0 ? void 0 : _b.map((source) => {
|
|
61
|
+
const url = resolveMediaUrl(source.imageUrl);
|
|
62
|
+
return url ? `${url} ${source.width}w` : undefined;
|
|
63
|
+
}).filter(Boolean).join(', ');
|
|
64
|
+
return <img src={src} style={props.style} alt={props.alt} sizes={props.sizes} srcSet={srcSet}/>;
|
|
65
|
+
}
|
|
66
|
+
function resolveMediaUrl(value) {
|
|
67
|
+
return typeof value === 'string' ? value : mediaUrl(value);
|
|
60
68
|
}
|
|
61
69
|
function toRichTextMetaData(meta) {
|
|
62
70
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextView.jsx","sourceRoot":"","sources":["../../src/views/RichTextView.tsx"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,aAAa,CAAC;AAC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,GAAG,MAAA,KAAK,CAAC,IAAI,CAAC,MAAM,0CAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QAC7C,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC7C,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IACvD,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;AACpG,CAAC;AAED,SAAS,eAAe,CAAC,KAAuB;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAc;IACtC,OAAO;QACH,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,IAAI,CAAC,UAAU;QACrB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,EAAE,EAAE,IAAI,CAAC,EAAE;KACd,CAAA;AACL,CAAC;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { MacroProps } from '../../types';
|
|
2
|
-
|
|
3
|
-
declare const DefaultMacro: ({ name, config, meta }: MacroProps) => ReactElement;
|
|
2
|
+
declare const DefaultMacro: ({ name, config, meta }: MacroProps) => string | import("react").JSX.Element | import("react").JSX.Element[];
|
|
4
3
|
export default DefaultMacro;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import HTMLReactParser from 'html-react-parser';
|
|
2
|
-
const DefaultMacro = ({ name, config, meta }) => HTMLReactParser(config.body);
|
|
2
|
+
const DefaultMacro = ({ name, config, meta }) => (HTMLReactParser(typeof config.body === 'string' ? config.body : ''));
|
|
3
3
|
export default DefaultMacro;
|
|
4
4
|
//# sourceMappingURL=DefaultMacro.jsx.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultMacro.jsx","sourceRoot":"","sources":["../../../src/views/macros/DefaultMacro.tsx"],"names":[],"mappings":"AACA,OAAO,eAAe,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"DefaultMacro.jsx","sourceRoot":"","sources":["../../../src/views/macros/DefaultMacro.tsx"],"names":[],"mappings":"AACA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAGhD,MAAM,YAAY,GAAG,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAa,EAAE,EAAE,CAAC,CACvD,eAAe,CAAC,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CACtE,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisableMacro.jsx","sourceRoot":"","sources":["../../../src/views/macros/DisableMacro.tsx"],"names":[],"mappings":"AAGA,MAAM,YAAY,GAAG,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAa,EAAE,EAAE,CAAC,CACvD,MAAM,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"DisableMacro.jsx","sourceRoot":"","sources":["../../../src/views/macros/DisableMacro.tsx"],"names":[],"mappings":"AAGA,MAAM,YAAY,GAAG,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAa,EAAE,EAAE,CAAC,CACvD,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CACvD,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enonic/nextjs-adapter",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
3
|
+
"version": "6.0.0-beta.7",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Pavel Milkevich <pmi@enonic.com>",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"test": "jest --no-cache --coverage"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@enonic/react-components": "
|
|
59
|
-
"@formatjs/intl-localematcher": "^0.
|
|
58
|
+
"@enonic/react-components": "7.1.0-beta.2",
|
|
59
|
+
"@formatjs/intl-localematcher": "^0.9.0",
|
|
60
60
|
"gqlmin": "^0.3.2",
|
|
61
61
|
"negotiator": "^1.1.0",
|
|
62
62
|
"unescape": "^1.0.1"
|
|
@@ -65,30 +65,30 @@
|
|
|
65
65
|
"@babel/core": "^7.29.7",
|
|
66
66
|
"@babel/preset-env": "^7.29.7",
|
|
67
67
|
"@edge-runtime/jest-environment": "^4.0.0",
|
|
68
|
-
"@enonic-types/core": "^8.
|
|
68
|
+
"@enonic-types/core": "^8.1.1",
|
|
69
69
|
"@enonic/eslint-config": "^2.3.0",
|
|
70
|
-
"@testing-library/dom": "^10.4.
|
|
70
|
+
"@testing-library/dom": "^10.4.2",
|
|
71
71
|
"@testing-library/jest-dom": "^7.0.1",
|
|
72
72
|
"@testing-library/react": "^16.3.3",
|
|
73
73
|
"@types/negotiator": "^0.6.5",
|
|
74
|
-
"@types/node": "^26.5
|
|
74
|
+
"@types/node": "^26.6.5",
|
|
75
75
|
"@types/react": "^19",
|
|
76
76
|
"@types/react-dom": "^19",
|
|
77
|
-
"babel-jest": "^30.5.
|
|
78
|
-
"concurrently": "^10.0.
|
|
77
|
+
"babel-jest": "^30.5.2",
|
|
78
|
+
"concurrently": "^10.0.6",
|
|
79
79
|
"cpy-cli": "^7.0.0",
|
|
80
|
-
"del-cli": "^
|
|
80
|
+
"del-cli": "^8.0.1",
|
|
81
81
|
"eslint": "^9.39.2",
|
|
82
82
|
"eslint-plugin-react": "^7.37.5",
|
|
83
83
|
"html-react-parser": "^5.2.6",
|
|
84
|
-
"jest": "^30.5.
|
|
85
|
-
"jest-environment-jsdom": "^30.5.
|
|
84
|
+
"jest": "^30.5.2",
|
|
85
|
+
"jest-environment-jsdom": "^30.5.2",
|
|
86
86
|
"madge": "^8.0.0",
|
|
87
87
|
"mkdirp": "^3.0.1",
|
|
88
|
-
"ts-jest": "^29.4.
|
|
88
|
+
"ts-jest": "^29.4.15",
|
|
89
89
|
"ts-node": "^10.9.2",
|
|
90
90
|
"typescript": "^5.9.3",
|
|
91
|
-
"typescript-eslint": "^8.
|
|
91
|
+
"typescript-eslint": "^8.72.0"
|
|
92
92
|
},
|
|
93
93
|
"types": "index.d.ts",
|
|
94
94
|
"peerDependencies": {
|