From be808f3a21fef7354c33ffb97faee827215100a2 Mon Sep 17 00:00:00 2001 From: Abrahem Alhofe Date: Wed, 22 Jul 2020 12:58:13 +0200 Subject: [PATCH] fix issue not convert   to space in data items --- dist/bundle.js | 158 ++++++++++++++++++++++++++++++++++++++++++++++++- src/index.js | 4 +- 2 files changed, 159 insertions(+), 3 deletions(-) diff --git a/dist/bundle.js b/dist/bundle.js index 1b40c801..a96ee0a3 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -1 +1,157 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.List=t():e.List=t()}(window,(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=0)}([function(e,t,n){function r(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n ',default:!1},{name:"ordered",title:this.api.i18n.t("Ordered"),icon:'',default:!0}],this._data={style:this.settings.find((function(e){return!0===e.default})).name,items:[]},this.data=n}return o(e,null,[{key:"enableLineBreaks",get:function(){return!0}},{key:"toolbox",get:function(){return{icon:' ',title:"List"}}}]),o(e,[{key:"render",value:function(){var e=this,t="ordered"===this._data.style?this.CSS.wrapperOrdered:this.CSS.wrapperUnordered;return this._elements.wrapper=this._make("ul",[this.CSS.baseBlock,this.CSS.wrapper,t],{contentEditable:!0}),this._data.items.length?this._data.items.forEach((function(t){e._elements.wrapper.appendChild(e._make("li",e.CSS.item,{innerHTML:t}))})):this._elements.wrapper.appendChild(this._make("li",this.CSS.item)),this._elements.wrapper.addEventListener("keydown",(function(t){switch(t.keyCode){case 13:e.getOutofList(t);break;case 8:e.backspace(t)}}),!1),this._elements.wrapper}},{key:"save",value:function(){return this.data}},{key:"renderSettings",value:function(){var e=this,t=this._make("div",[this.CSS.settingsWrapper],{});return this.settings.forEach((function(n){var r=e._make("div",e.CSS.settingsButton,{innerHTML:n.icon});r.addEventListener("click",(function(){e.toggleTune(n.name);var t=r.parentNode.querySelectorAll("."+e.CSS.settingsButton);Array.from(t).forEach((function(t){return t.classList.remove(e.CSS.settingsButtonActive)})),r.classList.toggle(e.CSS.settingsButtonActive)})),e.api.tooltip.onHover(r,n.title,{placement:"top",hidingDelay:500}),e._data.style===n.name&&r.classList.add(e.CSS.settingsButtonActive),t.appendChild(r)})),t}},{key:"onPaste",value:function(e){var t=e.detail.data;this.data=this.pasteHandler(t)}},{key:"toggleTune",value:function(e){this._elements.wrapper.classList.toggle(this.CSS.wrapperOrdered,"ordered"===e),this._elements.wrapper.classList.toggle(this.CSS.wrapperUnordered,"unordered"===e),this._data.style=e}},{key:"_make",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=document.createElement(e);Array.isArray(n)?(t=a.classList).add.apply(t,r(n)):n&&a.classList.add(n);for(var o in i)a[o]=i[o];return a}},{key:"getOutofList",value:function(e){var t=this._elements.wrapper.querySelectorAll("."+this.CSS.item);if(!(t.length<2)){var n=t[t.length-1],r=this.currentItem;r!==n||n.textContent.trim().length||(r.parentElement.removeChild(r),this.api.blocks.insert(void 0,void 0,void 0,void 0,!0),e.preventDefault(),e.stopPropagation())}}},{key:"backspace",value:function(e){var t=this._elements.wrapper.querySelectorAll("."+this.CSS.item),n=t[0];n&&t.length<2&&!n.innerHTML.replace("
"," ").trim()&&e.preventDefault()}},{key:"selectItem",value:function(e){e.preventDefault();var t=window.getSelection(),n=t.anchorNode.parentNode.closest("."+this.CSS.item),r=new Range;r.selectNodeContents(n),t.removeAllRanges(),t.addRange(r)}},{key:"pasteHandler",value:function(e){var t,n=e.tagName;switch(n){case"OL":t="ordered";break;case"UL":case"LI":t="unordered"}var r={style:t,items:[]};if("LI"===n)r.items=[e.innerHTML];else{var i=Array.from(e.querySelectorAll("LI"));r.items=i.map((function(e){return e.innerHTML})).filter((function(e){return!!e.trim()}))}return r}},{key:"CSS",get:function(){return{baseBlock:this.api.styles.block,wrapper:"cdx-list",wrapperOrdered:"cdx-list--ordered",wrapperUnordered:"cdx-list--unordered",item:"cdx-list__item",settingsWrapper:"cdx-list-settings",settingsButton:this.api.styles.settingsButton,settingsButtonActive:this.api.styles.settingsButtonActive}}},{key:"data",set:function(e){e||(e={}),this._data.style=e.style||this.settings.find((function(e){return!0===e.default})).name,this._data.items=e.items||[];var t=this._elements.wrapper;t&&t.parentNode.replaceChild(this.render(),t)},get:function(){this._data.items=[];for(var e=this._elements.wrapper.querySelectorAll(".".concat(this.CSS.item)),t=0;t"," ").trim()&&this._data.items.push(e[t].innerHTML)}return this._data}},{key:"currentItem",get:function(){var e=window.getSelection().anchorNode;return e.nodeType!==Node.ELEMENT_NODE&&(e=e.parentNode),e.closest(".".concat(this.CSS.item))}}],[{key:"conversionConfig",get:function(){return{export:function(e){return e.items.join(". ")},import:function(e){return{items:[e],style:"unordered"}}}}},{key:"sanitize",get:function(){return{style:{},items:{br:!0}}}},{key:"pasteConfig",get:function(){return{tags:["OL","UL","LI"]}}}]),e}();e.exports=s},function(e,t,n){var r=n(2),i=n(3);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var a={insert:"head",singleton:!1};r(i,a);e.exports=i.locals||{}},function(e,t,n){"use strict";var r,i=function(){return void 0===r&&(r=Boolean(window&&document&&document.all&&!window.atob)),r},a=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}(),o=[];function s(e){for(var t=-1,n=0;n\n // tags it will allow on a page\n\n if (!options.singleton && typeof options.singleton !== 'boolean') {\n options.singleton = isOldIE();\n }\n\n list = list || [];\n var lastIdentifiers = modulesToDom(list, options);\n return function update(newList) {\n newList = newList || [];\n\n if (Object.prototype.toString.call(newList) !== '[object Array]') {\n return;\n }\n\n for (var i = 0; i < lastIdentifiers.length; i++) {\n var identifier = lastIdentifiers[i];\n var index = getIndexByIdentifier(identifier);\n stylesInDom[index].references--;\n }\n\n var newLastIdentifiers = modulesToDom(newList, options);\n\n for (var _i = 0; _i < lastIdentifiers.length; _i++) {\n var _identifier = lastIdentifiers[_i];\n\n var _index = getIndexByIdentifier(_identifier);\n\n if (stylesInDom[_index].references === 0) {\n stylesInDom[_index].updater();\n\n stylesInDom.splice(_index, 1);\n }\n }\n\n lastIdentifiers = newLastIdentifiers;\n };\n};\n\n//# sourceURL=webpack://List/./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js?"); + +/***/ }), + +/***/ "./src/index.css": +/*!***********************!*\ + !*** ./src/index.css ***! + \***********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("var api = __webpack_require__(/*! ../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js */ \"./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js\");\n var content = __webpack_require__(/*! !../node_modules/css-loader/dist/cjs.js!../node_modules/postcss-loader/src??ref--5-2!./index.css */ \"./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/src/index.js?!./src/index.css\");\n\n content = content.__esModule ? content.default : content;\n\n if (typeof content === 'string') {\n content = [[module.i, content, '']];\n }\n\nvar options = {};\n\noptions.insert = \"head\";\noptions.singleton = false;\n\nvar update = api(content, options);\n\n\n\nmodule.exports = content.locals || {};\n\n//# sourceURL=webpack://List/./src/index.css?"); + +/***/ }), + +/***/ "./src/index.js": +/*!**********************!*\ + !*** ./src/index.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && Symbol.iterator in Object(iter)) return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\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\n/**\r\n * Build styles\r\n */\n__webpack_require__(/*! ./index.css */ \"./src/index.css\").toString();\n/**\r\n * @typedef {object} ListData\r\n * @property {string} style - can be ordered or unordered\r\n * @property {Array} items - li elements\r\n */\n\n/**\r\n * List Tool for the Editor.js 2.0\r\n */\n\n\nvar List = /*#__PURE__*/function () {\n _createClass(List, null, [{\n key: \"enableLineBreaks\",\n\n /**\r\n * Allow to use native Enter behaviour\r\n *\r\n * @returns {boolean}\r\n * @public\r\n */\n get: function get() {\n return true;\n }\n /**\r\n * Get Tool toolbox settings\r\n * icon - Tool icon's SVG\r\n * title - title to show in toolbox\r\n *\r\n * @returns {{icon: string, title: string}}\r\n */\n\n }, {\n key: \"toolbox\",\n get: function get() {\n return {\n icon: ' ',\n title: 'List'\n };\n }\n /**\r\n * Render plugin`s main Element and fill it with saved data\r\n *\r\n * @param {object} params - tool constructor options\r\n * @param {ListData} params.data - previously saved data\r\n * @param {object} params.config - user config for Tool\r\n * @param {object} params.api - Editor.js API\r\n */\n\n }]);\n\n function List(_ref) {\n var data = _ref.data,\n config = _ref.config,\n api = _ref.api;\n\n _classCallCheck(this, List);\n\n /**\r\n * HTML nodes\r\n *\r\n * @private\r\n */\n this._elements = {\n wrapper: null\n };\n this.api = api;\n this.settings = [{\n name: 'unordered',\n title: this.api.i18n.t('Unordered'),\n icon: ' ',\n \"default\": false\n }, {\n name: 'ordered',\n title: this.api.i18n.t('Ordered'),\n icon: '',\n \"default\": true\n }];\n /**\r\n * Tool's data\r\n *\r\n * @type {ListData}\r\n */\n\n this._data = {\n style: this.settings.find(function (tune) {\n return tune[\"default\"] === true;\n }).name,\n items: []\n };\n this.data = data;\n }\n /**\r\n * Returns list tag with items\r\n *\r\n * @returns {Element}\r\n * @public\r\n */\n\n\n _createClass(List, [{\n key: \"render\",\n value: function render() {\n var _this = this;\n\n var style = this._data.style === 'ordered' ? this.CSS.wrapperOrdered : this.CSS.wrapperUnordered;\n this._elements.wrapper = this._make('ul', [this.CSS.baseBlock, this.CSS.wrapper, style], {\n contentEditable: true\n }); // fill with data\n\n if (this._data.items.length) {\n this._data.items.forEach(function (item) {\n _this._elements.wrapper.appendChild(_this._make('li', _this.CSS.item, {\n innerHTML: item\n }));\n });\n } else {\n this._elements.wrapper.appendChild(this._make('li', this.CSS.item));\n } // detect keydown on the last item to escape List\n\n\n this._elements.wrapper.addEventListener('keydown', function (event) {\n var ENTER = 13,\n BACKSPACE = 8; // key codes\n\n switch (event.keyCode) {\n case ENTER:\n _this.getOutofList(event);\n\n break;\n\n case BACKSPACE:\n _this.backspace(event);\n\n break;\n }\n }, false);\n\n return this._elements.wrapper;\n }\n /**\r\n * @returns {ListData}\r\n * @public\r\n */\n\n }, {\n key: \"save\",\n value: function save() {\n return this.data;\n }\n /**\r\n * Allow List Tool to be converted to/from other block\r\n *\r\n * @returns {{export: Function, import: Function}}\r\n */\n\n }, {\n key: \"renderSettings\",\n\n /**\r\n * Settings\r\n *\r\n * @public\r\n * @returns {Element}\r\n */\n value: function renderSettings() {\n var _this2 = this;\n\n var wrapper = this._make('div', [this.CSS.settingsWrapper], {});\n\n this.settings.forEach(function (item) {\n var itemEl = _this2._make('div', _this2.CSS.settingsButton, {\n innerHTML: item.icon\n });\n\n itemEl.addEventListener('click', function () {\n _this2.toggleTune(item.name); // clear other buttons\n\n\n var buttons = itemEl.parentNode.querySelectorAll('.' + _this2.CSS.settingsButton);\n Array.from(buttons).forEach(function (button) {\n return button.classList.remove(_this2.CSS.settingsButtonActive);\n }); // mark active\n\n itemEl.classList.toggle(_this2.CSS.settingsButtonActive);\n });\n\n _this2.api.tooltip.onHover(itemEl, item.title, {\n placement: 'top',\n hidingDelay: 500\n });\n\n if (_this2._data.style === item.name) {\n itemEl.classList.add(_this2.CSS.settingsButtonActive);\n }\n\n wrapper.appendChild(itemEl);\n });\n return wrapper;\n }\n /**\r\n * On paste callback that is fired from Editor\r\n *\r\n * @param {PasteEvent} event - event with pasted data\r\n */\n\n }, {\n key: \"onPaste\",\n value: function onPaste(event) {\n var list = event.detail.data;\n this.data = this.pasteHandler(list);\n }\n /**\r\n * List Tool on paste configuration\r\n *\r\n * @public\r\n */\n\n }, {\n key: \"toggleTune\",\n\n /**\r\n * Toggles List style\r\n *\r\n * @param {string} style - 'ordered'|'unordered'\r\n */\n value: function toggleTune(style) {\n this._elements.wrapper.classList.toggle(this.CSS.wrapperOrdered, style === 'ordered');\n\n this._elements.wrapper.classList.toggle(this.CSS.wrapperUnordered, style === 'unordered');\n\n this._data.style = style;\n }\n /**\r\n * Styles\r\n *\r\n * @private\r\n */\n\n }, {\n key: \"_make\",\n\n /**\r\n * Helper for making Elements with attributes\r\n *\r\n * @param {string} tagName - new Element tag name\r\n * @param {Array|string} classNames - list or name of CSS classname(s)\r\n * @param {object} attributes - any attributes\r\n * @returns {Element}\r\n */\n value: function _make(tagName) {\n var classNames = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var el = document.createElement(tagName);\n\n if (Array.isArray(classNames)) {\n var _el$classList;\n\n (_el$classList = el.classList).add.apply(_el$classList, _toConsumableArray(classNames));\n } else if (classNames) {\n el.classList.add(classNames);\n }\n\n for (var attrName in attributes) {\n el[attrName] = attributes[attrName];\n }\n\n return el;\n }\n /**\r\n * Returns current List item by the caret position\r\n *\r\n * @returns {Element}\r\n */\n\n }, {\n key: \"getOutofList\",\n\n /**\r\n * Get out from List Tool\r\n * by Enter on the empty last item\r\n *\r\n * @param {KeyboardEvent} event\r\n */\n value: function getOutofList(event) {\n var items = this._elements.wrapper.querySelectorAll('.' + this.CSS.item);\n /**\r\n * Save the last one.\r\n */\n\n\n if (items.length < 2) {\n return;\n }\n\n var lastItem = items[items.length - 1];\n var currentItem = this.currentItem;\n /** Prevent Default li generation if item is empty */\n\n if (currentItem === lastItem && !lastItem.textContent.trim().length) {\n /** Insert New Block and set caret */\n currentItem.parentElement.removeChild(currentItem);\n this.api.blocks.insert(undefined, undefined, undefined, undefined, true);\n event.preventDefault();\n event.stopPropagation();\n }\n }\n /**\r\n * Handle backspace\r\n *\r\n * @param {KeyboardEvent} event\r\n */\n\n }, {\n key: \"backspace\",\n value: function backspace(event) {\n var items = this._elements.wrapper.querySelectorAll('.' + this.CSS.item),\n firstItem = items[0];\n\n if (!firstItem) {\n return;\n }\n /**\r\n * Save the last one.\r\n */\n\n\n if (items.length < 2 && !firstItem.innerHTML.replace('
', ' ').trim()) {\n event.preventDefault();\n }\n }\n /**\r\n * Select LI content by CMD+A\r\n *\r\n * @param {KeyboardEvent} event\r\n */\n\n }, {\n key: \"selectItem\",\n value: function selectItem(event) {\n event.preventDefault();\n var selection = window.getSelection(),\n currentNode = selection.anchorNode.parentNode,\n currentItem = currentNode.closest('.' + this.CSS.item),\n range = new Range();\n range.selectNodeContents(currentItem);\n selection.removeAllRanges();\n selection.addRange(range);\n }\n /**\r\n * Handle UL, OL and LI tags paste and returns List data\r\n *\r\n * @param {HTMLUListElement|HTMLOListElement|HTMLLIElement} element\r\n * @returns {ListData}\r\n */\n\n }, {\n key: \"pasteHandler\",\n value: function pasteHandler(element) {\n var tag = element.tagName;\n var style;\n\n switch (tag) {\n case 'OL':\n style = 'ordered';\n break;\n\n case 'UL':\n case 'LI':\n style = 'unordered';\n }\n\n var data = {\n style: style,\n items: []\n };\n\n if (tag === 'LI') {\n data.items = [element.innerHTML];\n } else {\n var items = Array.from(element.querySelectorAll('LI'));\n data.items = items.map(function (li) {\n return li.innerHTML;\n }).filter(function (item) {\n return !!item.trim();\n });\n }\n\n return data;\n }\n }, {\n key: \"CSS\",\n get: function get() {\n return {\n baseBlock: this.api.styles.block,\n wrapper: 'cdx-list',\n wrapperOrdered: 'cdx-list--ordered',\n wrapperUnordered: 'cdx-list--unordered',\n item: 'cdx-list__item',\n settingsWrapper: 'cdx-list-settings',\n settingsButton: this.api.styles.settingsButton,\n settingsButtonActive: this.api.styles.settingsButtonActive\n };\n }\n /**\r\n * List data setter\r\n *\r\n * @param {ListData} listData\r\n */\n\n }, {\n key: \"data\",\n set: function set(listData) {\n if (!listData) {\n listData = {};\n }\n\n this._data.style = listData.style || this.settings.find(function (tune) {\n return tune[\"default\"] === true;\n }).name;\n this._data.items = listData.items || [];\n var oldView = this._elements.wrapper;\n\n if (oldView) {\n oldView.parentNode.replaceChild(this.render(), oldView);\n }\n }\n /**\r\n * Return List data\r\n *\r\n * @returns {ListData}\r\n */\n ,\n get: function get() {\n this._data.items = [];\n\n var items = this._elements.wrapper.querySelectorAll(\".\".concat(this.CSS.item));\n\n for (var i = 0; i < items.length; i++) {\n var value = items[i].innerHTML.replace(/
| /gi, ' ').trim();\n\n if (value) {\n this._data.items.push(value);\n }\n }\n\n return this._data;\n }\n }, {\n key: \"currentItem\",\n get: function get() {\n var currentNode = window.getSelection().anchorNode;\n\n if (currentNode.nodeType !== Node.ELEMENT_NODE) {\n currentNode = currentNode.parentNode;\n }\n\n return currentNode.closest(\".\".concat(this.CSS.item));\n }\n }], [{\n key: \"conversionConfig\",\n get: function get() {\n return {\n /**\r\n * To create exported string from list, concatenate items by dot-symbol.\r\n *\r\n * @param {ListData} data - list data to create a string from thats\r\n * @returns {string}\r\n */\n \"export\": function _export(data) {\n return data.items.join('. ');\n },\n\n /**\r\n * To create a list from other block's string, just put it at the first item\r\n *\r\n * @param {string} string - string to create list tool data from that\r\n * @returns {ListData}\r\n */\n \"import\": function _import(string) {\n return {\n items: [string],\n style: 'unordered'\n };\n }\n };\n }\n /**\r\n * Sanitizer rules\r\n *\r\n * @returns {object}\r\n */\n\n }, {\n key: \"sanitize\",\n get: function get() {\n return {\n style: {},\n items: {\n br: true\n }\n };\n }\n }, {\n key: \"pasteConfig\",\n get: function get() {\n return {\n tags: ['OL', 'UL', 'LI']\n };\n }\n }]);\n\n return List;\n}();\n\nmodule.exports = List;\n\n//# sourceURL=webpack://List/./src/index.js?"); + +/***/ }) + +/******/ }); +}); \ No newline at end of file diff --git a/src/index.js b/src/index.js index c2ee8752..88b9af9a 100644 --- a/src/index.js +++ b/src/index.js @@ -305,10 +305,10 @@ class List { const items = this._elements.wrapper.querySelectorAll(`.${this.CSS.item}`); for (let i = 0; i < items.length; i++) { - const value = items[i].innerHTML.replace('
', ' ').trim(); + const value = items[i].innerHTML.replace(/
| /gi, ' ').trim(); if (value) { - this._data.items.push(items[i].innerHTML); + this._data.items.push(value); } }