@pie-lib/editable-html 12.1.1-next.0 → 12.2.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/lib/block-tags.js +0 -1
  2. package/lib/block-tags.js.map +1 -1
  3. package/lib/constants.js +0 -1
  4. package/lib/constants.js.map +1 -1
  5. package/lib/editor.js +6 -37
  6. package/lib/editor.js.map +1 -1
  7. package/lib/index.js +0 -16
  8. package/lib/index.js.map +1 -1
  9. package/lib/parse-html.js +0 -3
  10. package/lib/parse-html.js.map +1 -1
  11. package/lib/plugins/characters/custom-popper.js +0 -1
  12. package/lib/plugins/characters/custom-popper.js.map +1 -1
  13. package/lib/plugins/characters/index.js +6 -21
  14. package/lib/plugins/characters/index.js.map +1 -1
  15. package/lib/plugins/characters/utils.js +0 -2
  16. package/lib/plugins/characters/utils.js.map +1 -1
  17. package/lib/plugins/css/icons/index.js +0 -1
  18. package/lib/plugins/css/icons/index.js.map +1 -1
  19. package/lib/plugins/css/index.js +0 -12
  20. package/lib/plugins/css/index.js.map +1 -1
  21. package/lib/plugins/customPlugin/index.js +0 -11
  22. package/lib/plugins/customPlugin/index.js.map +1 -1
  23. package/lib/plugins/html/icons/index.js +0 -1
  24. package/lib/plugins/html/icons/index.js.map +1 -1
  25. package/lib/plugins/html/index.js +0 -1
  26. package/lib/plugins/html/index.js.map +1 -1
  27. package/lib/plugins/image/alt-dialog.js +0 -5
  28. package/lib/plugins/image/alt-dialog.js.map +1 -1
  29. package/lib/plugins/image/component.js +0 -14
  30. package/lib/plugins/image/component.js.map +1 -1
  31. package/lib/plugins/image/image-toolbar.js +0 -3
  32. package/lib/plugins/image/image-toolbar.js.map +1 -1
  33. package/lib/plugins/image/index.js +0 -14
  34. package/lib/plugins/image/index.js.map +1 -1
  35. package/lib/plugins/image/insert-image-handler.js +0 -1
  36. package/lib/plugins/image/insert-image-handler.js.map +1 -1
  37. package/lib/plugins/index.js +4 -22
  38. package/lib/plugins/index.js.map +1 -1
  39. package/lib/plugins/list/index.js +0 -12
  40. package/lib/plugins/list/index.js.map +1 -1
  41. package/lib/plugins/math/index.js +3 -18
  42. package/lib/plugins/math/index.js.map +1 -1
  43. package/lib/plugins/media/index.js +0 -13
  44. package/lib/plugins/media/index.js.map +1 -1
  45. package/lib/plugins/media/media-dialog.js +0 -18
  46. package/lib/plugins/media/media-dialog.js.map +1 -1
  47. package/lib/plugins/media/media-toolbar.js +0 -2
  48. package/lib/plugins/media/media-toolbar.js.map +1 -1
  49. package/lib/plugins/media/media-wrapper.js +0 -2
  50. package/lib/plugins/media/media-wrapper.js.map +1 -1
  51. package/lib/plugins/rendering/index.js +0 -10
  52. package/lib/plugins/rendering/index.js.map +1 -1
  53. package/lib/plugins/respArea/drag-in-the-blank/choice.js +0 -17
  54. package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
  55. package/lib/plugins/respArea/drag-in-the-blank/index.js +0 -1
  56. package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
  57. package/lib/plugins/respArea/drag-in-the-blank/utils.js +0 -10
  58. package/lib/plugins/respArea/drag-in-the-blank/utils.js.map +1 -1
  59. package/lib/plugins/respArea/explicit-constructed-response/index.js +0 -1
  60. package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
  61. package/lib/plugins/respArea/icons/index.js +0 -10
  62. package/lib/plugins/respArea/icons/index.js.map +1 -1
  63. package/lib/plugins/respArea/index.js +2 -13
  64. package/lib/plugins/respArea/index.js.map +1 -1
  65. package/lib/plugins/respArea/inline-dropdown/index.js +0 -1
  66. package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
  67. package/lib/plugins/respArea/math-templated/index.js +0 -1
  68. package/lib/plugins/respArea/math-templated/index.js.map +1 -1
  69. package/lib/plugins/respArea/utils.js +0 -6
  70. package/lib/plugins/respArea/utils.js.map +1 -1
  71. package/lib/plugins/table/CustomTablePlugin.js +0 -7
  72. package/lib/plugins/table/CustomTablePlugin.js.map +1 -1
  73. package/lib/plugins/table/icons/index.js +0 -2
  74. package/lib/plugins/table/icons/index.js.map +1 -1
  75. package/lib/plugins/table/index.js +0 -18
  76. package/lib/plugins/table/index.js.map +1 -1
  77. package/lib/plugins/table/table-toolbar.js +0 -15
  78. package/lib/plugins/table/table-toolbar.js.map +1 -1
  79. package/lib/plugins/textAlign/icons/index.js +0 -15
  80. package/lib/plugins/textAlign/icons/index.js.map +1 -1
  81. package/lib/plugins/textAlign/index.js +0 -1
  82. package/lib/plugins/textAlign/index.js.map +1 -1
  83. package/lib/plugins/toolbar/default-toolbar.js +0 -14
  84. package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
  85. package/lib/plugins/toolbar/done-button.js +0 -1
  86. package/lib/plugins/toolbar/done-button.js.map +1 -1
  87. package/lib/plugins/toolbar/editor-and-toolbar.js +0 -12
  88. package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
  89. package/lib/plugins/toolbar/index.js +0 -1
  90. package/lib/plugins/toolbar/index.js.map +1 -1
  91. package/lib/plugins/toolbar/toolbar-buttons.js +0 -12
  92. package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
  93. package/lib/plugins/toolbar/toolbar.js +2 -16
  94. package/lib/plugins/toolbar/toolbar.js.map +1 -1
  95. package/lib/plugins/utils.js +0 -3
  96. package/lib/plugins/utils.js.map +1 -1
  97. package/lib/serialization.js +5 -29
  98. package/lib/serialization.js.map +1 -1
  99. package/lib/shared/alert-dialog.js +0 -1
  100. package/lib/theme.js +0 -1
  101. package/lib/theme.js.map +1 -1
  102. package/package.json +12 -8
  103. package/src/__tests__/editor-utils.test.js +1 -1
  104. package/src/__tests__/serialization.test.js +0 -1
  105. package/src/editor.jsx +18 -22
  106. package/src/index.jsx +2 -2
  107. package/src/plugins/characters/index.jsx +2 -2
  108. package/src/plugins/html/icons/index.jsx +1 -3
  109. package/src/plugins/html/index.jsx +2 -10
  110. package/src/plugins/image/__tests__/component.test.jsx +1 -1
  111. package/src/plugins/image/__tests__/image-toolbar-logic.test.jsx +1 -5
  112. package/src/plugins/image/__tests__/image-toolbar.test.jsx +0 -1
  113. package/src/plugins/image/__tests__/index.test.js +0 -3
  114. package/src/plugins/image/alt-dialog.jsx +4 -3
  115. package/src/plugins/index.jsx +1 -2
  116. package/src/plugins/list/__tests__/index.test.js +0 -2
  117. package/src/plugins/list/index.jsx +6 -6
  118. package/src/plugins/math/__tests__/index.test.jsx +1 -1
  119. package/src/plugins/math/index.jsx +2 -2
  120. package/src/plugins/media/media-dialog.js +6 -23
  121. package/src/plugins/media/media-toolbar.jsx +2 -8
  122. package/src/plugins/respArea/drag-in-the-blank/choice.jsx +11 -33
  123. package/src/plugins/respArea/drag-in-the-blank/index.jsx +26 -26
  124. package/src/plugins/respArea/index.jsx +1 -1
  125. package/src/plugins/table/__tests__/index.test.jsx +5 -5
  126. package/src/plugins/table/index.jsx +1 -6
  127. package/src/plugins/table/table-toolbar.jsx +1 -1
  128. package/src/plugins/toolbar/__tests__/default-toolbar.test.jsx +2 -6
  129. package/src/plugins/toolbar/__tests__/editor-and-toolbar.test.jsx +2 -2
  130. package/src/plugins/toolbar/__tests__/toolbar-buttons.test.jsx +1 -1
  131. package/src/plugins/toolbar/__tests__/toolbar.test.jsx +1 -1
  132. package/src/plugins/toolbar/done-button.jsx +1 -6
  133. package/src/plugins/toolbar/editor-and-toolbar.jsx +2 -7
  134. package/src/plugins/toolbar/toolbar.jsx +4 -3
  135. package/src/serialization.jsx +6 -6
  136. package/NEXT.CHANGELOG.json +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"serialization.js","names":["_slateHtmlSerializer","_interopRequireDefault","require","_react","_debug","_toStyle","_isEmpty","_image","_math","_media","_list","_table","_respArea","_slate","_blockTags","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","log","debug","MARK_TAGS","b","em","u","s","code","strong","blockquote","h3","sup","sub","parseStyleString","exports","regex","match","result","exec","trim","getBase64","file","Promise","resolve","reject","reader","FileReader","readAsDataURL","onload","onerror","error","reactAttributes","toStyleObject","camelize","addUnits","attributesToMap","el","acc","attribute","value","getAttribute","styleString","reactStyleObject","attributes","blocks","deserialize","next","block","BLOCK_TAGS","tagName","toLowerCase","childNodes","cn","object","type","data","reduce","nodes","serialize","children","jsonData","toJSON","key","Tag","createElement","INLINE_TAGS","span","inlines","inlineTag","extraCSSRulesOpts","STYLES_MAP","fontSize","fontWeight","background","borderLeft","margin","padding","reactToHTMLAttributesMap","marks","mark","elClasses","hasCSSRule","names","find","name","includes","attrs","isEmpty","undefined","_object$data","_jsonData$attributes","htmlAttrs","obj","Mark","isMark","additionalStyles","style","findPreviousText","nodeName","previousSibling","TEXT_RULE","normalize","leaves","text","nodeValue","split","array","i","RULES","listSerialization","mathSerialization","mediaSerialization","imgSerialization","tableSerialization","responseAreaSerialization","allWhitespace","node","test","textContent","defaultParseHtml","html","DOMParser","Error","parsed","parseFromString","body","textNodes","document","createTreeWalker","NodeFilter","SHOW_TEXT","n","nextNode","_n$nextSibling","_n$previousSibling","isWhiteSpace","isNotNearMarkup","nextSibling","parentNode","removeChild","parseHtml","window","serializer","Html","defaultBlock","rules","_extends","assign","target","source","prototype","hasOwnProperty","call","options","_options$toJSON","fragment","Array","from","deserializeElements","memo","original","_block","isVoid","json","schema","ret","Value","fromJSON","reduceMultipleBrs","markup","replace","console","reduceRedundantNewLineCharacters","fixHtmlCode","wrapperEl","innerHTML","fixParagraphs","child","p","attr","setAttribute","replaceWith","fixTables","tableArray","index","parent","nodesBefore","nodesAfter","allNodes","beforeEl","append","after","afterEl","emptyBlockCheck","parseNode","childArray","hasParagraphs","tables","remove","handleHtml","htmlToValue","valueToHtml"],"sources":["../src/serialization.jsx"],"sourcesContent":["import Html from 'slate-html-serializer';\nimport React from 'react';\nimport debug from 'debug';\nimport { object as toStyleObject } from 'to-style';\nimport isEmpty from 'lodash/isEmpty';\n\nimport { serialization as imgSerialization } from './plugins/image';\nimport { serialization as mathSerialization } from './plugins/math';\nimport { serialization as mediaSerialization } from './plugins/media';\nimport { serialization as listSerialization } from './plugins/list';\nimport { serialization as tableSerialization } from './plugins/table';\nimport { serialization as responseAreaSerialization } from './plugins/respArea';\nimport { Mark, Value } from 'slate';\nimport { BLOCK_TAGS } from './block-tags';\n\nconst log = debug('@pie-lib:editable-html:serialization');\n\n/**\n * Tags to marks.\n *\n * @type {Object}\n */\n\nconst MARK_TAGS = {\n b: 'bold',\n em: 'italic',\n u: 'underline',\n s: 'strikethrough',\n code: 'code',\n strong: 'bold',\n blockquote: 'blockquote',\n h3: 'h3',\n sup: 'sup',\n sub: 'sub',\n};\n\nexport const parseStyleString = (s) => {\n const regex = /([\\w-]*)\\s*:\\s*([^;]*)/g;\n let match;\n const result = {};\n while ((match = regex.exec(s))) {\n result[match[1]] = match[2].trim();\n }\n return result;\n};\n\nexport const getBase64 = (file) => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n reader.onload = () => resolve(reader.result);\n reader.onerror = (error) => reject(error);\n });\n};\n\nexport const reactAttributes = (o) => toStyleObject(o, { camelize: true, addUnits: false });\n\nconst attributesToMap = (el) => (acc, attribute) => {\n const value = el.getAttribute(attribute);\n if (value) {\n if (attribute === 'style') {\n const styleString = el.getAttribute(attribute);\n const reactStyleObject = reactAttributes(parseStyleString(styleString));\n acc['style'] = reactStyleObject;\n } else {\n acc[attribute] = el.getAttribute(attribute);\n }\n }\n return acc;\n};\n\nconst attributes = ['border', 'cellpadding', 'cellspacing', 'class', 'style', 'align'];\n\n/**\n * Serializer rules.\n *\n * @type {Array}\n */\n\nconst blocks = {\n deserialize(el, next) {\n log('[blocks:deserialize] block: ', el);\n const block = BLOCK_TAGS[el.tagName.toLowerCase()];\n if (!block) return;\n log('[blocks:deserialize] block: ', block);\n\n if (el.childNodes.length === 1) {\n const cn = el.childNodes[0];\n if (cn && cn.tagName && cn.tagName.toLowerCase() === block) {\n log('[we have a child node of the same]...');\n return;\n }\n }\n\n return {\n object: 'block',\n type: block,\n /**\n * Here for rendering styles for all block elements\n */\n data: { attributes: attributes.reduce(attributesToMap(el), {}) },\n nodes: next(el.childNodes),\n };\n },\n serialize: (object, children) => {\n if (object.object !== 'block') return;\n\n const jsonData = object.data.toJSON();\n\n log('[blocks:serialize] object: ', object, children);\n let key;\n\n for (key in BLOCK_TAGS) {\n if (BLOCK_TAGS[key] === object.type) {\n const Tag = key;\n\n return <Tag {...jsonData.attributes}>{children}</Tag>;\n }\n }\n },\n};\n\nexport const INLINE_TAGS = {\n span: 'span',\n};\n\nconst inlines = {\n deserialize(el, next) {\n log('[inlines:deserialize] inline: ', el);\n const inlineTag = INLINE_TAGS[el.tagName.toLowerCase()];\n if (!inlineTag) return;\n log('[inlines:deserialize] inline: ', inlineTag);\n\n if (el.childNodes.length === 1) {\n const cn = el.childNodes[0];\n if (cn && cn.tagName && cn.tagName.toLowerCase() === inlineTag) {\n log('[we have a child node of the same]...');\n return;\n }\n }\n\n return {\n object: 'inline',\n type: inlineTag,\n /**\n * Here for rendering styles for all inline elements\n */\n data: { attributes: attributes.reduce(attributesToMap(el), {}) },\n nodes: next(el.childNodes),\n };\n },\n serialize: (object, children) => {\n if (object.object !== 'inline') return;\n\n const jsonData = object.data.toJSON();\n\n log('[inlines:serialize] object: ', object, children);\n let key;\n\n for (key in INLINE_TAGS) {\n if (INLINE_TAGS[key] === object.type) {\n const Tag = key;\n\n return <Tag {...jsonData.attributes}>{children}</Tag>;\n }\n }\n },\n};\n\nexport const extraCSSRulesOpts = {};\n\nconst STYLES_MAP = {\n h3: {\n fontSize: 'inherit',\n fontWeight: 'inherit',\n },\n blockquote: {\n background: '#f9f9f9',\n borderLeft: '5px solid #ccc',\n margin: '1.5em 10px',\n padding: '.5em 10px',\n },\n};\n\nconst reactToHTMLAttributesMap = {\n class: 'className',\n};\n\nconst marks = {\n deserialize(el, next) {\n const mark = MARK_TAGS[el.tagName.toLowerCase()];\n const elClasses = el.getAttribute('class') || '';\n const hasCSSRule = (extraCSSRulesOpts?.names || []).find((name) => elClasses?.includes(name));\n\n if (!mark && !hasCSSRule) {\n return;\n }\n\n log('[deserialize] mark: ', mark);\n const attrs = attributes.reduce(attributesToMap(el), {});\n const data = isEmpty(attrs) ? undefined : { attributes: attrs };\n\n return {\n object: 'mark',\n type: hasCSSRule ? 'css' : mark,\n /**\n * Here for rendering styles for all elements\n */\n data,\n nodes: next(el.childNodes),\n };\n },\n serialize(object, children) {\n const jsonData = object.data?.toJSON() || {};\n const elClasses = jsonData.attributes?.class || '';\n const hasCSSRule = (extraCSSRulesOpts?.names || []).find((name) => elClasses?.includes(name));\n\n if (hasCSSRule) {\n const htmlAttrs = Object.keys(jsonData.attributes).reduce((obj, key) => {\n obj[reactToHTMLAttributesMap[key] || key] = jsonData.attributes[key];\n return obj;\n }, {});\n\n return <span {...htmlAttrs}>{children}</span>;\n }\n\n if (Mark.isMark(object)) {\n for (var key in MARK_TAGS) {\n if (MARK_TAGS[key] === object.type) {\n const Tag = key;\n const additionalStyles = STYLES_MAP[Tag];\n\n if (additionalStyles) {\n if (!jsonData.attributes) {\n jsonData.attributes = {};\n }\n\n jsonData.attributes.style = {\n ...jsonData.attributes.style,\n ...additionalStyles,\n };\n }\n\n return <Tag {...jsonData.attributes}>{children}</Tag>;\n }\n }\n }\n },\n};\n\n// eslint-disable-next-line no-unused-vars\nconst findPreviousText = (el) => {\n if (el.nodeName === '#text') {\n return el;\n }\n\n if (el.previousSibling) {\n return findPreviousText(el.previousSibling);\n }\n\n return null;\n};\n\nexport const TEXT_RULE = {\n deserialize(el) {\n /**\n * This needs to be called on the dom element in order to merge the adjacent text nodes together\n * */\n el.normalize();\n\n if (el.tagName && el.tagName.toLowerCase() === 'br') {\n return {\n object: 'text',\n leaves: [\n {\n object: 'leaf',\n text: '\\n',\n },\n ],\n };\n }\n\n if (el.nodeName === '#text') {\n if (el.nodeValue && el.nodeValue.match(/<!--.*?-->/)) return;\n\n log('[text:deserialize] return text object..');\n return {\n object: 'text',\n leaves: [\n {\n object: 'leaf',\n text: el.nodeValue,\n },\n ],\n };\n }\n },\n\n serialize(obj, children) {\n if (obj.object === 'string') {\n return children.split('\\n').reduce((array, text, i) => {\n if (i !== 0) array.push(<br />);\n array.push(text);\n return array;\n }, []);\n }\n },\n};\n\nconst RULES = [\n listSerialization,\n mathSerialization,\n mediaSerialization,\n imgSerialization,\n tableSerialization,\n responseAreaSerialization,\n TEXT_RULE,\n inlines,\n blocks,\n marks,\n];\n\nfunction allWhitespace(node) {\n // Use ECMA-262 Edition 3 String and RegExp features\n return !/[^\\t\\n\\r ]/.test(node.textContent);\n}\n\nfunction defaultParseHtml(html) {\n if (typeof DOMParser === 'undefined') {\n throw new Error(\n 'The native `DOMParser` global which the `Html` serializer uses by default is not present in this environment. You must supply the `options.parseHtml` function instead.',\n );\n }\n\n const parsed = new DOMParser().parseFromString(html, 'text/html');\n\n const { body } = parsed;\n var textNodes = document.createTreeWalker(body, NodeFilter.SHOW_TEXT, null, null);\n var n = textNodes.nextNode();\n\n while (n) {\n const isWhiteSpace = allWhitespace(n);\n const isNotNearMarkup =\n !MARK_TAGS[n.nextSibling?.tagName?.toLowerCase()] && !MARK_TAGS[n.previousSibling?.tagName?.toLowerCase()];\n\n if ((isWhiteSpace && isNotNearMarkup) || n.nodeValue === '\\u200B') {\n n.parentNode.removeChild(n);\n }\n n = textNodes.nextNode();\n }\n\n return body;\n}\n\n/** If this lib is used on the server side, we need to bypass using the DOMParser - just put in a stub. */\nconst parseHtml =\n typeof window === 'undefined'\n ? () => ({\n childNodes: [],\n })\n : defaultParseHtml;\n\nconst serializer = new Html({\n defaultBlock: 'div',\n rules: RULES,\n parseHtml,\n});\n\nconst _extends =\n Object.assign ||\n function(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n/**\n * This is needed in order to override the function that eventually leads\n * to the max iteration of 12, which in most cases it's not enough. The newer versions\n * have a different way to calculate this, but updating to a newer version of slate\n * requires a lot of work fixing other issues. So we just increase the rules by 1000,\n * which means a lot of iterations.\n * Below is the code that calculates the max iterations.\n * var max = schema.stack.plugins.length + schema.rules.length + 1;\n */\nserializer.deserialize = function deserialize(html) {\n const options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n const _options$toJSON = options.toJSON;\n const toJSON = _options$toJSON === undefined ? false : _options$toJSON;\n const defaultBlock = this.defaultBlock;\n const parseHtml = this.parseHtml;\n\n const fragment = parseHtml(html);\n const children = Array.from(fragment.childNodes);\n let nodes = this.deserializeElements(children);\n\n // COMPAT: ensure that all top-level inline nodes are wrapped into a block.\n nodes = nodes.reduce(function(memo, node, i, original) {\n if (node.object === 'block') {\n memo.push(node);\n return memo;\n }\n\n if (i > 0 && original[i - 1].object !== 'block') {\n const _block = memo[memo.length - 1];\n\n _block.nodes.push(node);\n return memo;\n }\n\n const block = _extends({ object: 'block', data: {}, isVoid: false }, defaultBlock, {\n nodes: [node],\n });\n\n memo.push(block);\n return memo;\n }, []);\n\n if (nodes.length === 0) {\n nodes = [\n _extends({ object: 'block', data: {}, isVoid: false }, defaultBlock, {\n nodes: [{ object: 'text', leaves: [{ object: 'leaf', text: '', marks: [] }] }],\n }),\n ];\n }\n\n const json = {\n object: 'value',\n document: {\n object: 'document',\n data: {},\n nodes: nodes,\n },\n schema: {\n rules: [],\n },\n };\n\n let i;\n\n for (i = 0; i < 3000; i++) {\n json.schema.rules.push({\n match: { object: 'document' },\n nodes: [{ match: { object: 'block' } }],\n });\n }\n\n const ret = toJSON ? json : Value.fromJSON(json);\n\n if (ret) {\n return ret;\n }\n\n return null;\n};\n\nexport const reduceMultipleBrs = (markup) => {\n try {\n return markup.replace(/(<br\\s*\\/?>){3,}/gi, '<br>');\n } catch (e) {\n // eslint-disable-next-line no-console\n console.log('Couldn\\'t remove <br/> tags: ', e);\n }\n\n return markup;\n};\n\nconst reduceRedundantNewLineCharacters = (markup) => {\n try {\n return markup.replace(/\\n/gi, '');\n } catch (e) {\n // eslint-disable-next-line no-console\n console.log('Couldn\\'t remove <br/> tags: ', e);\n }\n\n return markup;\n};\n\n/**\n * Makes sure that the html provided respects the schema\n * rules for the slate editor.\n * @param markup\n * @returns {string}\n */\nconst fixHtmlCode = (markup) => {\n const wrapperEl = document.createElement('div');\n\n wrapperEl.innerHTML = markup;\n\n /**\n * DIV elements that are at the same level as paragraphs\n * are replaced with P elements for normalizing purposes\n * @param child\n */\n const fixParagraphs = (child) => {\n const p = document.createElement('p');\n\n p.innerHTML = child.innerHTML;\n\n Array.from(child.attributes).forEach((attr) => {\n p.setAttribute(attr.name, attr.value);\n });\n child.replaceWith(p);\n };\n\n /**\n * @summary Makes sure that tables are placed in the root document.\n * @description This function removes the tables from the nodes that are\n * placed inside the root element and places them exactly near\n * the parent element.\n * @param tableArray\n */\n const fixTables = (tableArray) => {\n tableArray.forEach((el) => {\n const { index, child, parent } = el;\n const nodesBefore = [];\n const nodesAfter = [];\n const allNodes = Array.from(parent.childNodes);\n let i;\n\n for (i = 0; i < allNodes.length; i++) {\n const node = allNodes[i];\n\n if (i < index) {\n nodesBefore.push(node);\n } else if (i > index) {\n nodesAfter.push(node);\n }\n }\n\n // creating the element that is going to be placed instead of the parent\n const beforeEl = document.createElement(parent.nodeName);\n\n beforeEl.append(...nodesBefore);\n\n // replacing parent with the beforeElement\n parent.replaceWith(beforeEl);\n\n // adding the table right after the before element\n beforeEl.after(child);\n\n // creating the element that is going to be placed after the table\n const afterEl = document.createElement(parent.nodeName);\n\n afterEl.append(...nodesAfter);\n\n // adding the after element near the table\n child.after(afterEl);\n });\n };\n\n const emptyBlockCheck = (node) =>\n (node.nodeName === 'DIV' || node.nodeName === 'P' || node.nodeName === 'LI') && node.childNodes.length === 0;\n\n const parseNode = (el) => {\n const childArray = Array.from(el.childNodes);\n const hasParagraphs = childArray.find((child) => child.nodeName === 'P');\n const tables = [];\n\n childArray.forEach((child, index) => {\n // removing empty blocks\n if (emptyBlockCheck(child)) {\n child.remove();\n return;\n }\n\n if (hasParagraphs && child.nodeName === 'DIV') {\n fixParagraphs(child);\n }\n\n if (wrapperEl !== el && child.nodeName === 'TABLE') {\n // we don't need to fix tables in the root element\n tables.push({\n index,\n child,\n parent: el,\n });\n }\n\n parseNode(child);\n });\n\n if (tables.length) {\n fixTables(tables);\n }\n };\n\n parseNode(wrapperEl);\n\n return wrapperEl.innerHTML;\n};\n\nexport const handleHtml = (html) => fixHtmlCode(reduceRedundantNewLineCharacters(reduceMultipleBrs(html)));\n\nexport const htmlToValue = (html) => {\n try {\n return serializer.deserialize(handleHtml(html));\n } catch (e) {\n // eslint-disable-next-line no-console\n console.log('Couldn\\'t parse html: ', e);\n return {};\n }\n};\n\nexport const valueToHtml = (value) => serializer.serialize(value);\n\n/**\n *\n * <div><div>a</div></div> -> <div>a</div>\n *\n * <div><div>a</div><div>b</div></div> -> <div>a</div><div>b</div>\n * <div><div>a</div>4444<div>b</div></div> -> <div>a</div>4444<div>b</div>\n */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,oBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAL,sBAAA,CAAAC,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,SAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IA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A,GAAG,SAAdA,WAAWA,CAAIlK,KAAK;EAAA,OAAKuG,UAAU,CAACpF,SAAS,CAACnB,KAAK,CAAC;AAAA;;AAEjE;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"serialization.js","names":["_slateHtmlSerializer","_interopRequireDefault","require","_react","_debug","_toStyle","_lodashEs","_image","_math","_media","_list","_table","_respArea","_slate","_blockTags","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","log","debug","MARK_TAGS","b","em","u","s","code","strong","blockquote","h3","sup","sub","parseStyleString","exports","regex","match","result","exec","trim","getBase64","file","Promise","resolve","reject","reader","FileReader","readAsDataURL","onload","onerror","error","reactAttributes","toStyleObject","camelize","addUnits","attributesToMap","el","acc","attribute","value","getAttribute","styleString","reactStyleObject","attributes","blocks","deserialize","next","block","BLOCK_TAGS","tagName","toLowerCase","childNodes","cn","object","type","data","reduce","nodes","serialize","children","jsonData","toJSON","key","Tag","createElement","INLINE_TAGS","span","inlines","inlineTag","extraCSSRulesOpts","STYLES_MAP","fontSize","fontWeight","background","borderLeft","margin","padding","reactToHTMLAttributesMap","marks","mark","elClasses","hasCSSRule","names","find","name","includes","attrs","isEmpty","undefined","_object$data","_jsonData$attributes","htmlAttrs","obj","Mark","isMark","additionalStyles","style","findPreviousText","nodeName","previousSibling","TEXT_RULE","normalize","leaves","text","nodeValue","split","array","i","RULES","listSerialization","mathSerialization","mediaSerialization","imgSerialization","tableSerialization","responseAreaSerialization","allWhitespace","node","test","textContent","defaultParseHtml","html","DOMParser","Error","parsed","parseFromString","body","textNodes","document","createTreeWalker","NodeFilter","SHOW_TEXT","n","nextNode","_n$nextSibling","_n$previousSibling","isWhiteSpace","isNotNearMarkup","nextSibling","parentNode","removeChild","parseHtml","window","serializer","Html","defaultBlock","rules","_extends","assign","target","source","prototype","hasOwnProperty","call","options","_options$toJSON","fragment","Array","from","deserializeElements","memo","original","_block","isVoid","json","schema","ret","Value","fromJSON","reduceMultipleBrs","markup","replace","console","reduceRedundantNewLineCharacters","fixHtmlCode","wrapperEl","innerHTML","fixParagraphs","child","p","attr","setAttribute","replaceWith","fixTables","tableArray","index","parent","nodesBefore","nodesAfter","allNodes","beforeEl","append","after","afterEl","emptyBlockCheck","parseNode","childArray","hasParagraphs","tables","remove","handleHtml","htmlToValue","valueToHtml"],"sources":["../src/serialization.jsx"],"sourcesContent":["import Html from 'slate-html-serializer';\nimport React from 'react';\nimport debug from 'debug';\nimport { object as toStyleObject } from 'to-style';\nimport { isEmpty } from 'lodash-es';\n\nimport { serialization as imgSerialization } from './plugins/image';\nimport { serialization as mathSerialization } from './plugins/math';\nimport { serialization as mediaSerialization } from './plugins/media';\nimport { serialization as listSerialization } from './plugins/list';\nimport { serialization as tableSerialization } from './plugins/table';\nimport { serialization as responseAreaSerialization } from './plugins/respArea';\nimport { Mark, Value } from 'slate';\nimport { BLOCK_TAGS } from './block-tags';\n\nconst log = debug('@pie-lib:editable-html:serialization');\n\n/**\n * Tags to marks.\n *\n * @type {Object}\n */\n\nconst MARK_TAGS = {\n b: 'bold',\n em: 'italic',\n u: 'underline',\n s: 'strikethrough',\n code: 'code',\n strong: 'bold',\n blockquote: 'blockquote',\n h3: 'h3',\n sup: 'sup',\n sub: 'sub',\n};\n\nexport const parseStyleString = (s) => {\n const regex = /([\\w-]*)\\s*:\\s*([^;]*)/g;\n let match;\n const result = {};\n while ((match = regex.exec(s))) {\n result[match[1]] = match[2].trim();\n }\n return result;\n};\n\nexport const getBase64 = (file) => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n reader.onload = () => resolve(reader.result);\n reader.onerror = (error) => reject(error);\n });\n};\n\nexport const reactAttributes = (o) => toStyleObject(o, { camelize: true, addUnits: false });\n\nconst attributesToMap = (el) => (acc, attribute) => {\n const value = el.getAttribute(attribute);\n if (value) {\n if (attribute === 'style') {\n const styleString = el.getAttribute(attribute);\n const reactStyleObject = reactAttributes(parseStyleString(styleString));\n acc['style'] = reactStyleObject;\n } else {\n acc[attribute] = el.getAttribute(attribute);\n }\n }\n return acc;\n};\n\nconst attributes = ['border', 'cellpadding', 'cellspacing', 'class', 'style', 'align'];\n\n/**\n * Serializer rules.\n *\n * @type {Array}\n */\n\nconst blocks = {\n deserialize(el, next) {\n log('[blocks:deserialize] block: ', el);\n const block = BLOCK_TAGS[el.tagName.toLowerCase()];\n if (!block) return;\n log('[blocks:deserialize] block: ', block);\n\n if (el.childNodes.length === 1) {\n const cn = el.childNodes[0];\n if (cn && cn.tagName && cn.tagName.toLowerCase() === block) {\n log('[we have a child node of the same]...');\n return;\n }\n }\n\n return {\n object: 'block',\n type: block,\n /**\n * Here for rendering styles for all block elements\n */\n data: { attributes: attributes.reduce(attributesToMap(el), {}) },\n nodes: next(el.childNodes),\n };\n },\n serialize: (object, children) => {\n if (object.object !== 'block') return;\n\n const jsonData = object.data.toJSON();\n\n log('[blocks:serialize] object: ', object, children);\n let key;\n\n for (key in BLOCK_TAGS) {\n if (BLOCK_TAGS[key] === object.type) {\n const Tag = key;\n\n return <Tag {...jsonData.attributes}>{children}</Tag>;\n }\n }\n },\n};\n\nexport const INLINE_TAGS = {\n span: 'span',\n};\n\nconst inlines = {\n deserialize(el, next) {\n log('[inlines:deserialize] inline: ', el);\n const inlineTag = INLINE_TAGS[el.tagName.toLowerCase()];\n if (!inlineTag) return;\n log('[inlines:deserialize] inline: ', inlineTag);\n\n if (el.childNodes.length === 1) {\n const cn = el.childNodes[0];\n if (cn && cn.tagName && cn.tagName.toLowerCase() === inlineTag) {\n log('[we have a child node of the same]...');\n return;\n }\n }\n\n return {\n object: 'inline',\n type: inlineTag,\n /**\n * Here for rendering styles for all inline elements\n */\n data: { attributes: attributes.reduce(attributesToMap(el), {}) },\n nodes: next(el.childNodes),\n };\n },\n serialize: (object, children) => {\n if (object.object !== 'inline') return;\n\n const jsonData = object.data.toJSON();\n\n log('[inlines:serialize] object: ', object, children);\n let key;\n\n for (key in INLINE_TAGS) {\n if (INLINE_TAGS[key] === object.type) {\n const Tag = key;\n\n return <Tag {...jsonData.attributes}>{children}</Tag>;\n }\n }\n },\n};\n\nexport const extraCSSRulesOpts = {};\n\nconst STYLES_MAP = {\n h3: {\n fontSize: 'inherit',\n fontWeight: 'inherit',\n },\n blockquote: {\n background: '#f9f9f9',\n borderLeft: '5px solid #ccc',\n margin: '1.5em 10px',\n padding: '.5em 10px',\n },\n};\n\nconst reactToHTMLAttributesMap = {\n class: 'className',\n};\n\nconst marks = {\n deserialize(el, next) {\n const mark = MARK_TAGS[el.tagName.toLowerCase()];\n const elClasses = el.getAttribute('class') || '';\n const hasCSSRule = (extraCSSRulesOpts?.names || []).find((name) => elClasses?.includes(name));\n\n if (!mark && !hasCSSRule) {\n return;\n }\n\n log('[deserialize] mark: ', mark);\n const attrs = attributes.reduce(attributesToMap(el), {});\n const data = isEmpty(attrs) ? undefined : { attributes: attrs };\n\n return {\n object: 'mark',\n type: hasCSSRule ? 'css' : mark,\n /**\n * Here for rendering styles for all elements\n */\n data,\n nodes: next(el.childNodes),\n };\n },\n serialize(object, children) {\n const jsonData = object.data?.toJSON() || {};\n const elClasses = jsonData.attributes?.class || '';\n const hasCSSRule = (extraCSSRulesOpts?.names || []).find((name) => elClasses?.includes(name));\n\n if (hasCSSRule) {\n const htmlAttrs = Object.keys(jsonData.attributes).reduce((obj, key) => {\n obj[reactToHTMLAttributesMap[key] || key] = jsonData.attributes[key];\n return obj;\n }, {});\n\n return <span {...htmlAttrs}>{children}</span>;\n }\n\n if (Mark.isMark(object)) {\n for (var key in MARK_TAGS) {\n if (MARK_TAGS[key] === object.type) {\n const Tag = key;\n const additionalStyles = STYLES_MAP[Tag];\n\n if (additionalStyles) {\n if (!jsonData.attributes) {\n jsonData.attributes = {};\n }\n\n jsonData.attributes.style = {\n ...jsonData.attributes.style,\n ...additionalStyles,\n };\n }\n\n return <Tag {...jsonData.attributes}>{children}</Tag>;\n }\n }\n }\n },\n};\n\n// eslint-disable-next-line no-unused-vars\nconst findPreviousText = (el) => {\n if (el.nodeName === '#text') {\n return el;\n }\n\n if (el.previousSibling) {\n return findPreviousText(el.previousSibling);\n }\n\n return null;\n};\n\nexport const TEXT_RULE = {\n deserialize(el) {\n /**\n * This needs to be called on the dom element in order to merge the adjacent text nodes together\n * */\n el.normalize();\n\n if (el.tagName && el.tagName.toLowerCase() === 'br') {\n return {\n object: 'text',\n leaves: [\n {\n object: 'leaf',\n text: '\\n',\n },\n ],\n };\n }\n\n if (el.nodeName === '#text') {\n if (el.nodeValue && el.nodeValue.match(/<!--.*?-->/)) return;\n\n log('[text:deserialize] return text object..');\n return {\n object: 'text',\n leaves: [\n {\n object: 'leaf',\n text: el.nodeValue,\n },\n ],\n };\n }\n },\n\n serialize(obj, children) {\n if (obj.object === 'string') {\n return children.split('\\n').reduce((array, text, i) => {\n if (i !== 0) array.push(<br />);\n array.push(text);\n return array;\n }, []);\n }\n },\n};\n\nconst RULES = [\n listSerialization,\n mathSerialization,\n mediaSerialization,\n imgSerialization,\n tableSerialization,\n responseAreaSerialization,\n TEXT_RULE,\n inlines,\n blocks,\n marks,\n];\n\nfunction allWhitespace(node) {\n // Use ECMA-262 Edition 3 String and RegExp features\n return !/[^\\t\\n\\r ]/.test(node.textContent);\n}\n\nfunction defaultParseHtml(html) {\n if (typeof DOMParser === 'undefined') {\n throw new Error(\n 'The native `DOMParser` global which the `Html` serializer uses by default is not present in this environment. You must supply the `options.parseHtml` function instead.',\n );\n }\n\n const parsed = new DOMParser().parseFromString(html, 'text/html');\n\n const { body } = parsed;\n var textNodes = document.createTreeWalker(body, NodeFilter.SHOW_TEXT, null, null);\n var n = textNodes.nextNode();\n\n while (n) {\n const isWhiteSpace = allWhitespace(n);\n const isNotNearMarkup =\n !MARK_TAGS[n.nextSibling?.tagName?.toLowerCase()] && !MARK_TAGS[n.previousSibling?.tagName?.toLowerCase()];\n\n if ((isWhiteSpace && isNotNearMarkup) || n.nodeValue === '\\u200B') {\n n.parentNode.removeChild(n);\n }\n n = textNodes.nextNode();\n }\n\n return body;\n}\n\n/** If this lib is used on the server side, we need to bypass using the DOMParser - just put in a stub. */\nconst parseHtml =\n typeof window === 'undefined'\n ? () => ({\n childNodes: [],\n })\n : defaultParseHtml;\n\nconst serializer = new Html({\n defaultBlock: 'div',\n rules: RULES,\n parseHtml,\n});\n\nconst _extends =\n Object.assign ||\n function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n/**\n * This is needed in order to override the function that eventually leads\n * to the max iteration of 12, which in most cases it's not enough. The newer versions\n * have a different way to calculate this, but updating to a newer version of slate\n * requires a lot of work fixing other issues. So we just increase the rules by 1000,\n * which means a lot of iterations.\n * Below is the code that calculates the max iterations.\n * var max = schema.stack.plugins.length + schema.rules.length + 1;\n */\nserializer.deserialize = function deserialize(html) {\n const options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n const _options$toJSON = options.toJSON;\n const toJSON = _options$toJSON === undefined ? false : _options$toJSON;\n const defaultBlock = this.defaultBlock;\n const parseHtml = this.parseHtml;\n\n const fragment = parseHtml(html);\n const children = Array.from(fragment.childNodes);\n let nodes = this.deserializeElements(children);\n\n // COMPAT: ensure that all top-level inline nodes are wrapped into a block.\n nodes = nodes.reduce(function (memo, node, i, original) {\n if (node.object === 'block') {\n memo.push(node);\n return memo;\n }\n\n if (i > 0 && original[i - 1].object !== 'block') {\n const _block = memo[memo.length - 1];\n\n _block.nodes.push(node);\n return memo;\n }\n\n const block = _extends({ object: 'block', data: {}, isVoid: false }, defaultBlock, {\n nodes: [node],\n });\n\n memo.push(block);\n return memo;\n }, []);\n\n if (nodes.length === 0) {\n nodes = [\n _extends({ object: 'block', data: {}, isVoid: false }, defaultBlock, {\n nodes: [{ object: 'text', leaves: [{ object: 'leaf', text: '', marks: [] }] }],\n }),\n ];\n }\n\n const json = {\n object: 'value',\n document: {\n object: 'document',\n data: {},\n nodes: nodes,\n },\n schema: {\n rules: [],\n },\n };\n\n let i;\n\n for (i = 0; i < 3000; i++) {\n json.schema.rules.push({\n match: { object: 'document' },\n nodes: [{ match: { object: 'block' } }],\n });\n }\n\n const ret = toJSON ? json : Value.fromJSON(json);\n\n if (ret) {\n return ret;\n }\n\n return null;\n};\n\nexport const reduceMultipleBrs = (markup) => {\n try {\n return markup.replace(/(<br\\s*\\/?>){3,}/gi, '<br>');\n } catch (e) {\n // eslint-disable-next-line no-console\n console.log(\"Couldn't remove <br/> tags: \", e);\n }\n\n return markup;\n};\n\nconst reduceRedundantNewLineCharacters = (markup) => {\n try {\n return markup.replace(/\\n/gi, '');\n } catch (e) {\n // eslint-disable-next-line no-console\n console.log(\"Couldn't remove <br/> tags: \", e);\n }\n\n return markup;\n};\n\n/**\n * Makes sure that the html provided respects the schema\n * rules for the slate editor.\n * @param markup\n * @returns {string}\n */\nconst fixHtmlCode = (markup) => {\n const wrapperEl = document.createElement('div');\n\n wrapperEl.innerHTML = markup;\n\n /**\n * DIV elements that are at the same level as paragraphs\n * are replaced with P elements for normalizing purposes\n * @param child\n */\n const fixParagraphs = (child) => {\n const p = document.createElement('p');\n\n p.innerHTML = child.innerHTML;\n\n Array.from(child.attributes).forEach((attr) => {\n p.setAttribute(attr.name, attr.value);\n });\n child.replaceWith(p);\n };\n\n /**\n * @summary Makes sure that tables are placed in the root document.\n * @description This function removes the tables from the nodes that are\n * placed inside the root element and places them exactly near\n * the parent element.\n * @param tableArray\n */\n const fixTables = (tableArray) => {\n tableArray.forEach((el) => {\n const { index, child, parent } = el;\n const nodesBefore = [];\n const nodesAfter = [];\n const allNodes = Array.from(parent.childNodes);\n let i;\n\n for (i = 0; i < allNodes.length; i++) {\n const node = allNodes[i];\n\n if (i < index) {\n nodesBefore.push(node);\n } else if (i > index) {\n nodesAfter.push(node);\n }\n }\n\n // creating the element that is going to be placed instead of the parent\n const beforeEl = document.createElement(parent.nodeName);\n\n beforeEl.append(...nodesBefore);\n\n // replacing parent with the beforeElement\n parent.replaceWith(beforeEl);\n\n // adding the table right after the before element\n beforeEl.after(child);\n\n // creating the element that is going to be placed after the table\n const afterEl = document.createElement(parent.nodeName);\n\n afterEl.append(...nodesAfter);\n\n // adding the after element near the table\n child.after(afterEl);\n });\n };\n\n const emptyBlockCheck = (node) =>\n (node.nodeName === 'DIV' || node.nodeName === 'P' || node.nodeName === 'LI') && node.childNodes.length === 0;\n\n const parseNode = (el) => {\n const childArray = Array.from(el.childNodes);\n const hasParagraphs = childArray.find((child) => child.nodeName === 'P');\n const tables = [];\n\n childArray.forEach((child, index) => {\n // removing empty blocks\n if (emptyBlockCheck(child)) {\n child.remove();\n return;\n }\n\n if (hasParagraphs && child.nodeName === 'DIV') {\n fixParagraphs(child);\n }\n\n if (wrapperEl !== el && child.nodeName === 'TABLE') {\n // we don't need to fix tables in the root element\n tables.push({\n index,\n child,\n parent: el,\n });\n }\n\n parseNode(child);\n });\n\n if (tables.length) {\n fixTables(tables);\n }\n };\n\n parseNode(wrapperEl);\n\n return wrapperEl.innerHTML;\n};\n\nexport const handleHtml = (html) => fixHtmlCode(reduceRedundantNewLineCharacters(reduceMultipleBrs(html)));\n\nexport const htmlToValue = (html) => {\n try {\n return serializer.deserialize(handleHtml(html));\n } catch (e) {\n // eslint-disable-next-line no-console\n console.log(\"Couldn't parse html: \", e);\n return {};\n }\n};\n\nexport const valueToHtml = (value) => serializer.serialize(value);\n\n/**\n *\n * <div><div>a</div></div> -> <div>a</div>\n *\n * <div><div>a</div><div>b</div></div> -> <div>a</div><div>b</div>\n * <div><div>a</div>4444<div>b</div></div> -> <div>a</div>4444<div>b</div>\n */\n"],"mappings":";;;;;;;;AAAA,IAAAA,oBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sB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AMgF,WAAW,GAAA1L,OAAA,CAAA0L,WAAA,GAAG,SAAdA,WAAWA,CAAIhF,IAAI,EAAK;EACnC,IAAI;IACF,OAAOsB,UAAU,CAACjG,WAAW,CAAC0J,UAAU,CAAC/E,IAAI,CAAC,CAAC;EACjD,CAAC,CAAC,OAAO5I,CAAC,EAAE;IACV;IACA+L,OAAO,CAAC3K,GAAG,CAAC,uBAAuB,EAAEpB,CAAC,CAAC;IACvC,OAAO,CAAC,CAAC;EACX;AACF,CAAC;AAEM,IAAM6N,WAAW,GAAA3L,OAAA,CAAA2L,WAAA,GAAG,SAAdA,WAAWA,CAAIlK,KAAK;EAAA,OAAKuG,UAAU,CAACpF,SAAS,CAACnB,KAAK,CAAC;AAAA;;AAEjE;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.object.define-property.js");
