@prismicio/vue 2.1.0-alpha.0 → 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/components/common.js +52 -46
- package/components/index.js +52 -46
- package/components/umd.js +52 -46
- package/dist/prismic-vue.common.js +56 -48
- package/dist/prismic-vue.esm.js +56 -48
- package/dist/prismic-vue.js +56 -48
- package/dist/prismic-vue.min.js +1 -1
- package/package.json +54 -19
- package/src/components/Embed.js +32 -32
- package/src/components/Image.js +27 -22
- package/src/components/Link.js +8 -6
- package/src/components/RichText.js +2 -2
- package/src/components/SliceZone.js +40 -39
- package/src/index.js +10 -9
- package/src/methods.js +16 -22
- package/vetur/attributes.json +86 -0
- package/vetur/tags.json +38 -0
package/dist/prismic-vue.esm.js
CHANGED
|
@@ -171,10 +171,15 @@ var Image = {
|
|
|
171
171
|
render: function render(h, _ref) {
|
|
172
172
|
var props = _ref.props,
|
|
173
173
|
data = _ref.data;
|
|
174
|
-
var
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
var field = props.field;
|
|
175
|
+
|
|
176
|
+
if (!field) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
var url = field.url,
|
|
181
|
+
alt = field.alt,
|
|
182
|
+
copyright = field.copyright;
|
|
178
183
|
return h('img', Object.assign(data, {
|
|
179
184
|
attrs: _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
180
185
|
src: url,
|
|
@@ -257,10 +262,12 @@ var Link = (function (_ref) {
|
|
|
257
262
|
|
|
258
263
|
if (typeof props.target !== "undefined" || field.target) {
|
|
259
264
|
data.attrs.target = typeof props.target !== "undefined" ? props.target : field.target;
|
|
265
|
+
}
|
|
260
266
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
267
|
+
if (data.attrs.target === "_blank") {
|
|
268
|
+
data.attrs.rel = typeof props.rel !== "undefined" ? props.rel : props.blankTargetRelAttribute;
|
|
269
|
+
} else if (typeof props.rel !== "undefined") {
|
|
270
|
+
data.attrs.rel = props.rel;
|
|
264
271
|
}
|
|
265
272
|
|
|
266
273
|
return h("a", data, children);
|
|
@@ -303,7 +310,7 @@ var RichText = {
|
|
|
303
310
|
return null;
|
|
304
311
|
}
|
|
305
312
|
|
|
306
|
-
var innerHTML = RichText$1.asHtml(field, linkResolver
|
|
313
|
+
var innerHTML = RichText$1.asHtml(field, linkResolver ? linkResolver : parent.$prismic ? parent.$prismic.linkResolver : undefined, htmlSerializer ? htmlSerializer : parent.$prismic ? parent.$prismic.htmlSerializer : undefined);
|
|
307
314
|
return h(wrapper, _objectSpread2(_objectSpread2({}, data), {}, {
|
|
308
315
|
domProps: {
|
|
309
316
|
innerHTML: innerHTML
|
|
@@ -389,27 +396,24 @@ var getSliceComponentProps = function getSliceComponentProps(propsHint) {
|
|
|
389
396
|
}
|
|
390
397
|
};
|
|
391
398
|
};
|
|
392
|
-
var TODOSliceComponent = __PRODUCTION__ ?
|
|
393
|
-
return null;
|
|
394
|
-
} : {
|
|
399
|
+
var TODOSliceComponent = __PRODUCTION__ ? null : {
|
|
395
400
|
name: "TODOSliceCOmponent",
|
|
396
401
|
functional: true,
|
|
397
402
|
props: getSliceComponentProps(),
|
|
398
|
-
|
|
403
|
+
render: function render(h, _ref) {
|
|
399
404
|
var props = _ref.props,
|
|
400
405
|
data = _ref.data;
|
|
401
406
|
console.warn("[SliceZone] Could not find a component for Slice type \"".concat(props.slice.slice_type, "\""), props.slice);
|
|
402
|
-
return
|
|
403
|
-
|
|
407
|
+
return h("section", _objectSpread2(_objectSpread2({}, data), {}, {
|
|
408
|
+
attrs: _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
404
409
|
"data-slice-zone-todo-component": "",
|
|
405
410
|
"data-slice-type": props.slice.slice_type
|
|
406
|
-
})
|
|
407
|
-
};
|
|
411
|
+
})
|
|
412
|
+
}), ["Could not find a component for Slice type \"".concat(props.slice.slice_type, "\"")]);
|
|
408
413
|
}
|
|
409
414
|
}; // Just mimiced to prevent confusion but doesn't provide any value with version 2 of this kit
|
|
410
415
|
var SliceZone = {
|
|
411
416
|
name: "SliceZone",
|
|
412
|
-
functional: true,
|
|
413
417
|
props: {
|
|
414
418
|
slices: {
|
|
415
419
|
type: Array,
|
|
@@ -441,23 +445,19 @@ var SliceZone = {
|
|
|
441
445
|
required: false
|
|
442
446
|
}
|
|
443
447
|
},
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
448
|
+
computed: {
|
|
449
|
+
renderedSlices: function renderedSlices() {
|
|
450
|
+
var _this = this;
|
|
447
451
|
|
|
448
|
-
|
|
449
|
-
if (!props.slices) {
|
|
450
|
-
return function () {
|
|
452
|
+
if (!this.slices) {
|
|
451
453
|
return null;
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
+
}
|
|
454
455
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
var component = props.components && slice.slice_type in props.components ? props.components[slice.slice_type] : props.defaultComponent || TODOSliceComponent; // TODO: Remove `resolver` in v3 in favor of `components`.
|
|
456
|
+
return this.slices.map(function (slice, index) {
|
|
457
|
+
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`.
|
|
458
458
|
|
|
459
|
-
if (
|
|
460
|
-
var resolvedComponent =
|
|
459
|
+
if (_this.resolver) {
|
|
460
|
+
var resolvedComponent = _this.resolver({
|
|
461
461
|
slice: slice,
|
|
462
462
|
sliceName: slice.slice_type,
|
|
463
463
|
i: index
|
|
@@ -470,25 +470,31 @@ var SliceZone = {
|
|
|
470
470
|
|
|
471
471
|
var p = {
|
|
472
472
|
key: "".concat(slice.slice_type, "-").concat(index),
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
473
|
+
props: {
|
|
474
|
+
slice: slice,
|
|
475
|
+
index: index,
|
|
476
|
+
context: _this.context,
|
|
477
|
+
slices: _this.slices
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
return {
|
|
481
|
+
component: component,
|
|
482
|
+
p: p
|
|
477
483
|
};
|
|
478
|
-
return h(component, p);
|
|
479
|
-
});
|
|
480
|
-
});
|
|
481
|
-
var parent = props.wrapper;
|
|
482
|
-
|
|
483
|
-
if (typeof parent === "string") {
|
|
484
|
-
return h(parent, data, renderedSlices.value);
|
|
485
|
-
} else {
|
|
486
|
-
return h(parent, data, {
|
|
487
|
-
"default": function _default() {
|
|
488
|
-
return renderedSlices.value;
|
|
489
|
-
}
|
|
490
484
|
});
|
|
491
485
|
}
|
|
486
|
+
},
|
|
487
|
+
render: function render(h) {
|
|
488
|
+
// Prevent fatal if user didn't check for field, throws `Invalid prop` warn
|
|
489
|
+
if (!this.slices) {
|
|
490
|
+
return null;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
return h(this.wrapper, this.renderedSlices.map(function (_ref2) {
|
|
494
|
+
var component = _ref2.component,
|
|
495
|
+
p = _ref2.p;
|
|
496
|
+
return h(component, p);
|
|
497
|
+
}));
|
|
492
498
|
}
|
|
493
499
|
};
|
|
494
500
|
|
|
@@ -524,7 +530,7 @@ function asText(richText, joinString) {
|
|
|
524
530
|
return PrismicDOM.RichText.asText(richText, joinString);
|
|
525
531
|
}
|
|
526
532
|
|
|
527
|
-
return
|
|
533
|
+
return "";
|
|
528
534
|
}
|
|
529
535
|
function asLink(link, linkResolver) {
|
|
530
536
|
if (link) {
|
|
@@ -537,6 +543,8 @@ function asDate(date) {
|
|
|
537
543
|
}
|
|
538
544
|
}
|
|
539
545
|
|
|
546
|
+
var client = prismicJS.client;
|
|
547
|
+
|
|
540
548
|
function attachMethods(Vue, options) {
|
|
541
549
|
Vue.prototype.$prismic.asHtml = function (richText, linkResolver, htmlSerializer) {
|
|
542
550
|
return asHtml(richText, linkResolver || options.linkResolver, htmlSerializer || options.htmlSerializer);
|
|
@@ -560,7 +568,7 @@ var PrismicVue = {
|
|
|
560
568
|
Vue.prototype.$prismic.endpoint = options.endpoint;
|
|
561
569
|
Vue.prototype.$prismic.linkResolver = options.linkResolver;
|
|
562
570
|
Vue.prototype.$prismic.htmlSerializer = options.htmlSerializer;
|
|
563
|
-
Vue.prototype.$prismic.client =
|
|
571
|
+
Vue.prototype.$prismic.client = client(options.endpoint, options.apiOptions);
|
|
564
572
|
attachMethods(Vue, options);
|
|
565
573
|
|
|
566
574
|
var components = _objectSpread2(_objectSpread2({}, exp.common), exp[linkType]);
|
package/dist/prismic-vue.js
CHANGED
|
@@ -179,10 +179,15 @@
|
|
|
179
179
|
render: function render(h, _ref) {
|
|
180
180
|
var props = _ref.props,
|
|
181
181
|
data = _ref.data;
|
|
182
|
-
var
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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;
|
|
186
191
|
return h('img', Object.assign(data, {
|
|
187
192
|
attrs: _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
188
193
|
src: url,
|
|
@@ -265,10 +270,12 @@
|
|
|
265
270
|
|
|
266
271
|
if (typeof props.target !== "undefined" || field.target) {
|
|
267
272
|
data.attrs.target = typeof props.target !== "undefined" ? props.target : field.target;
|
|
273
|
+
}
|
|
268
274
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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;
|
|
272
279
|
}
|
|
273
280
|
|
|
274
281
|
return h("a", data, children);
|
|
@@ -311,7 +318,7 @@
|
|
|
311
318
|
return null;
|
|
312
319
|
}
|
|
313
320
|
|
|
314
|
-
var innerHTML = PrismicDOM.RichText.asHtml(field, linkResolver
|
|
321
|
+
var innerHTML = PrismicDOM.RichText.asHtml(field, linkResolver ? linkResolver : parent.$prismic ? parent.$prismic.linkResolver : undefined, htmlSerializer ? htmlSerializer : parent.$prismic ? parent.$prismic.htmlSerializer : undefined);
|
|
315
322
|
return h(wrapper, _objectSpread2(_objectSpread2({}, data), {}, {
|
|
316
323
|
domProps: {
|
|
317
324
|
innerHTML: innerHTML
|
|
@@ -397,27 +404,24 @@
|
|
|
397
404
|
}
|
|
398
405
|
};
|
|
399
406
|
};
|
|
400
|
-
var TODOSliceComponent = __PRODUCTION__ ?
|
|
401
|
-
return null;
|
|
402
|
-
} : {
|
|
407
|
+
var TODOSliceComponent = __PRODUCTION__ ? null : {
|
|
403
408
|
name: "TODOSliceCOmponent",
|
|
404
409
|
functional: true,
|
|
405
410
|
props: getSliceComponentProps(),
|
|
406
|
-
|
|
411
|
+
render: function render(h, _ref) {
|
|
407
412
|
var props = _ref.props,
|
|
408
413
|
data = _ref.data;
|
|
409
414
|
console.warn("[SliceZone] Could not find a component for Slice type \"".concat(props.slice.slice_type, "\""), props.slice);
|
|
410
|
-
return
|
|
411
|
-
|
|
415
|
+
return h("section", _objectSpread2(_objectSpread2({}, data), {}, {
|
|
416
|
+
attrs: _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
412
417
|
"data-slice-zone-todo-component": "",
|
|
413
418
|
"data-slice-type": props.slice.slice_type
|
|
414
|
-
})
|
|
415
|
-
};
|
|
419
|
+
})
|
|
420
|
+
}), ["Could not find a component for Slice type \"".concat(props.slice.slice_type, "\"")]);
|
|
416
421
|
}
|
|
417
422
|
}; // Just mimiced to prevent confusion but doesn't provide any value with version 2 of this kit
|
|
418
423
|
var SliceZone = {
|
|
419
424
|
name: "SliceZone",
|
|
420
|
-
functional: true,
|
|
421
425
|
props: {
|
|
422
426
|
slices: {
|
|
423
427
|
type: Array,
|
|
@@ -449,23 +453,19 @@
|
|
|
449
453
|
required: false
|
|
450
454
|
}
|
|
451
455
|
},
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
456
|
+
computed: {
|
|
457
|
+
renderedSlices: function renderedSlices() {
|
|
458
|
+
var _this = this;
|
|
455
459
|
|
|
456
|
-
|
|
457
|
-
if (!props.slices) {
|
|
458
|
-
return function () {
|
|
460
|
+
if (!this.slices) {
|
|
459
461
|
return null;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
+
}
|
|
462
463
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
var component = props.components && slice.slice_type in props.components ? props.components[slice.slice_type] : props.defaultComponent || TODOSliceComponent; // TODO: Remove `resolver` in v3 in favor of `components`.
|
|
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
466
|
|
|
467
|
-
if (
|
|
468
|
-
var resolvedComponent =
|
|
467
|
+
if (_this.resolver) {
|
|
468
|
+
var resolvedComponent = _this.resolver({
|
|
469
469
|
slice: slice,
|
|
470
470
|
sliceName: slice.slice_type,
|
|
471
471
|
i: index
|
|
@@ -478,25 +478,31 @@
|
|
|
478
478
|
|
|
479
479
|
var p = {
|
|
480
480
|
key: "".concat(slice.slice_type, "-").concat(index),
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
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
|
|
485
491
|
};
|
|
486
|
-
return h(component, p);
|
|
487
|
-
});
|
|
488
|
-
});
|
|
489
|
-
var parent = props.wrapper;
|
|
490
|
-
|
|
491
|
-
if (typeof parent === "string") {
|
|
492
|
-
return h(parent, data, renderedSlices.value);
|
|
493
|
-
} else {
|
|
494
|
-
return h(parent, data, {
|
|
495
|
-
"default": function _default() {
|
|
496
|
-
return renderedSlices.value;
|
|
497
|
-
}
|
|
498
492
|
});
|
|
499
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
|
+
}));
|
|
500
506
|
}
|
|
501
507
|
};
|
|
502
508
|
|
|
@@ -532,7 +538,7 @@
|
|
|
532
538
|
return PrismicDOM__default["default"].RichText.asText(richText, joinString);
|
|
533
539
|
}
|
|
534
540
|
|
|
535
|
-
return
|
|
541
|
+
return "";
|
|
536
542
|
}
|
|
537
543
|
function asLink(link, linkResolver) {
|
|
538
544
|
if (link) {
|
|
@@ -545,6 +551,8 @@
|
|
|
545
551
|
}
|
|
546
552
|
}
|
|
547
553
|
|
|
554
|
+
var client = prismicJS__default["default"].client;
|
|
555
|
+
|
|
548
556
|
function attachMethods(Vue, options) {
|
|
549
557
|
Vue.prototype.$prismic.asHtml = function (richText, linkResolver, htmlSerializer) {
|
|
550
558
|
return asHtml(richText, linkResolver || options.linkResolver, htmlSerializer || options.htmlSerializer);
|
|
@@ -568,7 +576,7 @@
|
|
|
568
576
|
Vue.prototype.$prismic.endpoint = options.endpoint;
|
|
569
577
|
Vue.prototype.$prismic.linkResolver = options.linkResolver;
|
|
570
578
|
Vue.prototype.$prismic.htmlSerializer = options.htmlSerializer;
|
|
571
|
-
Vue.prototype.$prismic.client =
|
|
579
|
+
Vue.prototype.$prismic.client = client(options.endpoint, options.apiOptions);
|
|
572
580
|
attachMethods(Vue, options);
|
|
573
581
|
|
|
574
582
|
var components = _objectSpread2(_objectSpread2({}, exp.common), exp[linkType]);
|
package/dist/prismic-vue.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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 _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 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}}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||parent.$prismic.linkResolver,htmlSerializer||parent.$prismic.htmlSerializer);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__?function(){return null}:{name:"TODOSliceCOmponent",functional:true,props:getSliceComponentProps(),renfer:function renfer(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 function(){return h("section",_objectSpread2(_objectSpread2({},data),{},{"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",functional:true,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}},render:function render(h,_ref2){var props=_ref2.props,data=_ref2.data;if(!props.slices){return function(){return null}}var renderedSlices=computed(function(){return props.slices.map(function(slice,index){var component=props.components&&slice.slice_type in props.components?props.components[slice.slice_type]:props.defaultComponent||TODOSliceComponent;if(props.resolver){var resolvedComponent=props.resolver({slice:slice,sliceName:slice.slice_type,i:index});if(resolvedComponent){component=resolvedComponent}}var p={key:"".concat(slice.slice_type,"-").concat(index),slice:slice,index:index,context:props.context,slices:props.slices};return h(component,p)})});var parent=props.wrapper;if(typeof parent==="string"){return h(parent,data,renderedSlices.value)}else{return h(parent,data,{default:function _default(){return renderedSlices.value}})}}};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)}}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=prismicJS__default["default"].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});
|
|
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});
|
package/package.json
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/vue",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
4
|
-
"description": "Vue
|
|
3
|
+
"version": "2.1.0-alpha.1",
|
|
4
|
+
"description": "Vue plugin and components to fetch and present Prismic content",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"prismic",
|
|
7
|
+
"vue",
|
|
8
|
+
"plugin"
|
|
9
|
+
],
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "ssh://git@github.com/prismicio/prismic-vue.git"
|
|
13
|
+
},
|
|
5
14
|
"license": "Apache-2.0",
|
|
6
|
-
"
|
|
7
|
-
"author": "Prismic",
|
|
15
|
+
"author": "Prismic <contact@prismic.io> (https://prismic.io)",
|
|
8
16
|
"components": "dist/components.esm.js",
|
|
9
17
|
"main": "dist/prismic-vue.common.js",
|
|
10
18
|
"module": "dist/prismic-vue.esm.js",
|
|
@@ -13,38 +21,65 @@
|
|
|
13
21
|
"files": [
|
|
14
22
|
"components",
|
|
15
23
|
"dist",
|
|
16
|
-
"src"
|
|
24
|
+
"src",
|
|
25
|
+
"vetur"
|
|
17
26
|
],
|
|
18
27
|
"scripts": {
|
|
19
28
|
"build": "rollup -c --environment BUILD:production && uglifyjs dist/prismic-vue.js -o dist/prismic-vue.min.js",
|
|
20
|
-
"release": "npm run build && npm publish",
|
|
21
|
-
"beauty": "rollup -c",
|
|
22
29
|
"dev": "rollup -c --watch --environment BUILD:development",
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
30
|
+
"prepare": "npm run build",
|
|
31
|
+
"format": "prettier --write .",
|
|
32
|
+
"release": "npm run build && npm run test && standard-version && git push --follow-tags && npm run build && npm publish",
|
|
33
|
+
"release:dry": "standard-version --dry-run",
|
|
34
|
+
"release:alpha": "npm run build && npm run test && standard-version --release-as minor --prerelease alpha && git push --follow-tags && npm run build && npm publish --tag alpha",
|
|
35
|
+
"release:alpha:dry": "standard-version --release-as minor --prerelease alpha --dry-run",
|
|
36
|
+
"test": "npm run lint && npm run unit",
|
|
37
|
+
"lint": "eslint --ext .js,.ts .",
|
|
38
|
+
"unit": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava"
|
|
32
39
|
},
|
|
33
40
|
"devDependencies": {
|
|
34
41
|
"@babel/core": "^7.16.0",
|
|
35
42
|
"@babel/preset-env": "^7.16.4",
|
|
36
43
|
"@prismicio/client": "^5.1.0",
|
|
37
|
-
"
|
|
44
|
+
"@prismicio/mock": "^0.0.6",
|
|
45
|
+
"@prismicio/types": "^0.1.18",
|
|
46
|
+
"@vue/compiler-sfc": "^3.2.23",
|
|
47
|
+
"@vue/test-utils": "^1.3.0",
|
|
48
|
+
"ava": "^3.15.0",
|
|
49
|
+
"eslint": "^8.3.0",
|
|
50
|
+
"eslint-config-prettier": "^8.3.0",
|
|
51
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
52
|
+
"eslint-plugin-vue": "^8.1.1",
|
|
53
|
+
"esm": "^3.2.25",
|
|
54
|
+
"jsdom": "^18.1.1",
|
|
55
|
+
"jsdom-global": "^3.0.2",
|
|
56
|
+
"nyc": "^15.1.0",
|
|
57
|
+
"prettier": "^2.5.0",
|
|
38
58
|
"prismic-dom": "^2.2.6",
|
|
39
|
-
"rollup": "^2.60.
|
|
59
|
+
"rollup": "^2.60.2",
|
|
40
60
|
"rollup-plugin-auto-named-exports": "^1.0.0-beta.3",
|
|
41
61
|
"rollup-plugin-babel": "^4.4.0",
|
|
42
62
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
43
63
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
44
64
|
"rollup-plugin-visualizer": "^5.5.2",
|
|
45
65
|
"rollup-plugin-vue": "^6.0.0",
|
|
66
|
+
"sinon": "^12.0.1",
|
|
67
|
+
"standard-version": "^9.3.2",
|
|
46
68
|
"uglify-js": "^3.14.3",
|
|
47
|
-
"vue
|
|
69
|
+
"vue": "^2.6.14",
|
|
70
|
+
"vue-router": "^3.5.3",
|
|
71
|
+
"vue-template-compiler": "2.6.14"
|
|
72
|
+
},
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"@prismicio/client": "^4.0.0 || ^5.0.0",
|
|
75
|
+
"prismic-dom": "^2.2.0",
|
|
76
|
+
"vue": "^2.6.0"
|
|
77
|
+
},
|
|
78
|
+
"engines": {
|
|
79
|
+
"node": ">= 6.0.0"
|
|
80
|
+
},
|
|
81
|
+
"publishConfig": {
|
|
82
|
+
"access": "public"
|
|
48
83
|
},
|
|
49
84
|
"vetur": {
|
|
50
85
|
"tags": "vetur/tags.json",
|
package/src/components/Embed.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
name: 'PrismicEmbed',
|
|
3
|
+
functional: true,
|
|
4
|
+
props: {
|
|
5
|
+
field: {
|
|
6
|
+
type: Object,
|
|
7
|
+
required: true
|
|
8
|
+
},
|
|
9
|
+
wrapper: {
|
|
10
|
+
type: String,
|
|
11
|
+
required: false,
|
|
12
|
+
default: 'div'
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
render(h, { props, data }) {
|
|
16
|
+
const { field, wrapper } = props
|
|
17
|
+
if (!field || !field.html) {
|
|
18
|
+
return null
|
|
19
|
+
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const { embed_url: embedUrl, type, provider_name: providerName } = field
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const attrs = {
|
|
24
|
+
...data.attrs,
|
|
25
|
+
...(embedUrl && { 'data-oembed': embedUrl }),
|
|
26
|
+
...(type && { 'data-oembed-type': type }),
|
|
27
|
+
...(providerName && { 'data-oembed-provider': providerName })
|
|
28
|
+
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
return h(wrapper, {
|
|
31
|
+
...Object.assign(data, { attrs }),
|
|
32
|
+
domProps: {
|
|
33
|
+
innerHTML: field.html
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
37
|
}
|
package/src/components/Image.js
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
name: 'PrismicImage',
|
|
3
|
+
functional: true,
|
|
4
|
+
props: {
|
|
5
|
+
field: {
|
|
6
|
+
type: Object,
|
|
7
|
+
required: true,
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
render(h, { props, data }) {
|
|
11
|
+
const { field } = props;
|
|
12
|
+
if (!field) {
|
|
13
|
+
return null
|
|
14
|
+
}
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
const { url, alt, copyright } = field;
|
|
17
|
+
|
|
18
|
+
return h(
|
|
19
|
+
'img',
|
|
20
|
+
Object.assign(data, {
|
|
21
|
+
attrs: {
|
|
22
|
+
...data.attrs,
|
|
23
|
+
src: url,
|
|
24
|
+
alt,
|
|
25
|
+
copyright
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
},
|
|
25
30
|
};
|