@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/components/common.js
CHANGED
|
@@ -119,10 +119,15 @@ var Image = {
|
|
|
119
119
|
render: function render(h, _ref) {
|
|
120
120
|
var props = _ref.props,
|
|
121
121
|
data = _ref.data;
|
|
122
|
-
var
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
var field = props.field;
|
|
123
|
+
|
|
124
|
+
if (!field) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
var url = field.url,
|
|
129
|
+
alt = field.alt,
|
|
130
|
+
copyright = field.copyright;
|
|
126
131
|
return h('img', Object.assign(data, {
|
|
127
132
|
attrs: _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
128
133
|
src: url,
|
|
@@ -205,10 +210,12 @@ var Link = (function (_ref) {
|
|
|
205
210
|
|
|
206
211
|
if (typeof props.target !== "undefined" || field.target) {
|
|
207
212
|
data.attrs.target = typeof props.target !== "undefined" ? props.target : field.target;
|
|
213
|
+
}
|
|
208
214
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
215
|
+
if (data.attrs.target === "_blank") {
|
|
216
|
+
data.attrs.rel = typeof props.rel !== "undefined" ? props.rel : props.blankTargetRelAttribute;
|
|
217
|
+
} else if (typeof props.rel !== "undefined") {
|
|
218
|
+
data.attrs.rel = props.rel;
|
|
212
219
|
}
|
|
213
220
|
|
|
214
221
|
return h("a", data, children);
|
|
@@ -251,7 +258,7 @@ var RichText = {
|
|
|
251
258
|
return null;
|
|
252
259
|
}
|
|
253
260
|
|
|
254
|
-
var innerHTML = PrismicDom.RichText.asHtml(field, linkResolver
|
|
261
|
+
var innerHTML = PrismicDom.RichText.asHtml(field, linkResolver ? linkResolver : parent.$prismic ? parent.$prismic.linkResolver : undefined, htmlSerializer ? htmlSerializer : parent.$prismic ? parent.$prismic.htmlSerializer : undefined);
|
|
255
262
|
return h(wrapper, _objectSpread2(_objectSpread2({}, data), {}, {
|
|
256
263
|
domProps: {
|
|
257
264
|
innerHTML: innerHTML
|
|
@@ -337,22 +344,20 @@ var getSliceComponentProps = function getSliceComponentProps(propsHint) {
|
|
|
337
344
|
}
|
|
338
345
|
};
|
|
339
346
|
};
|
|
340
|
-
var TODOSliceComponent = __PRODUCTION__ ?
|
|
341
|
-
return null;
|
|
342
|
-
} : {
|
|
347
|
+
var TODOSliceComponent = __PRODUCTION__ ? null : {
|
|
343
348
|
name: "TODOSliceCOmponent",
|
|
344
349
|
functional: true,
|
|
345
350
|
props: getSliceComponentProps(),
|
|
346
|
-
|
|
351
|
+
render: function render(h, _ref) {
|
|
347
352
|
var props = _ref.props,
|
|
348
353
|
data = _ref.data;
|
|
349
354
|
console.warn("[SliceZone] Could not find a component for Slice type \"".concat(props.slice.slice_type, "\""), props.slice);
|
|
350
|
-
return
|
|
351
|
-
|
|
355
|
+
return h("section", _objectSpread2(_objectSpread2({}, data), {}, {
|
|
356
|
+
attrs: _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
352
357
|
"data-slice-zone-todo-component": "",
|
|
353
358
|
"data-slice-type": props.slice.slice_type
|
|
354
|
-
})
|
|
355
|
-
};
|
|
359
|
+
})
|
|
360
|
+
}), ["Could not find a component for Slice type \"".concat(props.slice.slice_type, "\"")]);
|
|
356
361
|
}
|
|
357
362
|
}; // Just mimiced to prevent confusion but doesn't provide any value with version 2 of this kit
|
|
358
363
|
|
|
@@ -361,7 +366,6 @@ var defineSliceZoneComponents = function defineSliceZoneComponents(components) {
|
|
|
361
366
|
};
|
|
362
367
|
var SliceZone = {
|
|
363
368
|
name: "SliceZone",
|
|
364
|
-
functional: true,
|
|
365
369
|
props: {
|
|
366
370
|
slices: {
|
|
367
371
|
type: Array,
|
|
@@ -393,23 +397,19 @@ var SliceZone = {
|
|
|
393
397
|
required: false
|
|
394
398
|
}
|
|
395
399
|
},
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
400
|
+
computed: {
|
|
401
|
+
renderedSlices: function renderedSlices() {
|
|
402
|
+
var _this = this;
|
|
399
403
|
|
|
400
|
-
|
|
401
|
-
if (!props.slices) {
|
|
402
|
-
return function () {
|
|
404
|
+
if (!this.slices) {
|
|
403
405
|
return null;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
+
}
|
|
406
407
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
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`.
|
|
408
|
+
return this.slices.map(function (slice, index) {
|
|
409
|
+
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`.
|
|
410
410
|
|
|
411
|
-
if (
|
|
412
|
-
var resolvedComponent =
|
|
411
|
+
if (_this.resolver) {
|
|
412
|
+
var resolvedComponent = _this.resolver({
|
|
413
413
|
slice: slice,
|
|
414
414
|
sliceName: slice.slice_type,
|
|
415
415
|
i: index
|
|
@@ -422,25 +422,31 @@ var SliceZone = {
|
|
|
422
422
|
|
|
423
423
|
var p = {
|
|
424
424
|
key: "".concat(slice.slice_type, "-").concat(index),
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
425
|
+
props: {
|
|
426
|
+
slice: slice,
|
|
427
|
+
index: index,
|
|
428
|
+
context: _this.context,
|
|
429
|
+
slices: _this.slices
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
return {
|
|
433
|
+
component: component,
|
|
434
|
+
p: p
|
|
429
435
|
};
|
|
430
|
-
return h(component, p);
|
|
431
|
-
});
|
|
432
|
-
});
|
|
433
|
-
var parent = props.wrapper;
|
|
434
|
-
|
|
435
|
-
if (typeof parent === "string") {
|
|
436
|
-
return h(parent, data, renderedSlices.value);
|
|
437
|
-
} else {
|
|
438
|
-
return h(parent, data, {
|
|
439
|
-
"default": function _default() {
|
|
440
|
-
return renderedSlices.value;
|
|
441
|
-
}
|
|
442
436
|
});
|
|
443
437
|
}
|
|
438
|
+
},
|
|
439
|
+
render: function render(h) {
|
|
440
|
+
// Prevent fatal if user didn't check for field, throws `Invalid prop` warn
|
|
441
|
+
if (!this.slices) {
|
|
442
|
+
return null;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
return h(this.wrapper, this.renderedSlices.map(function (_ref2) {
|
|
446
|
+
var component = _ref2.component,
|
|
447
|
+
p = _ref2.p;
|
|
448
|
+
return h(component, p);
|
|
449
|
+
}));
|
|
444
450
|
}
|
|
445
451
|
};
|
|
446
452
|
|
package/components/index.js
CHANGED
|
@@ -111,10 +111,15 @@ var Image = {
|
|
|
111
111
|
render: function render(h, _ref) {
|
|
112
112
|
var props = _ref.props,
|
|
113
113
|
data = _ref.data;
|
|
114
|
-
var
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
var field = props.field;
|
|
115
|
+
|
|
116
|
+
if (!field) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
var url = field.url,
|
|
121
|
+
alt = field.alt,
|
|
122
|
+
copyright = field.copyright;
|
|
118
123
|
return h('img', Object.assign(data, {
|
|
119
124
|
attrs: _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
120
125
|
src: url,
|
|
@@ -197,10 +202,12 @@ var Link = (function (_ref) {
|
|
|
197
202
|
|
|
198
203
|
if (typeof props.target !== "undefined" || field.target) {
|
|
199
204
|
data.attrs.target = typeof props.target !== "undefined" ? props.target : field.target;
|
|
205
|
+
}
|
|
200
206
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
207
|
+
if (data.attrs.target === "_blank") {
|
|
208
|
+
data.attrs.rel = typeof props.rel !== "undefined" ? props.rel : props.blankTargetRelAttribute;
|
|
209
|
+
} else if (typeof props.rel !== "undefined") {
|
|
210
|
+
data.attrs.rel = props.rel;
|
|
204
211
|
}
|
|
205
212
|
|
|
206
213
|
return h("a", data, children);
|
|
@@ -243,7 +250,7 @@ var RichText = {
|
|
|
243
250
|
return null;
|
|
244
251
|
}
|
|
245
252
|
|
|
246
|
-
var innerHTML = RichText$1.asHtml(field, linkResolver
|
|
253
|
+
var innerHTML = RichText$1.asHtml(field, linkResolver ? linkResolver : parent.$prismic ? parent.$prismic.linkResolver : undefined, htmlSerializer ? htmlSerializer : parent.$prismic ? parent.$prismic.htmlSerializer : undefined);
|
|
247
254
|
return h(wrapper, _objectSpread2(_objectSpread2({}, data), {}, {
|
|
248
255
|
domProps: {
|
|
249
256
|
innerHTML: innerHTML
|
|
@@ -329,22 +336,20 @@ var getSliceComponentProps = function getSliceComponentProps(propsHint) {
|
|
|
329
336
|
}
|
|
330
337
|
};
|
|
331
338
|
};
|
|
332
|
-
var TODOSliceComponent = __PRODUCTION__ ?
|
|
333
|
-
return null;
|
|
334
|
-
} : {
|
|
339
|
+
var TODOSliceComponent = __PRODUCTION__ ? null : {
|
|
335
340
|
name: "TODOSliceCOmponent",
|
|
336
341
|
functional: true,
|
|
337
342
|
props: getSliceComponentProps(),
|
|
338
|
-
|
|
343
|
+
render: function render(h, _ref) {
|
|
339
344
|
var props = _ref.props,
|
|
340
345
|
data = _ref.data;
|
|
341
346
|
console.warn("[SliceZone] Could not find a component for Slice type \"".concat(props.slice.slice_type, "\""), props.slice);
|
|
342
|
-
return
|
|
343
|
-
|
|
347
|
+
return h("section", _objectSpread2(_objectSpread2({}, data), {}, {
|
|
348
|
+
attrs: _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
344
349
|
"data-slice-zone-todo-component": "",
|
|
345
350
|
"data-slice-type": props.slice.slice_type
|
|
346
|
-
})
|
|
347
|
-
};
|
|
351
|
+
})
|
|
352
|
+
}), ["Could not find a component for Slice type \"".concat(props.slice.slice_type, "\"")]);
|
|
348
353
|
}
|
|
349
354
|
}; // Just mimiced to prevent confusion but doesn't provide any value with version 2 of this kit
|
|
350
355
|
|
|
@@ -353,7 +358,6 @@ var defineSliceZoneComponents = function defineSliceZoneComponents(components) {
|
|
|
353
358
|
};
|
|
354
359
|
var SliceZone = {
|
|
355
360
|
name: "SliceZone",
|
|
356
|
-
functional: true,
|
|
357
361
|
props: {
|
|
358
362
|
slices: {
|
|
359
363
|
type: Array,
|
|
@@ -385,23 +389,19 @@ var SliceZone = {
|
|
|
385
389
|
required: false
|
|
386
390
|
}
|
|
387
391
|
},
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
392
|
+
computed: {
|
|
393
|
+
renderedSlices: function renderedSlices() {
|
|
394
|
+
var _this = this;
|
|
391
395
|
|
|
392
|
-
|
|
393
|
-
if (!props.slices) {
|
|
394
|
-
return function () {
|
|
396
|
+
if (!this.slices) {
|
|
395
397
|
return null;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
+
}
|
|
398
399
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
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`.
|
|
400
|
+
return this.slices.map(function (slice, index) {
|
|
401
|
+
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`.
|
|
402
402
|
|
|
403
|
-
if (
|
|
404
|
-
var resolvedComponent =
|
|
403
|
+
if (_this.resolver) {
|
|
404
|
+
var resolvedComponent = _this.resolver({
|
|
405
405
|
slice: slice,
|
|
406
406
|
sliceName: slice.slice_type,
|
|
407
407
|
i: index
|
|
@@ -414,25 +414,31 @@ var SliceZone = {
|
|
|
414
414
|
|
|
415
415
|
var p = {
|
|
416
416
|
key: "".concat(slice.slice_type, "-").concat(index),
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
417
|
+
props: {
|
|
418
|
+
slice: slice,
|
|
419
|
+
index: index,
|
|
420
|
+
context: _this.context,
|
|
421
|
+
slices: _this.slices
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
return {
|
|
425
|
+
component: component,
|
|
426
|
+
p: p
|
|
421
427
|
};
|
|
422
|
-
return h(component, p);
|
|
423
|
-
});
|
|
424
|
-
});
|
|
425
|
-
var parent = props.wrapper;
|
|
426
|
-
|
|
427
|
-
if (typeof parent === "string") {
|
|
428
|
-
return h(parent, data, renderedSlices.value);
|
|
429
|
-
} else {
|
|
430
|
-
return h(parent, data, {
|
|
431
|
-
"default": function _default() {
|
|
432
|
-
return renderedSlices.value;
|
|
433
|
-
}
|
|
434
428
|
});
|
|
435
429
|
}
|
|
430
|
+
},
|
|
431
|
+
render: function render(h) {
|
|
432
|
+
// Prevent fatal if user didn't check for field, throws `Invalid prop` warn
|
|
433
|
+
if (!this.slices) {
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
return h(this.wrapper, this.renderedSlices.map(function (_ref2) {
|
|
438
|
+
var component = _ref2.component,
|
|
439
|
+
p = _ref2.p;
|
|
440
|
+
return h(component, p);
|
|
441
|
+
}));
|
|
436
442
|
}
|
|
437
443
|
};
|
|
438
444
|
|
package/components/umd.js
CHANGED
|
@@ -119,10 +119,15 @@
|
|
|
119
119
|
render: function render(h, _ref) {
|
|
120
120
|
var props = _ref.props,
|
|
121
121
|
data = _ref.data;
|
|
122
|
-
var
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
var field = props.field;
|
|
123
|
+
|
|
124
|
+
if (!field) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
var url = field.url,
|
|
129
|
+
alt = field.alt,
|
|
130
|
+
copyright = field.copyright;
|
|
126
131
|
return h('img', Object.assign(data, {
|
|
127
132
|
attrs: _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
128
133
|
src: url,
|
|
@@ -205,10 +210,12 @@
|
|
|
205
210
|
|
|
206
211
|
if (typeof props.target !== "undefined" || field.target) {
|
|
207
212
|
data.attrs.target = typeof props.target !== "undefined" ? props.target : field.target;
|
|
213
|
+
}
|
|
208
214
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
215
|
+
if (data.attrs.target === "_blank") {
|
|
216
|
+
data.attrs.rel = typeof props.rel !== "undefined" ? props.rel : props.blankTargetRelAttribute;
|
|
217
|
+
} else if (typeof props.rel !== "undefined") {
|
|
218
|
+
data.attrs.rel = props.rel;
|
|
212
219
|
}
|
|
213
220
|
|
|
214
221
|
return h("a", data, children);
|
|
@@ -251,7 +258,7 @@
|
|
|
251
258
|
return null;
|
|
252
259
|
}
|
|
253
260
|
|
|
254
|
-
var innerHTML = PrismicDom.RichText.asHtml(field, linkResolver
|
|
261
|
+
var innerHTML = PrismicDom.RichText.asHtml(field, linkResolver ? linkResolver : parent.$prismic ? parent.$prismic.linkResolver : undefined, htmlSerializer ? htmlSerializer : parent.$prismic ? parent.$prismic.htmlSerializer : undefined);
|
|
255
262
|
return h(wrapper, _objectSpread2(_objectSpread2({}, data), {}, {
|
|
256
263
|
domProps: {
|
|
257
264
|
innerHTML: innerHTML
|
|
@@ -337,22 +344,20 @@
|
|
|
337
344
|
}
|
|
338
345
|
};
|
|
339
346
|
};
|
|
340
|
-
var TODOSliceComponent = __PRODUCTION__ ?
|
|
341
|
-
return null;
|
|
342
|
-
} : {
|
|
347
|
+
var TODOSliceComponent = __PRODUCTION__ ? null : {
|
|
343
348
|
name: "TODOSliceCOmponent",
|
|
344
349
|
functional: true,
|
|
345
350
|
props: getSliceComponentProps(),
|
|
346
|
-
|
|
351
|
+
render: function render(h, _ref) {
|
|
347
352
|
var props = _ref.props,
|
|
348
353
|
data = _ref.data;
|
|
349
354
|
console.warn("[SliceZone] Could not find a component for Slice type \"".concat(props.slice.slice_type, "\""), props.slice);
|
|
350
|
-
return
|
|
351
|
-
|
|
355
|
+
return h("section", _objectSpread2(_objectSpread2({}, data), {}, {
|
|
356
|
+
attrs: _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
352
357
|
"data-slice-zone-todo-component": "",
|
|
353
358
|
"data-slice-type": props.slice.slice_type
|
|
354
|
-
})
|
|
355
|
-
};
|
|
359
|
+
})
|
|
360
|
+
}), ["Could not find a component for Slice type \"".concat(props.slice.slice_type, "\"")]);
|
|
356
361
|
}
|
|
357
362
|
}; // Just mimiced to prevent confusion but doesn't provide any value with version 2 of this kit
|
|
358
363
|
|
|
@@ -361,7 +366,6 @@
|
|
|
361
366
|
};
|
|
362
367
|
var SliceZone = {
|
|
363
368
|
name: "SliceZone",
|
|
364
|
-
functional: true,
|
|
365
369
|
props: {
|
|
366
370
|
slices: {
|
|
367
371
|
type: Array,
|
|
@@ -393,23 +397,19 @@
|
|
|
393
397
|
required: false
|
|
394
398
|
}
|
|
395
399
|
},
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
400
|
+
computed: {
|
|
401
|
+
renderedSlices: function renderedSlices() {
|
|
402
|
+
var _this = this;
|
|
399
403
|
|
|
400
|
-
|
|
401
|
-
if (!props.slices) {
|
|
402
|
-
return function () {
|
|
404
|
+
if (!this.slices) {
|
|
403
405
|
return null;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
+
}
|
|
406
407
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
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`.
|
|
408
|
+
return this.slices.map(function (slice, index) {
|
|
409
|
+
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`.
|
|
410
410
|
|
|
411
|
-
if (
|
|
412
|
-
var resolvedComponent =
|
|
411
|
+
if (_this.resolver) {
|
|
412
|
+
var resolvedComponent = _this.resolver({
|
|
413
413
|
slice: slice,
|
|
414
414
|
sliceName: slice.slice_type,
|
|
415
415
|
i: index
|
|
@@ -422,25 +422,31 @@
|
|
|
422
422
|
|
|
423
423
|
var p = {
|
|
424
424
|
key: "".concat(slice.slice_type, "-").concat(index),
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
425
|
+
props: {
|
|
426
|
+
slice: slice,
|
|
427
|
+
index: index,
|
|
428
|
+
context: _this.context,
|
|
429
|
+
slices: _this.slices
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
return {
|
|
433
|
+
component: component,
|
|
434
|
+
p: p
|
|
429
435
|
};
|
|
430
|
-
return h(component, p);
|
|
431
|
-
});
|
|
432
|
-
});
|
|
433
|
-
var parent = props.wrapper;
|
|
434
|
-
|
|
435
|
-
if (typeof parent === "string") {
|
|
436
|
-
return h(parent, data, renderedSlices.value);
|
|
437
|
-
} else {
|
|
438
|
-
return h(parent, data, {
|
|
439
|
-
"default": function _default() {
|
|
440
|
-
return renderedSlices.value;
|
|
441
|
-
}
|
|
442
436
|
});
|
|
443
437
|
}
|
|
438
|
+
},
|
|
439
|
+
render: function render(h) {
|
|
440
|
+
// Prevent fatal if user didn't check for field, throws `Invalid prop` warn
|
|
441
|
+
if (!this.slices) {
|
|
442
|
+
return null;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
return h(this.wrapper, this.renderedSlices.map(function (_ref2) {
|
|
446
|
+
var component = _ref2.component,
|
|
447
|
+
p = _ref2.p;
|
|
448
|
+
return h(component, p);
|
|
449
|
+
}));
|
|
444
450
|
}
|
|
445
451
|
};
|
|
446
452
|
|
|
@@ -178,10 +178,15 @@ var Image = {
|
|
|
178
178
|
render: function render(h, _ref) {
|
|
179
179
|
var props = _ref.props,
|
|
180
180
|
data = _ref.data;
|
|
181
|
-
var
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
181
|
+
var field = props.field;
|
|
182
|
+
|
|
183
|
+
if (!field) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
var url = field.url,
|
|
188
|
+
alt = field.alt,
|
|
189
|
+
copyright = field.copyright;
|
|
185
190
|
return h('img', Object.assign(data, {
|
|
186
191
|
attrs: _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
187
192
|
src: url,
|
|
@@ -264,10 +269,12 @@ var Link = (function (_ref) {
|
|
|
264
269
|
|
|
265
270
|
if (typeof props.target !== "undefined" || field.target) {
|
|
266
271
|
data.attrs.target = typeof props.target !== "undefined" ? props.target : field.target;
|
|
272
|
+
}
|
|
267
273
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
274
|
+
if (data.attrs.target === "_blank") {
|
|
275
|
+
data.attrs.rel = typeof props.rel !== "undefined" ? props.rel : props.blankTargetRelAttribute;
|
|
276
|
+
} else if (typeof props.rel !== "undefined") {
|
|
277
|
+
data.attrs.rel = props.rel;
|
|
271
278
|
}
|
|
272
279
|
|
|
273
280
|
return h("a", data, children);
|
|
@@ -310,7 +317,7 @@ var RichText = {
|
|
|
310
317
|
return null;
|
|
311
318
|
}
|
|
312
319
|
|
|
313
|
-
var innerHTML = PrismicDOM.RichText.asHtml(field, linkResolver
|
|
320
|
+
var innerHTML = PrismicDOM.RichText.asHtml(field, linkResolver ? linkResolver : parent.$prismic ? parent.$prismic.linkResolver : undefined, htmlSerializer ? htmlSerializer : parent.$prismic ? parent.$prismic.htmlSerializer : undefined);
|
|
314
321
|
return h(wrapper, _objectSpread2(_objectSpread2({}, data), {}, {
|
|
315
322
|
domProps: {
|
|
316
323
|
innerHTML: innerHTML
|
|
@@ -396,27 +403,24 @@ var getSliceComponentProps = function getSliceComponentProps(propsHint) {
|
|
|
396
403
|
}
|
|
397
404
|
};
|
|
398
405
|
};
|
|
399
|
-
var TODOSliceComponent = __PRODUCTION__ ?
|
|
400
|
-
return null;
|
|
401
|
-
} : {
|
|
406
|
+
var TODOSliceComponent = __PRODUCTION__ ? null : {
|
|
402
407
|
name: "TODOSliceCOmponent",
|
|
403
408
|
functional: true,
|
|
404
409
|
props: getSliceComponentProps(),
|
|
405
|
-
|
|
410
|
+
render: function render(h, _ref) {
|
|
406
411
|
var props = _ref.props,
|
|
407
412
|
data = _ref.data;
|
|
408
413
|
console.warn("[SliceZone] Could not find a component for Slice type \"".concat(props.slice.slice_type, "\""), props.slice);
|
|
409
|
-
return
|
|
410
|
-
|
|
414
|
+
return h("section", _objectSpread2(_objectSpread2({}, data), {}, {
|
|
415
|
+
attrs: _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
411
416
|
"data-slice-zone-todo-component": "",
|
|
412
417
|
"data-slice-type": props.slice.slice_type
|
|
413
|
-
})
|
|
414
|
-
};
|
|
418
|
+
})
|
|
419
|
+
}), ["Could not find a component for Slice type \"".concat(props.slice.slice_type, "\"")]);
|
|
415
420
|
}
|
|
416
421
|
}; // Just mimiced to prevent confusion but doesn't provide any value with version 2 of this kit
|
|
417
422
|
var SliceZone = {
|
|
418
423
|
name: "SliceZone",
|
|
419
|
-
functional: true,
|
|
420
424
|
props: {
|
|
421
425
|
slices: {
|
|
422
426
|
type: Array,
|
|
@@ -448,23 +452,19 @@ var SliceZone = {
|
|
|
448
452
|
required: false
|
|
449
453
|
}
|
|
450
454
|
},
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
455
|
+
computed: {
|
|
456
|
+
renderedSlices: function renderedSlices() {
|
|
457
|
+
var _this = this;
|
|
454
458
|
|
|
455
|
-
|
|
456
|
-
if (!props.slices) {
|
|
457
|
-
return function () {
|
|
459
|
+
if (!this.slices) {
|
|
458
460
|
return null;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
+
}
|
|
461
462
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
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`.
|
|
463
|
+
return this.slices.map(function (slice, index) {
|
|
464
|
+
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`.
|
|
465
465
|
|
|
466
|
-
if (
|
|
467
|
-
var resolvedComponent =
|
|
466
|
+
if (_this.resolver) {
|
|
467
|
+
var resolvedComponent = _this.resolver({
|
|
468
468
|
slice: slice,
|
|
469
469
|
sliceName: slice.slice_type,
|
|
470
470
|
i: index
|
|
@@ -477,25 +477,31 @@ var SliceZone = {
|
|
|
477
477
|
|
|
478
478
|
var p = {
|
|
479
479
|
key: "".concat(slice.slice_type, "-").concat(index),
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
480
|
+
props: {
|
|
481
|
+
slice: slice,
|
|
482
|
+
index: index,
|
|
483
|
+
context: _this.context,
|
|
484
|
+
slices: _this.slices
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
return {
|
|
488
|
+
component: component,
|
|
489
|
+
p: p
|
|
484
490
|
};
|
|
485
|
-
return h(component, p);
|
|
486
|
-
});
|
|
487
|
-
});
|
|
488
|
-
var parent = props.wrapper;
|
|
489
|
-
|
|
490
|
-
if (typeof parent === "string") {
|
|
491
|
-
return h(parent, data, renderedSlices.value);
|
|
492
|
-
} else {
|
|
493
|
-
return h(parent, data, {
|
|
494
|
-
"default": function _default() {
|
|
495
|
-
return renderedSlices.value;
|
|
496
|
-
}
|
|
497
491
|
});
|
|
498
492
|
}
|
|
493
|
+
},
|
|
494
|
+
render: function render(h) {
|
|
495
|
+
// Prevent fatal if user didn't check for field, throws `Invalid prop` warn
|
|
496
|
+
if (!this.slices) {
|
|
497
|
+
return null;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
return h(this.wrapper, this.renderedSlices.map(function (_ref2) {
|
|
501
|
+
var component = _ref2.component,
|
|
502
|
+
p = _ref2.p;
|
|
503
|
+
return h(component, p);
|
|
504
|
+
}));
|
|
499
505
|
}
|
|
500
506
|
};
|
|
501
507
|
|
|
@@ -531,7 +537,7 @@ function asText(richText, joinString) {
|
|
|
531
537
|
return PrismicDOM__default["default"].RichText.asText(richText, joinString);
|
|
532
538
|
}
|
|
533
539
|
|
|
534
|
-
return
|
|
540
|
+
return "";
|
|
535
541
|
}
|
|
536
542
|
function asLink(link, linkResolver) {
|
|
537
543
|
if (link) {
|
|
@@ -544,6 +550,8 @@ function asDate(date) {
|
|
|
544
550
|
}
|
|
545
551
|
}
|
|
546
552
|
|
|
553
|
+
var client = prismicJS__default["default"].client;
|
|
554
|
+
|
|
547
555
|
function attachMethods(Vue, options) {
|
|
548
556
|
Vue.prototype.$prismic.asHtml = function (richText, linkResolver, htmlSerializer) {
|
|
549
557
|
return asHtml(richText, linkResolver || options.linkResolver, htmlSerializer || options.htmlSerializer);
|
|
@@ -567,7 +575,7 @@ var PrismicVue = {
|
|
|
567
575
|
Vue.prototype.$prismic.endpoint = options.endpoint;
|
|
568
576
|
Vue.prototype.$prismic.linkResolver = options.linkResolver;
|
|
569
577
|
Vue.prototype.$prismic.htmlSerializer = options.htmlSerializer;
|
|
570
|
-
Vue.prototype.$prismic.client =
|
|
578
|
+
Vue.prototype.$prismic.client = client(options.endpoint, options.apiOptions);
|
|
571
579
|
attachMethods(Vue, options);
|
|
572
580
|
|
|
573
581
|
var components = _objectSpread2(_objectSpread2({}, exp.common), exp[linkType]);
|