4
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
package/lib/theme.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.object.define-property.js");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
package/lib/theme.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"theme.js","names":["primary","exports"],"sources":["../src/theme.js"],"sourcesContent":["export const primary = '#304ffe';\n"],"mappings":";;;;;;;AAAO,IAAMA,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG,SAAS","ignoreList":[]}
1
+ {"version":3,"file":"theme.js","names":["primary","exports"],"sources":["../src/theme.js"],"sourcesContent":["export const primary = '#304ffe';\n"],"mappings":";;;;;;AAAO,IAAMA,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG,SAAS","ignoreList":[]}
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "@pie-lib/editable-html",
3
- "version": "12.1.1-next.0",
3
+ "version": "12.2.0-next.0+c7578ca",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.jsx",
8
8
  "author": "pie-framework developers",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/pie-framework/pie-lib"
12
+ },
9
13
  "dependencies": {
10
14
  "@dnd-kit/core": "6.3.1",
11
15
  "@dnd-kit/modifiers": "9.0.0",
@@ -14,16 +18,16 @@
14
18
  "@emotion/style": "^0.8.0",
15
19
  "@mui/icons-material": "^7.3.4",
16
20
  "@mui/material": "^7.3.4",
17
- "@pie-lib/drag": "^3.1.1-next.0",
18
- "@pie-lib/math-input": "^7.1.1-next.0",
19
- "@pie-lib/math-rendering": "^4.1.1-next.0",
20
- "@pie-lib/math-toolbar": "^2.1.1-next.0",
21
- "@pie-lib/render-ui": "^5.1.1-next.0",
21
+ "@pie-lib/drag": "^3.2.0-next.0+c7578ca",
22
+ "@pie-lib/math-input": "^7.2.0-next.0+c7578ca",
23
+ "@pie-lib/math-rendering": "^4.2.0-next.0+c7578ca",
24
+ "@pie-lib/math-toolbar": "^2.2.0-next.0+c7578ca",
25
+ "@pie-lib/render-ui": "^5.2.0-next.0+c7578ca",
22
26
  "change-case": "^3.0.2",
23
27
  "classnames": "^2.2.6",
24
28
  "debug": "^4.1.1",
25
29
  "immutable": "^4.3.7",
26
- "lodash": "^4.17.23",
30
+ "lodash-es": "^4.17.23",
27
31
  "prop-types": "^15.6.2",
28
32
  "react-attr-converter": "^0.3.1",
29
33
  "react-jss": "^8.6.1",
@@ -50,6 +54,6 @@
50
54
  "publishConfig": {
51
55
  "access": "public"
52
56
  },
53
- "gitHead": "7bb08145106e65c83a8f4a51902cf669d1be19ac",
57
+ "gitHead": "c7578cae82de46ec0dae41b7d1ef924401e6226d",
54
58
  "scripts": {}
55
59
  }
