Socket
Socket
Sign inDemoInstall

@prismicio/richtext

Package Overview
Dependencies
Maintainers
14
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prismicio/richtext - npm Package Compare versions

Comparing version 1.0.6 to 1.1.0

6

dist/prismic-richtext.js

@@ -143,3 +143,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.ListBlockNode = exports.OrderedListBlockNode = exports.OrderedListItemBlockNode = exports.ListItemBlockNode = exports.BlockNode = exports.TextNode = exports.SpanNode = exports.Node = void 0;\n\nvar _uuid = _interopRequireDefault(__webpack_require__(/*! ./uuid */ \"./src/uuid.ts\"));\n\nvar _types = __webpack_require__(/*! ./types */ \"./src/types.ts\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _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); }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar Node = function Node(type, element, children) {\n _classCallCheck(this, Node);\n\n this.key = (0, _uuid.default)();\n this.type = type;\n this.element = element;\n this.children = children;\n};\n\nexports.Node = Node;\n\nvar SpanNode =\n/*#__PURE__*/\nfunction (_Node) {\n _inherits(SpanNode, _Node);\n\n function SpanNode(start, end, type, text, children, element) {\n var _this;\n\n _classCallCheck(this, SpanNode);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(SpanNode).call(this, type, element, children));\n _this.start = start;\n _this.end = end;\n _this.text = text;\n _this.children = children;\n return _this;\n }\n\n _createClass(SpanNode, [{\n key: \"boundaries\",\n value: function boundaries() {\n return {\n lower: this.start,\n upper: this.end\n };\n }\n }, {\n key: \"isParentOf\",\n value: function isParentOf(node) {\n return this.start <= node.start && this.end >= node.end;\n }\n }, {\n key: \"setChildren\",\n value: function setChildren(children) {\n return new SpanNode(this.start, this.end, this.type, this.text, children, this.element);\n }\n }], [{\n key: \"slice\",\n value: function slice(node, start, end, text) {\n return new SpanNode(start, end, node.type, text.slice(start, end), node.children, node.element);\n }\n }]);\n\n return SpanNode;\n}(Node);\n\nexports.SpanNode = SpanNode;\n\nvar TextNode =\n/*#__PURE__*/\nfunction (_SpanNode) {\n _inherits(TextNode, _SpanNode);\n\n function TextNode(start, end, text) {\n _classCallCheck(this, TextNode);\n\n var element = {\n type: _types.NODE_TYPES.span,\n start: start,\n end: end,\n text: text\n };\n return _possibleConstructorReturn(this, _getPrototypeOf(TextNode).call(this, start, end, _types.NODE_TYPES.span, text, [], element));\n }\n\n return TextNode;\n}(SpanNode);\n\nexports.TextNode = TextNode;\n\nvar BlockNode =\n/*#__PURE__*/\nfunction (_Node2) {\n _inherits(BlockNode, _Node2);\n\n function BlockNode(type, block) {\n var children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];\n\n _classCallCheck(this, BlockNode);\n\n return _possibleConstructorReturn(this, _getPrototypeOf(BlockNode).call(this, type, block, children));\n }\n\n return BlockNode;\n}(Node);\n\nexports.BlockNode = BlockNode;\n\nvar ListItemBlockNode =\n/*#__PURE__*/\nfunction (_BlockNode) {\n _inherits(ListItemBlockNode, _BlockNode);\n\n function ListItemBlockNode(block, children) {\n _classCallCheck(this, ListItemBlockNode);\n\n return _possibleConstructorReturn(this, _getPrototypeOf(ListItemBlockNode).call(this, _types.NODE_TYPES.listItem, block, children));\n }\n\n return ListItemBlockNode;\n}(BlockNode);\n\nexports.ListItemBlockNode = ListItemBlockNode;\n\nvar OrderedListItemBlockNode =\n/*#__PURE__*/\nfunction (_BlockNode2) {\n _inherits(OrderedListItemBlockNode, _BlockNode2);\n\n function OrderedListItemBlockNode(block, children) {\n _classCallCheck(this, OrderedListItemBlockNode);\n\n return _possibleConstructorReturn(this, _getPrototypeOf(OrderedListItemBlockNode).call(this, _types.NODE_TYPES.oListItem, block, children));\n }\n\n return OrderedListItemBlockNode;\n}(BlockNode);\n\nexports.OrderedListItemBlockNode = OrderedListItemBlockNode;\n\nvar OrderedListBlockNode =\n/*#__PURE__*/\nfunction (_BlockNode3) {\n _inherits(OrderedListBlockNode, _BlockNode3);\n\n function OrderedListBlockNode(block, children) {\n _classCallCheck(this, OrderedListBlockNode);\n\n return _possibleConstructorReturn(this, _getPrototypeOf(OrderedListBlockNode).call(this, _types.NODE_TYPES.oList, block, children));\n }\n\n _createClass(OrderedListBlockNode, [{\n key: \"addChild\",\n value: function addChild(node) {\n var children = this.children.concat(node);\n return new OrderedListBlockNode(this.element, children);\n }\n }]);\n\n return OrderedListBlockNode;\n}(BlockNode);\n\nexports.OrderedListBlockNode = OrderedListBlockNode;\n\nvar ListBlockNode =\n/*#__PURE__*/\nfunction (_BlockNode4) {\n _inherits(ListBlockNode, _BlockNode4);\n\n function ListBlockNode(block, children) {\n _classCallCheck(this, ListBlockNode);\n\n return _possibleConstructorReturn(this, _getPrototypeOf(ListBlockNode).call(this, _types.NODE_TYPES.list, block, children));\n }\n\n _createClass(ListBlockNode, [{\n key: \"addChild\",\n value: function addChild(node) {\n var children = this.children.concat(node);\n return new ListBlockNode(this.element, children);\n }\n }]);\n\n return ListBlockNode;\n}(BlockNode);\n\nexports.ListBlockNode = ListBlockNode;\n\n//# sourceURL=webpack://PrismicRichtext/./src/nodes.ts?");
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.ListBlockNode = exports.OrderedListBlockNode = exports.OrderedListItemBlockNode = exports.ListItemBlockNode = exports.BlockNode = exports.TextNode = exports.SpanNode = exports.Node = void 0;\n\nvar _uuid = _interopRequireDefault(__webpack_require__(/*! ./uuid */ \"./src/uuid.ts\"));\n\nvar _types = __webpack_require__(/*! ./types */ \"./src/types.ts\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _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); }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper2(Derived) {\n function isNativeReflectConstruct() {\n if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n if (Reflect.construct.sham) return false;\n if (typeof Proxy === \"function\") return true;\n\n try {\n Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));\n return true;\n } catch (e) {\n return false;\n }\n }\n\n return function () {\n var Super = _getPrototypeOf(Derived),\n result;\n\n if (isNativeReflectConstruct()) {\n var NewTarget = _getPrototypeOf(this).constructor;\n\n result = Reflect.construct(Super, arguments, NewTarget);\n } else {\n result = Super.apply(this, arguments);\n }\n\n return _possibleConstructorReturn(this, result);\n };\n}\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar Node = function Node(type, element, children) {\n _classCallCheck(this, Node);\n\n this.key = (0, _uuid.default)();\n this.type = type;\n this.element = element;\n this.children = children;\n};\n\nexports.Node = Node;\n\nvar SpanNode =\n/*#__PURE__*/\nfunction (_Node) {\n _inherits(SpanNode, _Node);\n\n var _super = _createSuper2(SpanNode);\n\n function SpanNode(start, end, type, text, children, element) {\n var _this;\n\n _classCallCheck(this, SpanNode);\n\n _this = _super.call(this, type, element, children);\n _this.start = start;\n _this.end = end;\n _this.text = text;\n _this.children = children;\n return _this;\n }\n\n _createClass(SpanNode, [{\n key: \"boundaries\",\n value: function boundaries() {\n return {\n lower: this.start,\n upper: this.end\n };\n }\n }, {\n key: \"isParentOf\",\n value: function isParentOf(node) {\n return this.start <= node.start && this.end >= node.end;\n }\n }, {\n key: \"setChildren\",\n value: function setChildren(children) {\n return new SpanNode(this.start, this.end, this.type, this.text, children, this.element);\n }\n }], [{\n key: \"slice\",\n value: function slice(node, start, end, text) {\n return new SpanNode(start, end, node.type, text.slice(start, end), node.children, node.element);\n }\n }]);\n\n return SpanNode;\n}(Node);\n\nexports.SpanNode = SpanNode;\n\nvar TextNode =\n/*#__PURE__*/\nfunction (_SpanNode) {\n _inherits(TextNode, _SpanNode);\n\n var _super2 = _createSuper2(TextNode);\n\n function TextNode(start, end, text) {\n _classCallCheck(this, TextNode);\n\n var element = {\n type: _types.NODE_TYPES.span,\n start: start,\n end: end,\n text: text\n };\n return _super2.call(this, start, end, _types.NODE_TYPES.span, text, [], element);\n }\n\n return TextNode;\n}(SpanNode);\n\nexports.TextNode = TextNode;\n\nvar BlockNode =\n/*#__PURE__*/\nfunction (_Node2) {\n _inherits(BlockNode, _Node2);\n\n var _super3 = _createSuper2(BlockNode);\n\n function BlockNode(type, block) {\n var children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];\n\n _classCallCheck(this, BlockNode);\n\n return _super3.call(this, type, block, children);\n }\n\n return BlockNode;\n}(Node);\n\nexports.BlockNode = BlockNode;\n\nvar ListItemBlockNode =\n/*#__PURE__*/\nfunction (_BlockNode) {\n _inherits(ListItemBlockNode, _BlockNode);\n\n var _super4 = _createSuper2(ListItemBlockNode);\n\n function ListItemBlockNode(block, children) {\n _classCallCheck(this, ListItemBlockNode);\n\n return _super4.call(this, _types.NODE_TYPES.listItem, block, children);\n }\n\n return ListItemBlockNode;\n}(BlockNode);\n\nexports.ListItemBlockNode = ListItemBlockNode;\n\nvar OrderedListItemBlockNode =\n/*#__PURE__*/\nfunction (_BlockNode2) {\n _inherits(OrderedListItemBlockNode, _BlockNode2);\n\n var _super5 = _createSuper2(OrderedListItemBlockNode);\n\n function OrderedListItemBlockNode(block, children) {\n _classCallCheck(this, OrderedListItemBlockNode);\n\n return _super5.call(this, _types.NODE_TYPES.oListItem, block, children);\n }\n\n return OrderedListItemBlockNode;\n}(BlockNode);\n\nexports.OrderedListItemBlockNode = OrderedListItemBlockNode;\n\nvar OrderedListBlockNode =\n/*#__PURE__*/\nfunction (_BlockNode3) {\n _inherits(OrderedListBlockNode, _BlockNode3);\n\n var _super6 = _createSuper2(OrderedListBlockNode);\n\n function OrderedListBlockNode(block, children) {\n _classCallCheck(this, OrderedListBlockNode);\n\n return _super6.call(this, _types.NODE_TYPES.oList, block, children);\n }\n\n _createClass(OrderedListBlockNode, [{\n key: \"addChild\",\n value: function addChild(node) {\n var children = this.children.concat(node);\n return new OrderedListBlockNode(this.element, children);\n }\n }]);\n\n return OrderedListBlockNode;\n}(BlockNode);\n\nexports.OrderedListBlockNode = OrderedListBlockNode;\n\nvar ListBlockNode =\n/*#__PURE__*/\nfunction (_BlockNode4) {\n _inherits(ListBlockNode, _BlockNode4);\n\n var _super7 = _createSuper2(ListBlockNode);\n\n function ListBlockNode(block, children) {\n _classCallCheck(this, ListBlockNode);\n\n return _super7.call(this, _types.NODE_TYPES.list, block, children);\n }\n\n _createClass(ListBlockNode, [{\n key: \"addChild\",\n value: function addChild(node) {\n var children = this.children.concat(node);\n return new ListBlockNode(this.element, children);\n }\n }]);\n\n return ListBlockNode;\n}(BlockNode);\n\nexports.ListBlockNode = ListBlockNode;\n\n//# sourceURL=webpack://PrismicRichtext/./src/nodes.ts?");

@@ -180,3 +180,3 @@ /***/ }),

