@pie-lib/editable-html 11.1.2-next.0 → 11.2.0-beta.2

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 (166) hide show
  1. package/CHANGELOG.md +50 -158
  2. package/NEXT.CHANGELOG.json +1 -0
  3. package/package.json +11 -6
  4. package/src/__tests__/editor.test.jsx +363 -0
  5. package/src/__tests__/serialization.test.js +291 -0
  6. package/src/__tests__/utils.js +36 -0
  7. package/src/block-tags.js +17 -0
  8. package/src/constants.js +7 -0
  9. package/src/editor.jsx +303 -49
  10. package/src/index.jsx +19 -10
  11. package/src/plugins/characters/index.jsx +11 -3
  12. package/src/plugins/characters/utils.js +12 -12
  13. package/src/plugins/css/icons/index.jsx +17 -0
  14. package/src/plugins/css/index.jsx +346 -0
  15. package/src/plugins/customPlugin/index.jsx +85 -0
  16. package/src/plugins/html/index.jsx +9 -6
  17. package/src/plugins/image/__tests__/__snapshots__/component.test.jsx.snap +51 -0
  18. package/src/plugins/image/__tests__/__snapshots__/image-toolbar-logic.test.jsx.snap +27 -0
  19. package/src/plugins/image/__tests__/__snapshots__/image-toolbar.test.jsx.snap +44 -0
  20. package/src/plugins/image/__tests__/component.test.jsx +41 -0
  21. package/src/plugins/image/__tests__/image-toolbar-logic.test.jsx +42 -0
  22. package/src/plugins/image/__tests__/image-toolbar.test.jsx +11 -0
  23. package/src/plugins/image/__tests__/index.test.js +95 -0
  24. package/src/plugins/image/__tests__/insert-image-handler.test.js +113 -0
  25. package/src/plugins/image/__tests__/mock-change.js +15 -0
  26. package/src/plugins/image/index.jsx +2 -1
  27. package/src/plugins/image/insert-image-handler.js +13 -6
  28. package/src/plugins/index.jsx +248 -5
  29. package/src/plugins/list/__tests__/index.test.js +54 -0
  30. package/src/plugins/list/index.jsx +130 -0
  31. package/src/plugins/math/__tests__/__snapshots__/index.test.jsx.snap +48 -0
  32. package/src/plugins/math/__tests__/index.test.jsx +245 -0
  33. package/src/plugins/math/index.jsx +87 -56
  34. package/src/plugins/media/__tests__/index.test.js +75 -0
  35. package/src/plugins/media/index.jsx +3 -2
  36. package/src/plugins/media/media-dialog.js +106 -57
  37. package/src/plugins/rendering/index.js +31 -0
  38. package/src/plugins/respArea/drag-in-the-blank/choice.jsx +4 -1
  39. package/src/plugins/respArea/explicit-constructed-response/index.jsx +10 -8
  40. package/src/plugins/respArea/index.jsx +53 -7
  41. package/src/plugins/respArea/inline-dropdown/index.jsx +13 -6
  42. package/src/plugins/respArea/math-templated/index.jsx +104 -0
  43. package/src/plugins/respArea/utils.jsx +11 -0
  44. package/src/plugins/table/CustomTablePlugin.js +113 -0
  45. package/src/plugins/table/__tests__/__snapshots__/table-toolbar.test.jsx.snap +44 -0
  46. package/src/plugins/table/__tests__/index.test.jsx +401 -0
  47. package/src/plugins/table/__tests__/table-toolbar.test.jsx +42 -0
  48. package/src/plugins/table/index.jsx +46 -59
  49. package/src/plugins/table/table-toolbar.jsx +39 -2
  50. package/src/plugins/textAlign/icons/index.jsx +139 -0
  51. package/src/plugins/textAlign/index.jsx +23 -0
  52. package/src/plugins/toolbar/__tests__/__snapshots__/default-toolbar.test.jsx.snap +923 -0
  53. package/src/plugins/toolbar/__tests__/__snapshots__/editor-and-toolbar.test.jsx.snap +20 -0
  54. package/src/plugins/toolbar/__tests__/__snapshots__/toolbar-buttons.test.jsx.snap +36 -0
  55. package/src/plugins/toolbar/__tests__/__snapshots__/toolbar.test.jsx.snap +46 -0
  56. package/src/plugins/toolbar/__tests__/default-toolbar.test.jsx +94 -0
  57. package/src/plugins/toolbar/__tests__/editor-and-toolbar.test.jsx +37 -0
  58. package/src/plugins/toolbar/__tests__/toolbar-buttons.test.jsx +51 -0
  59. package/src/plugins/toolbar/__tests__/toolbar.test.jsx +106 -0
  60. package/src/plugins/toolbar/default-toolbar.jsx +82 -20
  61. package/src/plugins/toolbar/done-button.jsx +3 -1
  62. package/src/plugins/toolbar/editor-and-toolbar.jsx +18 -13
  63. package/src/plugins/toolbar/toolbar-buttons.jsx +52 -11
  64. package/src/plugins/toolbar/toolbar.jsx +31 -8
  65. package/src/serialization.jsx +213 -38
  66. package/README.md +0 -45
  67. package/deploy.sh +0 -16
  68. package/lib/editor.js +0 -1094
  69. package/lib/editor.js.map +0 -1
  70. package/lib/index.js +0 -253
  71. package/lib/index.js.map +0 -1
  72. package/lib/parse-html.js +0 -16
  73. package/lib/parse-html.js.map +0 -1
  74. package/lib/plugins/characters/custom-popper.js +0 -73
  75. package/lib/plugins/characters/custom-popper.js.map +0 -1
  76. package/lib/plugins/characters/index.js +0 -300
  77. package/lib/plugins/characters/index.js.map +0 -1
  78. package/lib/plugins/characters/utils.js +0 -381
  79. package/lib/plugins/characters/utils.js.map +0 -1
  80. package/lib/plugins/html/icons/index.js +0 -38
  81. package/lib/plugins/html/icons/index.js.map +0 -1
  82. package/lib/plugins/html/index.js +0 -76
  83. package/lib/plugins/html/index.js.map +0 -1
  84. package/lib/plugins/image/alt-dialog.js +0 -129
  85. package/lib/plugins/image/alt-dialog.js.map +0 -1
  86. package/lib/plugins/image/component.js +0 -419
  87. package/lib/plugins/image/component.js.map +0 -1
  88. package/lib/plugins/image/image-toolbar.js +0 -177
  89. package/lib/plugins/image/image-toolbar.js.map +0 -1
  90. package/lib/plugins/image/index.js +0 -262
  91. package/lib/plugins/image/index.js.map +0 -1
  92. package/lib/plugins/image/insert-image-handler.js +0 -152
  93. package/lib/plugins/image/insert-image-handler.js.map +0 -1
  94. package/lib/plugins/index.js +0 -143
  95. package/lib/plugins/index.js.map +0 -1
  96. package/lib/plugins/list/index.js +0 -204
  97. package/lib/plugins/list/index.js.map +0 -1
  98. package/lib/plugins/math/index.js +0 -419
  99. package/lib/plugins/math/index.js.map +0 -1
  100. package/lib/plugins/media/index.js +0 -384
  101. package/lib/plugins/media/index.js.map +0 -1
  102. package/lib/plugins/media/media-dialog.js +0 -668
  103. package/lib/plugins/media/media-dialog.js.map +0 -1
  104. package/lib/plugins/media/media-toolbar.js +0 -101
  105. package/lib/plugins/media/media-toolbar.js.map +0 -1
  106. package/lib/plugins/media/media-wrapper.js +0 -93
  107. package/lib/plugins/media/media-wrapper.js.map +0 -1
  108. package/lib/plugins/respArea/drag-in-the-blank/choice.js +0 -251
  109. package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +0 -1
  110. package/lib/plugins/respArea/drag-in-the-blank/index.js +0 -97
  111. package/lib/plugins/respArea/drag-in-the-blank/index.js.map +0 -1
  112. package/lib/plugins/respArea/explicit-constructed-response/index.js +0 -55
  113. package/lib/plugins/respArea/explicit-constructed-response/index.js.map +0 -1
  114. package/lib/plugins/respArea/icons/index.js +0 -95
  115. package/lib/plugins/respArea/icons/index.js.map +0 -1
  116. package/lib/plugins/respArea/index.js +0 -293
  117. package/lib/plugins/respArea/index.js.map +0 -1
  118. package/lib/plugins/respArea/inline-dropdown/index.js +0 -70
  119. package/lib/plugins/respArea/inline-dropdown/index.js.map +0 -1
  120. package/lib/plugins/respArea/utils.js +0 -110
  121. package/lib/plugins/respArea/utils.js.map +0 -1
  122. package/lib/plugins/table/icons/index.js +0 -69
  123. package/lib/plugins/table/icons/index.js.map +0 -1
  124. package/lib/plugins/table/index.js +0 -499
  125. package/lib/plugins/table/index.js.map +0 -1
  126. package/lib/plugins/table/table-toolbar.js +0 -158
  127. package/lib/plugins/table/table-toolbar.js.map +0 -1
  128. package/lib/plugins/toolbar/default-toolbar.js +0 -174
  129. package/lib/plugins/toolbar/default-toolbar.js.map +0 -1
  130. package/lib/plugins/toolbar/done-button.js +0 -50
  131. package/lib/plugins/toolbar/done-button.js.map +0 -1
  132. package/lib/plugins/toolbar/editor-and-toolbar.js +0 -287
  133. package/lib/plugins/toolbar/editor-and-toolbar.js.map +0 -1
  134. package/lib/plugins/toolbar/index.js +0 -34
  135. package/lib/plugins/toolbar/index.js.map +0 -1
  136. package/lib/plugins/toolbar/toolbar-buttons.js +0 -161
  137. package/lib/plugins/toolbar/toolbar-buttons.js.map +0 -1
  138. package/lib/plugins/toolbar/toolbar.js +0 -352
  139. package/lib/plugins/toolbar/toolbar.js.map +0 -1
  140. package/lib/plugins/utils.js +0 -62
  141. package/lib/plugins/utils.js.map +0 -1
  142. package/lib/serialization.js +0 -488
  143. package/lib/serialization.js.map +0 -1
  144. package/lib/theme.js +0 -9
  145. package/lib/theme.js.map +0 -1
  146. package/playground/image/data.js +0 -59
  147. package/playground/image/index.html +0 -22
  148. package/playground/image/index.jsx +0 -81
  149. package/playground/index.html +0 -25
  150. package/playground/mathquill/index.html +0 -22
  151. package/playground/mathquill/index.jsx +0 -155
  152. package/playground/package.json +0 -15
  153. package/playground/prod-test/index.html +0 -22
  154. package/playground/prod-test/index.jsx +0 -28
  155. package/playground/schema-override/data.js +0 -29
  156. package/playground/schema-override/image-plugin.jsx +0 -41
  157. package/playground/schema-override/index.html +0 -21
  158. package/playground/schema-override/index.jsx +0 -97
  159. package/playground/serialization/data.js +0 -29
  160. package/playground/serialization/image-plugin.jsx +0 -41
  161. package/playground/serialization/index.html +0 -22
  162. package/playground/serialization/index.jsx +0 -12
  163. package/playground/static.json +0 -3
  164. package/playground/table-examples.html +0 -70
  165. package/playground/webpack.config.js +0 -42
  166. package/static.json +0 -1