@@ -1,4 +1,4 @@
1
- import { valueToSize, buildSizeStyle } from '../editor';
1
+ import { buildSizeStyle, valueToSize } from '../editor';
2
2
 
3
3
  describe('Editor Utilities', () => {
4
4
  describe('valueToSize', () => {
@@ -124,7 +124,6 @@ describe('htmlToValue', () => {
124
124
  const html = `<div><p>foo<img src="blah.jpg"/>bar</p></div>`;
125
125
  const v = htmlToValue(html);
126
126
 
127
- console.log(JSON.stringify(v.toJSON()));
128
127
  expect(v.toJSON()).toEqual(expected);
129
128
  });
130
129
 
package/src/editor.jsx CHANGED
@@ -1,23 +1,21 @@
1
1
  import React from 'react';
2
2
  import { Editor as SlateEditor, findNode, getEventRange, getEventTransfer } from 'slate-react';
3
3
  import SlateTypes from 'slate-prop-types';
4
- import { Value, Block, Inline } from 'slate';
4
+ import { Block, Inline, Value } from 'slate';
5
5
  import Plain from 'slate-plain-serializer';
6
6
  import PropTypes from 'prop-types';
7
- import debounce from 'lodash/debounce';
8
- import isEqual from 'lodash/isEqual';
7
+ import { debounce, isEqual } from 'lodash-es';
9
8
  import classNames from 'classnames';
10
9
  import debug from 'debug';
11
10
  import { styled } from '@mui/material/styles';
12
11
 
13
- import { color } from '@pie-lib/render-ui';
12
+ import { color, PreviewPrompt } from '@pie-lib/render-ui';
14
13
  import AlertDialog from '../../config-ui/src/alert-dialog';
15
- import { PreviewPrompt } from '@pie-lib/render-ui';
16
14
 
15
+ import * as serialization from './serialization';
17
16
  import { getBase64, htmlToValue } from './serialization';
18
17
  import InsertImageHandler from './plugins/image/insert-image-handler';
19
- import * as serialization from './serialization';
20
- import { buildPlugins, ALL_PLUGINS, DEFAULT_PLUGINS } from './plugins';
18
+ import { ALL_PLUGINS, buildPlugins, DEFAULT_PLUGINS } from './plugins';
21
19
 
22
20
  export { ALL_PLUGINS, DEFAULT_PLUGINS, serialization };
23
21
 
@@ -33,8 +31,8 @@ const defaultToolbarOpts = {
33
31
 
34
32
  const defaultResponseAreaProps = {
35
33
  options: {},
36
- respAreaToolbar: () => { },
37
- onHandleAreaChange: () => { },
34
+ respAreaToolbar: () => {},
35
+ onHandleAreaChange: () => {},
38
36
  };
39
37
 
40
38
  const defaultLanguageCharactersProps = [];
@@ -199,10 +197,10 @@ export class Editor extends React.Component {
199
197
 
200
198
  static defaultProps = {
201
199
  disableUnderline: true,
202
- onFocus: () => { },
203
- onBlur: () => { },
204
- onKeyDown: () => { },
205
- runSerializationOnMarkup: () => { },
200
+ onFocus: () => {},
201
+ onBlur: () => {},
202
+ onKeyDown: () => {},
203
+ runSerializationOnMarkup: () => {},
206
204
  mathMlOptions: {
207
205
  mmlOutput: false,
208
206
  mmlEditing: false,
@@ -977,7 +975,7 @@ export class Editor extends React.Component {
977
975
  this.onChange(ch);
978
976
  const handler = new InsertImageHandler(
979
977
  inline,
980
- () => { },
978
+ () => {},
981
979
  () => this.state.value,
982
980
  this.onChange,
983
981
  true,
@@ -1076,13 +1074,11 @@ export class Editor extends React.Component {
1076
1074
  >
1077
1075
  {scheduled && <StyledUploadingMessage>Uploading image and then saving...</StyledUploadingMessage>}
1078
1076
  <StyledSlateEditor
1079
- className={classNames(
1080
- {
1081
- noPadding: toolbarOpts?.noPadding,
1082
- showParagraph: showParagraphs && !showParagraphs.disabled,
1083
- separateParagraph: separateParagraphs && !separateParagraphs.disabled,
1084
- },
1085
- )}
1077
+ className={classNames({
1078
+ noPadding: toolbarOpts?.noPadding,
1079
+ showParagraph: showParagraphs && !showParagraphs.disabled,
1080
+ separateParagraph: separateParagraphs && !separateParagraphs.disabled,
1081
+ })}
1086
1082
  >
1087
1083
  <SlateEditor
1088
1084
  plugins={this.plugins}
@@ -1120,7 +1116,7 @@ export class Editor extends React.Component {
1120
1116
  minHeight: sizeStyle.minHeight,
1121
1117
  height: sizeStyle.height,
1122
1118
  maxHeight: sizeStyle.maxHeight,
1123
- ...slateEditorExtraStyles
1119
+ ...slateEditorExtraStyles,
1124
1120
  }}
1125
1121
  pluginProps={otherPluginProps}
1126
1122
  toolbarOpts={toolbarOpts}
package/src/index.jsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import Editor, { DEFAULT_PLUGINS, ALL_PLUGINS } from './editor';
4
- import { extraCSSRulesOpts, htmlToValue, valueToHtml, reduceMultipleBrs } from './serialization';
3
+ import Editor, { ALL_PLUGINS, DEFAULT_PLUGINS } from './editor';
4
+ import { extraCSSRulesOpts, htmlToValue, reduceMultipleBrs, valueToHtml } from './serialization';
5
5
  import { parseDegrees } from './parse-html';
6
6
  import constants from './constants';
7
7
  import { Range } from 'slate';
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { createRoot } from 'react-dom/client';
3
- import debug from 'debug';
4
- import get from 'lodash/get';
3
+ import { debug } from 'debug';
4
+ import { get } from 'lodash-es';
5
5
 
6
6
  import { PureToolbar } from '@pie-lib/math-toolbar';
7
7
 
@@ -11,9 +11,7 @@ const StyledHtmlIcon = styled('div')(({ theme }) => ({
11
11
  whiteSpace: 'nowrap',
12
12
  }));
13
13
 
14
- const HtmlModeIcon = ({ isHtmlMode }) => (
15
- <StyledHtmlIcon>{isHtmlMode ? 'Exit <HTML> mode' : '<HTML>'}</StyledHtmlIcon>
16
- );
14
+ const HtmlModeIcon = ({ isHtmlMode }) => <StyledHtmlIcon>{isHtmlMode ? 'Exit <HTML> mode' : '<HTML>'}</StyledHtmlIcon>;
17
15
 
18
16
  HtmlModeIcon.propTypes = {
19
17
  isHtmlMode: PropTypes.bool.isRequired,
@@ -6,11 +6,7 @@ const toggleToRichText = (value, onChange, dismiss) => {
6
6
  const plainText = value.document.text;
7
7
  const slateValue = dismiss ? value : htmlToValue(plainText);
8
8
 
9
- const change = value
10
- .change()
11
- .selectAll()
12
- .delete()
13
- .insertFragment(slateValue.document);
9
+ const change = value.change().selectAll().delete().insertFragment(slateValue.document);
14
10
  onChange(change);
15
11
  };
16
12
 
@@ -37,11 +33,7 @@ export default function HtmlPlugin(opts) {
37
33
  };
38
34
 
39
35
  const handleHtmlModeOff = (value, onChange) => {
40
- const change = value
41
- .change()
42
- .selectAll()
43
- .delete()
44
- .insertText(valueToHtml(value));
36
+ const change = value.change().selectAll().delete().insertText(valueToHtml(value));
45
37
  onChange(change);
46
38
  };
47
39
 
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { render } from '@testing-library/react';
3
- import { Data, Block } from 'slate';
3
+ import { Block, Data } from 'slate';
4
4
  import { Component } from '../component';
5
5
 
6
6
  describe('Image Component', () => {
@@ -8,11 +8,7 @@ jest.mock('../alt-dialog', () => {
8
8
  return function AltDialog({ alt, onDone }) {
9
9
  return (
10
10
  <div data-testid="alt-dialog">
11
- <input
12
- data-testid="alt-input"
13
- defaultValue={alt}
14
- onChange={(e) => onDone(e.target.value)}
15
- />
11
+ <input data-testid="alt-input" defaultValue={alt} onChange={(e) => onDone(e.target.value)} />
16
12
  </div>
17
13
  );
18
14
  };
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import Toolbar from '../image-toolbar';
3
3
  import { render } from '@testing-library/react';
4
- import { Data, Block, Value } from 'slate';
5
4
 
6
5
  it('renders image toolbar', () => {
7
6
  const classes = { holder: 'holder' };
@@ -1,6 +1,3 @@
1
- import MockChange, { MockDocument } from './mock-change';
2
-
3
- import { Data } from 'slate';
4
1
  import ImageToolbar from '../';
5
2
 
6
3
  describe('image plugin', () => {
@@ -26,7 +26,7 @@ export class AltDialog extends React.Component {
26
26
  closeDialog = () => {
27
27
  const allDialogs = document.querySelectorAll('#text-dialog');
28
28
 
29
- allDialogs.forEach(function(s) {
29
+ allDialogs.forEach(function (s) {
30
30
  return s.remove();
31
31
  });
32
32
  };
@@ -55,8 +55,9 @@ export class AltDialog extends React.Component {
55
55
  hideBackdrop
56
56
  disableScrollLock
57
57
  TransitionProps={{
58
- onEntered: this.handleOverflow
59
- }}>
58
+ onEntered: this.handleOverflow,
59
+ }}
60
+ >
60
61
  <DialogContent>
61
62
  <div style={{ display: 'flex' }}>
62
63
  <ArrowBackIos style={{ paddingTop: '6px' }} />
@@ -17,8 +17,7 @@ import React from 'react';
17
17
  import Strikethrough from '@mui/icons-material/FormatStrikethrough';
18
18
  import ToolbarPlugin from './toolbar';
19
19
  import Underline from '@mui/icons-material/FormatUnderlined';
20
- import compact from 'lodash/compact';
21
- import isEmpty from 'lodash/isEmpty';
20
+ import { compact, isEmpty } from 'lodash-es';
22
21
  import SoftBreakPlugin from 'slate-soft-break';
23
22
  import debug from 'debug';
24
23
  import List from './list';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import List, { serialization } from '../index';
4
2
  import debug from 'debug';
5
3
 
@@ -100,17 +100,17 @@ const createEditList = () => {
100
100
  * Wrap the blocks in the current selection in a new list. Selected
101
101
  * lists are merged together.
102
102
  */
103
- core.changes.wrapInList = function(change, type, data) {
103
+ core.changes.wrapInList = function (change, type, data) {
104
104
  const selectedBlocks = getHighestSelectedBlocks(change.value);
105
105
 
106
106
  // Wrap in container
107
107
  change.wrapBlock({ type: type, data: Data.create(data) }, { normalize: false });
108
108
 
109
109
  // Wrap in list items
110
- selectedBlocks.forEach(function(node) {
110
+ selectedBlocks.forEach(function (node) {
111
111
  if (core.utils.isList(node)) {
112
112
  // Merge its items with the created list
113
- node.nodes.forEach(function(_ref) {
113
+ node.nodes.forEach(function (_ref) {
114
114
  const key = _ref.key;
115
115
  return change.unwrapNodeByKey(key, { normalize: false });
116
116
  });
@@ -156,7 +156,7 @@ const createEditList = () => {
156
156
  return change;
157
157
  }.bind(this, listOptions);
158
158
 
159
- core.utils.getItemsAtRange = function(opts, value, range) {
159
+ core.utils.getItemsAtRange = function (opts, value, range) {
160
160
  range = range || value.selection;
161
161
 
162
162
  if (!range.startKey) {
@@ -188,13 +188,13 @@ const createEditList = () => {
188
188
  return Immutable.List();
189
189
  }.bind(this, listOptions);
190
190
 
191
- core.utils.getListForItem = function(opts, value, item) {
191
+ core.utils.getListForItem = function (opts, value, item) {
192
192
  const { document } = value;
193
193
  const parent = document.getParent(item.key);
194
194
  return parent && core.utils.isList(parent) ? parent : null;
195
195
  }.bind(this, listOptions);
196
196
 
197
- core.utils.isSelectionInList = function(opts, value, type) {
197
+ core.utils.isSelectionInList = function (opts, value, type) {
198
198
  const items = core.utils.getItemsAtRange(value);
199
199
  return (
200
200
  !items.isEmpty() &&
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import debug from 'debug';
3
3
  import MockChange from '../../image/__tests__/mock-change';
4
4
  import { Data } from 'slate';
5
- import MathPlugin, { serialization, inlineMath, CustomToolbarComp } from '../index';
5
+ import MathPlugin, { CustomToolbarComp, inlineMath, serialization } from '../index';
6
6
  import { render, screen } from '@testing-library/react';
7
7
 
8
8
  jest.mock('@pie-framework/mathquill', () => ({
@@ -1,14 +1,14 @@
1
1
  import Functions from '@mui/icons-material/Functions';
2
2
  import { Inline } from 'slate';
3
3
  import { MathPreview, MathToolbar } from '@pie-lib/math-toolbar';
4
- import { wrapMath, unWrapMath, mmlToLatex, renderMath } from '@pie-lib/math-rendering';
4
+ import { mmlToLatex, renderMath, unWrapMath, wrapMath } from '@pie-lib/math-rendering';
5
5
  import React from 'react';
6
6
  import debug from 'debug';
7
7
  import SlatePropTypes from 'slate-prop-types';
8
8
  import PropTypes from 'prop-types';
9
9
 
10
10
  import { BLOCK_TAGS } from '../../block-tags';
11
- import isEqual from 'lodash/isEqual';
11
+ import { isEqual } from 'lodash-es';
12
12
 
13
13
  const log = debug('@pie-lib:editable-html:plugins:math');
14
14