"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _helpers = __webpack_require__(/*! ./helpers */ \"./src/helpers.ts\");\n\nvar _nodes = __webpack_require__(/*! ./nodes */ \"./src/nodes.ts\");\n\nvar _richtext = __webpack_require__(/*! ./richtext */ \"./src/richtext.ts\");\n\nvar _types = __webpack_require__(/*! ./types */ \"./src/types.ts\");\n\nvar _uuid = _interopRequireDefault(__webpack_require__(/*! ./uuid */ \"./src/uuid.ts\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction sortByPriorities(nodes) {\n return nodes.sort(function (nodeA, nodeB) {\n if (nodeA.isParentOf(nodeB)) {\n return -1;\n } else if (nodeB.isParentOf(nodeA)) {\n return 1;\n } else {\n var result = _types.PRIORITIES[nodeA.type] - _types.PRIORITIES[nodeB.type];\n return result === 0 ? nodeA.text.length - nodeB.text.length : result;\n }\n });\n}\n\nfunction sliceNode(text, elected, node) {\n if (node.start < elected.start) {\n return {\n inner: _nodes.SpanNode.slice(node, elected.start, node.end, text),\n outer: _nodes.SpanNode.slice(node, node.start, elected.start, text)\n };\n } else if (node.end > elected.end) {\n return {\n inner: _nodes.SpanNode.slice(node, node.start, elected.end, text),\n outer: _nodes.SpanNode.slice(node, elected.end, node.end, text)\n };\n } else {\n return {\n inner: node\n };\n }\n}\n\nfunction partitionGroup(text, group) {\n var partitioned = group.others.reduce(function (_ref, node) {\n var innerAcc = _ref.inner,\n outerAcc = _ref.outer;\n var slicedNode = sliceNode(text, group.elected, node);\n return {\n inner: innerAcc.concat(slicedNode.inner),\n outer: slicedNode.outer ? outerAcc.concat(slicedNode.outer) : outerAcc\n };\n }, {\n inner: [],\n outer: []\n });\n var inner = partitioned.inner,\n outer = partitioned.outer;\n var head = group.elected.setChildren(buildTreeAndFill(text, inner, group.elected.boundaries()));\n return [head].concat(buildTree(text, outer));\n}\n\nfunction groupWith(p, nodes) {\n return nodes.reduce(function (groups, node) {\n var previousGroup = (0, _helpers.last)(groups);\n\n if (previousGroup) {\n var included = previousGroup.some(function (nodeGroup) {\n return nodeGroup.isParentOf(node);\n });\n\n if (included) {\n return (0, _helpers.init)(groups).concat([previousGroup.concat(node)]);\n } else {\n var previousNode = (0, _helpers.last)(previousGroup);\n\n if (previousNode && p(previousNode, node)) {\n return (0, _helpers.init)(groups).concat([previousGroup.concat(node)]);\n } else {\n return groups.concat([[node]]);\n }\n }\n } else {\n return [[node]];\n }\n }, []);\n}\n\nfunction groupNodes(nodes) {\n var sortByStart = function sortByStart(nodeA, nodeB) {\n return nodeA.start - nodeB.start;\n };\n\n var sortByEnd = function sortByEnd(nodeA, nodeB) {\n return nodeA.end - nodeB.end;\n };\n\n var sortedNodes = (0, _helpers.sort)(nodes, function (a, b) {\n return sortByStart(a, b) || sortByEnd(a, b);\n });\n return groupWith(function (nodeA, nodeB) {\n return nodeA.end >= nodeB.start;\n }, sortedNodes);\n}\n\nfunction electNode(candidates) {\n if (candidates.length === 0) {\n throw new Error(\"Unable to elect node on empty list\");\n } else {\n var _sortByPriorities = sortByPriorities(candidates),\n _sortByPriorities2 = _toArray(_sortByPriorities),\n elected = _sortByPriorities2[0],\n others = _sortByPriorities2.slice(1);\n\n return {\n elected: elected,\n others: others\n };\n }\n}\n\nfunction fill(text, nodes, boundaries) {\n return nodes.reduce(function (acc, node, index) {\n var result = [];\n var fillStart = index === 0 && node.start > boundaries.lower;\n var fillEnd = index === nodes.length - 1 && boundaries.upper > node.end;\n\n if (fillStart) {\n var textNode = new _nodes.TextNode(boundaries.lower, node.start, text.slice(boundaries.lower, node.start));\n result = result.concat(textNode);\n } else {\n var previousNode = nodes[index - 1];\n\n if (previousNode) {\n if (node.start > previousNode.end) {\n var subtext = text.slice(previousNode.end, node.start);\n\n var _textNode = new _nodes.TextNode(previousNode.end, node.start, subtext);\n\n result = result.concat(_textNode);\n }\n }\n }\n\n result = result.concat(node);\n\n if (fillEnd) {\n var _textNode2 = new _nodes.TextNode(node.end, boundaries.upper, text.slice(node.end, boundaries.upper));\n\n result = result.concat(_textNode2);\n }\n\n return acc.concat(result);\n }, []);\n}\n\nfunction buildTreeAndFill(text, nodes, boundaries) {\n if (nodes.length > 0) {\n var tree = buildTree(text, nodes);\n return fill(text, tree, boundaries);\n } else {\n var subtext = text.slice(boundaries.lower, boundaries.upper);\n return [new _nodes.TextNode(boundaries.lower, boundaries.upper, subtext)];\n }\n}\n\nfunction buildTree(text, nodes) {\n var sortedNodes = (0, _helpers.sort)(nodes, function (a, b) {\n return a.start - b.start;\n });\n var groups = groupNodes(sortedNodes);\n var postElection = groups.map(electNode);\n var tree = (0, _helpers.flatten)(postElection.map(function (group) {\n return partitionGroup(text, group);\n }));\n return (0, _helpers.sort)(tree, function (a, b) {\n return a.start - b.start;\n });\n}\n\nfunction processTextBlock(block) {\n var nodes = (block.spans || []).map(function (span) {\n var text = block.text.slice(span.start, span.end);\n return new _nodes.SpanNode(span.start, span.end, span.type, text, [], span);\n });\n var boundaries = {\n lower: 0,\n upper: block.text.length\n };\n return buildTreeAndFill(block.text, nodes, boundaries);\n}\n\nvar Tree =\n/*#__PURE__*/\nfunction () {\n function Tree() {\n _classCallCheck(this, Tree);\n }\n\n _createClass(Tree, null, [{\n key: \"fromRichText\",\n value: function fromRichText(richText) {\n return {\n key: (0, _uuid.default)(),\n children: richText.reduce(function (acc, block, index) {\n if (_richtext.RichTextBlock.isEmbedBlock(block.type) || _richtext.RichTextBlock.isImageBlock(block.type)) {\n return acc.concat(new _nodes.BlockNode(block.type, block));\n } else {\n var textNodes = processTextBlock(block);\n var previousBlock = acc[acc.length - 1];\n\n if (_richtext.RichTextBlock.isListItem(block.type) && previousBlock && previousBlock instanceof _nodes.ListBlockNode) {\n var listItem = new _nodes.ListItemBlockNode(block, textNodes);\n var updatedPreviousBlock = previousBlock.addChild(listItem);\n return (0, _helpers.init)(acc).concat(updatedPreviousBlock);\n } else if (_richtext.RichTextBlock.isOrderedListItem(block.type) && previousBlock && previousBlock instanceof _nodes.OrderedListBlockNode) {\n var orderedListItem = new _nodes.OrderedListItemBlockNode(block, textNodes);\n\n var _updatedPreviousBlock = previousBlock.addChild(orderedListItem);\n\n return (0, _helpers.init)(acc).concat(_updatedPreviousBlock);\n } else if (_richtext.RichTextBlock.isListItem(block.type)) {\n var _listItem = new _nodes.ListItemBlockNode(block, textNodes);\n\n var list = new _nodes.ListBlockNode(_richtext.RichTextBlock.emptyList(), [_listItem]);\n return acc.concat(list);\n } else if (_richtext.RichTextBlock.isOrderedListItem(block.type)) {\n var _orderedListItem = new _nodes.OrderedListItemBlockNode(block, textNodes);\n\n var orderedList = new _nodes.OrderedListBlockNode(_richtext.RichTextBlock.emptyOrderedList(), [_orderedListItem]);\n return acc.concat(orderedList);\n } else {\n return acc.concat(new _nodes.BlockNode(block.type, block, textNodes));\n }\n }\n }, [])\n };\n }\n }]);\n\n return Tree;\n}();\n\nexports.default = Tree;\n\n//# sourceURL=webpack://PrismicRichtext/./src/tree.ts?");
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _helpers = __webpack_require__(/*! ./helpers */ \"./src/helpers.ts\");\n\nvar _nodes = __webpack_require__(/*! ./nodes */ \"./src/nodes.ts\");\n\nvar _richtext = __webpack_require__(/*! ./richtext */ \"./src/richtext.ts\");\n\nvar _types = __webpack_require__(/*! ./types */ \"./src/types.ts\");\n\nvar _uuid = _interopRequireDefault(__webpack_require__(/*! ./uuid */ \"./src/uuid.ts\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction sortByPriorities(nodes) {\n return nodes.sort(function (nodeA, nodeB) {\n if (nodeA.isParentOf(nodeB)) {\n return -1;\n } else if (nodeB.isParentOf(nodeA)) {\n return 1;\n } else {\n var result = _types.PRIORITIES[nodeA.type] - _types.PRIORITIES[nodeB.type];\n return result === 0 ? nodeA.text.length - nodeB.text.length : result;\n }\n });\n}\n\nfunction sliceNode(text, elected, node) {\n if (node.start < elected.start) {\n return {\n inner: _nodes.SpanNode.slice(node, elected.start, node.end, text),\n outer: _nodes.SpanNode.slice(node, node.start, elected.start, text)\n };\n } else if (node.end > elected.end) {\n return {\n inner: _nodes.SpanNode.slice(node, node.start, elected.end, text),\n outer: _nodes.SpanNode.slice(node, elected.end, node.end, text)\n };\n } else {\n return {\n inner: node\n };\n }\n}\n\nfunction partitionGroup(text, group) {\n var partitioned = group.others.reduce(function (_ref, node) {\n var innerAcc = _ref.inner,\n outerAcc = _ref.outer;\n var slicedNode = sliceNode(text, group.elected, node);\n return {\n inner: innerAcc.concat(slicedNode.inner),\n outer: slicedNode.outer ? outerAcc.concat(slicedNode.outer) : outerAcc\n };\n }, {\n inner: [],\n outer: []\n });\n var inner = partitioned.inner,\n outer = partitioned.outer;\n var head = group.elected.setChildren(buildTreeAndFill(text, inner, group.elected.boundaries()));\n return [head].concat(buildTree(text, outer));\n}\n\nfunction groupWith(p, nodes) {\n return nodes.reduce(function (groups, node) {\n var previousGroup = (0, _helpers.last)(groups);\n\n if (previousGroup) {\n var included = previousGroup.some(function (nodeGroup) {\n return nodeGroup.isParentOf(node);\n });\n\n if (included) {\n return (0, _helpers.init)(groups).concat([previousGroup.concat(node)]);\n } else {\n var previousNode = (0, _helpers.last)(previousGroup);\n\n if (previousNode && p(previousNode, node)) {\n return (0, _helpers.init)(groups).concat([previousGroup.concat(node)]);\n } else {\n return groups.concat([[node]]);\n }\n }\n } else {\n return [[node]];\n }\n }, []);\n}\n\nfunction groupNodes(nodes) {\n var sortByStart = function sortByStart(nodeA, nodeB) {\n return nodeA.start - nodeB.start;\n };\n\n var sortByEnd = function sortByEnd(nodeA, nodeB) {\n return nodeA.end - nodeB.end;\n };\n\n var sortedNodes = (0, _helpers.sort)(nodes, function (a, b) {\n return sortByStart(a, b) || sortByEnd(a, b);\n });\n return groupWith(function (nodeA, nodeB) {\n return nodeA.end >= nodeB.start;\n }, sortedNodes);\n}\n\nfunction electNode(candidates) {\n if (candidates.length === 0) {\n throw new Error(\"Unable to elect node on empty list\");\n } else {\n var _sortByPriorities = sortByPriorities(candidates),\n _sortByPriorities2 = _toArray(_sortByPriorities),\n _elected = _sortByPriorities2[0],\n _others = _sortByPriorities2.slice(1);\n\n return {\n elected: _elected,\n others: _others\n };\n }\n}\n\nfunction fill(text, nodes, boundaries) {\n return nodes.reduce(function (acc, node, index) {\n var result = [];\n var fillStart = index === 0 && node.start > boundaries.lower;\n var fillEnd = index === nodes.length - 1 && boundaries.upper > node.end;\n\n if (fillStart) {\n var textNode = new _nodes.TextNode(boundaries.lower, node.start, text.slice(boundaries.lower, node.start));\n result = result.concat(textNode);\n } else {\n var previousNode = nodes[index - 1];\n\n if (previousNode) {\n if (node.start > previousNode.end) {\n var subtext = text.slice(previousNode.end, node.start);\n\n var _textNode = new _nodes.TextNode(previousNode.end, node.start, subtext);\n\n result = result.concat(_textNode);\n }\n }\n }\n\n result = result.concat(node);\n\n if (fillEnd) {\n var _textNode2 = new _nodes.TextNode(node.end, boundaries.upper, text.slice(node.end, boundaries.upper));\n\n result = result.concat(_textNode2);\n }\n\n return acc.concat(result);\n }, []);\n}\n\nfunction buildTreeAndFill(text, nodes, boundaries) {\n if (nodes.length > 0) {\n var tree = buildTree(text, nodes);\n return fill(text, tree, boundaries);\n } else {\n var subtext = text.slice(boundaries.lower, boundaries.upper);\n return [new _nodes.TextNode(boundaries.lower, boundaries.upper, subtext)];\n }\n}\n\nfunction buildTree(text, nodes) {\n var sortedNodes = (0, _helpers.sort)(nodes, function (a, b) {\n return a.start - b.start;\n });\n var groups = groupNodes(sortedNodes);\n var postElection = groups.map(electNode);\n var tree = (0, _helpers.flatten)(postElection.map(function (group) {\n return partitionGroup(text, group);\n }));\n return (0, _helpers.sort)(tree, function (a, b) {\n return a.start - b.start;\n });\n}\n\nfunction processTextBlock(block) {\n var nodes = (block.spans || []).map(function (span) {\n var text = block.text.slice(span.start, span.end);\n return new _nodes.SpanNode(span.start, span.end, span.type, text, [], span);\n });\n var boundaries = {\n lower: 0,\n upper: block.text.length\n };\n return buildTreeAndFill(block.text, nodes, boundaries);\n}\n\nvar Tree =\n/*#__PURE__*/\nfunction () {\n function Tree() {\n _classCallCheck(this, Tree);\n }\n\n _createClass(Tree, null, [{\n key: \"fromRichText\",\n value: function fromRichText(richText) {\n return {\n key: (0, _uuid.default)(),\n children: richText.reduce(function (acc, block, index) {\n if (_richtext.RichTextBlock.isEmbedBlock(block.type) || _richtext.RichTextBlock.isImageBlock(block.type)) {\n return acc.concat(new _nodes.BlockNode(block.type, block));\n } else {\n var textNodes = processTextBlock(block);\n var previousBlock = acc[acc.length - 1];\n\n if (_richtext.RichTextBlock.isListItem(block.type) && previousBlock && previousBlock instanceof _nodes.ListBlockNode) {\n var listItem = new _nodes.ListItemBlockNode(block, textNodes);\n var updatedPreviousBlock = previousBlock.addChild(listItem);\n return (0, _helpers.init)(acc).concat(updatedPreviousBlock);\n } else if (_richtext.RichTextBlock.isOrderedListItem(block.type) && previousBlock && previousBlock instanceof _nodes.OrderedListBlockNode) {\n var orderedListItem = new _nodes.OrderedListItemBlockNode(block, textNodes);\n\n var _updatedPreviousBlock = previousBlock.addChild(orderedListItem);\n\n return (0, _helpers.init)(acc).concat(_updatedPreviousBlock);\n } else if (_richtext.RichTextBlock.isListItem(block.type)) {\n var _listItem = new _nodes.ListItemBlockNode(block, textNodes);\n\n var list = new _nodes.ListBlockNode(_richtext.RichTextBlock.emptyList(), [_listItem]);\n return acc.concat(list);\n } else if (_richtext.RichTextBlock.isOrderedListItem(block.type)) {\n var _orderedListItem = new _nodes.OrderedListItemBlockNode(block, textNodes);\n\n var orderedList = new _nodes.OrderedListBlockNode(_richtext.RichTextBlock.emptyOrderedList(), [_orderedListItem]);\n return acc.concat(orderedList);\n } else {\n return acc.concat(new _nodes.BlockNode(block.type, block, textNodes));\n }\n }\n }, [])\n };\n }\n }]);\n\n return Tree;\n}();\n\nexports.default = Tree;\n\n//# sourceURL=webpack://PrismicRichtext/./src/tree.ts?");

