@prismicio/vue 2.0.11 → 2.1.1
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/LICENSE +202 -0
- package/README.md +81 -149
- package/components/common.js +289 -47
- package/components/index.js +283 -45
- package/components/umd.js +292 -49
- package/dist/prismic-vue.common.js +299 -55
- package/dist/prismic-vue.esm.js +292 -50
- package/dist/prismic-vue.js +303 -59
- package/dist/prismic-vue.min.js +1 -1
- package/package.json +86 -47
- package/src/components/Embed.js +32 -32
- package/src/components/Image.js +27 -22
- package/src/components/Link.js +87 -51
- package/src/components/RichText.js +40 -41
- package/src/components/SliceZone.js +145 -0
- package/src/components/Text.js +37 -0
- package/src/components/index.js +26 -22
- package/src/components-bundler.js +10 -5
- package/src/index.js +51 -39
- package/src/methods.js +16 -22
- package/vetur/attributes.json +86 -0
- package/vetur/tags.json +38 -0
package/dist/prismic-vue.js
CHANGED
|
@@ -1,35 +1,26 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['
|
|
4
|
-
(global.PrismicVue = factory(global.
|
|
5
|
-
}(this, (function (PrismicDOM
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@prismicio/client'), require('prismic-dom')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['@prismicio/client', 'prismic-dom'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.PrismicVue = factory(global.prismicJS, global.prismicDOM));
|
|
5
|
+
})(this, (function (prismicJS, PrismicDOM) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
prismicJS = prismicJS && prismicJS.hasOwnProperty('default') ? prismicJS['default'] : prismicJS;
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(obj, key, {
|
|
13
|
-
value: value,
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true
|
|
17
|
-
});
|
|
18
|
-
} else {
|
|
19
|
-
obj[key] = value;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return obj;
|
|
23
|
-
}
|
|
9
|
+
var prismicJS__default = /*#__PURE__*/_interopDefaultLegacy(prismicJS);
|
|
10
|
+
var PrismicDOM__default = /*#__PURE__*/_interopDefaultLegacy(PrismicDOM);
|
|
24
11
|
|
|
25
12
|
function ownKeys(object, enumerableOnly) {
|
|
26
13
|
var keys = Object.keys(object);
|
|
27
14
|
|
|
28
15
|
if (Object.getOwnPropertySymbols) {
|
|
29
16
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
|
|
18
|
+
if (enumerableOnly) {
|
|
19
|
+
symbols = symbols.filter(function (sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
33
24
|
keys.push.apply(keys, symbols);
|
|
34
25
|
}
|
|
35
26
|
|
|
@@ -56,6 +47,21 @@
|
|
|
56
47
|
return target;
|
|
57
48
|
}
|
|
58
49
|
|
|
50
|
+
function _defineProperty(obj, key, value) {
|
|
51
|
+
if (key in obj) {
|
|
52
|
+
Object.defineProperty(obj, key, {
|
|
53
|
+
value: value,
|
|
54
|
+
enumerable: true,
|
|
55
|
+
configurable: true,
|
|
56
|
+
writable: true
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
obj[key] = value;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return obj;
|
|
63
|
+
}
|
|
64
|
+
|
|
59
65
|
function _slicedToArray(arr, i) {
|
|
60
66
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
61
67
|
}
|
|
@@ -65,14 +71,17 @@
|
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
function _iterableToArrayLimit(arr, i) {
|
|
68
|
-
|
|
74
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
75
|
+
|
|
76
|
+
if (_i == null) return;
|
|
69
77
|
var _arr = [];
|
|
70
78
|
var _n = true;
|
|
71
79
|
var _d = false;
|
|
72
|
-
|
|
80
|
+
|
|
81
|
+
var _s, _e;
|
|
73
82
|
|
|
74
83
|
try {
|
|
75
|
-
for (
|
|
84
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
76
85
|
_arr.push(_s.value);
|
|
77
86
|
|
|
78
87
|
if (i && _arr.length === i) break;
|
|
@@ -121,7 +130,7 @@
|
|
|
121
130
|
required: true
|
|
122
131
|
},
|
|
123
132
|
wrapper: {
|
|
124
|
-
type: String,
|
|
133
|
+
type: [String, Object, Function],
|
|
125
134
|
required: false,
|
|
126
135
|
"default": 'div'
|
|
127
136
|
}
|
|
@@ -170,10 +179,15 @@
|
|
|
170
179
|
render: function render(h, _ref) {
|
|
171
180
|
var props = _ref.props,
|
|
172
181
|
data = _ref.data;
|
|
173
|
-
var
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
182
|
+
var field = props.field;
|
|
183
|
+
|
|
184
|
+
if (!field) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
var url = field.url,
|
|
189
|
+
alt = field.alt,
|
|
190
|
+
copyright = field.copyright;
|
|
177
191
|
return h('img', Object.assign(data, {
|
|
178
192
|
attrs: _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
179
193
|
src: url,
|
|
@@ -184,11 +198,24 @@
|
|
|
184
198
|
}
|
|
185
199
|
};
|
|
186
200
|
|
|
201
|
+
var isInternalURL = function isInternalURL(url) {
|
|
202
|
+
/**
|
|
203
|
+
* @see Regex101 expression: {@link https://regex101.com/r/1y7iod/1}
|
|
204
|
+
*/
|
|
205
|
+
var isInternal = /^\/(?!\/)/.test(url);
|
|
206
|
+
/**
|
|
207
|
+
* @see Regex101 expression: {@link https://regex101.com/r/RnUseS/1}
|
|
208
|
+
*/
|
|
209
|
+
|
|
210
|
+
var isSpecialLink = !isInternal && !/^https?:\/\//i.test(url);
|
|
211
|
+
return isInternal && !isSpecialLink;
|
|
212
|
+
};
|
|
213
|
+
|
|
187
214
|
var Link = (function (_ref) {
|
|
188
215
|
var _ref$component = _ref.component,
|
|
189
|
-
component = _ref$component === void 0 ?
|
|
216
|
+
component = _ref$component === void 0 ? "a" : _ref$component;
|
|
190
217
|
return {
|
|
191
|
-
name:
|
|
218
|
+
name: "PrismicLink",
|
|
192
219
|
functional: true,
|
|
193
220
|
props: {
|
|
194
221
|
field: {
|
|
@@ -198,6 +225,21 @@
|
|
|
198
225
|
linkResolver: {
|
|
199
226
|
type: Function,
|
|
200
227
|
required: false
|
|
228
|
+
},
|
|
229
|
+
target: {
|
|
230
|
+
type: String,
|
|
231
|
+
"default": undefined,
|
|
232
|
+
required: false
|
|
233
|
+
},
|
|
234
|
+
rel: {
|
|
235
|
+
type: String,
|
|
236
|
+
"default": undefined,
|
|
237
|
+
required: false
|
|
238
|
+
},
|
|
239
|
+
blankTargetRelAttribute: {
|
|
240
|
+
type: String,
|
|
241
|
+
"default": "noopener noreferrer",
|
|
242
|
+
required: false
|
|
201
243
|
}
|
|
202
244
|
},
|
|
203
245
|
render: function render(h, _ref2) {
|
|
@@ -212,11 +254,11 @@
|
|
|
212
254
|
return null;
|
|
213
255
|
}
|
|
214
256
|
|
|
215
|
-
var url = parent.$prismic ? parent.$prismic.asLink(field, linkResolver) : PrismicDOM__default.Link.url(field, linkResolver || function () {
|
|
257
|
+
var url = parent.$prismic ? parent.$prismic.asLink(field, linkResolver) : PrismicDOM__default["default"].Link.url(field, linkResolver || function () {
|
|
216
258
|
return null;
|
|
217
259
|
});
|
|
218
260
|
|
|
219
|
-
if (url
|
|
261
|
+
if (isInternalURL(url) && !props.target) {
|
|
220
262
|
data.props = data.props || {};
|
|
221
263
|
data.props.to = url;
|
|
222
264
|
return h(component, data, children);
|
|
@@ -224,39 +266,53 @@
|
|
|
224
266
|
|
|
225
267
|
data.attrs = _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
226
268
|
href: url
|
|
227
|
-
}, field.target && {
|
|
228
|
-
target: field.target,
|
|
229
|
-
rel: 'noopener'
|
|
230
269
|
});
|
|
231
|
-
|
|
270
|
+
|
|
271
|
+
if (typeof props.target !== "undefined") {
|
|
272
|
+
data.attrs.target = props.target;
|
|
273
|
+
} else if (field.target) {
|
|
274
|
+
data.attrs.target = field.target;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (typeof props.rel !== "undefined") {
|
|
278
|
+
data.attrs.rel = props.rel;
|
|
279
|
+
} else if (data.attrs.target === "_blank") {
|
|
280
|
+
data.attrs.rel = props.blankTargetRelAttribute;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return h("a", data, children);
|
|
232
284
|
}
|
|
233
285
|
};
|
|
234
286
|
});
|
|
235
287
|
|
|
236
288
|
var RichText = {
|
|
237
|
-
name:
|
|
289
|
+
name: "PrismicRichText",
|
|
238
290
|
functional: true,
|
|
239
291
|
props: {
|
|
240
292
|
field: {
|
|
241
293
|
type: Array,
|
|
242
294
|
required: true
|
|
243
295
|
},
|
|
296
|
+
linkResolver: {
|
|
297
|
+
type: Function,
|
|
298
|
+
required: false
|
|
299
|
+
},
|
|
244
300
|
htmlSerializer: {
|
|
245
301
|
type: Function,
|
|
246
302
|
required: false
|
|
247
303
|
},
|
|
248
304
|
wrapper: {
|
|
249
|
-
type: String,
|
|
305
|
+
type: [String, Object, Function],
|
|
250
306
|
required: false,
|
|
251
|
-
"default":
|
|
307
|
+
"default": "div"
|
|
252
308
|
}
|
|
253
309
|
},
|
|
254
310
|
render: function render(h, _ref) {
|
|
255
311
|
var props = _ref.props,
|
|
256
312
|
data = _ref.data,
|
|
257
|
-
children = _ref.children,
|
|
258
313
|
parent = _ref.parent;
|
|
259
314
|
var field = props.field,
|
|
315
|
+
linkResolver = props.linkResolver,
|
|
260
316
|
htmlSerializer = props.htmlSerializer,
|
|
261
317
|
wrapper = props.wrapper;
|
|
262
318
|
|
|
@@ -264,7 +320,48 @@
|
|
|
264
320
|
return null;
|
|
265
321
|
}
|
|
266
322
|
|
|
267
|
-
var innerHTML = PrismicDOM.RichText.asHtml(field, parent.$prismic.linkResolver, htmlSerializer
|
|
323
|
+
var innerHTML = PrismicDOM.RichText.asHtml(field, linkResolver ? linkResolver : parent.$prismic ? parent.$prismic.linkResolver : undefined, htmlSerializer ? htmlSerializer : parent.$prismic ? parent.$prismic.htmlSerializer : undefined);
|
|
324
|
+
return h(wrapper, _objectSpread2(_objectSpread2({}, data), {}, {
|
|
325
|
+
domProps: {
|
|
326
|
+
innerHTML: innerHTML
|
|
327
|
+
}
|
|
328
|
+
}));
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
var Text = {
|
|
333
|
+
name: "PrismicText",
|
|
334
|
+
functional: true,
|
|
335
|
+
props: {
|
|
336
|
+
field: {
|
|
337
|
+
type: Array,
|
|
338
|
+
required: true
|
|
339
|
+
},
|
|
340
|
+
separator: {
|
|
341
|
+
type: String,
|
|
342
|
+
"default": undefined,
|
|
343
|
+
required: false
|
|
344
|
+
},
|
|
345
|
+
wrapper: {
|
|
346
|
+
type: [String, Object, Function],
|
|
347
|
+
required: false,
|
|
348
|
+
"default": "div"
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
render: function render(h, _ref) {
|
|
352
|
+
var props = _ref.props,
|
|
353
|
+
data = _ref.data;
|
|
354
|
+
_ref.children;
|
|
355
|
+
_ref.parent;
|
|
356
|
+
var field = props.field,
|
|
357
|
+
separator = props.separator,
|
|
358
|
+
wrapper = props.wrapper;
|
|
359
|
+
|
|
360
|
+
if (!field) {
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
var innerHTML = PrismicDOM.RichText.asText(field, separator);
|
|
268
365
|
return h(wrapper, _objectSpread2(_objectSpread2({}, data), {}, {
|
|
269
366
|
domProps: {
|
|
270
367
|
innerHTML: innerHTML
|
|
@@ -273,17 +370,157 @@
|
|
|
273
370
|
}
|
|
274
371
|
};
|
|
275
372
|
|
|
373
|
+
// We need to polyfill process if it doesn't exist, such as in the browser.
|
|
374
|
+
if (typeof process === "undefined") {
|
|
375
|
+
globalThis.process = {
|
|
376
|
+
env: {}
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* `true` if in the production environment, `false` otherwise.
|
|
381
|
+
*
|
|
382
|
+
* This boolean can be used to perform actions only in development environments,
|
|
383
|
+
* such as logging.
|
|
384
|
+
*/
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
var __PRODUCTION__ = process.env.NODE_ENV === "production";
|
|
388
|
+
|
|
389
|
+
var getSliceComponentProps = function getSliceComponentProps(propsHint) {
|
|
390
|
+
return {
|
|
391
|
+
slice: {
|
|
392
|
+
type: Object,
|
|
393
|
+
required: true
|
|
394
|
+
},
|
|
395
|
+
index: {
|
|
396
|
+
type: Number,
|
|
397
|
+
required: true
|
|
398
|
+
},
|
|
399
|
+
slices: {
|
|
400
|
+
type: Array,
|
|
401
|
+
required: true
|
|
402
|
+
},
|
|
403
|
+
context: {
|
|
404
|
+
type: null,
|
|
405
|
+
required: true
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
var TODOSliceComponent = __PRODUCTION__ ? null : {
|
|
410
|
+
name: "TODOSliceComponent",
|
|
411
|
+
functional: true,
|
|
412
|
+
props: getSliceComponentProps(),
|
|
413
|
+
render: function render(h, _ref) {
|
|
414
|
+
var props = _ref.props,
|
|
415
|
+
data = _ref.data;
|
|
416
|
+
console.warn("[SliceZone] Could not find a component for Slice type \"".concat(props.slice.slice_type, "\""), props.slice);
|
|
417
|
+
return h("section", _objectSpread2(_objectSpread2({}, data), {}, {
|
|
418
|
+
attrs: _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
419
|
+
"data-slice-zone-todo-component": "",
|
|
420
|
+
"data-slice-type": props.slice.slice_type
|
|
421
|
+
})
|
|
422
|
+
}), ["Could not find a component for Slice type \"".concat(props.slice.slice_type, "\"")]);
|
|
423
|
+
}
|
|
424
|
+
}; // Just mimiced to prevent confusion but doesn't provide any value with version 2 of this kit
|
|
425
|
+
var SliceZone = {
|
|
426
|
+
name: "SliceZone",
|
|
427
|
+
props: {
|
|
428
|
+
slices: {
|
|
429
|
+
type: Array,
|
|
430
|
+
required: true
|
|
431
|
+
},
|
|
432
|
+
components: {
|
|
433
|
+
type: Object,
|
|
434
|
+
"default": undefined,
|
|
435
|
+
required: false
|
|
436
|
+
},
|
|
437
|
+
resolver: {
|
|
438
|
+
type: Function,
|
|
439
|
+
"default": undefined,
|
|
440
|
+
required: false
|
|
441
|
+
},
|
|
442
|
+
context: {
|
|
443
|
+
type: null,
|
|
444
|
+
"default": undefined,
|
|
445
|
+
required: false
|
|
446
|
+
},
|
|
447
|
+
defaultComponent: {
|
|
448
|
+
type: Object,
|
|
449
|
+
"default": undefined,
|
|
450
|
+
required: false
|
|
451
|
+
},
|
|
452
|
+
wrapper: {
|
|
453
|
+
type: [String, Object, Function],
|
|
454
|
+
"default": "div",
|
|
455
|
+
required: false
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
computed: {
|
|
459
|
+
renderedSlices: function renderedSlices() {
|
|
460
|
+
var _this = this;
|
|
461
|
+
|
|
462
|
+
if (!this.slices) {
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return this.slices.map(function (slice, index) {
|
|
467
|
+
var component = _this.components && slice.slice_type in _this.components ? _this.components[slice.slice_type] : _this.defaultComponent || TODOSliceComponent; // TODO: Remove `resolver` in v3 in favor of `components`.
|
|
468
|
+
|
|
469
|
+
if (_this.resolver) {
|
|
470
|
+
var resolvedComponent = _this.resolver({
|
|
471
|
+
slice: slice,
|
|
472
|
+
sliceName: slice.slice_type,
|
|
473
|
+
i: index
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
if (resolvedComponent) {
|
|
477
|
+
component = resolvedComponent;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
var p = {
|
|
482
|
+
key: "".concat(slice.slice_type, "-").concat(index),
|
|
483
|
+
props: {
|
|
484
|
+
slice: slice,
|
|
485
|
+
index: index,
|
|
486
|
+
context: _this.context,
|
|
487
|
+
slices: _this.slices
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
return {
|
|
491
|
+
component: component,
|
|
492
|
+
p: p
|
|
493
|
+
};
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
},
|
|
497
|
+
render: function render(h) {
|
|
498
|
+
// Prevent fatal if user didn't check for field, throws `Invalid prop` warn
|
|
499
|
+
if (!this.slices) {
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
return h(this.wrapper, this.renderedSlices.map(function (_ref2) {
|
|
504
|
+
var component = _ref2.component,
|
|
505
|
+
p = _ref2.p;
|
|
506
|
+
return h(component, p);
|
|
507
|
+
}));
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
|
|
276
511
|
var NuxtLink = Link({
|
|
277
|
-
component:
|
|
512
|
+
component: "nuxt-link"
|
|
278
513
|
});
|
|
279
514
|
var VueRouterLink = Link({
|
|
280
|
-
component:
|
|
515
|
+
component: "router-link"
|
|
281
516
|
});
|
|
282
517
|
var exp = {
|
|
283
518
|
common: {
|
|
284
519
|
Embed: Embed,
|
|
285
520
|
Image: Image,
|
|
286
|
-
RichText: RichText
|
|
521
|
+
RichText: RichText,
|
|
522
|
+
Text: Text,
|
|
523
|
+
SliceZone: SliceZone
|
|
287
524
|
},
|
|
288
525
|
nuxt: {
|
|
289
526
|
Link: NuxtLink
|
|
@@ -295,32 +532,35 @@
|
|
|
295
532
|
|
|
296
533
|
function asHtml(richText, linkResolver, htmlSerializer) {
|
|
297
534
|
if (richText) {
|
|
298
|
-
return PrismicDOM__default.RichText.asHtml(richText, linkResolver, htmlSerializer);
|
|
535
|
+
return PrismicDOM__default["default"].RichText.asHtml(richText, linkResolver, htmlSerializer);
|
|
299
536
|
}
|
|
300
537
|
}
|
|
301
538
|
function asText(richText, joinString) {
|
|
302
539
|
if (richText) {
|
|
303
|
-
return PrismicDOM__default.RichText.asText(richText, joinString);
|
|
540
|
+
return PrismicDOM__default["default"].RichText.asText(richText, joinString);
|
|
304
541
|
}
|
|
305
542
|
|
|
306
|
-
return
|
|
543
|
+
return "";
|
|
307
544
|
}
|
|
308
545
|
function asLink(link, linkResolver) {
|
|
309
546
|
if (link) {
|
|
310
|
-
return PrismicDOM__default.Link.url(link, linkResolver);
|
|
547
|
+
return PrismicDOM__default["default"].Link.url(link, linkResolver);
|
|
311
548
|
}
|
|
312
549
|
}
|
|
313
550
|
function asDate(date) {
|
|
314
551
|
if (date) {
|
|
315
|
-
return PrismicDOM__default.Date(date);
|
|
552
|
+
return PrismicDOM__default["default"].Date(date);
|
|
316
553
|
}
|
|
317
554
|
}
|
|
318
555
|
|
|
556
|
+
var client = prismicJS__default["default"].client;
|
|
557
|
+
|
|
319
558
|
function attachMethods(Vue, options) {
|
|
320
559
|
Vue.prototype.$prismic.asHtml = function (richText, linkResolver, htmlSerializer) {
|
|
321
560
|
return asHtml(richText, linkResolver || options.linkResolver, htmlSerializer || options.htmlSerializer);
|
|
322
561
|
};
|
|
323
562
|
|
|
563
|
+
Vue.prototype.$prismic.asHTML = Vue.prototype.$prismic.asHtml;
|
|
324
564
|
Vue.prototype.$prismic.asText = asText;
|
|
325
565
|
Vue.prototype.$prismic.richTextAsPlain = asText;
|
|
326
566
|
Vue.prototype.$prismic.asDate = asDate;
|
|
@@ -333,12 +573,16 @@
|
|
|
333
573
|
var PrismicVue = {
|
|
334
574
|
install: function install(Vue, options) {
|
|
335
575
|
var _options$linkType = options.linkType,
|
|
336
|
-
linkType = _options$linkType === void 0 ?
|
|
337
|
-
Vue.prototype.$prismic =
|
|
576
|
+
linkType = _options$linkType === void 0 ? "vueRouter" : _options$linkType;
|
|
577
|
+
Vue.prototype.$prismic = prismicJS__default["default"];
|
|
578
|
+
Vue.prototype.$prismic.predicate = prismicJS__default["default"].Predicates;
|
|
579
|
+
Vue.prototype.$prismic.cookie = {
|
|
580
|
+
preview: prismicJS__default["default"].previewCookie
|
|
581
|
+
};
|
|
338
582
|
Vue.prototype.$prismic.endpoint = options.endpoint;
|
|
339
583
|
Vue.prototype.$prismic.linkResolver = options.linkResolver;
|
|
340
584
|
Vue.prototype.$prismic.htmlSerializer = options.htmlSerializer;
|
|
341
|
-
Vue.prototype.$prismic.client =
|
|
585
|
+
Vue.prototype.$prismic.client = client(options.endpoint, options.apiOptions);
|
|
342
586
|
attachMethods(Vue, options);
|
|
343
587
|
|
|
344
588
|
var components = _objectSpread2(_objectSpread2({}, exp.common), exp[linkType]);
|
|
@@ -349,9 +593,9 @@
|
|
|
349
593
|
|
|
350
594
|
|
|
351
595
|
Object.entries(components).forEach(function (_ref) {
|
|
352
|
-
var _ref2 = _slicedToArray(_ref, 2)
|
|
353
|
-
|
|
354
|
-
c = _ref2[1];
|
|
596
|
+
var _ref2 = _slicedToArray(_ref, 2);
|
|
597
|
+
_ref2[0];
|
|
598
|
+
var c = _ref2[1];
|
|
355
599
|
|
|
356
600
|
Vue.component(c.name, c);
|
|
357
601
|
});
|
|
@@ -360,4 +604,4 @@
|
|
|
360
604
|
|
|
361
605
|
return PrismicVue;
|
|
362
606
|
|
|
363
|
-
}))
|
|
607
|
+
}));
|
package/dist/prismic-vue.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory(require("prismic-dom"),require("@prismicio/client")):typeof define==="function"&&define.amd?define(["prismic-dom","@prismicio/client"],factory):global.PrismicVue=factory(global.prismicDOM,global.prismicJS)})(this,function(PrismicDOM,prismicJS){"use strict";var PrismicDOM__default="default"in PrismicDOM?PrismicDOM["default"]:PrismicDOM;prismicJS=prismicJS&&prismicJS.hasOwnProperty("default")?prismicJS["default"]:prismicJS;function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly)symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable});keys.push.apply(keys,symbols)}return keys}function _objectSpread2(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};if(i%2){ownKeys(Object(source),true).forEach(function(key){_defineProperty(target,key,source[key])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}}return target}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _iterableToArrayLimit(arr,i){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(arr)))return;var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var Embed={name:"PrismicEmbed",functional:true,props:{field:{type:Object,required:true},wrapper:{type:String,required:false,default:"div"}},render:function render(h,_ref){var props=_ref.props,data=_ref.data;var field=props.field,wrapper=props.wrapper;if(!field||!field.html){return null}var embedUrl=field.embed_url,type=field.type,providerName=field.provider_name;var attrs=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({},data.attrs),embedUrl&&{"data-oembed":embedUrl}),type&&{"data-oembed-type":type}),providerName&&{"data-oembed-provider":providerName});return h(wrapper,_objectSpread2(_objectSpread2({},Object.assign(data,{attrs:attrs})),{},{domProps:{innerHTML:field.html}}))}};var Image={name:"PrismicImage",functional:true,props:{field:{type:Object,required:true}},render:function render(h,_ref){var props=_ref.props,data=_ref.data;var _props$field=props.field,url=_props$field.url,alt=_props$field.alt,copyright=_props$field.copyright;return h("img",Object.assign(data,{attrs:_objectSpread2(_objectSpread2({},data.attrs),{},{src:url,alt:alt,copyright:copyright})}))}};var Link=function(_ref){var _ref$component=_ref.component,component=_ref$component===void 0?"a":_ref$component;return{name:"PrismicLink",functional:true,props:{field:{type:Object,required:true},linkResolver:{type:Function,required:false}},render:function render(h,_ref2){var props=_ref2.props,data=_ref2.data,children=_ref2.children,parent=_ref2.parent;var field=props.field,linkResolver=props.linkResolver;if(!field){return null}var url=parent.$prismic?parent.$prismic.asLink(field,linkResolver):PrismicDOM__default.Link.url(field,linkResolver||function(){return null});if(url.indexOf("/")===0){data.props=data.props||{};data.props.to=url;return h(component,data,children)}data.attrs=_objectSpread2(_objectSpread2({},data.attrs),{},{href:url},field.target&&{target:field.target,rel:"noopener"});return h("a",data,children)}}};var RichText={name:"PrismicRichText",functional:true,props:{field:{type:Array,required:true},htmlSerializer:{type:Function,required:false},wrapper:{type:String,required:false,default:"div"}},render:function render(h,_ref){var props=_ref.props,data=_ref.data,children=_ref.children,parent=_ref.parent;var field=props.field,htmlSerializer=props.htmlSerializer,wrapper=props.wrapper;if(!field){return null}var innerHTML=PrismicDOM.RichText.asHtml(field,parent.$prismic.linkResolver,htmlSerializer||parent.$prismic.htmlSerializer);return h(wrapper,_objectSpread2(_objectSpread2({},data),{},{domProps:{innerHTML:innerHTML}}))}};var NuxtLink=Link({component:"nuxt-link"});var VueRouterLink=Link({component:"router-link"});var exp={common:{Embed:Embed,Image:Image,RichText:RichText},nuxt:{Link:NuxtLink},vueRouter:{Link:VueRouterLink}};function asHtml(richText,linkResolver,htmlSerializer){if(richText){return PrismicDOM__default.RichText.asHtml(richText,linkResolver,htmlSerializer)}}function asText(richText,joinString){if(richText){return PrismicDOM__default.RichText.asText(richText,joinString)}return""}function asLink(link,linkResolver){if(link){return PrismicDOM__default.Link.url(link,linkResolver)}}function asDate(date){if(date){return PrismicDOM__default.Date(date)}}function attachMethods(Vue,options){Vue.prototype.$prismic.asHtml=function(richText,linkResolver,htmlSerializer){return asHtml(richText,linkResolver||options.linkResolver,htmlSerializer||options.htmlSerializer)};Vue.prototype.$prismic.asText=asText;Vue.prototype.$prismic.richTextAsPlain=asText;Vue.prototype.$prismic.asDate=asDate;Vue.prototype.$prismic.asLink=function(link,linkResolver){return asLink(link,linkResolver||options.linkResolver)}}var PrismicVue={install:function install(Vue,options){var _options$linkType=options.linkType,linkType=_options$linkType===void 0?"vueRouter":_options$linkType;Vue.prototype.$prismic=prismicJS;Vue.prototype.$prismic.endpoint=options.endpoint;Vue.prototype.$prismic.linkResolver=options.linkResolver;Vue.prototype.$prismic.htmlSerializer=options.htmlSerializer;Vue.prototype.$prismic.client=prismicJS.client(options.endpoint,options.apiOptions);attachMethods(Vue,options);var components=_objectSpread2(_objectSpread2({},exp.common),exp[linkType]);Object.entries(components).forEach(function(_ref){var _ref2=_slicedToArray(_ref,2),_=_ref2[0],c=_ref2[1];Vue.component(c.name,c)})}};return PrismicVue});
|
|
1
|
+
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory(require("@prismicio/client"),require("prismic-dom")):typeof define==="function"&&define.amd?define(["@prismicio/client","prismic-dom"],factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,global.PrismicVue=factory(global.prismicJS,global.prismicDOM))})(this,function(prismicJS,PrismicDOM){"use strict";function _interopDefaultLegacy(e){return e&&typeof e==="object"&&"default"in e?e:{default:e}}var prismicJS__default=_interopDefaultLegacy(prismicJS);var PrismicDOM__default=_interopDefaultLegacy(PrismicDOM);function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _objectSpread2(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};if(i%2){ownKeys(Object(source),true).forEach(function(key){_defineProperty(target,key,source[key])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}}return target}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var Embed={name:"PrismicEmbed",functional:true,props:{field:{type:Object,required:true},wrapper:{type:[String,Object,Function],required:false,default:"div"}},render:function render(h,_ref){var props=_ref.props,data=_ref.data;var field=props.field,wrapper=props.wrapper;if(!field||!field.html){return null}var embedUrl=field.embed_url,type=field.type,providerName=field.provider_name;var attrs=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({},data.attrs),embedUrl&&{"data-oembed":embedUrl}),type&&{"data-oembed-type":type}),providerName&&{"data-oembed-provider":providerName});return h(wrapper,_objectSpread2(_objectSpread2({},Object.assign(data,{attrs:attrs})),{},{domProps:{innerHTML:field.html}}))}};var Image={name:"PrismicImage",functional:true,props:{field:{type:Object,required:true}},render:function render(h,_ref){var props=_ref.props,data=_ref.data;var field=props.field;if(!field){return null}var url=field.url,alt=field.alt,copyright=field.copyright;return h("img",Object.assign(data,{attrs:_objectSpread2(_objectSpread2({},data.attrs),{},{src:url,alt:alt,copyright:copyright})}))}};var isInternalURL=function isInternalURL(url){var isInternal=/^\/(?!\/)/.test(url);var isSpecialLink=!isInternal&&!/^https?:\/\//i.test(url);return isInternal&&!isSpecialLink};var Link=function(_ref){var _ref$component=_ref.component,component=_ref$component===void 0?"a":_ref$component;return{name:"PrismicLink",functional:true,props:{field:{type:Object,required:true},linkResolver:{type:Function,required:false},target:{type:String,default:undefined,required:false},rel:{type:String,default:undefined,required:false},blankTargetRelAttribute:{type:String,default:"noopener noreferrer",required:false}},render:function render(h,_ref2){var props=_ref2.props,data=_ref2.data,children=_ref2.children,parent=_ref2.parent;var field=props.field,linkResolver=props.linkResolver;if(!field){return null}var url=parent.$prismic?parent.$prismic.asLink(field,linkResolver):PrismicDOM__default["default"].Link.url(field,linkResolver||function(){return null});if(isInternalURL(url)&&!props.target){data.props=data.props||{};data.props.to=url;return h(component,data,children)}data.attrs=_objectSpread2(_objectSpread2({},data.attrs),{},{href:url});if(typeof props.target!=="undefined"){data.attrs.target=props.target}else if(field.target){data.attrs.target=field.target}if(typeof props.rel!=="undefined"){data.attrs.rel=props.rel}else if(data.attrs.target==="_blank"){data.attrs.rel=props.blankTargetRelAttribute}return h("a",data,children)}}};var RichText={name:"PrismicRichText",functional:true,props:{field:{type:Array,required:true},linkResolver:{type:Function,required:false},htmlSerializer:{type:Function,required:false},wrapper:{type:[String,Object,Function],required:false,default:"div"}},render:function render(h,_ref){var props=_ref.props,data=_ref.data,parent=_ref.parent;var field=props.field,linkResolver=props.linkResolver,htmlSerializer=props.htmlSerializer,wrapper=props.wrapper;if(!field){return null}var innerHTML=PrismicDOM.RichText.asHtml(field,linkResolver?linkResolver:parent.$prismic?parent.$prismic.linkResolver:undefined,htmlSerializer?htmlSerializer:parent.$prismic?parent.$prismic.htmlSerializer:undefined);return h(wrapper,_objectSpread2(_objectSpread2({},data),{},{domProps:{innerHTML:innerHTML}}))}};var Text={name:"PrismicText",functional:true,props:{field:{type:Array,required:true},separator:{type:String,default:undefined,required:false},wrapper:{type:[String,Object,Function],required:false,default:"div"}},render:function render(h,_ref){var props=_ref.props,data=_ref.data;_ref.children;_ref.parent;var field=props.field,separator=props.separator,wrapper=props.wrapper;if(!field){return null}var innerHTML=PrismicDOM.RichText.asText(field,separator);return h(wrapper,_objectSpread2(_objectSpread2({},data),{},{domProps:{innerHTML:innerHTML}}))}};if(typeof process==="undefined"){globalThis.process={env:{}}}var __PRODUCTION__=process.env.NODE_ENV==="production";var getSliceComponentProps=function getSliceComponentProps(propsHint){return{slice:{type:Object,required:true},index:{type:Number,required:true},slices:{type:Array,required:true},context:{type:null,required:true}}};var TODOSliceComponent=__PRODUCTION__?null:{name:"TODOSliceComponent",functional:true,props:getSliceComponentProps(),render:function render(h,_ref){var props=_ref.props,data=_ref.data;console.warn('[SliceZone] Could not find a component for Slice type "'.concat(props.slice.slice_type,'"'),props.slice);return h("section",_objectSpread2(_objectSpread2({},data),{},{attrs:_objectSpread2(_objectSpread2({},data.attrs),{},{"data-slice-zone-todo-component":"","data-slice-type":props.slice.slice_type})}),['Could not find a component for Slice type "'.concat(props.slice.slice_type,'"')])}};var SliceZone={name:"SliceZone",props:{slices:{type:Array,required:true},components:{type:Object,default:undefined,required:false},resolver:{type:Function,default:undefined,required:false},context:{type:null,default:undefined,required:false},defaultComponent:{type:Object,default:undefined,required:false},wrapper:{type:[String,Object,Function],default:"div",required:false}},computed:{renderedSlices:function renderedSlices(){var _this=this;if(!this.slices){return null}return this.slices.map(function(slice,index){var component=_this.components&&slice.slice_type in _this.components?_this.components[slice.slice_type]:_this.defaultComponent||TODOSliceComponent;if(_this.resolver){var resolvedComponent=_this.resolver({slice:slice,sliceName:slice.slice_type,i:index});if(resolvedComponent){component=resolvedComponent}}var p={key:"".concat(slice.slice_type,"-").concat(index),props:{slice:slice,index:index,context:_this.context,slices:_this.slices}};return{component:component,p:p}})}},render:function render(h){if(!this.slices){return null}return h(this.wrapper,this.renderedSlices.map(function(_ref2){var component=_ref2.component,p=_ref2.p;return h(component,p)}))}};var NuxtLink=Link({component:"nuxt-link"});var VueRouterLink=Link({component:"router-link"});var exp={common:{Embed:Embed,Image:Image,RichText:RichText,Text:Text,SliceZone:SliceZone},nuxt:{Link:NuxtLink},vueRouter:{Link:VueRouterLink}};function asHtml(richText,linkResolver,htmlSerializer){if(richText){return PrismicDOM__default["default"].RichText.asHtml(richText,linkResolver,htmlSerializer)}}function asText(richText,joinString){if(richText){return PrismicDOM__default["default"].RichText.asText(richText,joinString)}return""}function asLink(link,linkResolver){if(link){return PrismicDOM__default["default"].Link.url(link,linkResolver)}}function asDate(date){if(date){return PrismicDOM__default["default"].Date(date)}}var client=prismicJS__default["default"].client;function attachMethods(Vue,options){Vue.prototype.$prismic.asHtml=function(richText,linkResolver,htmlSerializer){return asHtml(richText,linkResolver||options.linkResolver,htmlSerializer||options.htmlSerializer)};Vue.prototype.$prismic.asHTML=Vue.prototype.$prismic.asHtml;Vue.prototype.$prismic.asText=asText;Vue.prototype.$prismic.richTextAsPlain=asText;Vue.prototype.$prismic.asDate=asDate;Vue.prototype.$prismic.asLink=function(link,linkResolver){return asLink(link,linkResolver||options.linkResolver)}}var PrismicVue={install:function install(Vue,options){var _options$linkType=options.linkType,linkType=_options$linkType===void 0?"vueRouter":_options$linkType;Vue.prototype.$prismic=prismicJS__default["default"];Vue.prototype.$prismic.predicate=prismicJS__default["default"].Predicates;Vue.prototype.$prismic.cookie={preview:prismicJS__default["default"].previewCookie};Vue.prototype.$prismic.endpoint=options.endpoint;Vue.prototype.$prismic.linkResolver=options.linkResolver;Vue.prototype.$prismic.htmlSerializer=options.htmlSerializer;Vue.prototype.$prismic.client=client(options.endpoint,options.apiOptions);attachMethods(Vue,options);var components=_objectSpread2(_objectSpread2({},exp.common),exp[linkType]);Object.entries(components).forEach(function(_ref){var _ref2=_slicedToArray(_ref,2);_ref2[0];var c=_ref2[1];Vue.component(c.name,c)})}};return PrismicVue});
|