package/lib/editor.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/editor.jsx"],"names":["log","defaultToolbarOpts","position","alignment","alwaysVisible","showDone","doneOn","defaultResponseAreaProps","options","respAreaToolbar","onHandleAreaChange","defaultLanguageCharactersProps","createToolbarOpts","toolbarOpts","error","isHtmlMode","Editor","props","open","extraDialogProps","callback","setState","dialog","isEdited","prevState","state","newToolbarOpts","normalizedResponseAreaProps","responseAreaProps","htmlPluginOpts","toggleHtmlMode","handleAlertDialog","plugins","activePlugins","math","onClick","onMathClick","onFocus","onPluginFocus","onBlur","onPluginBlur","mathMlOptions","html","image","disableImageAlignmentButtons","onDelete","imageSupport","src","done","e","value","insertImageRequested","addedImage","getHandler","pendingImages","onFinish","result","cb","scheduled","onEditingDone","bind","newPendingImages","filter","img","key","newState","length","handler","add","maxImageWidth","maxImageHeight","toolbar","disableScrollbar","disableUnderline","autoWidth","autoWidthToolbar","onDone","nonEmpty","toolbarInFocus","focusedNode","editor","blur","startText","text","resetValue","then","table","responseArea","type","maxResponseAreas","languageCharacters","languageCharactersProps","media","focus","createChange","change","onChange","uploadSoundSupport","mmlOutput","mmlEditing","runSerializationOnMarkup","relatedTarget","target","node","stashedValue","stashValue","c","collapseToStartOf","selectedNode","resolve","event","Promise","preBlurValue","handleBlur","editorDOM","document","querySelector","setTimeout","stateValue","wrapperRef","editorElement","activeElement","closest","className","toolbarElement","toolbarRef","isInCurrentComponent","contains","removeEventListener","handleDomBlur","isFocused","__TEMPORARY_CHANGE_DATA","data","domEl","setNodeByKey","addEventListener","force","stopReset","reduce","s","p","toObject","newValue","Value","fromJSON","toJSON","charactersLimit","v","endsWith","undefined","parseInt","isNaN","object","last","nodes","parent","getParent","Block","pos","dropContext","transfer","file","files","fragment","inline","Inline","create","isVoid","loading","range","select","ch","insertInline","InsertImageHandler","fileChosen","insertFragment","selection","startBlock","defaultBlock","defaultMarks","getInsertMarksAtRange","frag","Plain","deserialize","placeholder","size","display","width","maxWidth","whiteSpace","opacity","pointerEvents","userSelect","onResize","handlePlugins","onRef","window","autoFocus","nextProps","differentCharacterProps","differentMathMlProps","equals","prevProps","zeroWidthEls","querySelectorAll","Array","from","forEach","el","style","minWidth","minHeight","height","maxHeight","valueToSize","disabled","spellCheck","highlightShape","classes","pluginProps","onKeyDown","sizeStyle","buildSizeStyle","names","withBg","toolbarOnTop","ref","uploading","r","slateEditor","editorRef","getFocusedValue","onDropPaste","normalize","noPadding","noBorder","renderPlaceholder","changeData","title","onClose","onConfirm","React","Component","PropTypes","bool","func","isRequired","any","SlateTypes","shape","number","oneOfType","string","oneOf","arrayOf","language","characterIcon","characters","values","allValid","every","ALL_PLUGINS","includes","Error","join","styles","backgroundColor","top","left","transform","fontFamily","tableLayout","borderCollapse","color","background","borderTop","padding","textAlign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AACZsD,IAAAA,SAAS,EAAE;AADC,GAxCD;AA2Cb7C,EAAAA,SAAS,EAAE;AACT0C,IAAAA,OAAO,EAAE;AADA;AA3CE,CAAf;;eAgDe,wBAAWX,MAAX,EAAmBzP,MAAnB,C","sourcesContent":["import { Editor as SlateEditor, findNode, getEventRange, getEventTransfer } from 'slate-react';\nimport SlateTypes from 'slate-prop-types';\n\nimport isEqual from 'lodash/isEqual';\nimport * as serialization from './serialization';\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport { Value, Block, Inline } from 'slate';\nimport { buildPlugins, ALL_PLUGINS, DEFAULT_PLUGINS } from './plugins';\nimport debug from 'debug';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport { color } from '@pie-lib/render-ui';\nimport Plain from 'slate-plain-serializer';\nimport { AlertDialog } from '@pie-lib/config-ui';\n\nimport { getBase64 } from './serialization';\nimport InsertImageHandler from './plugins/image/insert-image-handler';\n\nexport { ALL_PLUGINS, DEFAULT_PLUGINS, serialization };\n\nconst log = debug('editable-html:editor');\n\nconst defaultToolbarOpts = {\n position: 'bottom',\n alignment: 'left',\n alwaysVisible: false,\n showDone: true,\n doneOn: 'blur',\n};\n\nconst defaultResponseAreaProps = {\n options: {},\n respAreaToolbar: () => {},\n onHandleAreaChange: () => {},\n};\n\nconst defaultLanguageCharactersProps = [];\n\nconst createToolbarOpts = (toolbarOpts, error, isHtmlMode) => {\n return {\n ...defaultToolbarOpts,\n ...toolbarOpts,\n error,\n isHtmlMode,\n };\n};\n\nexport class Editor extends React.Component {\n static propTypes = {\n autoFocus: PropTypes.bool,\n editorRef: PropTypes.func.isRequired,\n error: PropTypes.any,\n onRef: PropTypes.func.isRequired,\n onChange: PropTypes.func.isRequired,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n onKeyDown: PropTypes.func,\n focus: PropTypes.func.isRequired,\n value: SlateTypes.value.isRequired,\n imageSupport: PropTypes.object,\n mathMlOptions: PropTypes.shape({\n mmlOutput: PropTypes.bool,\n mmlEditing: PropTypes.bool,\n }),\n disableImageAlignmentButtons: PropTypes.bool,\n uploadSoundSupport: PropTypes.shape({\n add: PropTypes.func,\n delete: PropTypes.func,\n }),\n charactersLimit: PropTypes.number,\n width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n minHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n classes: PropTypes.object.isRequired,\n highlightShape: PropTypes.bool,\n disabled: PropTypes.bool,\n spellCheck: PropTypes.bool,\n nonEmpty: PropTypes.bool,\n disableScrollbar: PropTypes.bool,\n disableUnderline: PropTypes.bool,\n autoWidthToolbar: PropTypes.bool,\n pluginProps: PropTypes.any,\n placeholder: PropTypes.string,\n responseAreaProps: PropTypes.shape({\n type: PropTypes.oneOf(['explicit-constructed-response', 'inline-dropdown', 'drag-in-the-blank']),\n options: PropTypes.object,\n respAreaToolbar: PropTypes.func,\n onHandleAreaChange: PropTypes.func,\n }),\n languageCharactersProps: PropTypes.arrayOf(\n PropTypes.shape({\n language: PropTypes.string,\n characterIcon: PropTypes.string,\n characters: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string)),\n }),\n ),\n runSerializationOnMarkup: PropTypes.func,\n toolbarOpts: PropTypes.shape({\n position: PropTypes.oneOf(['bottom', 'top']),\n alignment: PropTypes.oneOf(['left', 'right']),\n alwaysVisible: PropTypes.bool,\n showDone: PropTypes.bool,\n doneOn: PropTypes.string,\n }),\n activePlugins: PropTypes.arrayOf((values) => {\n const allValid = values.every((v) => ALL_PLUGINS.includes(v));\n\n return !allValid && new Error(`Invalid values: ${values}, values must be one of [${ALL_PLUGINS.join(',')}]`);\n }),\n className: PropTypes.string,\n maxImageWidth: PropTypes.number,\n maxImageHeight: PropTypes.number,\n };\n\n static defaultProps = {\n disableUnderline: true,\n onFocus: () => {},\n onBlur: () => {},\n onKeyDown: () => {},\n runSerializationOnMarkup: () => {},\n mathMlOptions: {\n mmlOutput: false,\n mmlEditing: false,\n },\n toolbarOpts: defaultToolbarOpts,\n responseAreaProps: defaultResponseAreaProps,\n languageCharactersProps: defaultLanguageCharactersProps,\n };\n\n constructor(props) {\n super(props);\n this.state = {\n value: props.value,\n toolbarOpts: createToolbarOpts(props.toolbarOpts, props.error),\n pendingImages: [],\n isHtmlMode: false,\n isEdited: false,\n dialog: {\n open: false,\n },\n };\n\n this.toggleHtmlMode = this.toggleHtmlMode.bind(this);\n\n this.onResize = () => {\n props.onChange(this.state.value, true);\n };\n\n this.handlePlugins(this.props);\n }\n\n handleAlertDialog = (open, extraDialogProps, callback) => {\n this.setState(\n {\n dialog: {\n open,\n ...extraDialogProps,\n },\n isEdited: false,\n },\n callback,\n );\n };\n\n toggleHtmlMode = () => {\n this.setState(\n (prevState) => ({\n isHtmlMode: !prevState.isHtmlMode,\n }),\n () => {\n const { error } = this.props;\n const { toolbarOpts } = this.state;\n const newToolbarOpts = createToolbarOpts(toolbarOpts, error, this.state.isHtmlMode);\n this.setState({\n toolbarOpts: newToolbarOpts,\n });\n },\n );\n };\n\n handlePlugins = (props) => {\n const normalizedResponseAreaProps = {\n ...defaultResponseAreaProps,\n ...props.responseAreaProps,\n };\n\n const htmlPluginOpts = {\n isHtmlMode: this.state.isHtmlMode,\n isEdited: this.state.isEdited,\n toggleHtmlMode: this.toggleHtmlMode,\n handleAlertDialog: this.handleAlertDialog,\n };\n\n this.plugins = buildPlugins(props.activePlugins, {\n math: {\n onClick: this.onMathClick,\n onFocus: this.onPluginFocus,\n onBlur: this.onPluginBlur,\n ...props.mathMlOptions,\n },\n html: htmlPluginOpts,\n image: {\n disableImageAlignmentButtons: props.disableImageAlignmentButtons,\n onDelete:\n props.imageSupport &&\n props.imageSupport.delete &&\n ((src, done) => {\n props.imageSupport.delete(src, (e) => {\n done(e, this.state.value);\n });\n }),\n insertImageRequested:\n props.imageSupport &&\n ((addedImage, getHandler) => {\n const { pendingImages } = this.state;\n const onFinish = (result) => {\n let cb;\n\n if (this.state.scheduled && result) {\n // finish editing only on success\n cb = this.onEditingDone.bind(this);\n }\n\n const newPendingImages = this.state.pendingImages.filter((img) => img.key !== addedImage.key);\n const newState = {\n pendingImages: newPendingImages,\n };\n\n if (newPendingImages.length === 0) {\n newState.scheduled = false;\n }\n\n this.setState(newState, cb);\n };\n const callback = () => {\n /**\n * The handler is the object through which the outer context\n * communicates file upload events like: fileChosen, cancel, progress\n */\n const handler = getHandler(onFinish, () => this.state.value);\n props.imageSupport.add(handler);\n };\n\n this.setState(\n {\n pendingImages: [...pendingImages, addedImage],\n },\n callback,\n );\n }),\n onFocus: this.onPluginFocus,\n onBlur: this.onPluginBlur,\n maxImageWidth: this.props.maxImageWidth,\n maxImageHeight: this.props.maxImageHeight,\n },\n toolbar: {\n /**\n * To minimize converting html -> state -> html\n * We only emit markup once 'done' is clicked.\n */\n disableScrollbar: !!props.disableScrollbar,\n disableUnderline: props.disableUnderline,\n autoWidth: props.autoWidthToolbar,\n onDone: () => {\n const { nonEmpty } = props;\n\n log('[onDone]');\n this.setState({ toolbarInFocus: false, focusedNode: null });\n this.editor.blur();\n\n if (nonEmpty && this.state.value.startText?.text?.length === 0) {\n this.resetValue(true).then(() => {\n this.onEditingDone();\n });\n } else {\n this.onEditingDone();\n }\n },\n },\n table: {\n onFocus: () => {\n log('[table:onFocus]...');\n this.onPluginFocus();\n },\n onBlur: () => {\n log('[table:onBlur]...');\n this.onPluginBlur();\n },\n },\n responseArea: {\n type: normalizedResponseAreaProps.type,\n options: normalizedResponseAreaProps.options,\n maxResponseAreas: normalizedResponseAreaProps.maxResponseAreas,\n respAreaToolbar: normalizedResponseAreaProps.respAreaToolbar,\n onHandleAreaChange: normalizedResponseAreaProps.onHandleAreaChange,\n error: normalizedResponseAreaProps.error,\n onFocus: () => {\n log('[table:onFocus]...');\n this.onPluginFocus();\n },\n onBlur: () => {\n log('[table:onBlur]...');\n this.onPluginBlur();\n },\n },\n languageCharacters: props.languageCharactersProps,\n media: {\n focus: this.focus,\n createChange: () => this.state.value.change(),\n onChange: this.onChange,\n uploadSoundSupport: props.uploadSoundSupport,\n },\n });\n\n if (props.mathMlOptions.mmlOutput || props.mathMlOptions.mmlEditing) {\n this.props.runSerializationOnMarkup();\n }\n };\n\n componentDidMount() {\n // onRef is needed to get the ref of the component because we export it using withStyles\n this.props.onRef(this);\n\n window.addEventListener('resize', this.onResize);\n\n if (this.editor && this.props.autoFocus) {\n Promise.resolve().then(() => {\n if (this.editor) {\n const editorDOM = document.querySelector(`[data-key=\"${this.editor.value.document.key}\"]`);\n\n this.editor.focus();\n\n if (editorDOM) {\n editorDOM.focus();\n }\n }\n });\n }\n }\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n const { isHtmlMode, toolbarOpts } = this.state;\n const newToolbarOpts = createToolbarOpts(nextProps.toolbarOpts, nextProps.error, isHtmlMode);\n\n if (!isEqual(newToolbarOpts, toolbarOpts)) {\n this.setState({\n toolbarOpts: newToolbarOpts,\n });\n }\n\n const differentCharacterProps = !isEqual(nextProps.languageCharactersProps, this.props.languageCharactersProps);\n const differentMathMlProps = !isEqual(nextProps.mathMlOptions, this.props.mathMlOptions);\n\n if (differentCharacterProps || differentMathMlProps) {\n this.handlePlugins(nextProps);\n }\n\n if (!nextProps.value?.document?.equals(this.props.value?.document)) {\n this.setState({\n focus: false,\n value: nextProps.value,\n });\n }\n }\n\n componentDidUpdate(prevProps, prevState) {\n // The cursor is on a zero width element and when that is placed near void elements, it is not visible\n // so we increase the width to at least 2px in order for the user to see it\n\n // Trigger plugins and finish editing if:\n // 1. The 'isHtmlMode' state has been toggled.\n // 2. We're currently in 'isHtmlMode' and the editor value has been modified.\n if (\n this.state.isHtmlMode !== prevState.isHtmlMode ||\n (this.state.isHtmlMode && !prevState.isEdited && this.state.isEdited)\n ) {\n this.handlePlugins(this.props);\n this.onEditingDone();\n }\n\n const zeroWidthEls = document.querySelectorAll('[data-slate-zero-width=\"z\"]');\n\n Array.from(zeroWidthEls).forEach((el) => {\n el.style.minWidth = '2px';\n el.style.display = 'inline-block';\n });\n }\n\n onPluginBlur = (e) => {\n log('[onPluginBlur]', e && e.relatedTarget);\n const target = e && e.relatedTarget;\n\n const node = target ? findNode(target, this.state.value) : null;\n log('[onPluginBlur] node: ', node);\n this.setState({ focusedNode: node }, () => {\n this.resetValue();\n });\n };\n\n onPluginFocus = (e) => {\n log('[onPluginFocus]', e && e.target);\n const target = e && e.target;\n if (target) {\n const node = findNode(target, this.state.value);\n log('[onPluginFocus] node: ', node);\n\n const stashedValue = this.state.stashedValue || this.state.value;\n this.setState({ focusedNode: node, stashedValue });\n } else {\n this.setState({ focusedNode: null });\n }\n this.stashValue();\n };\n\n onMathClick = (node) => {\n this.editor.change((c) => c.collapseToStartOf(node));\n this.setState({ selectedNode: node });\n };\n\n onEditingDone = () => {\n if (this.state.isHtmlMode) {\n return;\n }\n\n const { pendingImages } = this.state;\n\n if (pendingImages.length) {\n this.setState({ scheduled: true });\n return;\n }\n\n log('[onEditingDone]');\n this.setState({ pendingImages: [], stashedValue: null, focusedNode: null });\n log('[onEditingDone] value: ', this.state.value);\n this.props.onChange(this.state.value, true);\n };\n\n /**\n * Remove onResize event listener\n */\n componentWillUnmount() {\n window.removeEventListener('resize', this.onResize);\n }\n\n // Allowing time for onChange to take effect if it is called\n handleBlur = (resolve) => {\n const { nonEmpty } = this.props;\n const {\n toolbarOpts: { doneOn },\n } = this.state;\n\n this.setState({ toolbarInFocus: false, focusedNode: null });\n\n if (this.editor) {\n this.editor.blur();\n }\n\n if (doneOn === 'blur') {\n if (nonEmpty && this.state.value.startText?.text?.length === 0) {\n this.resetValue(true).then(() => {\n this.onEditingDone();\n resolve();\n });\n } else {\n this.onEditingDone();\n resolve();\n }\n }\n };\n\n onBlur = (event) => {\n log('[onBlur]');\n const target = event.relatedTarget;\n\n const node = target ? findNode(target, this.state.value) : null;\n\n log('[onBlur] node: ', node);\n\n return new Promise((resolve) => {\n this.setState(\n { preBlurValue: this.state.value, focusedNode: !node ? null : node },\n this.handleBlur.bind(this, resolve),\n );\n this.props.onBlur(event);\n });\n };\n\n handleDomBlur = (e) => {\n const editorDOM = document.querySelector(`[data-key=\"${this.state.value.document.key}\"]`);\n\n setTimeout(() => {\n const { value: stateValue } = this.state;\n\n if (!this.wrapperRef) {\n return;\n }\n\n const editorElement = !editorDOM || document.activeElement.closest(`[class*=\"${editorDOM.className}\"]`);\n const toolbarElement =\n !this.toolbarRef || document.activeElement.closest(`[class*=\"${this.toolbarRef.className}\"]`);\n const isInCurrentComponent = this.wrapperRef.contains(editorElement) || this.wrapperRef.contains(toolbarElement);\n\n if (!isInCurrentComponent) {\n editorDOM.removeEventListener('blur', this.handleDomBlur);\n\n if (stateValue.isFocused) {\n this.onBlur(e);\n }\n }\n }, 50);\n };\n\n /*\n * Needs to be wrapped otherwise it causes issues because of race conditions\n * Known issue for slatejs. See: https://github.com/ianstormtaylor/slate/issues/2097\n * Using timeout I wasn't able to test this\n *\n * Note: The use of promises has been causing issues with MathQuill\n * */\n onFocus = () =>\n new Promise((resolve) => {\n const editorDOM = document.querySelector(`[data-key=\"${this.state.value.document.key}\"]`);\n\n log('[onFocus]', document.activeElement);\n\n /**\n * This is a temporary hack - @see changeData below for some more information.\n */\n if (this.__TEMPORARY_CHANGE_DATA) {\n const { key, data } = this.__TEMPORARY_CHANGE_DATA;\n const domEl = document.querySelector(`[data-key=\"${key}\"]`);\n\n if (domEl) {\n let change = this.state.value.change().setNodeByKey(key, { data });\n\n this.setState({ value: change.value }, () => {\n this.__TEMPORARY_CHANGE_DATA = null;\n });\n }\n }\n\n /**\n * This is needed just in case the browser decides to make the editor\n * lose focus without triggering the onBlur event (can happen in a few cases).\n * This will also trigger onBlur if the user clicks outside of the page when the editor\n * is focused.\n */\n if (editorDOM === document.activeElement) {\n editorDOM.removeEventListener('blur', this.handleDomBlur);\n editorDOM.addEventListener('blur', this.handleDomBlur);\n }\n\n this.stashValue();\n this.props.onFocus();\n\n resolve();\n });\n\n stashValue = () => {\n log('[stashValue]');\n if (!this.state.stashedValue) {\n this.setState({ stashedValue: this.state.value });\n }\n };\n\n /**\n * Reset the value if the user didn't click done.\n */\n resetValue = (force) => {\n const { value, focusedNode } = this.state;\n\n const stopReset = this.plugins.reduce((s, p) => {\n return s || (p.stopReset && p.stopReset(this.state.value));\n }, false);\n\n log('[resetValue]', value.isFocused, focusedNode, 'stopReset: ', stopReset);\n if ((this.state.stashedValue && !value.isFocused && !focusedNode && !stopReset) || force) {\n log('[resetValue] resetting...');\n log('stashed', this.state.stashedValue.document.toObject());\n log('current', this.state.value.document.toObject());\n\n const newValue = Value.fromJSON(this.state.stashedValue.toJSON());\n\n log('newValue: ', newValue.document);\n return new Promise((resolve) => {\n setTimeout(() => {\n this.setState({ value: newValue, stashedValue: null }, () => {\n log('value now: ', this.state.value.document.toJSON());\n resolve();\n });\n }, 50);\n });\n } else {\n return Promise.resolve({});\n }\n };\n\n onChange = (change, done) => {\n log('[onChange]');\n\n const { value } = change;\n const { charactersLimit } = this.props;\n\n if (value && value.document && value.document.text && value.document.text.length > charactersLimit) {\n return;\n }\n\n // Mark the editor as edited when in HTML mode and its content has changed.\n // This status will later be used to decide whether to prompt a warning to the user when exiting HTML mode.\n const isEdited = !this.state.isHtmlMode\n ? false\n : this.state.value.document.text !== value.document.text\n ? true\n : this.state.isEdited;\n\n this.setState({ value, isEdited }, () => {\n log('[onChange], call done()');\n\n if (done) {\n done();\n }\n });\n };\n\n getFocusedValue = () => {\n if (this.state.value.isFocused) {\n return this.state.value;\n }\n\n return this.state.preBlurValue;\n };\n\n valueToSize = (v) => {\n if (!v) {\n return;\n }\n\n if (typeof v === 'string') {\n if (v.endsWith('%')) {\n return undefined;\n } else if (v.endsWith('px') || v.endsWith('vh') || v.endsWith('vw')) {\n return v;\n } else {\n const value = parseInt(v, 10);\n return isNaN(value) ? value : `${value}px`;\n }\n }\n if (typeof v === 'number') {\n return `${v}px`;\n }\n\n return;\n };\n\n buildSizeStyle() {\n const { width, minHeight, height, maxHeight } = this.props;\n\n return {\n width: this.valueToSize(width),\n height: this.valueToSize(height),\n minHeight: this.valueToSize(minHeight),\n maxHeight: this.valueToSize(maxHeight),\n };\n }\n\n validateNode = (node) => {\n if (node.object !== 'block') return;\n\n const last = node.nodes.last();\n if (!last) return;\n\n if (last.type !== 'image') return;\n\n log('[validateNode] last is image..');\n\n const parent = last.getParent(last.key);\n const p = Block.getParent(last.key);\n log('[validateNode] parent:', parent, p);\n\n return undefined;\n };\n\n changeData = (key, data) => {\n log('[changeData]. .. ', key, data);\n\n /**\n * HACK ALERT: We should be calling setState here and storing the change data:\n *\n * <code>this.setState({changeData: { key, data}})</code>\n * However this is causing issues with the Mathquill instance. The 'input' event stops firing on the element and no\n * more changes get through. The issues seem to be related to the promises in onBlur/onFocus. But removing these\n * brings it's own problems. A major clean up is planned for this component so I've decided to temporarily settle\n * on this hack rather than spend more time on this.\n */\n\n // Uncomment this line to see the bug described above.\n // this.setState({changeData: {key, data}})\n\n this.__TEMPORARY_CHANGE_DATA = { key, data };\n };\n\n focus = (pos, node) => {\n const position = pos || 'end';\n\n this.props.focus(position, node);\n };\n\n onDropPaste = async (event, change, dropContext) => {\n const editor = change.editor;\n const transfer = getEventTransfer(event);\n const file = transfer.files && transfer.files[0];\n\n const type = transfer.type;\n const fragment = transfer.fragment;\n const text = transfer.text;\n\n if (file && (file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png')) {\n if (!this.props.imageSupport) {\n return;\n }\n try {\n log('[onDropPaste]');\n const src = await getBase64(file);\n const inline = Inline.create({\n type: 'image',\n isVoid: true,\n data: {\n loading: false,\n src,\n },\n });\n\n if (dropContext) {\n this.focus();\n } else {\n const range = getEventRange(event, editor);\n if (range) {\n change.select(range);\n }\n }\n\n const ch = change.insertInline(inline);\n this.onChange(ch);\n const handler = new InsertImageHandler(\n inline,\n () => {},\n () => this.state.value,\n this.onChange,\n true,\n );\n handler.fileChosen(file);\n this.props.imageSupport.add(handler);\n } catch (err) {\n log('[onDropPaste] error: ', err);\n }\n } else if (type === 'fragment') {\n change.insertFragment(fragment);\n } else if (type === 'text' || type === 'html') {\n if (!text) {\n return;\n }\n const {\n value: { document, selection, startBlock },\n } = change;\n\n if (startBlock.isVoid) {\n return;\n }\n\n const defaultBlock = startBlock;\n const defaultMarks = document.getInsertMarksAtRange(selection);\n const frag = Plain.deserialize(text, {\n defaultBlock,\n defaultMarks,\n }).document;\n change.insertFragment(frag);\n }\n };\n\n renderPlaceholder = (props) => {\n const { editor } = props;\n const { document } = editor.value;\n\n if (!editor.props.placeholder || document.text !== '' || document.nodes.size !== 1) {\n return false;\n }\n\n return (\n <span\n contentEditable={false}\n style={{\n display: 'inline-block',\n width: 'fit-content', // for centering the placeholder if text-align is set to center\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: '0.33',\n pointerEvents: 'none',\n userSelect: 'none',\n }}\n >\n {editor.props.placeholder}\n </span>\n );\n };\n\n render() {\n const {\n disabled,\n spellCheck,\n highlightShape,\n classes,\n className,\n placeholder,\n pluginProps,\n onKeyDown,\n } = this.props;\n\n const { value, focusedNode, toolbarOpts, dialog, scheduled } = this.state;\n\n log('[render] value: ', value);\n const sizeStyle = this.buildSizeStyle();\n const names = classNames(\n {\n [classes.withBg]: highlightShape,\n [classes.toolbarOnTop]: toolbarOpts.alwaysVisible && toolbarOpts.position === 'top',\n [classes.scheduled]: scheduled,\n },\n className,\n );\n\n return (\n <div ref={(ref) => (this.wrapperRef = ref)} style={{ width: sizeStyle.width }} className={names}>\n {scheduled && <div className={classes.uploading}>Uploading image and then saving...</div>}\n <SlateEditor\n plugins={this.plugins}\n innerRef={(r) => {\n if (r) {\n this.slateEditor = r;\n }\n }}\n ref={(r) => (this.editor = r && this.props.editorRef(r))}\n toolbarRef={(r) => {\n if (r) {\n this.toolbarRef = r;\n }\n }}\n value={value}\n focus={this.focus}\n onKeyDown={onKeyDown}\n onChange={this.onChange}\n getFocusedValue={this.getFocusedValue}\n onBlur={this.onBlur}\n onDrop={(event, editor) => this.onDropPaste(event, editor, true)}\n onPaste={(event, editor) => this.onDropPaste(event, editor)}\n onFocus={this.onFocus}\n onEditingDone={this.onEditingDone}\n focusedNode={focusedNode}\n normalize={this.normalize}\n readOnly={disabled}\n spellCheck={spellCheck}\n autoCorrect={spellCheck}\n className={classNames(\n {\n [classes.noPadding]: toolbarOpts && toolbarOpts.noBorder,\n },\n classes.slateEditor,\n )}\n style={{\n minHeight: sizeStyle.minHeight,\n height: sizeStyle.height,\n maxHeight: sizeStyle.maxHeight,\n }}\n pluginProps={pluginProps}\n toolbarOpts={toolbarOpts}\n placeholder={placeholder}\n renderPlaceholder={this.renderPlaceholder}\n onDataChange={this.changeData}\n />\n <AlertDialog\n open={dialog.open}\n title={dialog.title}\n text={dialog.text}\n onClose={dialog.onClose}\n onConfirm={dialog.onConfirm}\n />\n </div>\n );\n }\n}\n\n// TODO color - hardcoded gray background and keypad colors will need to change too\nconst styles = {\n withBg: {\n backgroundColor: 'rgba(0,0,0,0.06)',\n },\n scheduled: {\n opacity: 0.5,\n pointerEvents: 'none',\n position: 'relative',\n },\n uploading: {\n position: 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n },\n slateEditor: {\n fontFamily: 'Roboto, sans-serif',\n\n '& table': {\n tableLayout: 'fixed',\n width: '100%',\n borderCollapse: 'collapse',\n color: color.text(),\n backgroundColor: color.background(),\n },\n '& table:not([border=\"1\"]) tr': {\n borderTop: '1px solid #dfe2e5',\n // TODO perhaps secondary color for background, for now disable\n // '&:nth-child(2n)': {\n // backgroundColor: '#f6f8fa'\n // }\n },\n '& td, th': {\n padding: '.6em 1em',\n textAlign: 'center',\n },\n '& table:not([border=\"1\"]) td, th': {\n border: '1px solid #dfe2e5',\n },\n },\n toolbarOnTop: {\n marginTop: '45px',\n },\n noPadding: {\n padding: '0 !important',\n },\n};\n\nexport default withStyles(styles)(Editor);\n"],"file":"editor.js"}
package/lib/index.js DELETED
@@ -1,253 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- Object.defineProperty(exports, "ALL_PLUGINS", {
11
- enumerable: true,
12
- get: function get() {
13
- return _editor.ALL_PLUGINS;
14
- }
15
- });
16
- Object.defineProperty(exports, "DEFAULT_PLUGINS", {
17
- enumerable: true,
18
- get: function get() {
19
- return _editor.DEFAULT_PLUGINS;
20
- }
21
- });
22
- Object.defineProperty(exports, "Editor", {
23
- enumerable: true,
24
- get: function get() {
25
- return _editor["default"];
26
- }
27
- });
28
- exports["default"] = void 0;
29
- Object.defineProperty(exports, "htmlToValue", {
30
- enumerable: true,
31
- get: function get() {
32
- return _serialization.htmlToValue;
33
- }
34
- });
35
- Object.defineProperty(exports, "valueToHtml", {
36
- enumerable: true,
37
- get: function get() {
38
- return _serialization.valueToHtml;
39
- }
40
- });
41
-
42
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
43
-
44
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
45
-
46
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
47
-
48
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
49
-
50
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
51
-
52
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
53
-
54
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
55
-
56
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
57
-
58
- var _react = _interopRequireDefault(require("react"));
59
-
60
- var _propTypes = _interopRequireDefault(require("prop-types"));
61
-
62
- var _editor = _interopRequireWildcard(require("./editor"));
63
-
64
- var _serialization = require("./serialization");
65
-
66
- var _parseHtml = require("./parse-html");
67
-
68
- var _debug = _interopRequireDefault(require("debug"));
69
-
70
- var _slate = require("slate");
71
-
72
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
73
-
74
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
75
-
76
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
77
-
78
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
79
-
80
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
81
-
82
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
83
-
84
- var log = (0, _debug["default"])('@pie-lib:editable-html');
85
- /**
86
- * Export lower level Editor and serialization functions.
87
- */
88
-
89
- /**
90
- * Wrapper around the editor that exposes a `markup` and `onChange(markup:string)` api.
91
- * Because of the mismatch between the markup and the `Value` we need to convert the incoming markup to a value and
92
- * compare it. TODO: This is an interim fix, we'll need to strip back `Editor` and look how best to maintain the
93
- * `markup` api whilst avoiding the serialization mismatch. We should be making better use of schemas w/ normalize.
94
- */
95
- var EditableHtml = /*#__PURE__*/function (_React$Component) {
96
- (0, _inherits2["default"])(EditableHtml, _React$Component);
97
-
98
- var _super = _createSuper(EditableHtml);
99
-
100
- function EditableHtml(props) {
101
- var _this;
102
-
103
- (0, _classCallCheck2["default"])(this, EditableHtml);
104
- _this = _super.call(this, props);
105
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "runSerializationOnMarkup", function () {
106
- if (!_this.props.markup) {
107
- return;
108
- }
109
-
110
- var v = (0, _serialization.htmlToValue)((0, _serialization.reduceMultipleBrs)(_this.props.markup));
111
-
112
- _this.setState({
113
- value: v
114
- });
115
- });
116
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (value, done) {
117
- var html = (0, _serialization.valueToHtml)(value);
118
- var htmlParsed = (0, _parseHtml.parseDegrees)(html);
119
- log('value as html: ', html);
120
-
121
- if (html !== _this.props.markup) {
122
- _this.props.onChange(htmlParsed);
123
- }
124
-
125
- if (done) {
126
- _this.props.onDone(htmlParsed);
127
- }
128
- });
129
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "focus", function (position, node) {
130
- var select = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
131
-
132
- if (_this.editorRef) {
133
- _this.editorRef.change(function (c) {
134
- var lastText = node ? c.value.document.getNextText(node.key) : c.value.document.getLastText();
135
- var editorDOM = document.querySelector("[data-key=\"".concat(_this.editorRef.value.document.key, "\"]"));
136
-
137
- if (editorDOM !== document.activeElement) {
138
- document.activeElement.blur();
139
- }
140
-
141
- c.focus();
142
-
143
- if (position === 'end' && lastText) {
144
- var _lastText$text, _lastText$text2;
145
-
146
- c.moveFocusTo(lastText.key, (_lastText$text = lastText.text) === null || _lastText$text === void 0 ? void 0 : _lastText$text.length).moveAnchorTo(lastText.key, (_lastText$text2 = lastText.text) === null || _lastText$text2 === void 0 ? void 0 : _lastText$text2.length);
147
-
148
- if (select) {
149
- var _lastText$text3;
150
-
151
- var range = _slate.Range.fromJSON({
152
- anchorKey: lastText.key,
153
- anchorOffset: 0,
154
- focusKey: lastText.key,
155
- focusOffset: (_lastText$text3 = lastText.text) === null || _lastText$text3 === void 0 ? void 0 : _lastText$text3.length,
156
- isFocused: true,
157
- isBackward: false
158
- });
159
-
160
- c.select(range);
161
- }
162
- }
163
-
164
- if (position === 'beginning' && lastText) {
165
- c.moveFocusTo(lastText.key, 0).moveAnchorTo(lastText.key, 0);
166
- }
167
-
168
- editorDOM.focus();
169
- });
170
- }
171
- });
172
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "finishEditing", function () {
173
- if (_this.editorRef) {
174
- _this.editorRef.props.onEditingDone();
175
- }
176
- });
177
-
178
- var _v = (0, _serialization.htmlToValue)(props.markup);
179
-
180
- _this.state = {
181
- value: _v
182
- };
183
- return _this;
184
- } // eslint-disable-next-line react/no-deprecated
185
-
186
-
187
- (0, _createClass2["default"])(EditableHtml, [{
188
- key: "componentWillReceiveProps",
189
- value: function componentWillReceiveProps(props) {
190
- if (!props.allowValidation && props.markup === this.props.markup) {
191
- return;
192
- }
193
-
194
- var v = (0, _serialization.htmlToValue)(props.markup);
195
- var current = (0, _serialization.htmlToValue)(props.markup);
196
-
197
- if (v.equals && !v.equals(current)) {
198
- this.setState({
199
- value: v
200
- });
201
- }
202
- }
203
- }, {
204
- key: "render",
205
- value: function render() {
206
- var _this2 = this;
207
-
208
- var value = this.state.value;
209
- var _this$props = this.props,
210
- toolbarOpts = _this$props.toolbarOpts,
211
- error = _this$props.error;
212
-
213
- if (toolbarOpts) {
214
- toolbarOpts.error = error;
215
- }
216
-
217
- var props = _objectSpread(_objectSpread({}, this.props), {}, {
218
- markup: null,
219
- value: value,
220
- onChange: this.onChange,
221
- focus: this.focus,
222
- runSerializationOnMarkup: this.runSerializationOnMarkup
223
- });
224
-
225
- return /*#__PURE__*/_react["default"].createElement(_editor["default"], (0, _extends2["default"])({
226
- onRef: function onRef(ref) {
227
- if (ref) {
228
- _this2.rootRef = ref;
229
- }
230
- },
231
- editorRef: function editorRef(ref) {
232
- return ref && (_this2.editorRef = ref);
233
- }
234
- }, props));
235
- }
236
- }]);
237
- return EditableHtml;
238
- }(_react["default"].Component);
239
-
240
- exports["default"] = EditableHtml;
241
- (0, _defineProperty2["default"])(EditableHtml, "propTypes", {
242
- error: _propTypes["default"].any,
243
- onChange: _propTypes["default"].func.isRequired,
244
- onDone: _propTypes["default"].func,
245
- markup: _propTypes["default"].string.isRequired,
246
- allowValidation: _propTypes["default"].bool,
247
- toolbarOpts: _propTypes["default"].object
248
- });
249
- (0, _defineProperty2["default"])(EditableHtml, "defaultProps", {
250
- onDone: function onDone() {},
251
- allowValidation: false
252
- });
253
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.jsx"],"names":["log","EditableHtml","props","markup","v","setState","value","done","html","htmlParsed","onChange","onDone","position","node","select","editorRef","change","c","lastText","document","getNextText","key","getLastText","editorDOM","querySelector","activeElement","blur","focus","moveFocusTo","text","length","moveAnchorTo","range","Range","fromJSON","anchorKey","anchorOffset","focusKey","focusOffset","isFocused","isBackward","onEditingDone","state","allowValidation","current","equals","toolbarOpts","error","runSerializationOnMarkup","ref","rootRef","React","Component","PropTypes","any","func","isRequired","string","bool","object"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,wBAAN,CAAZ;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;IACqBC,Y;;;;;AAenB,wBAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,iHAsBQ,YAAM;AAC/B,UAAI,CAAC,MAAKA,KAAL,CAAWC,MAAhB,EAAwB;AACtB;AACD;;AAED,UAAMC,CAAC,GAAG,gCAAY,sCAAkB,MAAKF,KAAL,CAAWC,MAA7B,CAAZ,CAAV;;AAEA,YAAKE,QAAL,CAAc;AAAEC,QAAAA,KAAK,EAAEF;AAAT,OAAd;AACD,KA9BkB;AAAA,iGAgCR,UAACE,KAAD,EAAQC,IAAR,EAAiB;AAC1B,UAAMC,IAAI,GAAG,gCAAYF,KAAZ,CAAb;AACA,UAAMG,UAAU,GAAG,6BAAaD,IAAb,CAAnB;AAEAR,MAAAA,GAAG,CAAC,iBAAD,EAAoBQ,IAApB,CAAH;;AAEA,UAAIA,IAAI,KAAK,MAAKN,KAAL,CAAWC,MAAxB,EAAgC;AAC9B,cAAKD,KAAL,CAAWQ,QAAX,CAAoBD,UAApB;AACD;;AAED,UAAIF,IAAJ,EAAU;AACR,cAAKL,KAAL,CAAWS,MAAX,CAAkBF,UAAlB;AACD;AAC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qBC,KAArB,eAAqBA,KAArB;;AAEA,UAAID,WAAJ,EAAiB;AACfA,QAAAA,WAAW,CAACC,KAAZ,GAAoBA,KAApB;AACD;;AAED,UAAM7C,KAAK,mCACN,KAAKA,KADC;AAETC,QAAAA,MAAM,EAAE,IAFC;AAGTG,QAAAA,KAAK,EAALA,KAHS;AAITI,QAAAA,QAAQ,EAAE,KAAKA,QAJN;AAKTiB,QAAAA,KAAK,EAAE,KAAKA,KALH;AAMTqB,QAAAA,wBAAwB,EAAE,KAAKA;AANtB,QAAX;;AASA,0BACE,gCAAC,kBAAD;AACE,QAAA,KAAK,EAAE,eAACC,GAAD,EAAS;AACd,cAAIA,GAAJ,EAAS;AACP,YAAA,MAAI,CAACC,OAAL,GAAeD,GAAf;AACD;AACF,SALH;AAME,QAAA,SAAS,EAAE,mBAACA,GAAD;AAAA,iBAASA,GAAG,KAAK,MAAI,CAAClC,SAAL,GAAiBkC,GAAtB,CAAZ;AAAA;AANb,SAOM/C,KAPN,EADF;AAWD;;;EAnIuCiD,kBAAMC,S;;;iCAA3BnD,Y,eACA;AACjB8C,EAAAA,KAAK,EAAEM,sBAAUC,GADA;AAEjB5C,EAAAA,QAAQ,EAAE2C,sBAAUE,IAAV,CAAeC,UAFR;AAGjB7C,EAAAA,MAAM,EAAE0C,sBAAUE,IAHD;AAIjBpD,EAAAA,MAAM,EAAEkD,sBAAUI,MAAV,CAAiBD,UAJR;AAKjBb,EAAAA,eAAe,EAAEU,sBAAUK,IALV;AAMjBZ,EAAAA,WAAW,EAAEO,sBAAUM;AANN,C;iCADA1D,Y,kBAUG;AACpBU,EAAAA,MAAM,EAAE,kBAAM,CAAE,CADI;AAEpBgC,EAAAA,eAAe,EAAE;AAFG,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Editor, { DEFAULT_PLUGINS, ALL_PLUGINS } from './editor';\nimport { htmlToValue, valueToHtml, reduceMultipleBrs } from './serialization';\nimport { parseDegrees } from './parse-html';\nimport debug from 'debug';\nimport { Range } from 'slate';\n\nconst log = debug('@pie-lib:editable-html');\n/**\n * Export lower level Editor and serialization functions.\n */\nexport { htmlToValue, valueToHtml, Editor, DEFAULT_PLUGINS, ALL_PLUGINS };\n\n/**\n * Wrapper around the editor that exposes a `markup` and `onChange(markup:string)` api.\n * Because of the mismatch between the markup and the `Value` we need to convert the incoming markup to a value and\n * compare it. TODO: This is an interim fix, we'll need to strip back `Editor` and look how best to maintain the\n * `markup` api whilst avoiding the serialization mismatch. We should be making better use of schemas w/ normalize.\n */\nexport default class EditableHtml extends React.Component {\n static propTypes = {\n error: PropTypes.any,\n onChange: PropTypes.func.isRequired,\n onDone: PropTypes.func,\n markup: PropTypes.string.isRequired,\n allowValidation: PropTypes.bool,\n toolbarOpts: PropTypes.object,\n };\n\n static defaultProps = {\n onDone: () => {},\n allowValidation: false,\n };\n\n constructor(props) {\n super(props);\n const v = htmlToValue(props.markup);\n this.state = {\n value: v,\n };\n }\n\n // eslint-disable-next-line react/no-deprecated\n componentWillReceiveProps(props) {\n if (!props.allowValidation && props.markup === this.props.markup) {\n return;\n }\n\n const v = htmlToValue(props.markup);\n const current = htmlToValue(props.markup);\n\n if (v.equals && !v.equals(current)) {\n this.setState({ value: v });\n }\n }\n\n runSerializationOnMarkup = () => {\n if (!this.props.markup) {\n return;\n }\n\n const v = htmlToValue(reduceMultipleBrs(this.props.markup));\n\n this.setState({ value: v });\n };\n\n onChange = (value, done) => {\n const html = valueToHtml(value);\n const htmlParsed = parseDegrees(html);\n\n log('value as html: ', html);\n\n if (html !== this.props.markup) {\n this.props.onChange(htmlParsed);\n }\n\n if (done) {\n this.props.onDone(htmlParsed);\n }\n };\n\n focus = (position, node, select = false) => {\n if (this.editorRef) {\n this.editorRef.change((c) => {\n const lastText = node ? c.value.document.getNextText(node.key) : c.value.document.getLastText();\n const editorDOM = document.querySelector(`[data-key=\"${this.editorRef.value.document.key}\"]`);\n\n if (editorDOM !== document.activeElement) {\n document.activeElement.blur();\n }\n\n c.focus();\n\n if (position === 'end' && lastText) {\n c.moveFocusTo(lastText.key, lastText.text?.length).moveAnchorTo(lastText.key, lastText.text?.length);\n if (select) {\n const range = Range.fromJSON({\n anchorKey: lastText.key,\n anchorOffset: 0,\n focusKey: lastText.key,\n focusOffset: lastText.text?.length,\n isFocused: true,\n isBackward: false,\n });\n c.select(range);\n }\n }\n\n if (position === 'beginning' && lastText) {\n c.moveFocusTo(lastText.key, 0).moveAnchorTo(lastText.key, 0);\n }\n editorDOM.focus();\n });\n }\n };\n\n finishEditing = () => {\n if (this.editorRef) {\n this.editorRef.props.onEditingDone();\n }\n };\n\n render() {\n const { value } = this.state;\n const { toolbarOpts, error } = this.props;\n\n if (toolbarOpts) {\n toolbarOpts.error = error;\n }\n\n const props = {\n ...this.props,\n markup: null,\n value,\n onChange: this.onChange,\n focus: this.focus,\n runSerializationOnMarkup: this.runSerializationOnMarkup,\n };\n\n return (\n <Editor\n onRef={(ref) => {\n if (ref) {\n this.rootRef = ref;\n }\n }}\n editorRef={(ref) => ref && (this.editorRef = ref)}\n {...props}\n />\n );\n }\n}\n"],"file":"index.js"}
package/lib/parse-html.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.parseDegrees = void 0;
7
-
8
- var parseDegrees = function parseDegrees(html) {
9
- return html // removes \( use case: 50°
10
- .replace(/\\[(]/g, '') // removes \) use case: 50°+m<1
11
- .replace(/\\[)]/g, '') // removes \degree use case: 50°
12
- .replace(/\\degree/g, '&deg;');
13
- };
14
-
15
- exports.parseDegrees = parseDegrees;
16
- //# sourceMappingURL=parse-html.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/parse-html.js"],"names":["parseDegrees","html","replace"],"mappings":";;;;;;;AAAO,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAACC,IAAD;AAAA,SAC1BA,IAAI,CACF;AADE,GAEDC,OAFH,CAEW,QAFX,EAEqB,EAFrB,EAGE;AAHF,GAIGA,OAJH,CAIW,QAJX,EAIqB,EAJrB,EAKE;AALF,GAMGA,OANH,CAMW,WANX,EAMwB,OANxB,CAD0B;AAAA,CAArB","sourcesContent":["export const parseDegrees = (html) =>\n html\n // removes \\( use case: 50°\n .replace(/\\\\[(]/g, '')\n // removes \\) use case: 50°+m<1\n .replace(/\\\\[)]/g, '')\n // removes \\degree use case: 50°\n .replace(/\\\\degree/g, '&deg;');\n"],"file":"parse-html.js"}
@@ -1,73 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
-
12
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
-
14
- var _react = _interopRequireDefault(require("react"));
15
-
16
- var _styles = require("@material-ui/core/styles");
17
-
18
- var _Popper = _interopRequireDefault(require("@material-ui/core/Popper"));
19
-
20
- var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
21
-
22
- var _excluded = ["classes", "children"];
23
-
24
- var styles = function styles() {
25
- return {
26
- popover: {
27
- background: '#fff',
28
- padding: '10px',
29
- pointerEvents: 'none',
30
- zIndex: 99999
31
- },
32
- paper: {
33
- padding: 20,
34
- height: 'auto',
35
- width: 'auto'
36
- },
37
- typography: {
38
- fontSize: 50,
39
- textAlign: 'center'
40
- }
41
- };
42
- };
43
-
44
- var CustomPopper = (0, _styles.withStyles)(styles)(function (_ref) {
45
- var classes = _ref.classes,
46
- children = _ref.children,
47
- props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
48
- return /*#__PURE__*/_react["default"].createElement(_Popper["default"], (0, _extends2["default"])({
49
- id: "mouse-over-popover",
50
- open: true,
51
- className: classes.popover,
52
- classes: {
53
- paper: classes.paper
54
- },
55
- anchorOrigin: {
56
- vertical: 'bottom',
57
- horizontal: 'left'
58
- },
59
- transformOrigin: {
60
- vertical: 'top',
61
- horizontal: 'left'
62
- },
63
- disableRestoreFocus: true,
64
- disableAutoFocus: true
65
- }, props), /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
66
- classes: {
67
- root: classes.typography
68
- }
69
- }, children));
70
- });
71
- var _default = CustomPopper;
72
- exports["default"] = _default;
73
- //# sourceMappingURL=custom-popper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/plugins/characters/custom-popper.js"],"names":["styles","popover","background","padding","pointerEvents","zIndex","paper","height","width","typography","fontSize","textAlign","CustomPopper","classes","children","props","vertical","horizontal","root"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS;AAAA,SAAO;AACpBC,IAAAA,OAAO,EAAE;AACPC,MAAAA,UAAU,EAAE,MADL;AAEPC,MAAAA,OAAO,EAAE,MAFF;AAGPC,MAAAA,aAAa,EAAE,MAHR;AAIPC,MAAAA,MAAM,EAAE;AAJD,KADW;AAOpBC,IAAAA,KAAK,EAAE;AACLH,MAAAA,OAAO,EAAE,EADJ;AAELI,MAAAA,MAAM,EAAE,MAFH;AAGLC,MAAAA,KAAK,EAAE;AAHF,KAPa;AAYpBC,IAAAA,UAAU,EAAE;AACVC,MAAAA,QAAQ,EAAE,EADA;AAEVC,MAAAA,SAAS,EAAE;AAFD;AAZQ,GAAP;AAAA,CAAf;;AAkBA,IAAMC,YAAY,GAAG,wBAAWZ,MAAX,EAAmB;AAAA,MAAGa,OAAH,QAAGA,OAAH;AAAA,MAAYC,QAAZ,QAAYA,QAAZ;AAAA,MAAyBC,KAAzB;AAAA,sBACtC,gCAAC,kBAAD;AACE,IAAA,EAAE,EAAC,oBADL;AAEE,IAAA,IAAI,MAFN;AAGE,IAAA,SAAS,EAAEF,OAAO,CAACZ,OAHrB;AAIE,IAAA,OAAO,EAAE;AACPK,MAAAA,KAAK,EAAEO,OAAO,CAACP;AADR,KAJX;AAOE,IAAA,YAAY,EAAE;AACZU,MAAAA,QAAQ,EAAE,QADE;AAEZC,MAAAA,UAAU,EAAE;AAFA,KAPhB;AAWE,IAAA,eAAe,EAAE;AACfD,MAAAA,QAAQ,EAAE,KADK;AAEfC,MAAAA,UAAU,EAAE;AAFG,KAXnB;AAeE,IAAA,mBAAmB,MAfrB;AAgBE,IAAA,gBAAgB;AAhBlB,KAiBMF,KAjBN,gBAmBE,gCAAC,sBAAD;AAAY,IAAA,OAAO,EAAE;AAAEG,MAAAA,IAAI,EAAEL,OAAO,CAACJ;AAAhB;AAArB,KAAoDK,QAApD,CAnBF,CADsC;AAAA,CAAnB,CAArB;eAwBeF,Y","sourcesContent":["import React from 'react';\nimport { withStyles } from '@material-ui/core/styles';\nimport Popper from '@material-ui/core/Popper';\nimport Typography from '@material-ui/core/Typography';\n\nconst styles = () => ({\n popover: {\n background: '#fff',\n padding: '10px',\n pointerEvents: 'none',\n zIndex: 99999,\n },\n paper: {\n padding: 20,\n height: 'auto',\n width: 'auto',\n },\n typography: {\n fontSize: 50,\n textAlign: 'center',\n },\n});\n\nconst CustomPopper = withStyles(styles)(({ classes, children, ...props }) => (\n <Popper\n id=\"mouse-over-popover\"\n open\n className={classes.popover}\n classes={{\n paper: classes.paper,\n }}\n anchorOrigin={{\n vertical: 'bottom',\n horizontal: 'left',\n }}\n transformOrigin={{\n vertical: 'top',\n horizontal: 'left',\n }}\n disableRestoreFocus\n disableAutoFocus\n {...props}\n >\n <Typography classes={{ root: classes.typography }}>{children}</Typography>\n </Popper>\n));\n\nexport default CustomPopper;\n"],"file":"custom-popper.js"}