@@ -216,3 +216,3 @@ /***/ }),

eval("module.exports = __webpack_require__(/*! /Users/hvillain/lerna-tutorial/packages/prismic-richtext/src/index.ts */\"./src/index.ts\");\n\n\n//# sourceURL=webpack://PrismicRichtext/multi_./src/index.ts?");
eval("module.exports = __webpack_require__(/*! /Users/hvillain/Libs/prismic-richtext/src/index.ts */\"./src/index.ts\");\n\n\n//# sourceURL=webpack://PrismicRichtext/multi_./src/index.ts?");

@@ -219,0 +219,0 @@ /***/ })

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("PrismicRichtext",[],t):"object"==typeof exports?exports.PrismicRichtext=t():e.PrismicRichtext=t()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t,n){"use strict";var r;function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Object.defineProperty(t,"__esModule",{value:!0}),t.PRIORITIES=t.NODE_TYPES=void 0;var o={heading1:"heading1",heading2:"heading2",heading3:"heading3",heading4:"heading4",heading5:"heading5",heading6:"heading6",paragraph:"paragraph",preformatted:"preformatted",strong:"strong",em:"em",listItem:"list-item",oListItem:"o-list-item",list:"group-list-item",oList:"group-o-list-item",image:"image",embed:"embed",hyperlink:"hyperlink",label:"label",span:"span"};t.NODE_TYPES=o;var u=(i(r={},o.heading1,4),i(r,o.heading2,4),i(r,o.heading3,4),i(r,o.heading4,4),i(r,o.heading5,4),i(r,o.heading6,4),i(r,o.paragraph,3),i(r,o.preformatted,5),i(r,o.strong,6),i(r,o.em,6),i(r,o.oList,1),i(r,o.list,1),i(r,o.listItem,1),i(r,o.oListItem,1),i(r,o.image,1),i(r,o.embed,1),i(r,o.hyperlink,3),i(r,o.label,4),i(r,o.span,7),r);t.PRIORITIES=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,i=n(7),o=n(2),u=n(8),a=n(0),c=(r=n(3))&&r.__esModule?r:{default:r};function l(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function f(e,t){var n=t.others.reduce(function(n,r){var i=n.inner,u=n.outer,a=function(e,t,n){return n.start<t.start?{inner:o.SpanNode.slice(n,t.start,n.end,e),outer:o.SpanNode.slice(n,n.start,t.start,e)}:n.end>t.end?{inner:o.SpanNode.slice(n,n.start,t.end,e),outer:o.SpanNode.slice(n,t.end,n.end,e)}:{inner:n}}(e,t.elected,r);return{inner:i.concat(a.inner),outer:a.outer?u.concat(a.outer):u}},{inner:[],outer:[]}),r=n.inner,i=n.outer;return[t.elected.setChildren(h(e,r,t.elected.boundaries()))].concat(y(e,i))}function d(e){return function(e,t){return t.reduce(function(t,n){var r=(0,i.last)(t);if(r){if(r.some(function(e){return e.isParentOf(n)}))return(0,i.init)(t).concat([r.concat(n)]);var o=(0,i.last)(r);return o&&e(o,n)?(0,i.init)(t).concat([r.concat(n)]):t.concat([[n]])}return[[n]]},[])}(function(e,t){return e.end>=t.start},(0,i.sort)(e,function(e,t){return n=t,e.start-n.start||function(e,t){return e.end-t.end}(e,t);var n}))}function p(e){if(0===e.length)throw new Error("Unable to elect node on empty list");var t=s(e.sort(function(e,t){if(e.isParentOf(t))return-1;if(t.isParentOf(e))return 1;var n=a.PRIORITIES[e.type]-a.PRIORITIES[t.type];return 0===n?e.text.length-t.text.length:n}));return{elected:t[0],others:t.slice(1)}}function h(e,t,n){if(t.length>0)return function(e,t,n){return t.reduce(function(r,i,u){var a=[],c=0===u&&i.start>n.lower,l=u===t.length-1&&n.upper>i.end;if(c){var s=new o.TextNode(n.lower,i.start,e.slice(n.lower,i.start));a=a.concat(s)}else{var f=t[u-1];if(f&&i.start>f.end){var d=e.slice(f.end,i.start),p=new o.TextNode(f.end,i.start,d);a=a.concat(p)}}if(a=a.concat(i),l){var h=new o.TextNode(i.end,n.upper,e.slice(i.end,n.upper));a=a.concat(h)}return r.concat(a)},[])}(e,y(e,t),n);var r=e.slice(n.lower,n.upper);return[new o.TextNode(n.lower,n.upper,r)]}function y(e,t){var n=d((0,i.sort)(t,function(e,t){return e.start-t.start})).map(p),r=(0,i.flatten)(n.map(function(t){return f(e,t)}));return(0,i.sort)(r,function(e,t){return e.start-t.start})}var v=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,r;return t=e,r=[{key:"fromRichText",value:function(e){return{key:(0,c.default)(),children:e.reduce(function(e,t,n){if(u.RichTextBlock.isEmbedBlock(t.type)||u.RichTextBlock.isImageBlock(t.type))return e.concat(new o.BlockNode(t.type,t));var r=function(e){var t=(e.spans||[]).map(function(t){var n=e.text.slice(t.start,t.end);return new o.SpanNode(t.start,t.end,t.type,n,[],t)}),n={lower:0,upper:e.text.length};return h(e.text,t,n)}(t),a=e[e.length-1];if(u.RichTextBlock.isListItem(t.type)&&a&&a instanceof o.ListBlockNode){var c=new o.ListItemBlockNode(t,r),l=a.addChild(c);return(0,i.init)(e).concat(l)}if(u.RichTextBlock.isOrderedListItem(t.type)&&a&&a instanceof o.OrderedListBlockNode){var s=new o.OrderedListItemBlockNode(t,r),f=a.addChild(s);return(0,i.init)(e).concat(f)}if(u.RichTextBlock.isListItem(t.type)){var d=new o.ListItemBlockNode(t,r),p=new o.ListBlockNode(u.RichTextBlock.emptyList(),[d]);return e.concat(p)}if(u.RichTextBlock.isOrderedListItem(t.type)){var y=new o.OrderedListItemBlockNode(t,r),v=new o.OrderedListBlockNode(u.RichTextBlock.emptyOrderedList(),[y]);return e.concat(v)}return e.concat(new o.BlockNode(t.type,t,r))},[])}}}],(n=null)&&l(t.prototype,n),r&&l(t,r),e}();t.default=v},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ListBlockNode=t.OrderedListBlockNode=t.OrderedListItemBlockNode=t.ListItemBlockNode=t.BlockNode=t.TextNode=t.SpanNode=t.Node=void 0;var r,i=(r=n(3))&&r.__esModule?r:{default:r},o=n(0);function u(e){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),e}function l(e,t){return!t||"object"!==u(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&d(e,t)}function d(e,t){return(d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var h=function e(t,n,r){p(this,e),this.key=(0,i.default)(),this.type=t,this.element=n,this.children=r};t.Node=h;var y=function(e){function t(e,n,r,i,o,u){var a;return p(this,t),(a=l(this,s(t).call(this,r,u,o))).start=e,a.end=n,a.text=i,a.children=o,a}return f(t,h),c(t,[{key:"boundaries",value:function(){return{lower:this.start,upper:this.end}}},{key:"isParentOf",value:function(e){return this.start<=e.start&&this.end>=e.end}},{key:"setChildren",value:function(e){return new t(this.start,this.end,this.type,this.text,e,this.element)}}],[{key:"slice",value:function(e,n,r,i){return new t(n,r,e.type,i.slice(n,r),e.children,e.element)}}]),t}();t.SpanNode=y;var v=function(e){function t(e,n,r){p(this,t);var i={type:o.NODE_TYPES.span,start:e,end:n,text:r};return l(this,s(t).call(this,e,n,o.NODE_TYPES.span,r,[],i))}return f(t,y),t}();t.TextNode=v;var m=function(e){function t(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return p(this,t),l(this,s(t).call(this,e,n,r))}return f(t,h),t}();t.BlockNode=m;var b=function(e){function t(e,n){return p(this,t),l(this,s(t).call(this,o.NODE_TYPES.listItem,e,n))}return f(t,m),t}();t.ListItemBlockNode=b;var x=function(e){function t(e,n){return p(this,t),l(this,s(t).call(this,o.NODE_TYPES.oListItem,e,n))}return f(t,m),t}();t.OrderedListItemBlockNode=x;var O=function(e){function t(e,n){return p(this,t),l(this,s(t).call(this,o.NODE_TYPES.oList,e,n))}return f(t,m),c(t,[{key:"addChild",value:function(e){var n=this.children.concat(e);return new t(this.element,n)}}]),t}();t.OrderedListBlockNode=O;var g=function(e){function t(e,n){return p(this,t),l(this,s(t).call(this,o.NODE_TYPES.list,e,n))}return f(t,m),c(t,[{key:"addChild",value:function(e){var n=this.children.concat(e);return new t(this.element,n)}}]),t}();t.ListBlockNode=g},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?n:3&n|8).toString(16)})}},function(e,t,n){e.exports=n(5)},function(e,t,n){"use strict";var r=a(n(6)),i=a(n(1)),o=a(n(9)),u=n(0);function a(e){return e&&e.__esModule?e:{default:e}}e.exports={asText:r.default,asTree:i.default.fromRichText,serialize:o.default,Elements:u.NODE_TYPES}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function(e,t){var n="string"==typeof t?t:" ";return e.map(function(e){return e.text}).join(n)};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.init=function(e){return e.slice(0,-1)},t.last=function(e){return e[e.length-1]},t.flatten=function(e){var t=[],n=!0,r=!1,i=void 0;try{for(var o,u=e[Symbol.iterator]();!(n=(o=u.next()).done);n=!0){var a=o.value;Array.isArray(a)?t.push.apply(t,a):t.push(a)}}catch(e){r=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(r)throw i}}return t},t.sort=function(e,t){return function(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}(e).sort(t)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RichTextBlock=void 0;var r=n(0);function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=function(){function e(t,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.type=t,this.text=n,this.spans=r}var t,n,o;return t=e,o=[{key:"isEmbedBlock",value:function(e){return e===r.NODE_TYPES.embed}},{key:"isImageBlock",value:function(e){return e===r.NODE_TYPES.image}},{key:"isList",value:function(e){return e===r.NODE_TYPES.list}},{key:"isOrderedList",value:function(e){return e===r.NODE_TYPES.oList}},{key:"isListItem",value:function(e){return e===r.NODE_TYPES.listItem}},{key:"isOrderedListItem",value:function(e){return e===r.NODE_TYPES.oListItem}},{key:"emptyList",value:function(){return{type:r.NODE_TYPES.list,spans:[],text:""}}},{key:"emptyOrderedList",value:function(){return{type:r.NODE_TYPES.oList,spans:[],text:""}}}],(n=null)&&i(t.prototype,n),o&&i(t,o),e}();t.RichTextBlock=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,i=(r=n(1))&&r.__esModule?r:{default:r},o=n(2);var u=function(e,t,n){return i.default.fromRichText(e).children.map(function(e,r){return function(e,t,n,r){return function e(n,i){var u=n instanceof o.SpanNode?n.text:null,a=n.children.reduce(function(t,n,r){return t.concat([e(n,r)])},[]),c=r&&r(n.type,n.element,u,a,i);return c||t(n.type,n.element,u,a,i)}(e,n)}(e,t,r,n)})};t.default=u}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("PrismicRichtext",[],t):"object"==typeof exports?exports.PrismicRichtext=t():e.PrismicRichtext=t()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t,n){"use strict";var r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Object.defineProperty(t,"__esModule",{value:!0}),t.PRIORITIES=t.NODE_TYPES=void 0;var i={heading1:"heading1",heading2:"heading2",heading3:"heading3",heading4:"heading4",heading5:"heading5",heading6:"heading6",paragraph:"paragraph",preformatted:"preformatted",strong:"strong",em:"em",listItem:"list-item",oListItem:"o-list-item",list:"group-list-item",oList:"group-o-list-item",image:"image",embed:"embed",hyperlink:"hyperlink",label:"label",span:"span"};t.NODE_TYPES=i;var u=(o(r={},i.heading1,4),o(r,i.heading2,4),o(r,i.heading3,4),o(r,i.heading4,4),o(r,i.heading5,4),o(r,i.heading6,4),o(r,i.paragraph,3),o(r,i.preformatted,5),o(r,i.strong,6),o(r,i.em,6),o(r,i.oList,1),o(r,i.list,1),o(r,i.listItem,1),o(r,i.oListItem,1),o(r,i.image,1),o(r,i.embed,1),o(r,i.hyperlink,3),o(r,i.label,4),o(r,i.span,7),r);t.PRIORITIES=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,o=n(7),i=n(2),u=n(8),c=n(0),a=(r=n(3))&&r.__esModule?r:{default:r};function l(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function f(e,t){var n=t.others.reduce(function(n,r){var o=n.inner,u=n.outer,c=function(e,t,n){return n.start<t.start?{inner:i.SpanNode.slice(n,t.start,n.end,e),outer:i.SpanNode.slice(n,n.start,t.start,e)}:n.end>t.end?{inner:i.SpanNode.slice(n,n.start,t.end,e),outer:i.SpanNode.slice(n,t.end,n.end,e)}:{inner:n}}(e,t.elected,r);return{inner:o.concat(c.inner),outer:c.outer?u.concat(c.outer):u}},{inner:[],outer:[]}),r=n.inner,o=n.outer;return[t.elected.setChildren(y(e,r,t.elected.boundaries()))].concat(h(e,o))}function d(e){return function(e,t){return t.reduce(function(t,n){var r=(0,o.last)(t);if(r){if(r.some(function(e){return e.isParentOf(n)}))return(0,o.init)(t).concat([r.concat(n)]);var i=(0,o.last)(r);return i&&e(i,n)?(0,o.init)(t).concat([r.concat(n)]):t.concat([[n]])}return[[n]]},[])}(function(e,t){return e.end>=t.start},(0,o.sort)(e,function(e,t){return n=t,e.start-n.start||function(e,t){return e.end-t.end}(e,t);var n}))}function p(e){if(0===e.length)throw new Error("Unable to elect node on empty list");var t=s(e.sort(function(e,t){if(e.isParentOf(t))return-1;if(t.isParentOf(e))return 1;var n=c.PRIORITIES[e.type]-c.PRIORITIES[t.type];return 0===n?e.text.length-t.text.length:n}));return{elected:t[0],others:t.slice(1)}}function y(e,t,n){if(t.length>0)return function(e,t,n){return t.reduce(function(r,o,u){var c=[],a=0===u&&o.start>n.lower,l=u===t.length-1&&n.upper>o.end;if(a){var s=new i.TextNode(n.lower,o.start,e.slice(n.lower,o.start));c=c.concat(s)}else{var f=t[u-1];if(f&&o.start>f.end){var d=e.slice(f.end,o.start),p=new i.TextNode(f.end,o.start,d);c=c.concat(p)}}if(c=c.concat(o),l){var y=new i.TextNode(o.end,n.upper,e.slice(o.end,n.upper));c=c.concat(y)}return r.concat(c)},[])}(e,h(e,t),n);var r=e.slice(n.lower,n.upper);return[new i.TextNode(n.lower,n.upper,r)]}function h(e,t){var n=d((0,o.sort)(t,function(e,t){return e.start-t.start})).map(p),r=(0,o.flatten)(n.map(function(t){return f(e,t)}));return(0,o.sort)(r,function(e,t){return e.start-t.start})}var v=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,r;return t=e,r=[{key:"fromRichText",value:function(e){return{key:(0,a.default)(),children:e.reduce(function(e,t,n){if(u.RichTextBlock.isEmbedBlock(t.type)||u.RichTextBlock.isImageBlock(t.type))return e.concat(new i.BlockNode(t.type,t));var r=function(e){var t=(e.spans||[]).map(function(t){var n=e.text.slice(t.start,t.end);return new i.SpanNode(t.start,t.end,t.type,n,[],t)}),n={lower:0,upper:e.text.length};return y(e.text,t,n)}(t),c=e[e.length-1];if(u.RichTextBlock.isListItem(t.type)&&c&&c instanceof i.ListBlockNode){var a=new i.ListItemBlockNode(t,r),l=c.addChild(a);return(0,o.init)(e).concat(l)}if(u.RichTextBlock.isOrderedListItem(t.type)&&c&&c instanceof i.OrderedListBlockNode){var s=new i.OrderedListItemBlockNode(t,r),f=c.addChild(s);return(0,o.init)(e).concat(f)}if(u.RichTextBlock.isListItem(t.type)){var d=new i.ListItemBlockNode(t,r),p=new i.ListBlockNode(u.RichTextBlock.emptyList(),[d]);return e.concat(p)}if(u.RichTextBlock.isOrderedListItem(t.type)){var h=new i.OrderedListItemBlockNode(t,r),v=new i.OrderedListBlockNode(u.RichTextBlock.emptyOrderedList(),[h]);return e.concat(v)}return e.concat(new i.BlockNode(t.type,t,r))},[])}}}],(n=null)&&l(t.prototype,n),r&&l(t,r),e}();t.default=v},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ListBlockNode=t.OrderedListBlockNode=t.OrderedListItemBlockNode=t.ListItemBlockNode=t.BlockNode=t.TextNode=t.SpanNode=t.Node=void 0;var r,o=(r=n(3))&&r.__esModule?r:{default:r},i=n(0);function u(e){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&c(e.prototype,t),n&&c(e,n),e}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e){return function(){var t,n=d(e);if(function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()){var r=d(this).constructor;t=Reflect.construct(n,arguments,r)}else t=n.apply(this,arguments);return function(e,t){if(t&&("object"===u(t)||"function"==typeof t))return t;return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,t)}}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var y=function e(t,n,r){p(this,e),this.key=(0,o.default)(),this.type=t,this.element=n,this.children=r};t.Node=y;var h=function(e){l(n,y);var t=f(n);function n(e,r,o,i,u,c){var a;return p(this,n),(a=t.call(this,o,c,u)).start=e,a.end=r,a.text=i,a.children=u,a}return a(n,[{key:"boundaries",value:function(){return{lower:this.start,upper:this.end}}},{key:"isParentOf",value:function(e){return this.start<=e.start&&this.end>=e.end}},{key:"setChildren",value:function(e){return new n(this.start,this.end,this.type,this.text,e,this.element)}}],[{key:"slice",value:function(e,t,r,o){return new n(t,r,e.type,o.slice(t,r),e.children,e.element)}}]),n}();t.SpanNode=h;var v=function(e){l(n,h);var t=f(n);function n(e,r,o){p(this,n);var u={type:i.NODE_TYPES.span,start:e,end:r,text:o};return t.call(this,e,r,i.NODE_TYPES.span,o,[],u)}return n}();t.TextNode=v;var m=function(e){l(n,y);var t=f(n);function n(e,r){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return p(this,n),t.call(this,e,r,o)}return n}();t.BlockNode=m;var b=function(e){l(n,m);var t=f(n);function n(e,r){return p(this,n),t.call(this,i.NODE_TYPES.listItem,e,r)}return n}();t.ListItemBlockNode=b;var x=function(e){l(n,m);var t=f(n);function n(e,r){return p(this,n),t.call(this,i.NODE_TYPES.oListItem,e,r)}return n}();t.OrderedListItemBlockNode=x;var O=function(e){l(n,m);var t=f(n);function n(e,r){return p(this,n),t.call(this,i.NODE_TYPES.oList,e,r)}return a(n,[{key:"addChild",value:function(e){var t=this.children.concat(e);return new n(this.element,t)}}]),n}();t.OrderedListBlockNode=O;var g=function(e){l(n,m);var t=f(n);function n(e,r){return p(this,n),t.call(this,i.NODE_TYPES.list,e,r)}return a(n,[{key:"addChild",value:function(e){var t=this.children.concat(e);return new n(this.element,t)}}]),n}();t.ListBlockNode=g},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?n:3&n|8).toString(16)})}},function(e,t,n){e.exports=n(5)},function(e,t,n){"use strict";var r=c(n(6)),o=c(n(1)),i=c(n(9)),u=n(0);function c(e){return e&&e.__esModule?e:{default:e}}e.exports={asText:r.default,asTree:o.default.fromRichText,serialize:i.default,Elements:u.NODE_TYPES}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function(e,t){var n="string"==typeof t?t:" ";return e.map(function(e){return e.text}).join(n)};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.init=function(e){return e.slice(0,-1)},t.last=function(e){return e[e.length-1]},t.flatten=function(e){var t=[],n=!0,r=!1,o=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done);n=!0){var c=i.value;Array.isArray(c)?t.push.apply(t,c):t.push(c)}}catch(e){r=!0,o=e}finally{try{n||null==u.return||u.return()}finally{if(r)throw o}}return t},t.sort=function(e,t){return function(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}(e).sort(t)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RichTextBlock=void 0;var r=n(0);function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=function(){function e(t,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.type=t,this.text=n,this.spans=r}var t,n,i;return t=e,i=[{key:"isEmbedBlock",value:function(e){return e===r.NODE_TYPES.embed}},{key:"isImageBlock",value:function(e){return e===r.NODE_TYPES.image}},{key:"isList",value:function(e){return e===r.NODE_TYPES.list}},{key:"isOrderedList",value:function(e){return e===r.NODE_TYPES.oList}},{key:"isListItem",value:function(e){return e===r.NODE_TYPES.listItem}},{key:"isOrderedListItem",value:function(e){return e===r.NODE_TYPES.oListItem}},{key:"emptyList",value:function(){return{type:r.NODE_TYPES.list,spans:[],text:""}}},{key:"emptyOrderedList",value:function(){return{type:r.NODE_TYPES.oList,spans:[],text:""}}}],(n=null)&&o(t.prototype,n),i&&o(t,i),e}();t.RichTextBlock=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,o=(r=n(1))&&r.__esModule?r:{default:r},i=n(2);var u=function(e,t,n){return o.default.fromRichText(e).children.map(function(e,r){return function(e,t,n,r){return function e(n,o){var u=n instanceof i.SpanNode?n.text:null,c=n.children.reduce(function(t,n,r){return t.concat([e(n,r)])},[]),a=r&&r(n.type,n.element,u,c,o);return a||t(n.type,n.element,u,c,o)}(e,n)}(e,t,r,n)})};t.default=u}])});
{
"name": "@prismicio/richtext",
"version": "1.0.6",
"version": "1.1.0",
"description": "Convert Rich Text raw data to generic tree to simplify serialization",

@@ -15,5 +15,2 @@ "main": "dist/prismic-richtext.min.js",

},
"publishConfig": {
"access": "public"
},
"repository": {

@@ -34,3 +31,2 @@ "type": "git",

"@babel/preset-typescript": "^7.1.0",
"@prismicio/alpha": "^1.0.1",
"@types/node": "^12.7.5",

@@ -51,4 +47,3 @@ "@types/ramda": "0.25.44",

"yargs": "^10.0.3"
},
"gitHead": "9e8521270bceff5032ab3015ba6e699894fb5976"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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

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

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

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc