├── .gitignore
├── .npmignore
├── .babelrc
├── src
├── plugin.js
├── BlockContent.vue
└── types
│ ├── Block.vue
│ └── RenderType.vue
├── package.json
├── webpack.config.js
├── README.md
└── dist
├── block-content-to-vue.min.js
└── block-content-to-vue.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .idea
3 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .idea
3 | src
4 | webpack.config.js
5 | package-lock.json
6 |
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015", "stage-2"],
3 | "plugins": ["transform-runtime"],
4 | "comments": false
5 | }
6 |
--------------------------------------------------------------------------------
/src/plugin.js:
--------------------------------------------------------------------------------
1 | import BlockContent from './BlockContent.vue';
2 |
3 | module.exports = {
4 | install: function (Vue, options) {
5 | Vue.component('block-content', BlockContent);
6 | }
7 | };
8 |
--------------------------------------------------------------------------------
/src/BlockContent.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
38 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "block-content-to-vue",
3 | "version": "0.1.0",
4 | "description": "Dynamically render Vue.js components from Sanity",
5 | "main": "dist/block-content-to-vue.js",
6 | "scripts": {
7 | "build": "rimraf ./dist && webpack --config ./webpack.config.js"
8 | },
9 | "author": "Leif Riksheim",
10 | "license": "MIT",
11 | "repository": {
12 | "type": "git",
13 | "url": "git+https://github.com/leifriksheim/block-content-to-vue"
14 | },
15 | "devDependencies": {
16 | "babel-core": "^6.10.4",
17 | "babel-loader": "^6.2.4",
18 | "babel-plugin-transform-runtime": "^6.9.0",
19 | "babel-preset-es2015": "^6.9.0",
20 | "babel-preset-stage-2": "^6.11.0",
21 | "babel-runtime": "^6.9.2",
22 | "rimraf": "^2.6.1",
23 | "vue": "^2.2.1",
24 | "vue-html-loader": "^1.2.3",
25 | "vue-loader": "^11.1.4",
26 | "vue-style-loader": "^2.0.3",
27 | "vue-template-compiler": "^2.2.1",
28 | "webpack": "1.13.1",
29 | "webpack-merge": "^4.1.0"
30 | },
31 | "dependencies": {
32 | "@sanity/block-content-to-html": "^1.3.5",
33 | "@sanity/block-content-to-hyperscript": "^1.2.8"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/types/Block.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
13 |
14 |
15 |
48 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | const webpack = require('webpack');
2 | const merge = require('webpack-merge');
3 | const path = require('path');
4 |
5 | var config = {
6 | output: {
7 | path: path.resolve(__dirname + '/dist/'),
8 | },
9 | module: {
10 | loaders: [
11 | {
12 | test: /\.js$/,
13 | loader: 'babel',
14 | include: __dirname,
15 | exclude: /node_modules/
16 | },
17 | {
18 | test: /\.vue$/,
19 | loader: 'vue'
20 | },
21 | {
22 | test: /\.css$/,
23 | loader: 'style!less!css'
24 | }
25 | ]
26 | },
27 | externals: {
28 | moment: 'moment'
29 | },
30 | plugins: [
31 | new webpack.optimize.UglifyJsPlugin( {
32 | minimize : true,
33 | sourceMap : false,
34 | mangle: true,
35 | compress: {
36 | warnings: false
37 | }
38 | } )
39 | ]
40 | };
41 |
42 |
43 | module.exports = [
44 | merge(config, {
45 | entry: path.resolve(__dirname + '/src/plugin.js'),
46 | output: {
47 | filename: 'block-content-to-vue.min.js',
48 | libraryTarget: 'window',
49 | library: 'BlockContent',
50 | }
51 | }),
52 | merge(config, {
53 | entry: path.resolve(__dirname + '/src/BlockContent.vue'),
54 | output: {
55 | filename: 'block-content-to-vue.js',
56 | libraryTarget: 'umd',
57 | library: 'block-content-to-vue',
58 | umdNamedDefine: true
59 | }
60 | })
61 | ];
62 |
--------------------------------------------------------------------------------
/src/types/RenderType.vue:
--------------------------------------------------------------------------------
1 |
58 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | **Depricated:** Use [sanity-block-vue-component](https://github.com/rdunk/sanity-blocks-vue-component) instead.
3 |
4 |
5 | # block-content-to-vue
6 |
7 | Dynamically render Vue.js components from [Sanity](https://www.sanity.io/).
8 |
9 | ## Installation
10 |
11 | ```js
12 | npm i --save block-content-to-vue
13 | ```
14 |
15 | ### Import as module
16 |
17 | ```js
18 | import BlockContent from 'block-content-to-vue';
19 | ```
20 |
21 | ### Use via cdn
22 |
23 | Include the script file, then install the component with `Vue.use(BlockContent);` e.g.:
24 |
25 | ```html
26 |
27 |
28 |
31 | ```
32 |
33 | ## Usage
34 |
35 | The component requires the props `blocks` and `serializer`.
36 |
37 | ```html
38 |
39 | ```
40 |
41 | `blocks` must be an array of content blocks from a Sanity query response e.g.:
42 |
43 | ```js
44 | [
45 | {
46 | _id: 12345, // required
47 | _type: 'heading-block',
48 | heading: 'The heading!',
49 | subtitle: 'The subtitle'
50 | },
51 | {
52 | _id: 12346, // required
53 | _type: 'two-column-block',
54 | leftColumn: 'Left column content',
55 | rightColumn: 'Right column content'
56 | }
57 | ]
58 | ```
59 |
60 | `serializer` is an object describing the components you want to render based on the Sanity block's `_type` value.
61 | For now the serializer supports all custom types you define yourself in the schema, and the types `span`, `em`, `underline` and `strike-through`.
62 | The regular types like `span` receive the prop `fields` with all it's properties inside.
63 |
64 | ```js
65 | import Heading from '@/components/Heading.vue';
66 | import TwoColumn from '@/components/TwoColumn.vue';
67 | import Span from '@/components/Span.vue';
68 | import Underline from '@/components/Underline.vue';
69 |
70 | const serializer = {
71 | types: {
72 | 'heading-block': Heading,
73 | 'two-column-block': TwoColumn,
74 | 'span': Span,
75 | 'underline': Underline,
76 | }
77 | }
78 | ```
79 |
80 |
81 | The block-content-to-vue component will automatically make the properties of each block available as props in your component.
82 |
83 | Let's have a look at the `Heading` component.
84 |
85 | ```html
86 |
87 |
88 |
{{heading}}
89 |
{{subtitle}}
90 |
91 |
92 |
93 |
102 | ```
103 |
104 | We can now define the props our component will receive, and we can type-check each of them.
105 | We can also use internal state and all the other good stuff from a regular Vue.js component.
106 |
107 | ## Implementation example
108 |
109 | ```html
110 |
111 |
112 |
113 |
114 |
115 |
116 |
157 | ```
158 |
--------------------------------------------------------------------------------
/dist/block-content-to-vue.min.js:
--------------------------------------------------------------------------------
1 | window.BlockContent=function(t){function n(e){if(r[e])return r[e].exports;var o=r[e]={exports:{},id:e,loaded:!1};return t[e].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var r={};return n.m=t,n.c=r,n.p="",n(0)}([function(t,n,r){"use strict";function e(t){return t&&t.__esModule?t:{"default":t}}var o=r(1),u=e(o);t.exports={install:function(t,n){t.component("block-content",u["default"])}}},function(t,n,r){var e=r(2)(r(3),r(67),null,null);t.exports=e.exports},function(t,n){t.exports=function(t,n,r,e){var o,u=t=t||{},i=typeof t["default"];"object"!==i&&"function"!==i||(o=t,u=t["default"]);var c="function"==typeof u?u.options:u;if(n&&(c.render=n.render,c.staticRenderFns=n.staticRenderFns),r&&(c._scopeId=r),e){var f=Object.create(c.computed||null);Object.keys(e).forEach(function(t){var n=e[t];f[t]=function(){return n}}),c.computed=f}return{esModule:o,exports:u,options:c}}},function(t,n,r){"use strict";function e(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(n,"__esModule",{value:!0});var o=r(4),u=e(o),i=r(58),c=e(i);n["default"]={name:"block-content",props:{blocks:Array,serializers:Object},components:{Block:c["default"]},computed:{reducedBlocks:function(){var t=this.blocks.reduce(function(t,n){var r=n.style;return delete n.style,n.styling=r,[].concat((0,u["default"])(t),[n])},[]);return t}}}},function(t,n,r){"use strict";function e(t){return t&&t.__esModule?t:{"default":t}}n.__esModule=!0;var o=r(5),u=e(o);n["default"]=function(t){if(Array.isArray(t)){for(var n=0,r=Array(t.length);n=n.length?{value:void 0,done:!0}:(t=e(n,r),this._i+=t.length,{value:t,done:!1})})},function(t,n,r){var e=r(9),o=r(10);t.exports=function(t){return function(n,r){var u,i,c=String(o(n)),f=e(r),s=c.length;return f<0||f>=s?t?"":void 0:(u=c.charCodeAt(f),u<55296||u>56319||f+1===s||(i=c.charCodeAt(f+1))<56320||i>57343?t?c.charAt(f):u:t?c.slice(f,f+2):(u-55296<<10)+(i-56320)+65536)}}},function(t,n){var r=Math.ceil,e=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?e:r)(t)}},function(t,n){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,n,r){"use strict";var e=r(12),o=r(13),u=r(28),i=r(18),c=r(29),f=r(30),s=r(31),a=r(47),l=r(49),p=r(48)("iterator"),d=!([].keys&&"next"in[].keys()),v="@@iterator",y="keys",h="values",x=function(){return this};t.exports=function(t,n,r,m,_,b,g){s(r,n,m);var k,O,j,w=function(t){if(!d&&t in T)return T[t];switch(t){case y:return function(){return new r(this,t)};case h:return function(){return new r(this,t)}}return function(){return new r(this,t)}},M=n+" Iterator",S=_==h,A=!1,T=t.prototype,P=T[p]||T[v]||_&&T[_],E=!d&&P||w(_),C=_?S?w("entries"):E:void 0,F="Array"==n?T.entries||P:P;if(F&&(j=l(F.call(new t)),j!==Object.prototype&&j.next&&(a(j,M,!0),e||c(j,p)||i(j,p,x))),S&&P&&P.name!==h&&(A=!0,E=function(){return P.call(this)}),e&&!g||!d&&!A&&T[p]||i(T,p,E),f[n]=E,f[M]=x,_)if(k={values:S?E:w(h),keys:b?E:w(y),entries:C},g)for(O in k)O in T||u(T,O,k[O]);else o(o.P+o.F*(d||A),n,k);return k}},function(t,n){t.exports=!0},function(t,n,r){var e=r(14),o=r(15),u=r(16),i=r(18),c="prototype",f=function(t,n,r){var s,a,l,p=t&f.F,d=t&f.G,v=t&f.S,y=t&f.P,h=t&f.B,x=t&f.W,m=d?o:o[n]||(o[n]={}),_=m[c],b=d?e:v?e[n]:(e[n]||{})[c];d&&(r=n);for(s in r)a=!p&&b&&void 0!==b[s],a&&s in m||(l=a?b[s]:r[s],m[s]=d&&"function"!=typeof b[s]?r[s]:h&&a?u(l,e):x&&b[s]==l?function(t){var n=function(n,r,e){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(n);case 2:return new t(n,r)}return new t(n,r,e)}return t.apply(this,arguments)};return n[c]=t[c],n}(l):y&&"function"==typeof l?u(Function.call,l):l,y&&((m.virtual||(m.virtual={}))[s]=l,t&f.R&&_&&!_[s]&&i(_,s,l)))};f.F=1,f.G=2,f.S=4,f.P=8,f.B=16,f.W=32,f.U=64,f.R=128,t.exports=f},function(t,n){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,n){var r=t.exports={version:"2.5.3"};"number"==typeof __e&&(__e=r)},function(t,n,r){var e=r(17);t.exports=function(t,n,r){if(e(t),void 0===n)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 2:return function(r,e){return t.call(n,r,e)};case 3:return function(r,e,o){return t.call(n,r,e,o)}}return function(){return t.apply(n,arguments)}}},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n,r){var e=r(19),o=r(27);t.exports=r(23)?function(t,n,r){return e.f(t,n,o(1,r))}:function(t,n,r){return t[n]=r,t}},function(t,n,r){var e=r(20),o=r(22),u=r(26),i=Object.defineProperty;n.f=r(23)?Object.defineProperty:function(t,n,r){if(e(t),n=u(n,!0),e(r),o)try{return i(t,n,r)}catch(c){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[n]=r.value),t}},function(t,n,r){var e=r(21);t.exports=function(t){if(!e(t))throw TypeError(t+" is not an object!");return t}},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n,r){t.exports=!r(23)&&!r(24)(function(){return 7!=Object.defineProperty(r(25)("div"),"a",{get:function(){return 7}}).a})},function(t,n,r){t.exports=!r(24)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,n){t.exports=function(t){try{return!!t()}catch(n){return!0}}},function(t,n,r){var e=r(21),o=r(14).document,u=e(o)&&e(o.createElement);t.exports=function(t){return u?o.createElement(t):{}}},function(t,n,r){var e=r(21);t.exports=function(t,n){if(!e(t))return t;var r,o;if(n&&"function"==typeof(r=t.toString)&&!e(o=r.call(t)))return o;if("function"==typeof(r=t.valueOf)&&!e(o=r.call(t)))return o;if(!n&&"function"==typeof(r=t.toString)&&!e(o=r.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n,r){t.exports=r(18)},function(t,n){var r={}.hasOwnProperty;t.exports=function(t,n){return r.call(t,n)}},function(t,n){t.exports={}},function(t,n,r){"use strict";var e=r(32),o=r(27),u=r(47),i={};r(18)(i,r(48)("iterator"),function(){return this}),t.exports=function(t,n,r){t.prototype=e(i,{next:o(1,r)}),u(t,n+" Iterator")}},function(t,n,r){var e=r(20),o=r(33),u=r(45),i=r(42)("IE_PROTO"),c=function(){},f="prototype",s=function(){var t,n=r(25)("iframe"),e=u.length,o="<",i=">";for(n.style.display="none",r(46).appendChild(n),n.src="javascript:",t=n.contentWindow.document,t.open(),t.write(o+"script"+i+"document.F=Object"+o+"/script"+i),t.close(),s=t.F;e--;)delete s[f][u[e]];return s()};t.exports=Object.create||function(t,n){var r;return null!==t?(c[f]=e(t),r=new c,c[f]=null,r[i]=t):r=s(),void 0===n?r:o(r,n)}},function(t,n,r){var e=r(19),o=r(20),u=r(34);t.exports=r(23)?Object.defineProperties:function(t,n){o(t);for(var r,i=u(n),c=i.length,f=0;c>f;)e.f(t,r=i[f++],n[r]);return t}},function(t,n,r){var e=r(35),o=r(45);t.exports=Object.keys||function(t){return e(t,o)}},function(t,n,r){var e=r(29),o=r(36),u=r(39)(!1),i=r(42)("IE_PROTO");t.exports=function(t,n){var r,c=o(t),f=0,s=[];for(r in c)r!=i&&e(c,r)&&s.push(r);for(;n.length>f;)e(c,r=n[f++])&&(~u(s,r)||s.push(r));return s}},function(t,n,r){var e=r(37),o=r(10);t.exports=function(t){return e(o(t))}},function(t,n,r){var e=r(38);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==e(t)?t.split(""):Object(t)}},function(t,n){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,n,r){var e=r(36),o=r(40),u=r(41);t.exports=function(t){return function(n,r,i){var c,f=e(n),s=o(f.length),a=u(i,s);if(t&&r!=r){for(;s>a;)if(c=f[a++],c!=c)return!0}else for(;s>a;a++)if((t||a in f)&&f[a]===r)return t||a||0;return!t&&-1}}},function(t,n,r){var e=r(9),o=Math.min;t.exports=function(t){return t>0?o(e(t),9007199254740991):0}},function(t,n,r){var e=r(9),o=Math.max,u=Math.min;t.exports=function(t,n){return t=e(t),t<0?o(t+n,0):u(t,n)}},function(t,n,r){var e=r(43)("keys"),o=r(44);t.exports=function(t){return e[t]||(e[t]=o(t))}},function(t,n,r){var e=r(14),o="__core-js_shared__",u=e[o]||(e[o]={});t.exports=function(t){return u[t]||(u[t]={})}},function(t,n){var r=0,e=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+e).toString(36))}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,n,r){var e=r(14).document;t.exports=e&&e.documentElement},function(t,n,r){var e=r(19).f,o=r(29),u=r(48)("toStringTag");t.exports=function(t,n,r){t&&!o(t=r?t:t.prototype,u)&&e(t,u,{configurable:!0,value:n})}},function(t,n,r){var e=r(43)("wks"),o=r(44),u=r(14).Symbol,i="function"==typeof u,c=t.exports=function(t){return e[t]||(e[t]=i&&u[t]||(i?u:o)("Symbol."+t))};c.store=e},function(t,n,r){var e=r(29),o=r(50),u=r(42)("IE_PROTO"),i=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=o(t),e(t,u)?t[u]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?i:null}},function(t,n,r){var e=r(10);t.exports=function(t){return Object(e(t))}},function(t,n,r){"use strict";var e=r(16),o=r(13),u=r(50),i=r(52),c=r(53),f=r(40),s=r(54),a=r(55);o(o.S+o.F*!r(57)(function(t){Array.from(t)}),"Array",{from:function(t){var n,r,o,l,p=u(t),d="function"==typeof this?this:Array,v=arguments.length,y=v>1?arguments[1]:void 0,h=void 0!==y,x=0,m=a(p);if(h&&(y=e(y,v>2?arguments[2]:void 0,2)),void 0==m||d==Array&&c(m))for(n=f(p.length),r=new d(n);n>x;x++)s(r,x,h?y(p[x],x):p[x]);else for(l=m.call(p),r=new d;!(o=l.next()).done;x++)s(r,x,h?i(l,y,[o.value,x],!0):o.value);return r.length=x,r}})},function(t,n,r){var e=r(20);t.exports=function(t,n,r,o){try{return o?n(e(r)[0],r[1]):n(r)}catch(u){var i=t["return"];throw void 0!==i&&e(i.call(t)),u}}},function(t,n,r){var e=r(30),o=r(48)("iterator"),u=Array.prototype;t.exports=function(t){return void 0!==t&&(e.Array===t||u[o]===t)}},function(t,n,r){"use strict";var e=r(19),o=r(27);t.exports=function(t,n,r){n in t?e.f(t,n,o(0,r)):t[n]=r}},function(t,n,r){var e=r(56),o=r(48)("iterator"),u=r(30);t.exports=r(15).getIteratorMethod=function(t){if(void 0!=t)return t[o]||t["@@iterator"]||u[e(t)]}},function(t,n,r){var e=r(38),o=r(48)("toStringTag"),u="Arguments"==e(function(){return arguments}()),i=function(t,n){try{return t[n]}catch(r){}};t.exports=function(t){var n,r,c;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=i(n=Object(t),o))?r:u?e(n):"Object"==(c=e(n))&&"function"==typeof n.callee?"Arguments":c}},function(t,n,r){var e=r(48)("iterator"),o=!1;try{var u=[7][e]();u["return"]=function(){o=!0},Array.from(u,function(){throw 2})}catch(i){}t.exports=function(t,n){if(!n&&!o)return!1;var r=!1;try{var u=[7],i=u[e]();i.next=function(){return{done:r=!0}},u[e]=function(){return i},t(u)}catch(c){}return r}},function(t,n,r){var e=r(2)(r(59),r(66),null,null);t.exports=e.exports},function(t,n,r){"use strict";function e(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(n,"__esModule",{value:!0});var o=r(60),u=e(o),i=r(64),c=e(i);n["default"]={props:{_type:String,children:Array,styling:String,markDefs:Array,serializers:Object},components:{RenderType:c["default"]},methods:{getMarks:function(t){return this.markDefs.filter(function(n){return t.marks.some(function(t){return n._key===t})})}},computed:{isCustomType:function(){var t=["span","em","underline","strike-through"],n=(0,u["default"])(this.serializers.types);return t.some(function(t){return n.includes(t)})}}}},function(t,n,r){t.exports={"default":r(61),__esModule:!0}},function(t,n,r){r(62),t.exports=r(15).Object.keys},function(t,n,r){var e=r(50),o=r(34);r(63)("keys",function(){return function(t){return o(e(t))}})},function(t,n,r){var e=r(13),o=r(15),u=r(24);t.exports=function(t,n){var r=(o.Object||{})[t]||Object[t],i={};i[t]=n(r),e(e.S+e.F*u(function(){r(1)}),"Object",i)}},function(t,n,r){var e=r(2)(r(65),null,null,null);t.exports=e.exports},function(t,n,r){"use strict";function e(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(n,"__esModule",{value:!0});var o=r(58);e(o);n["default"]={name:"default-type",props:{block:Object,isCustomType:Boolean,styling:String,markDefs:Array,serializers:Object},render:function(t){var n=this.styling,r="normal"===n?"span":n;return t(r,{},[this.renderMark(t)])},methods:{renderMark:function(t){var n=this.markDefs,r=this.isCustomType?this.renderCustomType(t):this.renderDefaultType(t);if(n.length){var e=n[0];"link"===e._type?"a":"span";return t("a",{attrs:{href:e.href}},[r])}return r},renderDefaultType:function(t){var n=this.block;return t(n._type,n.text)},renderCustomType:function(t){var n=this.serializers.types[this.block._type];return t(n,{props:{fields:this.block}})}}}},function(t,n){t.exports={render:function(){var t=this,n=t.$createElement,r=t._self._c||n;return r("p",t._l(t.children,function(n){return r("RenderType",{key:n._key,attrs:{block:n,styling:t.styling,serializers:t.serializers,markDefs:t.getMarks(n),isCustomType:t.isCustomType}})}))},staticRenderFns:[]}},function(t,n){t.exports={render:function(){var t=this,n=t.$createElement,r=t._self._c||n;return r("div",[t._l(t.reducedBlocks,function(n){return["block"===n._type?r("Block",t._b({key:n._key,attrs:{serializers:t.serializers}},"Block",n,!1)):r(t.serializers.types[n._type],t._b({key:n._key,tag:"component"},"component",n,!1))]})],2)},staticRenderFns:[]}}]);
--------------------------------------------------------------------------------
/dist/block-content-to-vue.js:
--------------------------------------------------------------------------------
1 | !function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("block-content-to-vue",[],n):"object"==typeof exports?exports["block-content-to-vue"]=n():t["block-content-to-vue"]=n()}(this,function(){return function(t){function n(r){if(e[r])return e[r].exports;var o=e[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var e={};return n.m=t,n.c=e,n.p="",n(0)}([function(t,n,e){var r=e(1)(e(2),e(66),null,null);t.exports=r.exports},function(t,n){t.exports=function(t,n,e,r){var o,u=t=t||{},i=typeof t["default"];"object"!==i&&"function"!==i||(o=t,u=t["default"]);var c="function"==typeof u?u.options:u;if(n&&(c.render=n.render,c.staticRenderFns=n.staticRenderFns),e&&(c._scopeId=e),r){var f=Object.create(c.computed||null);Object.keys(r).forEach(function(t){var n=r[t];f[t]=function(){return n}}),c.computed=f}return{esModule:o,exports:u,options:c}}},function(t,n,e){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(n,"__esModule",{value:!0});var o=e(3),u=r(o),i=e(57),c=r(i);n["default"]={name:"block-content",props:{blocks:Array,serializers:Object},components:{Block:c["default"]},computed:{reducedBlocks:function(){var t=this.blocks.reduce(function(t,n){var e=n.style;return delete n.style,n.styling=e,[].concat((0,u["default"])(t),[n])},[]);return t}}}},function(t,n,e){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}n.__esModule=!0;var o=e(4),u=r(o);n["default"]=function(t){if(Array.isArray(t)){for(var n=0,e=Array(t.length);n=n.length?{value:void 0,done:!0}:(t=r(n,e),this._i+=t.length,{value:t,done:!1})})},function(t,n,e){var r=e(8),o=e(9);t.exports=function(t){return function(n,e){var u,i,c=String(o(n)),f=r(e),s=c.length;return f<0||f>=s?t?"":void 0:(u=c.charCodeAt(f),u<55296||u>56319||f+1===s||(i=c.charCodeAt(f+1))<56320||i>57343?t?c.charAt(f):u:t?c.slice(f,f+2):(u-55296<<10)+(i-56320)+65536)}}},function(t,n){var e=Math.ceil,r=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?r:e)(t)}},function(t,n){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,n,e){"use strict";var r=e(11),o=e(12),u=e(27),i=e(17),c=e(28),f=e(29),s=e(30),a=e(46),l=e(48),p=e(47)("iterator"),d=!([].keys&&"next"in[].keys()),v="@@iterator",y="keys",h="values",x=function(){return this};t.exports=function(t,n,e,m,b,_,g){s(e,n,m);var k,O,j,w=function(t){if(!d&&t in T)return T[t];switch(t){case y:return function(){return new e(this,t)};case h:return function(){return new e(this,t)}}return function(){return new e(this,t)}},M=n+" Iterator",S=b==h,A=!1,T=t.prototype,P=T[p]||T[v]||b&&T[b],E=!d&&P||w(b),F=b?S?w("entries"):E:void 0,C="Array"==n?T.entries||P:P;if(C&&(j=l(C.call(new t)),j!==Object.prototype&&j.next&&(a(j,M,!0),r||c(j,p)||i(j,p,x))),S&&P&&P.name!==h&&(A=!0,E=function(){return P.call(this)}),r&&!g||!d&&!A&&T[p]||i(T,p,E),f[n]=E,f[M]=x,b)if(k={values:S?E:w(h),keys:_?E:w(y),entries:F},g)for(O in k)O in T||u(T,O,k[O]);else o(o.P+o.F*(d||A),n,k);return k}},function(t,n){t.exports=!0},function(t,n,e){var r=e(13),o=e(14),u=e(15),i=e(17),c="prototype",f=function(t,n,e){var s,a,l,p=t&f.F,d=t&f.G,v=t&f.S,y=t&f.P,h=t&f.B,x=t&f.W,m=d?o:o[n]||(o[n]={}),b=m[c],_=d?r:v?r[n]:(r[n]||{})[c];d&&(e=n);for(s in e)a=!p&&_&&void 0!==_[s],a&&s in m||(l=a?_[s]:e[s],m[s]=d&&"function"!=typeof _[s]?e[s]:h&&a?u(l,r):x&&_[s]==l?function(t){var n=function(n,e,r){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(n);case 2:return new t(n,e)}return new t(n,e,r)}return t.apply(this,arguments)};return n[c]=t[c],n}(l):y&&"function"==typeof l?u(Function.call,l):l,y&&((m.virtual||(m.virtual={}))[s]=l,t&f.R&&b&&!b[s]&&i(b,s,l)))};f.F=1,f.G=2,f.S=4,f.P=8,f.B=16,f.W=32,f.U=64,f.R=128,t.exports=f},function(t,n){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)},function(t,n){var e=t.exports={version:"2.5.3"};"number"==typeof __e&&(__e=e)},function(t,n,e){var r=e(16);t.exports=function(t,n,e){if(r(t),void 0===n)return t;switch(e){case 1:return function(e){return t.call(n,e)};case 2:return function(e,r){return t.call(n,e,r)};case 3:return function(e,r,o){return t.call(n,e,r,o)}}return function(){return t.apply(n,arguments)}}},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n,e){var r=e(18),o=e(26);t.exports=e(22)?function(t,n,e){return r.f(t,n,o(1,e))}:function(t,n,e){return t[n]=e,t}},function(t,n,e){var r=e(19),o=e(21),u=e(25),i=Object.defineProperty;n.f=e(22)?Object.defineProperty:function(t,n,e){if(r(t),n=u(n,!0),r(e),o)try{return i(t,n,e)}catch(c){}if("get"in e||"set"in e)throw TypeError("Accessors not supported!");return"value"in e&&(t[n]=e.value),t}},function(t,n,e){var r=e(20);t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t}},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n,e){t.exports=!e(22)&&!e(23)(function(){return 7!=Object.defineProperty(e(24)("div"),"a",{get:function(){return 7}}).a})},function(t,n,e){t.exports=!e(23)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,n){t.exports=function(t){try{return!!t()}catch(n){return!0}}},function(t,n,e){var r=e(20),o=e(13).document,u=r(o)&&r(o.createElement);t.exports=function(t){return u?o.createElement(t):{}}},function(t,n,e){var r=e(20);t.exports=function(t,n){if(!r(t))return t;var e,o;if(n&&"function"==typeof(e=t.toString)&&!r(o=e.call(t)))return o;if("function"==typeof(e=t.valueOf)&&!r(o=e.call(t)))return o;if(!n&&"function"==typeof(e=t.toString)&&!r(o=e.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n,e){t.exports=e(17)},function(t,n){var e={}.hasOwnProperty;t.exports=function(t,n){return e.call(t,n)}},function(t,n){t.exports={}},function(t,n,e){"use strict";var r=e(31),o=e(26),u=e(46),i={};e(17)(i,e(47)("iterator"),function(){return this}),t.exports=function(t,n,e){t.prototype=r(i,{next:o(1,e)}),u(t,n+" Iterator")}},function(t,n,e){var r=e(19),o=e(32),u=e(44),i=e(41)("IE_PROTO"),c=function(){},f="prototype",s=function(){var t,n=e(24)("iframe"),r=u.length,o="<",i=">";for(n.style.display="none",e(45).appendChild(n),n.src="javascript:",t=n.contentWindow.document,t.open(),t.write(o+"script"+i+"document.F=Object"+o+"/script"+i),t.close(),s=t.F;r--;)delete s[f][u[r]];return s()};t.exports=Object.create||function(t,n){var e;return null!==t?(c[f]=r(t),e=new c,c[f]=null,e[i]=t):e=s(),void 0===n?e:o(e,n)}},function(t,n,e){var r=e(18),o=e(19),u=e(33);t.exports=e(22)?Object.defineProperties:function(t,n){o(t);for(var e,i=u(n),c=i.length,f=0;c>f;)r.f(t,e=i[f++],n[e]);return t}},function(t,n,e){var r=e(34),o=e(44);t.exports=Object.keys||function(t){return r(t,o)}},function(t,n,e){var r=e(28),o=e(35),u=e(38)(!1),i=e(41)("IE_PROTO");t.exports=function(t,n){var e,c=o(t),f=0,s=[];for(e in c)e!=i&&r(c,e)&&s.push(e);for(;n.length>f;)r(c,e=n[f++])&&(~u(s,e)||s.push(e));return s}},function(t,n,e){var r=e(36),o=e(9);t.exports=function(t){return r(o(t))}},function(t,n,e){var r=e(37);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==r(t)?t.split(""):Object(t)}},function(t,n){var e={}.toString;t.exports=function(t){return e.call(t).slice(8,-1)}},function(t,n,e){var r=e(35),o=e(39),u=e(40);t.exports=function(t){return function(n,e,i){var c,f=r(n),s=o(f.length),a=u(i,s);if(t&&e!=e){for(;s>a;)if(c=f[a++],c!=c)return!0}else for(;s>a;a++)if((t||a in f)&&f[a]===e)return t||a||0;return!t&&-1}}},function(t,n,e){var r=e(8),o=Math.min;t.exports=function(t){return t>0?o(r(t),9007199254740991):0}},function(t,n,e){var r=e(8),o=Math.max,u=Math.min;t.exports=function(t,n){return t=r(t),t<0?o(t+n,0):u(t,n)}},function(t,n,e){var r=e(42)("keys"),o=e(43);t.exports=function(t){return r[t]||(r[t]=o(t))}},function(t,n,e){var r=e(13),o="__core-js_shared__",u=r[o]||(r[o]={});t.exports=function(t){return u[t]||(u[t]={})}},function(t,n){var e=0,r=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++e+r).toString(36))}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,n,e){var r=e(13).document;t.exports=r&&r.documentElement},function(t,n,e){var r=e(18).f,o=e(28),u=e(47)("toStringTag");t.exports=function(t,n,e){t&&!o(t=e?t:t.prototype,u)&&r(t,u,{configurable:!0,value:n})}},function(t,n,e){var r=e(42)("wks"),o=e(43),u=e(13).Symbol,i="function"==typeof u,c=t.exports=function(t){return r[t]||(r[t]=i&&u[t]||(i?u:o)("Symbol."+t))};c.store=r},function(t,n,e){var r=e(28),o=e(49),u=e(41)("IE_PROTO"),i=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=o(t),r(t,u)?t[u]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?i:null}},function(t,n,e){var r=e(9);t.exports=function(t){return Object(r(t))}},function(t,n,e){"use strict";var r=e(15),o=e(12),u=e(49),i=e(51),c=e(52),f=e(39),s=e(53),a=e(54);o(o.S+o.F*!e(56)(function(t){Array.from(t)}),"Array",{from:function(t){var n,e,o,l,p=u(t),d="function"==typeof this?this:Array,v=arguments.length,y=v>1?arguments[1]:void 0,h=void 0!==y,x=0,m=a(p);if(h&&(y=r(y,v>2?arguments[2]:void 0,2)),void 0==m||d==Array&&c(m))for(n=f(p.length),e=new d(n);n>x;x++)s(e,x,h?y(p[x],x):p[x]);else for(l=m.call(p),e=new d;!(o=l.next()).done;x++)s(e,x,h?i(l,y,[o.value,x],!0):o.value);return e.length=x,e}})},function(t,n,e){var r=e(19);t.exports=function(t,n,e,o){try{return o?n(r(e)[0],e[1]):n(e)}catch(u){var i=t["return"];throw void 0!==i&&r(i.call(t)),u}}},function(t,n,e){var r=e(29),o=e(47)("iterator"),u=Array.prototype;t.exports=function(t){return void 0!==t&&(r.Array===t||u[o]===t)}},function(t,n,e){"use strict";var r=e(18),o=e(26);t.exports=function(t,n,e){n in t?r.f(t,n,o(0,e)):t[n]=e}},function(t,n,e){var r=e(55),o=e(47)("iterator"),u=e(29);t.exports=e(14).getIteratorMethod=function(t){if(void 0!=t)return t[o]||t["@@iterator"]||u[r(t)]}},function(t,n,e){var r=e(37),o=e(47)("toStringTag"),u="Arguments"==r(function(){return arguments}()),i=function(t,n){try{return t[n]}catch(e){}};t.exports=function(t){var n,e,c;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(e=i(n=Object(t),o))?e:u?r(n):"Object"==(c=r(n))&&"function"==typeof n.callee?"Arguments":c}},function(t,n,e){var r=e(47)("iterator"),o=!1;try{var u=[7][r]();u["return"]=function(){o=!0},Array.from(u,function(){throw 2})}catch(i){}t.exports=function(t,n){if(!n&&!o)return!1;var e=!1;try{var u=[7],i=u[r]();i.next=function(){return{done:e=!0}},u[r]=function(){return i},t(u)}catch(c){}return e}},function(t,n,e){var r=e(1)(e(58),e(65),null,null);t.exports=r.exports},function(t,n,e){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(n,"__esModule",{value:!0});var o=e(59),u=r(o),i=e(63),c=r(i);n["default"]={props:{_type:String,children:Array,styling:String,markDefs:Array,serializers:Object},components:{RenderType:c["default"]},methods:{getMarks:function(t){return this.markDefs.filter(function(n){return t.marks.some(function(t){return n._key===t})})}},computed:{isCustomType:function(){var t=["span","em","underline","strike-through"],n=(0,u["default"])(this.serializers.types);return t.some(function(t){return n.includes(t)})}}}},function(t,n,e){t.exports={"default":e(60),__esModule:!0}},function(t,n,e){e(61),t.exports=e(14).Object.keys},function(t,n,e){var r=e(49),o=e(33);e(62)("keys",function(){return function(t){return o(r(t))}})},function(t,n,e){var r=e(12),o=e(14),u=e(23);t.exports=function(t,n){var e=(o.Object||{})[t]||Object[t],i={};i[t]=n(e),r(r.S+r.F*u(function(){e(1)}),"Object",i)}},function(t,n,e){var r=e(1)(e(64),null,null,null);t.exports=r.exports},function(t,n,e){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(n,"__esModule",{value:!0});var o=e(57);r(o);n["default"]={name:"default-type",props:{block:Object,isCustomType:Boolean,styling:String,markDefs:Array,serializers:Object},render:function(t){var n=this.styling,e="normal"===n?"span":n;return t(e,{},[this.renderMark(t)])},methods:{renderMark:function(t){var n=this.markDefs,e=this.isCustomType?this.renderCustomType(t):this.renderDefaultType(t);if(n.length){var r=n[0];"link"===r._type?"a":"span";return t("a",{attrs:{href:r.href}},[e])}return e},renderDefaultType:function(t){var n=this.block;return t(n._type,n.text)},renderCustomType:function(t){var n=this.serializers.types[this.block._type];return t(n,{props:{fields:this.block}})}}}},function(t,n){t.exports={render:function(){var t=this,n=t.$createElement,e=t._self._c||n;return e("p",t._l(t.children,function(n){return e("RenderType",{key:n._key,attrs:{block:n,styling:t.styling,serializers:t.serializers,markDefs:t.getMarks(n),isCustomType:t.isCustomType}})}))},staticRenderFns:[]}},function(t,n){t.exports={render:function(){var t=this,n=t.$createElement,e=t._self._c||n;return e("div",[t._l(t.reducedBlocks,function(n){return["block"===n._type?e("Block",t._b({key:n._key,attrs:{serializers:t.serializers}},"Block",n,!1)):e(t.serializers.types[n._type],t._b({key:n._key,tag:"component"},"component",n,!1))]})],2)},staticRenderFns:[]}}])});
--------------------------------------------------------------------------------