@prismicio/vue 2.0.9 → 2.1.0-alpha.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 +288 -49
- package/components/index.js +283 -48
- package/components/umd.js +291 -51
- package/dist/prismic-vue.common.js +294 -57
- package/dist/prismic-vue.esm.js +288 -53
- package/dist/prismic-vue.js +298 -61
- package/dist/prismic-vue.min.js +1 -1
- package/package.json +86 -46
- package/src/components/Embed.js +32 -32
- package/src/components/Image.js +27 -22
- package/src/components/Link.js +89 -54
- 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 +47 -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;
|
|
@@ -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: {
|
|
@@ -197,10 +224,22 @@
|
|
|
197
224
|
},
|
|
198
225
|
linkResolver: {
|
|
199
226
|
type: Function,
|
|
200
|
-
required: false
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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",
|
|
242
|
+
required: false
|
|
204
243
|
}
|
|
205
244
|
},
|
|
206
245
|
render: function render(h, _ref2) {
|
|
@@ -215,9 +254,11 @@
|
|
|
215
254
|
return null;
|
|
216
255
|
}
|
|
217
256
|
|
|
218
|
-
var url = parent.$prismic ? parent.$prismic.asLink(field, linkResolver) : PrismicDOM__default.Link.url(field, linkResolver)
|
|
257
|
+
var url = parent.$prismic ? parent.$prismic.asLink(field, linkResolver) : PrismicDOM__default["default"].Link.url(field, linkResolver || function () {
|
|
258
|
+
return null;
|
|
259
|
+
});
|
|
219
260
|
|
|
220
|
-
if (url
|
|
261
|
+
if (isInternalURL(url) && !props.target) {
|
|
221
262
|
data.props = data.props || {};
|
|
222
263
|
data.props.to = url;
|
|
223
264
|
return h(component, data, children);
|
|
@@ -225,23 +266,35 @@
|
|
|
225
266
|
|
|
226
267
|
data.attrs = _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
227
268
|
href: url
|
|
228
|
-
}, field.target && {
|
|
229
|
-
target: field.target,
|
|
230
|
-
rel: 'noopener'
|
|
231
269
|
});
|
|
232
|
-
|
|
270
|
+
|
|
271
|
+
if (typeof props.target !== "undefined" || field.target) {
|
|
272
|
+
data.attrs.target = typeof props.target !== "undefined" ? props.target : field.target;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (data.attrs.target === "_blank") {
|
|
276
|
+
data.attrs.rel = typeof props.rel !== "undefined" ? props.rel : props.blankTargetRelAttribute;
|
|
277
|
+
} else if (typeof props.rel !== "undefined") {
|
|
278
|
+
data.attrs.rel = props.rel;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return h("a", data, children);
|
|
233
282
|
}
|
|
234
283
|
};
|
|
235
284
|
});
|
|
236
285
|
|
|
237
286
|
var RichText = {
|
|
238
|
-
name:
|
|
287
|
+
name: "PrismicRichText",
|
|
239
288
|
functional: true,
|
|
240
289
|
props: {
|
|
241
290
|
field: {
|
|
242
291
|
type: Array,
|
|
243
292
|
required: true
|
|
244
293
|
},
|
|
294
|
+
linkResolver: {
|
|
295
|
+
type: Function,
|
|
296
|
+
required: false
|
|
297
|
+
},
|
|
245
298
|
htmlSerializer: {
|
|
246
299
|
type: Function,
|
|
247
300
|
required: false
|
|
@@ -249,15 +302,15 @@
|
|
|
249
302
|
wrapper: {
|
|
250
303
|
type: String,
|
|
251
304
|
required: false,
|
|
252
|
-
"default":
|
|
305
|
+
"default": "div"
|
|
253
306
|
}
|
|
254
307
|
},
|
|
255
308
|
render: function render(h, _ref) {
|
|
256
309
|
var props = _ref.props,
|
|
257
310
|
data = _ref.data,
|
|
258
|
-
children = _ref.children,
|
|
259
311
|
parent = _ref.parent;
|
|
260
312
|
var field = props.field,
|
|
313
|
+
linkResolver = props.linkResolver,
|
|
261
314
|
htmlSerializer = props.htmlSerializer,
|
|
262
315
|
wrapper = props.wrapper;
|
|
263
316
|
|
|
@@ -265,7 +318,7 @@
|
|
|
265
318
|
return null;
|
|
266
319
|
}
|
|
267
320
|
|
|
268
|
-
var innerHTML = PrismicDOM.RichText.asHtml(field, parent.$prismic.linkResolver, htmlSerializer
|
|
321
|
+
var innerHTML = PrismicDOM.RichText.asHtml(field, linkResolver ? linkResolver : parent.$prismic ? parent.$prismic.linkResolver : undefined, htmlSerializer ? htmlSerializer : parent.$prismic ? parent.$prismic.htmlSerializer : undefined);
|
|
269
322
|
return h(wrapper, _objectSpread2(_objectSpread2({}, data), {}, {
|
|
270
323
|
domProps: {
|
|
271
324
|
innerHTML: innerHTML
|
|
@@ -274,17 +327,198 @@
|
|
|
274
327
|
}
|
|
275
328
|
};
|
|
276
329
|
|
|
330
|
+
var Text = {
|
|
331
|
+
name: "PrismicText",
|
|
332
|
+
functional: true,
|
|
333
|
+
props: {
|
|
334
|
+
field: {
|
|
335
|
+
type: Array,
|
|
336
|
+
required: true
|
|
337
|
+
},
|
|
338
|
+
separator: {
|
|
339
|
+
type: String,
|
|
340
|
+
"default": undefined,
|
|
341
|
+
required: false
|
|
342
|
+
},
|
|
343
|
+
wrapper: {
|
|
344
|
+
type: String,
|
|
345
|
+
required: false,
|
|
346
|
+
"default": "div"
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
render: function render(h, _ref) {
|
|
350
|
+
var props = _ref.props,
|
|
351
|
+
data = _ref.data;
|
|
352
|
+
_ref.children;
|
|
353
|
+
_ref.parent;
|
|
354
|
+
var field = props.field,
|
|
355
|
+
separator = props.separator,
|
|
356
|
+
wrapper = props.wrapper;
|
|
357
|
+
|
|
358
|
+
if (!field) {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
var innerHTML = PrismicDOM.RichText.asText(field, separator);
|
|
363
|
+
return h(wrapper, _objectSpread2(_objectSpread2({}, data), {}, {
|
|
364
|
+
domProps: {
|
|
365
|
+
innerHTML: innerHTML
|
|
366
|
+
}
|
|
367
|
+
}));
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
// We need to polyfill process if it doesn't exist, such as in the browser.
|
|
372
|
+
if (typeof process === "undefined") {
|
|
373
|
+
globalThis.process = {
|
|
374
|
+
env: {}
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* `true` if in the production environment, `false` otherwise.
|
|
379
|
+
*
|
|
380
|
+
* This boolean can be used to perform actions only in development environments,
|
|
381
|
+
* such as logging.
|
|
382
|
+
*/
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
var __PRODUCTION__ = process.env.NODE_ENV === "production";
|
|
386
|
+
|
|
387
|
+
var getSliceComponentProps = function getSliceComponentProps(propsHint) {
|
|
388
|
+
return {
|
|
389
|
+
slice: {
|
|
390
|
+
type: Object,
|
|
391
|
+
required: true
|
|
392
|
+
},
|
|
393
|
+
index: {
|
|
394
|
+
type: Number,
|
|
395
|
+
required: true
|
|
396
|
+
},
|
|
397
|
+
slices: {
|
|
398
|
+
type: Array,
|
|
399
|
+
required: true
|
|
400
|
+
},
|
|
401
|
+
context: {
|
|
402
|
+
type: null,
|
|
403
|
+
required: true
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
var TODOSliceComponent = __PRODUCTION__ ? null : {
|
|
408
|
+
name: "TODOSliceCOmponent",
|
|
409
|
+
functional: true,
|
|
410
|
+
props: getSliceComponentProps(),
|
|
411
|
+
render: function render(h, _ref) {
|
|
412
|
+
var props = _ref.props,
|
|
413
|
+
data = _ref.data;
|
|
414
|
+
console.warn("[SliceZone] Could not find a component for Slice type \"".concat(props.slice.slice_type, "\""), props.slice);
|
|
415
|
+
return h("section", _objectSpread2(_objectSpread2({}, data), {}, {
|
|
416
|
+
attrs: _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
417
|
+
"data-slice-zone-todo-component": "",
|
|
418
|
+
"data-slice-type": props.slice.slice_type
|
|
419
|
+
})
|
|
420
|
+
}), ["Could not find a component for Slice type \"".concat(props.slice.slice_type, "\"")]);
|
|
421
|
+
}
|
|
422
|
+
}; // Just mimiced to prevent confusion but doesn't provide any value with version 2 of this kit
|
|
423
|
+
var SliceZone = {
|
|
424
|
+
name: "SliceZone",
|
|
425
|
+
props: {
|
|
426
|
+
slices: {
|
|
427
|
+
type: Array,
|
|
428
|
+
required: true
|
|
429
|
+
},
|
|
430
|
+
components: {
|
|
431
|
+
type: Object,
|
|
432
|
+
"default": undefined,
|
|
433
|
+
required: false
|
|
434
|
+
},
|
|
435
|
+
resolver: {
|
|
436
|
+
type: Function,
|
|
437
|
+
"default": undefined,
|
|
438
|
+
required: false
|
|
439
|
+
},
|
|
440
|
+
context: {
|
|
441
|
+
type: null,
|
|
442
|
+
"default": undefined,
|
|
443
|
+
required: false
|
|
444
|
+
},
|
|
445
|
+
defaultComponent: {
|
|
446
|
+
type: Object,
|
|
447
|
+
"default": undefined,
|
|
448
|
+
required: false
|
|
449
|
+
},
|
|
450
|
+
wrapper: {
|
|
451
|
+
type: [String, Object, Function],
|
|
452
|
+
"default": "div",
|
|
453
|
+
required: false
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
computed: {
|
|
457
|
+
renderedSlices: function renderedSlices() {
|
|
458
|
+
var _this = this;
|
|
459
|
+
|
|
460
|
+
if (!this.slices) {
|
|
461
|
+
return null;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return this.slices.map(function (slice, index) {
|
|
465
|
+
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`.
|
|
466
|
+
|
|
467
|
+
if (_this.resolver) {
|
|
468
|
+
var resolvedComponent = _this.resolver({
|
|
469
|
+
slice: slice,
|
|
470
|
+
sliceName: slice.slice_type,
|
|
471
|
+
i: index
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
if (resolvedComponent) {
|
|
475
|
+
component = resolvedComponent;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
var p = {
|
|
480
|
+
key: "".concat(slice.slice_type, "-").concat(index),
|
|
481
|
+
props: {
|
|
482
|
+
slice: slice,
|
|
483
|
+
index: index,
|
|
484
|
+
context: _this.context,
|
|
485
|
+
slices: _this.slices
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
return {
|
|
489
|
+
component: component,
|
|
490
|
+
p: p
|
|
491
|
+
};
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
render: function render(h) {
|
|
496
|
+
// Prevent fatal if user didn't check for field, throws `Invalid prop` warn
|
|
497
|
+
if (!this.slices) {
|
|
498
|
+
return null;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
return h(this.wrapper, this.renderedSlices.map(function (_ref2) {
|
|
502
|
+
var component = _ref2.component,
|
|
503
|
+
p = _ref2.p;
|
|
504
|
+
return h(component, p);
|
|
505
|
+
}));
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
|
|
277
509
|
var NuxtLink = Link({
|
|
278
|
-
component:
|
|
510
|
+
component: "nuxt-link"
|
|
279
511
|
});
|
|
280
512
|
var VueRouterLink = Link({
|
|
281
|
-
component:
|
|
513
|
+
component: "router-link"
|
|
282
514
|
});
|
|
283
515
|
var exp = {
|
|
284
516
|
common: {
|
|
285
517
|
Embed: Embed,
|
|
286
518
|
Image: Image,
|
|
287
|
-
RichText: RichText
|
|
519
|
+
RichText: RichText,
|
|
520
|
+
Text: Text,
|
|
521
|
+
SliceZone: SliceZone
|
|
288
522
|
},
|
|
289
523
|
nuxt: {
|
|
290
524
|
Link: NuxtLink
|
|
@@ -296,32 +530,35 @@
|
|
|
296
530
|
|
|
297
531
|
function asHtml(richText, linkResolver, htmlSerializer) {
|
|
298
532
|
if (richText) {
|
|
299
|
-
return PrismicDOM__default.RichText.asHtml(richText, linkResolver, htmlSerializer);
|
|
533
|
+
return PrismicDOM__default["default"].RichText.asHtml(richText, linkResolver, htmlSerializer);
|
|
300
534
|
}
|
|
301
535
|
}
|
|
302
536
|
function asText(richText, joinString) {
|
|
303
537
|
if (richText) {
|
|
304
|
-
return PrismicDOM__default.RichText.asText(richText, joinString);
|
|
538
|
+
return PrismicDOM__default["default"].RichText.asText(richText, joinString);
|
|
305
539
|
}
|
|
306
540
|
|
|
307
|
-
return
|
|
541
|
+
return "";
|
|
308
542
|
}
|
|
309
543
|
function asLink(link, linkResolver) {
|
|
310
544
|
if (link) {
|
|
311
|
-
return PrismicDOM__default.Link.url(link, linkResolver);
|
|
545
|
+
return PrismicDOM__default["default"].Link.url(link, linkResolver);
|
|
312
546
|
}
|
|
313
547
|
}
|
|
314
548
|
function asDate(date) {
|
|
315
549
|
if (date) {
|
|
316
|
-
return PrismicDOM__default.Date(date);
|
|
550
|
+
return PrismicDOM__default["default"].Date(date);
|
|
317
551
|
}
|
|
318
552
|
}
|
|
319
553
|
|
|
554
|
+
var client = prismicJS__default["default"].client;
|
|
555
|
+
|
|
320
556
|
function attachMethods(Vue, options) {
|
|
321
557
|
Vue.prototype.$prismic.asHtml = function (richText, linkResolver, htmlSerializer) {
|
|
322
558
|
return asHtml(richText, linkResolver || options.linkResolver, htmlSerializer || options.htmlSerializer);
|
|
323
559
|
};
|
|
324
560
|
|
|
561
|
+
Vue.prototype.$prismic.asHTML = Vue.prototype.$prismic.asHtml;
|
|
325
562
|
Vue.prototype.$prismic.asText = asText;
|
|
326
563
|
Vue.prototype.$prismic.richTextAsPlain = asText;
|
|
327
564
|
Vue.prototype.$prismic.asDate = asDate;
|
|
@@ -334,12 +571,12 @@
|
|
|
334
571
|
var PrismicVue = {
|
|
335
572
|
install: function install(Vue, options) {
|
|
336
573
|
var _options$linkType = options.linkType,
|
|
337
|
-
linkType = _options$linkType === void 0 ?
|
|
338
|
-
Vue.prototype.$prismic =
|
|
574
|
+
linkType = _options$linkType === void 0 ? "vueRouter" : _options$linkType;
|
|
575
|
+
Vue.prototype.$prismic = prismicJS__default["default"];
|
|
339
576
|
Vue.prototype.$prismic.endpoint = options.endpoint;
|
|
340
577
|
Vue.prototype.$prismic.linkResolver = options.linkResolver;
|
|
341
578
|
Vue.prototype.$prismic.htmlSerializer = options.htmlSerializer;
|
|
342
|
-
Vue.prototype.$prismic.client =
|
|
579
|
+
Vue.prototype.$prismic.client = client(options.endpoint, options.apiOptions);
|
|
343
580
|
attachMethods(Vue, options);
|
|
344
581
|
|
|
345
582
|
var components = _objectSpread2(_objectSpread2({}, exp.common), exp[linkType]);
|
|
@@ -350,9 +587,9 @@
|
|
|
350
587
|
|
|
351
588
|
|
|
352
589
|
Object.entries(components).forEach(function (_ref) {
|
|
353
|
-
var _ref2 = _slicedToArray(_ref, 2)
|
|
354
|
-
|
|
355
|
-
c = _ref2[1];
|
|
590
|
+
var _ref2 = _slicedToArray(_ref, 2);
|
|
591
|
+
_ref2[0];
|
|
592
|
+
var c = _ref2[1];
|
|
356
593
|
|
|
357
594
|
Vue.component(c.name, c);
|
|
358
595
|
});
|
|
@@ -361,4 +598,4 @@
|
|
|
361
598
|
|
|
362
599
|
return PrismicVue;
|
|
363
600
|
|
|
364
|
-
}))
|
|
601
|
+
}));
|
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,default:function _default(){return null}}},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);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,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",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"||field.target){data.attrs.target=typeof props.target!=="undefined"?props.target:field.target}if(data.attrs.target==="_blank"){data.attrs.rel=typeof props.rel!=="undefined"?props.rel:props.blankTargetRelAttribute}else if(typeof props.rel!=="undefined"){data.attrs.rel=props.rel}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,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,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.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});
|