mobiledoc-text-renderer
Advanced tools
Comparing version 0.4.0-beta to 0.4.0-beta.1
@@ -1,12 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _default = { | ||
export default { | ||
name: 'image-card', | ||
type: 'text', | ||
render: function render() {} | ||
}; | ||
exports.default = _default; | ||
}; |
@@ -1,26 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.registerGlobal = registerGlobal; | ||
Object.defineProperty(exports, "RENDER_TYPE", { | ||
enumerable: true, | ||
get: function get() { | ||
return _renderType.default; | ||
} | ||
}); | ||
exports.default = void 0; | ||
var _rendererFactory = _interopRequireDefault(require("./renderer-factory")); | ||
var _renderType = _interopRequireDefault(require("./utils/render-type")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function registerGlobal(window) { | ||
window.MobiledocTextRenderer = _rendererFactory.default; | ||
import RendererFactory from './renderer-factory'; | ||
import RENDER_TYPE from './utils/render-type'; | ||
export function registerGlobal(window) { | ||
window.MobiledocTextRenderer = RendererFactory; | ||
} | ||
var _default = _rendererFactory.default; | ||
exports.default = _default; | ||
export { RENDER_TYPE }; | ||
export default RendererFactory; |
@@ -1,18 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _ = _interopRequireWildcard(require("./renderers/0-2")); | ||
var _2 = _interopRequireWildcard(require("./renderers/0-3")); | ||
var _renderType = _interopRequireDefault(require("./utils/render-type")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -24,2 +7,5 @@ | ||
import Renderer_0_2, { MOBILEDOC_VERSION as MOBILEDOC_VERSION_0_2 } from './renderers/0-2'; | ||
import Renderer_0_3, { MOBILEDOC_VERSION_0_3, MOBILEDOC_VERSION_0_3_1 } from './renderers/0-3'; | ||
import RENDER_TYPE from './utils/render-type'; | ||
/** | ||
@@ -32,2 +18,3 @@ * runtime Text renderer | ||
*/ | ||
function validateCards(cards) { | ||
@@ -41,4 +28,4 @@ if (!Array.isArray(cards)) { | ||
if (card.type !== _renderType.default) { | ||
throw new Error("Card \"".concat(card.name, "\" must be type \"").concat(_renderType.default, "\", was \"").concat(card.type, "\"")); | ||
if (card.type !== RENDER_TYPE) { | ||
throw new Error("Card \"".concat(card.name, "\" must be type \"").concat(RENDER_TYPE, "\", was \"").concat(card.type, "\"")); | ||
} | ||
@@ -60,4 +47,4 @@ | ||
if (atom.type !== _renderType.default) { | ||
throw new Error("Atom \"".concat(atom.name, "\" must be type \"").concat(_renderType.default, "\", was \"").concat(atom.type, "\"")); | ||
if (atom.type !== RENDER_TYPE) { | ||
throw new Error("Atom \"".concat(atom.name, "\" must be type \"").concat(RENDER_TYPE, "\", was \"").concat(atom.type, "\"")); | ||
} | ||
@@ -104,10 +91,10 @@ | ||
switch (version) { | ||
case _.MOBILEDOC_VERSION: | ||
return new _.default(mobiledoc, this.state).render(); | ||
case MOBILEDOC_VERSION_0_2: | ||
return new Renderer_0_2(mobiledoc, this.state).render(); | ||
case undefined: | ||
case null: | ||
case _2.MOBILEDOC_VERSION_0_3: | ||
case _2.MOBILEDOC_VERSION_0_3_1: | ||
return new _2.default(mobiledoc, this.state).render(); | ||
case MOBILEDOC_VERSION_0_3: | ||
case MOBILEDOC_VERSION_0_3_1: | ||
return new Renderer_0_3(mobiledoc, this.state).render(); | ||
@@ -123,2 +110,2 @@ default: | ||
exports.default = RendererFactory; | ||
export { RendererFactory as default }; |
@@ -1,16 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.MOBILEDOC_VERSION = void 0; | ||
var _image = _interopRequireDefault(require("../cards/image")); | ||
var _renderType = _interopRequireDefault(require("../utils/render-type")); | ||
var _sectionTypes = require("../utils/section-types"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
@@ -32,5 +17,14 @@ | ||
/** | ||
* runtime Text renderer | ||
* renders a mobiledoc to Text | ||
* | ||
* input: mobiledoc | ||
* output: Text (string) | ||
*/ | ||
import ImageCard from '../cards/image'; | ||
import RENDER_TYPE from '../utils/render-type'; | ||
var LINE_BREAK = '\n'; | ||
var MOBILEDOC_VERSION = '0.2.0'; | ||
exports.MOBILEDOC_VERSION = MOBILEDOC_VERSION; | ||
import { MARKUP_SECTION_TYPE, LIST_SECTION_TYPE, CARD_SECTION_TYPE, IMAGE_SECTION_TYPE } from '../utils/section-types'; | ||
export var MOBILEDOC_VERSION = '0.2.0'; | ||
@@ -99,12 +93,12 @@ function validateVersion(version) { | ||
switch (type) { | ||
case _sectionTypes.MARKUP_SECTION_TYPE: | ||
case MARKUP_SECTION_TYPE: | ||
return this.renderMarkupSection(section); | ||
case _sectionTypes.IMAGE_SECTION_TYPE: | ||
case IMAGE_SECTION_TYPE: | ||
return this.renderImageSection(section); | ||
case _sectionTypes.LIST_SECTION_TYPE: | ||
case LIST_SECTION_TYPE: | ||
return this.renderListSection(section); | ||
case _sectionTypes.CARD_SECTION_TYPE: | ||
case CARD_SECTION_TYPE: | ||
return this.renderCardSection(section); | ||
@@ -149,4 +143,4 @@ | ||
if (name === _image.default.name) { | ||
return _image.default; | ||
if (name === ImageCard.name) { | ||
return ImageCard; | ||
} | ||
@@ -161,3 +155,3 @@ | ||
name: name, | ||
type: _renderType.default, | ||
type: RENDER_TYPE, | ||
render: this.unknownCardHandler | ||
@@ -192,3 +186,3 @@ }; | ||
if (typeof rendered !== 'string') { | ||
throw new Error("Card \"".concat(cardName, "\" must render ").concat(_renderType.default, ", but result was ").concat(_typeof(rendered), "\"")); | ||
throw new Error("Card \"".concat(cardName, "\" must render ").concat(RENDER_TYPE, ", but result was ").concat(_typeof(rendered), "\"")); | ||
} | ||
@@ -254,2 +248,2 @@ } | ||
exports.default = Renderer; | ||
export { Renderer as default }; |
@@ -1,18 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.MOBILEDOC_VERSION = exports.MOBILEDOC_VERSION_0_3_1 = exports.MOBILEDOC_VERSION_0_3 = void 0; | ||
var _image = _interopRequireDefault(require("../cards/image")); | ||
var _renderType = _interopRequireDefault(require("../utils/render-type")); | ||
var _sectionTypes = require("../utils/section-types"); | ||
var _markerTypes = require("../utils/marker-types"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
@@ -34,9 +17,17 @@ | ||
/** | ||
* runtime Text renderer | ||
* renders a mobiledoc to Text | ||
* | ||
* input: mobiledoc | ||
* output: Text (string) | ||
*/ | ||
import ImageCard from '../cards/image'; | ||
import RENDER_TYPE from '../utils/render-type'; | ||
var LINE_BREAK = '\n'; | ||
var MOBILEDOC_VERSION_0_3 = '0.3.0'; | ||
exports.MOBILEDOC_VERSION_0_3 = MOBILEDOC_VERSION_0_3; | ||
var MOBILEDOC_VERSION_0_3_1 = '0.3.1'; | ||
exports.MOBILEDOC_VERSION_0_3_1 = MOBILEDOC_VERSION_0_3_1; | ||
var MOBILEDOC_VERSION = MOBILEDOC_VERSION_0_3_1; | ||
exports.MOBILEDOC_VERSION = MOBILEDOC_VERSION; | ||
import { MARKUP_SECTION_TYPE, LIST_SECTION_TYPE, CARD_SECTION_TYPE, IMAGE_SECTION_TYPE } from '../utils/section-types'; | ||
import { MARKUP_MARKER_TYPE, ATOM_MARKER_TYPE } from '../utils/marker-types'; | ||
export var MOBILEDOC_VERSION_0_3 = '0.3.0'; | ||
export var MOBILEDOC_VERSION_0_3_1 = '0.3.1'; | ||
export var MOBILEDOC_VERSION = MOBILEDOC_VERSION_0_3_1; | ||
@@ -107,12 +98,12 @@ function validateVersion(version) { | ||
switch (type) { | ||
case _sectionTypes.MARKUP_SECTION_TYPE: | ||
case MARKUP_SECTION_TYPE: | ||
return this.renderMarkupSection(section); | ||
case _sectionTypes.IMAGE_SECTION_TYPE: | ||
case IMAGE_SECTION_TYPE: | ||
return this.renderImageSection(section); | ||
case _sectionTypes.LIST_SECTION_TYPE: | ||
case LIST_SECTION_TYPE: | ||
return this.renderListSection(section); | ||
case _sectionTypes.CARD_SECTION_TYPE: | ||
case CARD_SECTION_TYPE: | ||
return this.renderCardSection(section); | ||
@@ -157,4 +148,4 @@ | ||
if (name === _image.default.name) { | ||
return _image.default; | ||
if (name === ImageCard.name) { | ||
return ImageCard; | ||
} | ||
@@ -188,3 +179,3 @@ | ||
name: name, | ||
type: _renderType.default, | ||
type: RENDER_TYPE, | ||
render: this.unknownCardHandler | ||
@@ -220,3 +211,3 @@ }; | ||
if (typeof rendered !== 'string') { | ||
throw new Error("Card \"".concat(cardName, "\" must render ").concat(_renderType.default, ", but result was ").concat(_typeof(rendered), "\"")); | ||
throw new Error("Card \"".concat(cardName, "\" must render ").concat(RENDER_TYPE, ", but result was ").concat(_typeof(rendered), "\"")); | ||
} | ||
@@ -275,3 +266,3 @@ } | ||
name: name, | ||
type: _renderType.default, | ||
type: RENDER_TYPE, | ||
render: this.unknownAtomHandler | ||
@@ -307,3 +298,3 @@ }; | ||
if (typeof rendered !== 'string') { | ||
throw new Error("Atom \"".concat(atomName, "\" must render ").concat(_renderType.default, ", but result was ").concat(_typeof(rendered), "\"")); | ||
throw new Error("Atom \"".concat(atomName, "\" must render ").concat(RENDER_TYPE, ", but result was ").concat(_typeof(rendered), "\"")); | ||
} | ||
@@ -360,7 +351,7 @@ } | ||
switch (type) { | ||
case _markerTypes.MARKUP_MARKER_TYPE: | ||
case MARKUP_MARKER_TYPE: | ||
str += value; | ||
break; | ||
case _markerTypes.ATOM_MARKER_TYPE: | ||
case ATOM_MARKER_TYPE: | ||
str += _this5._renderAtom(value); | ||
@@ -394,2 +385,2 @@ break; | ||
exports.default = Renderer; | ||
export { Renderer as default }; |
@@ -1,10 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ATOM_MARKER_TYPE = exports.MARKUP_MARKER_TYPE = void 0; | ||
var MARKUP_MARKER_TYPE = 0; | ||
exports.MARKUP_MARKER_TYPE = MARKUP_MARKER_TYPE; | ||
var ATOM_MARKER_TYPE = 1; | ||
exports.ATOM_MARKER_TYPE = ATOM_MARKER_TYPE; | ||
export var MARKUP_MARKER_TYPE = 0; | ||
export var ATOM_MARKER_TYPE = 1; |
@@ -1,8 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _default = 'text'; | ||
exports.default = _default; | ||
export default 'text'; |
@@ -1,14 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.CARD_SECTION_TYPE = exports.LIST_SECTION_TYPE = exports.IMAGE_SECTION_TYPE = exports.MARKUP_SECTION_TYPE = void 0; | ||
var MARKUP_SECTION_TYPE = 1; | ||
exports.MARKUP_SECTION_TYPE = MARKUP_SECTION_TYPE; | ||
var IMAGE_SECTION_TYPE = 2; | ||
exports.IMAGE_SECTION_TYPE = IMAGE_SECTION_TYPE; | ||
var LIST_SECTION_TYPE = 3; | ||
exports.LIST_SECTION_TYPE = LIST_SECTION_TYPE; | ||
var CARD_SECTION_TYPE = 10; | ||
exports.CARD_SECTION_TYPE = CARD_SECTION_TYPE; | ||
export var MARKUP_SECTION_TYPE = 1; | ||
export var IMAGE_SECTION_TYPE = 2; | ||
export var LIST_SECTION_TYPE = 3; | ||
export var CARD_SECTION_TYPE = 10; |
{ | ||
"name": "mobiledoc-text-renderer", | ||
"version": "0.4.0-beta", | ||
"version": "0.4.0-beta.1", | ||
"description": "Renders mobiledoc input to text (string) output", | ||
@@ -10,3 +10,3 @@ "main": "dist/commonjs/mobiledoc-text-renderer/index.js", | ||
"build": "rm -rf dist/ && broccoli build dist && npm run transpile", | ||
"transpile": "babel lib --out-dir dist/esm --presets=@babel/preset-env" | ||
"transpile": "babel lib --out-dir dist/esm" | ||
}, | ||
@@ -13,0 +13,0 @@ "repository": { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
435132
8936