@bustle/mobiledoc-facebook-instant-renderer
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -1201,4 +1201,17 @@ define('mobiledoc-dom-renderer/cards/image', ['exports', 'mobiledoc-dom-renderer/utils/render-type'], function (exports, _mobiledocDomRendererUtilsRenderType) { | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
var SUPPORTED_VERSIONS = ['0.3.0', '0.3.1']; | ||
function skipEmptySections(mobiledoc) { | ||
var sections = mobiledoc.sections.filter(function (section) { | ||
var isEmpty = section[0] === 1 && section[2].length === 0; | ||
return !isEmpty; | ||
}); | ||
return _extends({}, mobiledoc, { | ||
sections: sections | ||
}); | ||
} | ||
var RendererFactory = (function () { | ||
@@ -1230,3 +1243,8 @@ function RendererFactory() { | ||
value: function render(mobiledoc) { | ||
return this.renderer.render(mobiledoc); | ||
var version = mobiledoc.version; | ||
if (!SUPPORTED_VERSIONS.includes(version)) { | ||
throw new Error('Unsupported mobiledoc version: "' + version + '"'); | ||
} | ||
return this.renderer.render(skipEmptySections(mobiledoc)); | ||
} | ||
@@ -1233,0 +1251,0 @@ }]); |
@@ -5,2 +5,4 @@ 'use strict'; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
@@ -12,2 +14,13 @@ | ||
var SUPPORTED_VERSIONS = ['0.3.0', '0.3.1']; | ||
function skipEmptySections(mobiledoc) { | ||
var sections = mobiledoc.sections.filter(function (section) { | ||
var isEmpty = section[0] === 1 && section[2].length === 0; | ||
return !isEmpty; | ||
}); | ||
return _extends({}, mobiledoc, { | ||
sections: sections | ||
}); | ||
} | ||
var RendererFactory = (function () { | ||
@@ -39,3 +52,8 @@ function RendererFactory() { | ||
value: function render(mobiledoc) { | ||
return this.renderer.render(mobiledoc); | ||
var version = mobiledoc.version; | ||
if (!SUPPORTED_VERSIONS.includes(version)) { | ||
throw new Error('Unsupported mobiledoc version: "' + version + '"'); | ||
} | ||
return this.renderer.render(skipEmptySections(mobiledoc)); | ||
} | ||
@@ -42,0 +60,0 @@ }]); |
@@ -1538,4 +1538,17 @@ ;(function() { | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
var SUPPORTED_VERSIONS = ['0.3.0', '0.3.1']; | ||
function skipEmptySections(mobiledoc) { | ||
var sections = mobiledoc.sections.filter(function (section) { | ||
var isEmpty = section[0] === 1 && section[2].length === 0; | ||
return !isEmpty; | ||
}); | ||
return _extends({}, mobiledoc, { | ||
sections: sections | ||
}); | ||
} | ||
var RendererFactory = (function () { | ||
@@ -1567,3 +1580,8 @@ function RendererFactory() { | ||
value: function render(mobiledoc) { | ||
return this.renderer.render(mobiledoc); | ||
var version = mobiledoc.version; | ||
if (!SUPPORTED_VERSIONS.includes(version)) { | ||
throw new Error('Unsupported mobiledoc version: "' + version + '"'); | ||
} | ||
return this.renderer.render(skipEmptySections(mobiledoc)); | ||
} | ||
@@ -1570,0 +1588,0 @@ }]); |
@@ -50,2 +50,3 @@ QUnit.module('ESLint | tests/eslint/cards/image.js'); | ||
exports.createSimpleMobiledoc = createSimpleMobiledoc; | ||
exports.createMobiledocWithEmptyParagraph = createMobiledocWithEmptyParagraph; | ||
var MOBILEDOC_VERSION_0_3_1 = '0.3.1'; | ||
@@ -132,2 +133,17 @@ var MOBILEDOC_VERSION = MOBILEDOC_VERSION_0_3_1; | ||
} | ||
function createMobiledocWithEmptyParagraph() { | ||
var _ref5 = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var _ref5$version = _ref5.version; | ||
var version = _ref5$version === undefined ? MOBILEDOC_VERSION : _ref5$version; | ||
return { | ||
version: version, | ||
atoms: [], | ||
cards: [], | ||
markups: [], | ||
sections: [[1, 'p', []]] | ||
}; | ||
} | ||
}); | ||
@@ -179,2 +195,11 @@ define('tests/helpers/dom', ['exports'], function (exports) { | ||
_module('Unit: Mobiledoc Facebook Instant Renderer - 0.2'); | ||
test('version 0.2.0 is not supported', function (assert) { | ||
var mockMobiledoc = { version: '0.2.0' }; | ||
assert.throws(function () { | ||
return render(mockMobiledoc); | ||
}, /Unsupported mobiledoc version.*0\.2\.0/i); | ||
}); | ||
_module('Unit: Mobiledoc Facebook Instant Renderer - 0.3'); | ||
@@ -207,2 +232,8 @@ | ||
}); | ||
test('empty paragraphs are skipped', function (assert) { | ||
var mobiledoc = (0, _helpersCreateMobiledoc.createMobiledocWithEmptyParagraph)(); | ||
var html = renderToHTML(mobiledoc); | ||
assert.ok(!html.includes('<p></p>')); | ||
}); | ||
});//# sourceMappingURL=built-amd-tests.map |
import MobiledocDOMRenderer from 'mobiledoc-dom-renderer'; | ||
import imageCard from './cards/image'; | ||
const SUPPORTED_VERSIONS = ['0.3.0', '0.3.1']; | ||
function skipEmptySections(mobiledoc) { | ||
const sections = mobiledoc.sections.filter((section) => { | ||
const isEmpty = section[0] === 1 && section[2].length === 0; | ||
return !isEmpty; | ||
}); | ||
return { | ||
...mobiledoc, | ||
sections | ||
}; | ||
} | ||
export default class RendererFactory { | ||
@@ -22,4 +34,8 @@ constructor(_options={}) { | ||
render(mobiledoc) { | ||
return this.renderer.render(mobiledoc); | ||
const { version } = mobiledoc; | ||
if (!SUPPORTED_VERSIONS.includes(version)) { | ||
throw new Error(`Unsupported mobiledoc version: "${version}"`); | ||
} | ||
return this.renderer.render(skipEmptySections(mobiledoc)); | ||
} | ||
} |
{ | ||
"name": "@bustle/mobiledoc-facebook-instant-renderer", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Renders mobiledoc input to Facebook Instant output", | ||
@@ -5,0 +5,0 @@ "main": "dist/commonjs/mobiledoc-facebook-instant-renderer/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
430923
8042