@pie-lib/editable-html-tip-tap 2.1.1 → 2.1.2-next.14
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.
- package/lib/components/CharacterPicker.js +10 -4
- package/lib/components/CharacterPicker.js.map +1 -1
- package/lib/components/EditableHtml.js +6 -5
- package/lib/components/EditableHtml.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/EditableHtml.test.jsx +80 -0
- package/src/components/CharacterPicker.jsx +11 -4
- package/src/components/EditableHtml.jsx +7 -5
- package/src/components/__tests__/CharacterPicker.test.jsx +47 -5
|
@@ -41,6 +41,7 @@ function CharacterPicker(_ref2) {
|
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
43
|
var containerRef = (0, _react.useRef)(null);
|
|
44
|
+
var onCloseRef = (0, _react.useRef)(onClose);
|
|
44
45
|
var _useState = (0, _react.useState)({
|
|
45
46
|
top: 0,
|
|
46
47
|
left: 0
|
|
@@ -52,6 +53,7 @@ function CharacterPicker(_ref2) {
|
|
|
52
53
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
53
54
|
popover = _useState4[0],
|
|
54
55
|
setPopover = _useState4[1];
|
|
56
|
+
onCloseRef.current = onClose;
|
|
55
57
|
var configToUse = (0, _react.useMemo)(function () {
|
|
56
58
|
if (!opts) return _characterUtils.spanishConfig;
|
|
57
59
|
switch (true) {
|
|
@@ -82,6 +84,10 @@ function CharacterPicker(_ref2) {
|
|
|
82
84
|
closePopOver();
|
|
83
85
|
};
|
|
84
86
|
}, []);
|
|
87
|
+
|
|
88
|
+
// Keep `onClose` out of the dependency array — parents often pass a new callback each
|
|
89
|
+
// render (e.g. after each keystroke), which would re-run this effect constantly. Use a
|
|
90
|
+
// ref so click-outside always calls the latest close handler.
|
|
85
91
|
(0, _react.useEffect)(function () {
|
|
86
92
|
if (!editor) return;
|
|
87
93
|
|
|
@@ -96,13 +102,13 @@ function CharacterPicker(_ref2) {
|
|
|
96
102
|
top = top - (containerRef.current.offsetHeight + editorRect.height) - 80;
|
|
97
103
|
}
|
|
98
104
|
setPosition({
|
|
99
|
-
// top: start.top + Math.abs(bodyRect.top) - containerRef.current.offsetHeight - 10 + additionalTopOffset, // shift above
|
|
100
105
|
top: top,
|
|
101
106
|
left: start.left
|
|
102
107
|
});
|
|
108
|
+
var editorViewDom = editor.view.dom;
|
|
103
109
|
var handleClickOutside = function handleClickOutside(e) {
|
|
104
|
-
if (containerRef.current && !containerRef.current.contains(e.target) && !
|
|
105
|
-
|
|
110
|
+
if (containerRef.current && !containerRef.current.contains(e.target) && !editorViewDom.contains(e.target)) {
|
|
111
|
+
onCloseRef.current();
|
|
106
112
|
}
|
|
107
113
|
};
|
|
108
114
|
var timeoutId = setTimeout(function () {
|
|
@@ -112,7 +118,7 @@ function CharacterPicker(_ref2) {
|
|
|
112
118
|
clearTimeout(timeoutId);
|
|
113
119
|
document.removeEventListener('click', handleClickOutside);
|
|
114
120
|
};
|
|
115
|
-
}, [editor
|
|
121
|
+
}, [editor]);
|
|
116
122
|
var renderPopOver = function renderPopOver(event, el) {
|
|
117
123
|
return setPopover({
|
|
118
124
|
anchorEl: event.currentTarget,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CharacterPicker.js","names":["_react","_interopRequireWildcard","require","_reactDom","_interopRequireDefault","_propTypes","_get","_mathToolbar","_customPopper","_characterUtils","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","CharacterIcon","exports","_ref","letter","createElement","style","fontSize","lineHeight","propTypes","PropTypes","string","CharacterPicker","_ref2","_opts$characters","editor","opts","onClose","characters","containerRef","useRef","_useState","useState","top","left","_useState2","_slicedToArray2","position","setPosition","_useState3","_useState4","popover","setPopover","configToUse","useMemo","spanishConfig","language","specialConfig","layoutForCharacters","reduce","obj","arr","columns","rows","closePopOver","useEffect","editorDOM","options","element","editorRect","getBoundingClientRect","bodyRect","document","body","from","state","selection","start","view","coordsAtPos","Math","abs","height","y","current","offsetHeight","handleClickOutside","contains","target","dom","timeoutId","setTimeout","addEventListener","clearTimeout","removeEventListener","renderPopOver","event","el","anchorEl","currentTarget","handleChange","val","chain","focus","insertContent","run","Fragment","ReactDOM","createPortal","ref","className","instanceId","visibility","concat","maxWidth","zIndex","PureToolbar","keyPadCharacterRef","setKeypadInteraction","autoFocus","noDecimal","hideInput","noLatexHandling","hideDoneButtonBackground","layoutForKeyPad","additionalKeys","_toConsumableArray2","map","k","name","write","label","category","extraClass","extraProps","border","hasPreview","actions","onMouseEnter","ev","onMouseLeave","keypadMode","onChange","onDone","description","unicode","object","func","isRequired"],"sources":["../../src/components/CharacterPicker.jsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport get from 'lodash-es/get';\n\nimport { PureToolbar } from '@pie-lib/math-toolbar';\n\nimport CustomPopper from './characters/custom-popper';\nimport { spanishConfig, specialConfig } from './characters/characterUtils';\n\nconst CharacterIcon = ({ letter }) => (\n <div\n style={{\n fontSize: '24px',\n lineHeight: '24px',\n }}\n >\n {letter}\n </div>\n);\n\nCharacterIcon.propTypes = {\n letter: PropTypes.string,\n};\n\nexport function CharacterPicker({ editor, opts, onClose }) {\n if (!opts?.characters?.length) {\n return null;\n }\n\n const containerRef = useRef(null);\n const [position, setPosition] = useState({ top: 0, left: 0 });\n const [popover, setPopover] = useState(null);\n\n const configToUse = useMemo(() => {\n if (!opts) return spanishConfig;\n\n switch (true) {\n case opts.language === 'spanish':\n return spanishConfig;\n case opts.language === 'special':\n return specialConfig;\n default:\n return opts;\n }\n }, [opts]);\n\n const layoutForCharacters = useMemo(\n () =>\n configToUse.characters.reduce(\n (obj, arr) => {\n if (arr.length >= obj.columns) {\n obj.columns = arr.length;\n }\n\n return obj;\n },\n { rows: configToUse.characters.length, columns: 0 },\n ),\n [configToUse],\n );\n\n const closePopOver = () => setPopover(null);\n\n useEffect(\n () => () => {\n closePopOver();\n },\n [],\n );\n\n useEffect(() => {\n if (!editor) return;\n\n // Calculate position relative to selection\n const editorDOM = editor.options.element;\n const editorRect = editorDOM.getBoundingClientRect();\n const bodyRect = document.body.getBoundingClientRect();\n const { from } = editor.state.selection;\n const start = editor.view.coordsAtPos(from);\n\n let top = editorRect.top + Math.abs(bodyRect.top) + editorRect.height + 60;\n\n if (editorRect.y > containerRef.current.offsetHeight) {\n top = top - (containerRef.current.offsetHeight + editorRect.height) - 80;\n }\n\n setPosition({\n // top: start.top + Math.abs(bodyRect.top) - containerRef.current.offsetHeight - 10 + additionalTopOffset, // shift above\n top: top,\n left: start.left,\n });\n\n const handleClickOutside = (e) => {\n if (containerRef.current && !containerRef.current.contains(e.target) && !editor.view.dom.contains(e.target)) {\n onClose();\n }\n };\n\n const timeoutId = setTimeout(() => {\n document.addEventListener('click', handleClickOutside);\n });\n\n return () => {\n clearTimeout(timeoutId);\n document.removeEventListener('click', handleClickOutside);\n };\n }, [editor, onClose]);\n\n const renderPopOver = (event, el) => setPopover({ anchorEl: event.currentTarget, el });\n\n const handleChange = (val) => {\n if (typeof val === 'string') {\n editor.chain().focus().insertContent(val).run();\n }\n };\n\n return (\n <>\n {ReactDOM.createPortal(\n <div\n ref={containerRef}\n className=\"insert-character-dialog\"\n data-toolbar-for={editor.instanceId}\n style={{\n visibility: position.top === 0 && position.left === 0 ? 'hidden' : 'initial',\n position: 'absolute',\n top: `${position.top}px`,\n left: `${position.left}px`,\n maxWidth: '500px',\n zIndex: 99,\n }}\n >\n <div>\n <PureToolbar\n keyPadCharacterRef={opts.keyPadCharacterRef}\n setKeypadInteraction={opts.setKeypadInteraction}\n autoFocus\n noDecimal\n hideInput\n noLatexHandling\n hideDoneButtonBackground\n layoutForKeyPad={layoutForCharacters}\n additionalKeys={configToUse.characters.reduce((arr, n) => {\n arr = [\n ...arr,\n ...n.map((k) => ({\n name: get(k, 'name') || k,\n write: get(k, 'write') || k,\n label: get(k, 'label') || k,\n category: 'character',\n extraClass: 'character',\n extraProps: {\n ...(k.extraProps || {}),\n style: {\n ...(k.extraProps || {}).style,\n border: '1px solid #000',\n },\n },\n ...(configToUse.hasPreview\n ? {\n actions: {\n onMouseEnter: (ev) => renderPopOver(ev, k),\n onMouseLeave: closePopOver,\n },\n }\n : {}),\n })),\n ];\n\n return arr;\n }, [])}\n keypadMode=\"language\"\n onChange={handleChange}\n onDone={onClose}\n />\n </div>\n </div>,\n document.body,\n )}\n {popover &&\n ReactDOM.createPortal(\n <CustomPopper onClose={closePopOver} anchorEl={popover.anchorEl}>\n <div>{popover.el.label}</div>\n <div style={{ fontSize: 20, lineHeight: '20px' }}>{popover.el.description}</div>\n <div style={{ fontSize: 20, lineHeight: '20px' }}>{popover.el.unicode}</div>\n </CustomPopper>,\n document.body,\n )}\n </>\n );\n}\n\nCharacterPicker.propTypes = {\n editor: PropTypes.object,\n opts: PropTypes.object,\n onClose: PropTypes.func.isRequired,\n};\n\nexport { CharacterIcon };\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,UAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,IAAA,GAAAF,sBAAA,CAAAF,OAAA;AAEA,IAAAK,YAAA,GAAAL,OAAA;AAEA,IAAAM,aAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,eAAA,GAAAP,OAAA;AAA2E,SAAAD,wBAAAS,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAX,uBAAA,YAAAA,wBAAAS,CAAA,EAAAC,CAAA,SAAAA,CAAA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","_interopRequireDefault","_propTypes","_get","_mathToolbar","_customPopper","_characterUtils","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","CharacterIcon","exports","_ref","letter","createElement","style","fontSize","lineHeight","propTypes","PropTypes","string","CharacterPicker","_ref2","_opts$characters","editor","opts","onClose","characters","containerRef","useRef","onCloseRef","_useState","useState","top","left","_useState2","_slicedToArray2","position","setPosition","_useState3","_useState4","popover","setPopover","current","configToUse","useMemo","spanishConfig","language","specialConfig","layoutForCharacters","reduce","obj","arr","columns","rows","closePopOver","useEffect","editorDOM","options","element","editorRect","getBoundingClientRect","bodyRect","document","body","from","state","selection","start","view","coordsAtPos","Math","abs","height","y","offsetHeight","editorViewDom","dom","handleClickOutside","contains","target","timeoutId","setTimeout","addEventListener","clearTimeout","removeEventListener","renderPopOver","event","el","anchorEl","currentTarget","handleChange","val","chain","focus","insertContent","run","Fragment","ReactDOM","createPortal","ref","className","instanceId","visibility","concat","maxWidth","zIndex","PureToolbar","keyPadCharacterRef","setKeypadInteraction","autoFocus","noDecimal","hideInput","noLatexHandling","hideDoneButtonBackground","layoutForKeyPad","additionalKeys","_toConsumableArray2","map","k","name","write","label","category","extraClass","extraProps","border","hasPreview","actions","onMouseEnter","ev","onMouseLeave","keypadMode","onChange","onDone","description","unicode","object","func","isRequired"],"sources":["../../src/components/CharacterPicker.jsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport get from 'lodash-es/get';\n\nimport { PureToolbar } from '@pie-lib/math-toolbar';\n\nimport CustomPopper from './characters/custom-popper';\nimport { spanishConfig, specialConfig } from './characters/characterUtils';\n\nconst CharacterIcon = ({ letter }) => (\n <div\n style={{\n fontSize: '24px',\n lineHeight: '24px',\n }}\n >\n {letter}\n </div>\n);\n\nCharacterIcon.propTypes = {\n letter: PropTypes.string,\n};\n\nexport function CharacterPicker({ editor, opts, onClose }) {\n if (!opts?.characters?.length) {\n return null;\n }\n\n const containerRef = useRef(null);\n const onCloseRef = useRef(onClose);\n const [position, setPosition] = useState({ top: 0, left: 0 });\n const [popover, setPopover] = useState(null);\n\n onCloseRef.current = onClose;\n\n const configToUse = useMemo(() => {\n if (!opts) return spanishConfig;\n\n switch (true) {\n case opts.language === 'spanish':\n return spanishConfig;\n case opts.language === 'special':\n return specialConfig;\n default:\n return opts;\n }\n }, [opts]);\n\n const layoutForCharacters = useMemo(\n () =>\n configToUse.characters.reduce(\n (obj, arr) => {\n if (arr.length >= obj.columns) {\n obj.columns = arr.length;\n }\n\n return obj;\n },\n { rows: configToUse.characters.length, columns: 0 },\n ),\n [configToUse],\n );\n\n const closePopOver = () => setPopover(null);\n\n useEffect(\n () => () => {\n closePopOver();\n },\n [],\n );\n\n // Keep `onClose` out of the dependency array — parents often pass a new callback each\n // render (e.g. after each keystroke), which would re-run this effect constantly. Use a\n // ref so click-outside always calls the latest close handler.\n useEffect(() => {\n if (!editor) return;\n\n // Calculate position relative to selection\n const editorDOM = editor.options.element;\n const editorRect = editorDOM.getBoundingClientRect();\n const bodyRect = document.body.getBoundingClientRect();\n const { from } = editor.state.selection;\n const start = editor.view.coordsAtPos(from);\n\n let top = editorRect.top + Math.abs(bodyRect.top) + editorRect.height + 60;\n\n if (editorRect.y > containerRef.current.offsetHeight) {\n top = top - (containerRef.current.offsetHeight + editorRect.height) - 80;\n }\n\n setPosition({\n top: top,\n left: start.left,\n });\n\n const editorViewDom = editor.view.dom;\n\n const handleClickOutside = (e) => {\n if (containerRef.current && !containerRef.current.contains(e.target) && !editorViewDom.contains(e.target)) {\n onCloseRef.current();\n }\n };\n\n const timeoutId = setTimeout(() => {\n document.addEventListener('click', handleClickOutside);\n });\n\n return () => {\n clearTimeout(timeoutId);\n document.removeEventListener('click', handleClickOutside);\n };\n }, [editor]);\n\n const renderPopOver = (event, el) => setPopover({ anchorEl: event.currentTarget, el });\n\n const handleChange = (val) => {\n if (typeof val === 'string') {\n editor.chain().focus().insertContent(val).run();\n }\n };\n\n return (\n <>\n {ReactDOM.createPortal(\n <div\n ref={containerRef}\n className=\"insert-character-dialog\"\n data-toolbar-for={editor.instanceId}\n style={{\n visibility: position.top === 0 && position.left === 0 ? 'hidden' : 'initial',\n position: 'absolute',\n top: `${position.top}px`,\n left: `${position.left}px`,\n maxWidth: '500px',\n zIndex: 99,\n }}\n >\n <div>\n <PureToolbar\n keyPadCharacterRef={opts.keyPadCharacterRef}\n setKeypadInteraction={opts.setKeypadInteraction}\n autoFocus\n noDecimal\n hideInput\n noLatexHandling\n hideDoneButtonBackground\n layoutForKeyPad={layoutForCharacters}\n additionalKeys={configToUse.characters.reduce((arr, n) => {\n arr = [\n ...arr,\n ...n.map((k) => ({\n name: get(k, 'name') || k,\n write: get(k, 'write') || k,\n label: get(k, 'label') || k,\n category: 'character',\n extraClass: 'character',\n extraProps: {\n ...(k.extraProps || {}),\n style: {\n ...(k.extraProps || {}).style,\n border: '1px solid #000',\n },\n },\n ...(configToUse.hasPreview\n ? {\n actions: {\n onMouseEnter: (ev) => renderPopOver(ev, k),\n onMouseLeave: closePopOver,\n },\n }\n : {}),\n })),\n ];\n\n return arr;\n }, [])}\n keypadMode=\"language\"\n onChange={handleChange}\n onDone={onClose}\n />\n </div>\n </div>,\n document.body,\n )}\n {popover &&\n ReactDOM.createPortal(\n <CustomPopper onClose={closePopOver} anchorEl={popover.anchorEl}>\n <div>{popover.el.label}</div>\n <div style={{ fontSize: 20, lineHeight: '20px' }}>{popover.el.description}</div>\n <div style={{ fontSize: 20, lineHeight: '20px' }}>{popover.el.unicode}</div>\n </CustomPopper>,\n document.body,\n )}\n </>\n );\n}\n\nCharacterPicker.propTypes = {\n editor: PropTypes.object,\n opts: PropTypes.object,\n onClose: PropTypes.func.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CAAC+C,EAAE,CAACkC,KAAW,CAAC,eAC7B5J,MAAA,YAAAgD,aAAA;IAAKC,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,UAAU,EAAE;IAAO;EAAE,GAAEwB,OAAO,CAAC+C,EAAE,CAAC+C,WAAiB,CAAC,eAChFzK,MAAA,YAAAgD,aAAA;IAAKC,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,UAAU,EAAE;IAAO;EAAE,GAAEwB,OAAO,CAAC+C,EAAE,CAACgD,OAAa,CAC/D,CAAC,EACfzE,QAAQ,CAACC,IACX,CACF,CAAC;AAEP;AAEA3C,eAAe,CAACH,SAAS,GAAG;EAC1BM,MAAM,EAAEL,qBAAS,CAACsH,MAAM;EACxBhH,IAAI,EAAEN,qBAAS,CAACsH,MAAM;EACtB/G,OAAO,EAAEP,qBAAS,CAACuH,IAAI,CAACC;AAC1B,CAAC","ignoreList":[]}
|
|
@@ -244,16 +244,17 @@ var EditableHtml = exports.EditableHtml = function EditableHtml(props) {
|
|
|
244
244
|
onBlur: (0, _debounce["default"])(function (_ref5) {
|
|
245
245
|
var editor = _ref5.editor;
|
|
246
246
|
var otherToolbarOpened = editor._insertingImage || editor._toolbarOpened || editor.isActive('inline_dropdown') || editor.isActive('explicit_constructed_response');
|
|
247
|
-
if (otherToolbarOpened) {
|
|
247
|
+
if (otherToolbarOpened || !editor.schema) {
|
|
248
248
|
return;
|
|
249
249
|
}
|
|
250
|
-
|
|
250
|
+
var html = editor.getHTML();
|
|
251
|
+
if (props.markup !== html) {
|
|
251
252
|
var _props$onChange2;
|
|
252
|
-
(_props$onChange2 = props.onChange) === null || _props$onChange2 === void 0 || _props$onChange2.call(props,
|
|
253
|
+
(_props$onChange2 = props.onChange) === null || _props$onChange2 === void 0 || _props$onChange2.call(props, html);
|
|
253
254
|
}
|
|
254
255
|
if (toolbarOptsToUse.doneOn === 'blur') {
|
|
255
256
|
var _props$onDone2;
|
|
256
|
-
(_props$onDone2 = props.onDone) === null || _props$onDone2 === void 0 || _props$onDone2.call(props,
|
|
257
|
+
(_props$onDone2 = props.onDone) === null || _props$onDone2 === void 0 || _props$onDone2.call(props, html);
|
|
257
258
|
}
|
|
258
259
|
}, 200)
|
|
259
260
|
}, [props.charactersLimit]);
|
|
@@ -365,7 +366,7 @@ var StyledEditorContent = (0, _styles.styled)(_react2.EditorContent, {
|
|
|
365
366
|
color: '#146EB3'
|
|
366
367
|
}
|
|
367
368
|
}), separateParagraph && {
|
|
368
|
-
'& >
|
|
369
|
+
'& > p:has(+ p)': {
|
|
369
370
|
marginBottom: '1em'
|
|
370
371
|
}
|
|
371
372
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditableHtml.js","names":["_react","_interopRequireWildcard","require","_debounce","_interopRequireDefault","_react2","_styles","_starterKit","_extensionTextStyle","_extensionCharacterCount","_extensionSuperscript","_extensionSubscript","_extensionTextAlign","_extensionImage","_extensionPlaceholder","_helper","_extendedTable","_extendedTableCell","_divNode","_ensureEmptyRootDiv","_ensureListItemContentIsDiv","_extensionTableRow","_responseArea","_math","_image","_media","_css","_extendedListItem","_headingParagraph","_TiptapContainer","_size","_extensions","_excluded","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defaultToolbarOpts","position","alignment","alwaysVisible","showDone","doneOn","defaultResponseAreaProps","options","respAreaToolbar","onHandleAreaChange","DEFAULT_ACTIVE_PLUGINS","cssVariables","EditableHtml","exports","props","_props$pluginProps","_ref","pluginProps","showParagraphs","separateParagraphs","_useState","useState","_useState2","_slicedToArray2","pendingImages","setPendingImages","_useState3","_useState4","scheduled","setScheduled","toolbarOpts","removePendingImage","useCallback","imagePos","prev","next","img","pos","toolbarOptsToUse","activePluginsToUse","useMemo","_ref3","_props$responseAreaPr","_ref2","customPlugins","otherPluginProps","_objectWithoutProperties2","filteredActivePlugins","activePlugins","pluginName","nameToUse","PLUGINS_MAP","pluginInfo","disabled","buildExtensions","math","textAlign","html","extraCSSRules","image","imageSupport","toolbar","table","responseArea","type","responseAreaProps","languageCharacters","languageCharactersProps","keyPadCharacterRef","setKeypadInteraction","media","extensions","TextAlign","configure","types","alignments","TextStyleKit","CharacterCount","limit","charactersLimit","StarterKit","trailingNode","node","notAfter","ExtendedListItem","DivNode","HeadingParagraph","EnsureEmptyRootIsDiv","EnsureListItemContentIsDiv","Placeholder","placeholder","showOnlyWhenEditable","showOnlyCurrent","includeChildren","ExtendedTable","TableRow","ExtendedTableHeader","ExtendedTableCell","ResponseAreaExtension","ExplicitConstructedResponseNode","DragInTheBlankNode","InlineDropdownNode","MathTemplatedNode","MathNode","SubScript","SuperScript","Image","ImageUploadNode","imageHandling","disableImageAlignmentButtons","onDone","editor","_props$onDone","getHTML","onDelete","src","attrs","insertImageRequested","imageInfo","getHandler","_imageInfo","addedImage","onFinish","result","_cb","cb","onChange","callback","handler","focusHandler","debounce","detach","window","removeEventListener","_insertingImage","addEventListener","add","concat","_toConsumableArray2","maxImageWidth","maxImageHeight","Media","uploadSoundSupport","CSSMark","useEditor","immediatelyRender","editorProps","handleKeyDown","view","event","onKeyDown","editable","content","normalizeInitialMarkup","markup","onUpdate","_ref4","transaction","isDone","_props$onChange","onBlur","_ref5","otherToolbarOpened","_toolbarOpened","isActive","_props$onChange2","_props$onDone2","useEffect","editorRef","setEditable","nextMarkup","commands","setContent","entries","_ref6","_ref7","key","value","document","documentElement","style","setProperty","editorState","useEditorState","selector","ctx","_ctx$editor","isFocused","sizeStyle","minWidth","width","maxWidth","minHeight","height","maxHeight","valueToSize","createElement","_extends2","StyledEditorContent","showParagraph","separateParagraph","styled","EditorContent","shouldForwardProp","prop","includes","_ref8","display","outline","flex","padding","margin","left","top","color","pointerEvents","whiteSpace","fontSize","marginBottom","_default"],"sources":["../../src/components/EditableHtml.jsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from 'react';\nimport debounce from 'lodash-es/debounce';\nimport { EditorContent, useEditor, useEditorState } from '@tiptap/react';\nimport { styled } from '@mui/material/styles';\nimport StarterKit from '@tiptap/starter-kit';\nimport { TextStyleKit } from '@tiptap/extension-text-style';\nimport { CharacterCount } from '@tiptap/extension-character-count';\nimport SuperScript from '@tiptap/extension-superscript';\nimport SubScript from '@tiptap/extension-subscript';\nimport TextAlign from '@tiptap/extension-text-align';\nimport Image from '@tiptap/extension-image';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport { normalizeInitialMarkup } from '../utils/helper';\n\nimport ExtendedTable from '../extensions/extended-table';\nimport { ExtendedTableCell, ExtendedTableHeader } from '../extensions/extended-table-cell';\nimport { DivNode } from '../extensions/div-node';\nimport { EnsureEmptyRootIsDiv } from '../extensions/ensure-empty-root-div';\nimport { EnsureListItemContentIsDiv } from '../extensions/ensure-list-item-content-is-div';\nimport { TableRow } from '@tiptap/extension-table-row';\nimport {\n DragInTheBlankNode,\n ExplicitConstructedResponseNode,\n InlineDropdownNode,\n MathTemplatedNode,\n ResponseAreaExtension,\n} from '../extensions/responseArea';\nimport { MathNode } from '../extensions/math';\nimport { ImageUploadNode } from '../extensions/image';\nimport { Media } from '../extensions/media';\nimport { CSSMark } from '../extensions/css';\nimport { ExtendedListItem } from '../extensions/extended-list-item';\nimport { HeadingParagraph } from '../extensions/heading-paragraph';\n\nimport EditorContainer from './TiptapContainer';\nimport { valueToSize } from '../utils/size';\nimport { buildExtensions, PLUGINS_MAP } from '../extensions';\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 DEFAULT_ACTIVE_PLUGINS = [\n 'bold',\n 'italic',\n 'underline',\n 'strikethrough',\n 'code',\n 'bulleted-list',\n 'numbered-list',\n 'image',\n 'math',\n 'languageCharacters',\n 'text-align',\n 'table',\n 'video',\n 'audio',\n 'responseArea',\n 'superscript',\n 'subscript',\n 'css',\n 'h3',\n 'undo',\n 'redo',\n];\n\nconst cssVariables = {\n '--white': '#fff',\n '--black': '#2e2b29',\n '--black-contrast': '#110f0e',\n '--gray-1': 'rgba(61, 37, 20, .05)',\n '--gray-2': 'rgba(61, 37, 20, .08)',\n '--gray-3': 'rgba(61, 37, 20, .12)',\n '--gray-4': 'rgba(53, 38, 28, .3)',\n '--gray-5': 'rgba(28, 25, 23, .6)',\n '--green': '#22c55e',\n '--purple': '#6a00f5',\n '--purple-contrast': '#5800cc',\n '--purple-light': 'rgba(88, 5, 255, .05)',\n '--yellow-contrast': '#facc15',\n '--yellow': 'rgba(250, 204, 21, .4)',\n '--yellow-light': '#fffae5',\n '--red': '#ff5c33',\n '--red-light': '#ffebe5',\n '--shadow': `0px 12px 33px 0px rgba(0, 0, 0, .06),\n 0px 3.618px 9.949px 0px rgba(0, 0, 0, .04)`,\n};\n\nexport const EditableHtml = (props) => {\n const { showParagraphs, separateParagraphs } = props.pluginProps || {};\n const [pendingImages, setPendingImages] = useState([]);\n const [scheduled, setScheduled] = useState(false);\n const { toolbarOpts } = props;\n\n const removePendingImage = useCallback(\n (imagePos) => {\n setPendingImages((prev) => {\n const next = prev.filter((img) => img.pos !== imagePos);\n if (next.length === 0) {\n setScheduled(false);\n }\n return next;\n });\n },\n [setPendingImages],\n );\n\n const toolbarOptsToUse = {\n ...defaultToolbarOpts,\n ...toolbarOpts,\n };\n\n const activePluginsToUse = useMemo(() => {\n let { customPlugins, ...otherPluginProps } = props.pluginProps || {};\n\n customPlugins = customPlugins || [];\n\n const filteredActivePlugins = (props.activePlugins || DEFAULT_ACTIVE_PLUGINS)?.filter((pluginName) => {\n const nameToUse = PLUGINS_MAP[pluginName] || pluginName;\n const pluginInfo = otherPluginProps[nameToUse] || {};\n\n return !pluginInfo || !pluginInfo.disabled;\n });\n\n return buildExtensions(filteredActivePlugins, customPlugins, {\n math: {},\n textAlign: props.textAlign,\n html: {},\n extraCSSRules: props.extraCSSRules || {},\n image: {\n ...props.imageSupport,\n },\n toolbar: {},\n table: {},\n responseArea: {\n type: props.responseAreaProps?.type,\n },\n languageCharacters: props.languageCharactersProps,\n keyPadCharacterRef: {},\n setKeypadInteraction: {},\n media: {},\n });\n }, [props]);\n\n const extensions = [\n TextAlign.configure({\n types: ['heading', 'paragraph', 'div', 'headingParagraph', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'td', 'th'],\n alignments: ['left', 'right', 'center', 'justify'],\n }),\n TextStyleKit,\n CharacterCount.configure({\n limit: props.charactersLimit || 1000000,\n }),\n StarterKit.configure({\n trailingNode: {\n node: 'paragraph',\n notAfter: ['paragraph', 'div'],\n },\n }),\n ExtendedListItem,\n DivNode,\n HeadingParagraph,\n EnsureEmptyRootIsDiv,\n EnsureListItemContentIsDiv,\n Placeholder.configure({\n placeholder: props.placeholder,\n // show placeholder even when editor is focused\n showOnlyWhenEditable: true,\n showOnlyCurrent: false, // show on all empty nodes, not only the current one\n includeChildren: true,\n }),\n ExtendedTable,\n TableRow,\n ExtendedTableHeader,\n ExtendedTableCell,\n ResponseAreaExtension.configure(props.responseAreaProps),\n ExplicitConstructedResponseNode.configure(props.responseAreaProps),\n DragInTheBlankNode.configure(props.responseAreaProps),\n InlineDropdownNode.configure(props.responseAreaProps),\n MathTemplatedNode.configure(props.responseAreaProps),\n MathNode.configure({\n toolbarOpts: toolbarOptsToUse,\n math: props.pluginProps?.math || {},\n }),\n SubScript,\n SuperScript,\n Image,\n ImageUploadNode.configure({\n toolbarOpts: toolbarOptsToUse,\n imageHandling: {\n disableImageAlignmentButtons: props.disableImageAlignmentButtons,\n onDone: (editor) => props.onDone?.(editor.getHTML()),\n onDelete:\n props.imageSupport &&\n props.imageSupport.delete &&\n ((node) => {\n const { src } = node.attrs;\n\n props.imageSupport.delete(src, (e) => {\n removePendingImage(node.pos);\n });\n }),\n insertImageRequested:\n props.imageSupport &&\n ((editor, imageInfo, getHandler) => {\n const [addedImage, pos] = imageInfo;\n\n const onFinish = (result) => {\n let cb;\n\n if (scheduled && result) {\n // finish editing only on success\n cb = props.onChange;\n }\n\n removePendingImage(pos);\n cb?.(editor.getHTML());\n };\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);\n\n // If the user closes the file picker without choosing a file, the window regains\n // focus while _insertingImage is still true — drop the stale pending entry.\n const focusHandler = debounce(() => {\n const detach = () => window.removeEventListener('focus', focusHandler);\n\n if (!editor._insertingImage) {\n detach();\n return;\n }\n\n removePendingImage(pos);\n editor._insertingImage = false;\n detach();\n }, 500);\n\n window.addEventListener('focus', focusHandler);\n\n props.imageSupport.add(handler);\n };\n\n editor._insertingImage = true;\n setPendingImages((prev) => [...prev, addedImage]);\n callback();\n }),\n maxImageWidth: props.maxImageWidth,\n maxImageHeight: props.maxImageHeight,\n },\n limit: 3,\n }),\n Media.configure({\n uploadSoundSupport: props.uploadSoundSupport,\n }),\n CSSMark.configure({\n extraCSSRules: props.extraCSSRules,\n }),\n ];\n\n const editor = useEditor(\n {\n extensions,\n immediatelyRender: false,\n editorProps: {\n handleKeyDown(view, event) {\n if (props.onKeyDown) {\n return props.onKeyDown(event);\n }\n\n // Return false to let default behavior continue\n return false;\n },\n },\n editable: !props.disabled,\n content: normalizeInitialMarkup(props.markup),\n onUpdate: ({ editor, transaction }) => {\n if (transaction.isDone || props.markup !== editor.getHTML()) {\n props.onChange?.(editor.getHTML());\n }\n },\n onBlur: debounce(({ editor }) => {\n const otherToolbarOpened =\n editor._insertingImage ||\n editor._toolbarOpened ||\n editor.isActive('inline_dropdown') ||\n editor.isActive('explicit_constructed_response');\n\n if (otherToolbarOpened) {\n return;\n }\n\n if (props.markup !== editor.getHTML()) {\n props.onChange?.(editor.getHTML());\n }\n\n if (toolbarOptsToUse.doneOn === 'blur') {\n props.onDone?.(editor.getHTML());\n }\n }, 200),\n },\n [props.charactersLimit],\n );\n\n useEffect(() => {\n if (props.editorRef) {\n props.editorRef(editor);\n }\n }, [props.editorRef, editor]);\n\n useEffect(() => {\n editor?.setEditable(!props.disabled);\n }, [props.disabled, editor]);\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n const nextMarkup = normalizeInitialMarkup(props.markup);\n\n if (nextMarkup !== editor.getHTML()) {\n editor.commands.setContent(nextMarkup, false);\n }\n }, [props.markup, editor]);\n\n useEffect(() => {\n Object.entries(cssVariables).forEach(([key, value]) => {\n document.documentElement.style.setProperty(key, value);\n });\n }, []);\n\n const editorState = useEditorState({\n editor,\n selector: (ctx) => ({\n isFocused: ctx.editor?.isFocused,\n }),\n });\n\n const sizeStyle = useMemo(() => {\n const { minWidth, width, maxWidth, minHeight, height, maxHeight } = props;\n\n return {\n width: valueToSize(width),\n minWidth: valueToSize(minWidth),\n maxWidth: valueToSize(maxWidth),\n height: valueToSize(height),\n minHeight: valueToSize(minHeight),\n maxHeight: valueToSize(maxHeight),\n };\n }, [props]);\n\n return (\n <EditorContainer\n {...{\n ...props,\n activePlugins: activePluginsToUse,\n toolbarOpts: toolbarOptsToUse,\n }}\n editorState={editorState}\n editor={editor}\n >\n {editor && (\n <StyledEditorContent\n style={{\n minHeight: sizeStyle.minHeight,\n height: sizeStyle.height,\n maxHeight: sizeStyle.maxHeight,\n }}\n showParagraph={showParagraphs && !showParagraphs.disabled}\n separateParagraph={separateParagraphs && !separateParagraphs.disabled}\n editor={editor}\n />\n )}\n </EditorContainer>\n );\n};\n\nconst StyledEditorContent = styled(EditorContent, {\n shouldForwardProp: (prop) => !['showParagraph', 'separateParagraph'].includes(prop),\n})(({ showParagraph, separateParagraph }) => ({\n display: 'flex',\n outline: 'none !important',\n '& .ProseMirror': {\n flex: 1,\n padding: '5px',\n maxHeight: '500px',\n outline: 'none !important',\n position: 'initial',\n\n // reset default margins for all block paragraphs/divs in the editor\n '& > p, & > div': {\n margin: '0',\n },\n\n // Out of flow so the caret stays at the start of the block; in-flow ::before pushes the caret after the hint text.\n '& p.is-editor-empty, & div.is-editor-empty': {\n position: 'relative',\n },\n '& p.is-editor-empty::before, & div.is-editor-empty::before': {\n content: 'attr(data-placeholder)',\n position: 'absolute',\n left: 0,\n top: 0,\n color: '#9CA3AF',\n pointerEvents: 'none',\n whiteSpace: 'pre-wrap',\n },\n\n ...(showParagraph && {\n '& > p:has(+ p)::after, & > div:has(+ div)::after': {\n display: 'block',\n content: '\"¶\"',\n fontSize: '1em',\n color: '#146EB3',\n },\n }),\n ...(separateParagraph && {\n '& > div:has(+ div)': {\n marginBottom: '1em',\n },\n }),\n },\n}));\n\nexport default EditableHtml;\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,mBAAA,GAAAN,OAAA;AACA,IAAAO,wBAAA,GAAAP,OAAA;AACA,IAAAQ,qBAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,mBAAA,GAAAP,sBAAA,CAAAF,OAAA;AACA,IAAAU,mBAAA,GAAAR,sBAAA,CAAAF,OAAA;AACA,IAAAW,eAAA,GAAAT,sBAAA,CAAAF,OAAA;AACA,IAAAY,qBAAA,GAAAV,sBAAA,CAAAF,OAAA;AACA,IAAAa,OAAA,GAAAb,OAAA;AAEA,IAAAc,cAAA,GAAAZ,sBAAA,CAAAF,OAAA;AACA,IAAAe,kBAAA,GAAAf,OAAA;AACA,IAAAgB,QAAA,GAAAhB,OAAA;AACA,IAAAiB,mBAAA,GAAAjB,OAAA;AACA,IAAAkB,2BAAA,GAAAlB,OAAA;AACA,IA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c,OAAO,EAAE,iBAAiB;MAC1B/M,QAAQ,EAAE,SAAS;MAEnB;MACA,gBAAgB,EAAE;QAChBkN,MAAM,EAAE;MACV,CAAC;MAED;MACA,4CAA4C,EAAE;QAC5ClN,QAAQ,EAAE;MACZ,CAAC;MACD,4DAA4D,EAAE;QAC5DuJ,OAAO,EAAE,wBAAwB;QACjCvJ,QAAQ,EAAE,UAAU;QACpBmN,IAAI,EAAE,CAAC;QACPC,GAAG,EAAE,CAAC;QACNC,KAAK,EAAE,SAAS;QAChBC,aAAa,EAAE,MAAM;QACrBC,UAAU,EAAE;MACd;IAAC,GAEGjB,aAAa,IAAI;MACnB,kDAAkD,EAAE;QAClDQ,OAAO,EAAE,OAAO;QAChBvD,OAAO,EAAE,KAAK;QACdiE,QAAQ,EAAE,KAAK;QACfH,KAAK,EAAE;MACT;IACF,CAAC,GACGd,iBAAiB,IAAI;MACvB,oBAAoB,EAAE;QACpBkB,YAAY,EAAE;MAChB;IACF,CAAC;EAEL,CAAC;AAAA,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAA9M,OAAA,cAEWD,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"EditableHtml.js","names":["_react","_interopRequireWildcard","require","_debounce","_interopRequireDefault","_react2","_styles","_starterKit","_extensionTextStyle","_extensionCharacterCount","_extensionSuperscript","_extensionSubscript","_extensionTextAlign","_extensionImage","_extensionPlaceholder","_helper","_extendedTable","_extendedTableCell","_divNode","_ensureEmptyRootDiv","_ensureListItemContentIsDiv","_extensionTableRow","_responseArea","_math","_image","_media","_css","_extendedListItem","_headingParagraph","_TiptapContainer","_size","_extensions","_excluded","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defaultToolbarOpts","position","alignment","alwaysVisible","showDone","doneOn","defaultResponseAreaProps","options","respAreaToolbar","onHandleAreaChange","DEFAULT_ACTIVE_PLUGINS","cssVariables","EditableHtml","exports","props","_props$pluginProps","_ref","pluginProps","showParagraphs","separateParagraphs","_useState","useState","_useState2","_slicedToArray2","pendingImages","setPendingImages","_useState3","_useState4","scheduled","setScheduled","toolbarOpts","removePendingImage","useCallback","imagePos","prev","next","img","pos","toolbarOptsToUse","activePluginsToUse","useMemo","_ref3","_props$responseAreaPr","_ref2","customPlugins","otherPluginProps","_objectWithoutProperties2","filteredActivePlugins","activePlugins","pluginName","nameToUse","PLUGINS_MAP","pluginInfo","disabled","buildExtensions","math","textAlign","html","extraCSSRules","image","imageSupport","toolbar","table","responseArea","type","responseAreaProps","languageCharacters","languageCharactersProps","keyPadCharacterRef","setKeypadInteraction","media","extensions","TextAlign","configure","types","alignments","TextStyleKit","CharacterCount","limit","charactersLimit","StarterKit","trailingNode","node","notAfter","ExtendedListItem","DivNode","HeadingParagraph","EnsureEmptyRootIsDiv","EnsureListItemContentIsDiv","Placeholder","placeholder","showOnlyWhenEditable","showOnlyCurrent","includeChildren","ExtendedTable","TableRow","ExtendedTableHeader","ExtendedTableCell","ResponseAreaExtension","ExplicitConstructedResponseNode","DragInTheBlankNode","InlineDropdownNode","MathTemplatedNode","MathNode","SubScript","SuperScript","Image","ImageUploadNode","imageHandling","disableImageAlignmentButtons","onDone","editor","_props$onDone","getHTML","onDelete","src","attrs","insertImageRequested","imageInfo","getHandler","_imageInfo","addedImage","onFinish","result","_cb","cb","onChange","callback","handler","focusHandler","debounce","detach","window","removeEventListener","_insertingImage","addEventListener","add","concat","_toConsumableArray2","maxImageWidth","maxImageHeight","Media","uploadSoundSupport","CSSMark","useEditor","immediatelyRender","editorProps","handleKeyDown","view","event","onKeyDown","editable","content","normalizeInitialMarkup","markup","onUpdate","_ref4","transaction","isDone","_props$onChange","onBlur","_ref5","otherToolbarOpened","_toolbarOpened","isActive","schema","_props$onChange2","_props$onDone2","useEffect","editorRef","setEditable","nextMarkup","commands","setContent","entries","_ref6","_ref7","key","value","document","documentElement","style","setProperty","editorState","useEditorState","selector","ctx","_ctx$editor","isFocused","sizeStyle","minWidth","width","maxWidth","minHeight","height","maxHeight","valueToSize","createElement","_extends2","StyledEditorContent","showParagraph","separateParagraph","styled","EditorContent","shouldForwardProp","prop","includes","_ref8","display","outline","flex","padding","margin","left","top","color","pointerEvents","whiteSpace","fontSize","marginBottom","_default"],"sources":["../../src/components/EditableHtml.jsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from 'react';\nimport debounce from 'lodash-es/debounce';\nimport { EditorContent, useEditor, useEditorState } from '@tiptap/react';\nimport { styled } from '@mui/material/styles';\nimport StarterKit from '@tiptap/starter-kit';\nimport { TextStyleKit } from '@tiptap/extension-text-style';\nimport { CharacterCount } from '@tiptap/extension-character-count';\nimport SuperScript from '@tiptap/extension-superscript';\nimport SubScript from '@tiptap/extension-subscript';\nimport TextAlign from '@tiptap/extension-text-align';\nimport Image from '@tiptap/extension-image';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport { normalizeInitialMarkup } from '../utils/helper';\n\nimport ExtendedTable from '../extensions/extended-table';\nimport { ExtendedTableCell, ExtendedTableHeader } from '../extensions/extended-table-cell';\nimport { DivNode } from '../extensions/div-node';\nimport { EnsureEmptyRootIsDiv } from '../extensions/ensure-empty-root-div';\nimport { EnsureListItemContentIsDiv } from '../extensions/ensure-list-item-content-is-div';\nimport { TableRow } from '@tiptap/extension-table-row';\nimport {\n DragInTheBlankNode,\n ExplicitConstructedResponseNode,\n InlineDropdownNode,\n MathTemplatedNode,\n ResponseAreaExtension,\n} from '../extensions/responseArea';\nimport { MathNode } from '../extensions/math';\nimport { ImageUploadNode } from '../extensions/image';\nimport { Media } from '../extensions/media';\nimport { CSSMark } from '../extensions/css';\nimport { ExtendedListItem } from '../extensions/extended-list-item';\nimport { HeadingParagraph } from '../extensions/heading-paragraph';\n\nimport EditorContainer from './TiptapContainer';\nimport { valueToSize } from '../utils/size';\nimport { buildExtensions, PLUGINS_MAP } from '../extensions';\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 DEFAULT_ACTIVE_PLUGINS = [\n 'bold',\n 'italic',\n 'underline',\n 'strikethrough',\n 'code',\n 'bulleted-list',\n 'numbered-list',\n 'image',\n 'math',\n 'languageCharacters',\n 'text-align',\n 'table',\n 'video',\n 'audio',\n 'responseArea',\n 'superscript',\n 'subscript',\n 'css',\n 'h3',\n 'undo',\n 'redo',\n];\n\nconst cssVariables = {\n '--white': '#fff',\n '--black': '#2e2b29',\n '--black-contrast': '#110f0e',\n '--gray-1': 'rgba(61, 37, 20, .05)',\n '--gray-2': 'rgba(61, 37, 20, .08)',\n '--gray-3': 'rgba(61, 37, 20, .12)',\n '--gray-4': 'rgba(53, 38, 28, .3)',\n '--gray-5': 'rgba(28, 25, 23, .6)',\n '--green': '#22c55e',\n '--purple': '#6a00f5',\n '--purple-contrast': '#5800cc',\n '--purple-light': 'rgba(88, 5, 255, .05)',\n '--yellow-contrast': '#facc15',\n '--yellow': 'rgba(250, 204, 21, .4)',\n '--yellow-light': '#fffae5',\n '--red': '#ff5c33',\n '--red-light': '#ffebe5',\n '--shadow': `0px 12px 33px 0px rgba(0, 0, 0, .06),\n 0px 3.618px 9.949px 0px rgba(0, 0, 0, .04)`,\n};\n\nexport const EditableHtml = (props) => {\n const { showParagraphs, separateParagraphs } = props.pluginProps || {};\n const [pendingImages, setPendingImages] = useState([]);\n const [scheduled, setScheduled] = useState(false);\n const { toolbarOpts } = props;\n\n const removePendingImage = useCallback(\n (imagePos) => {\n setPendingImages((prev) => {\n const next = prev.filter((img) => img.pos !== imagePos);\n if (next.length === 0) {\n setScheduled(false);\n }\n return next;\n });\n },\n [setPendingImages],\n );\n\n const toolbarOptsToUse = {\n ...defaultToolbarOpts,\n ...toolbarOpts,\n };\n\n const activePluginsToUse = useMemo(() => {\n let { customPlugins, ...otherPluginProps } = props.pluginProps || {};\n\n customPlugins = customPlugins || [];\n\n const filteredActivePlugins = (props.activePlugins || DEFAULT_ACTIVE_PLUGINS)?.filter((pluginName) => {\n const nameToUse = PLUGINS_MAP[pluginName] || pluginName;\n const pluginInfo = otherPluginProps[nameToUse] || {};\n\n return !pluginInfo || !pluginInfo.disabled;\n });\n\n return buildExtensions(filteredActivePlugins, customPlugins, {\n math: {},\n textAlign: props.textAlign,\n html: {},\n extraCSSRules: props.extraCSSRules || {},\n image: {\n ...props.imageSupport,\n },\n toolbar: {},\n table: {},\n responseArea: {\n type: props.responseAreaProps?.type,\n },\n languageCharacters: props.languageCharactersProps,\n keyPadCharacterRef: {},\n setKeypadInteraction: {},\n media: {},\n });\n }, [props]);\n\n const extensions = [\n TextAlign.configure({\n types: ['heading', 'paragraph', 'div', 'headingParagraph', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'td', 'th'],\n alignments: ['left', 'right', 'center', 'justify'],\n }),\n TextStyleKit,\n CharacterCount.configure({\n limit: props.charactersLimit || 1000000,\n }),\n StarterKit.configure({\n trailingNode: {\n node: 'paragraph',\n notAfter: ['paragraph', 'div'],\n },\n }),\n ExtendedListItem,\n DivNode,\n HeadingParagraph,\n EnsureEmptyRootIsDiv,\n EnsureListItemContentIsDiv,\n Placeholder.configure({\n placeholder: props.placeholder,\n // show placeholder even when editor is focused\n showOnlyWhenEditable: true,\n showOnlyCurrent: false, // show on all empty nodes, not only the current one\n includeChildren: true,\n }),\n ExtendedTable,\n TableRow,\n ExtendedTableHeader,\n ExtendedTableCell,\n ResponseAreaExtension.configure(props.responseAreaProps),\n ExplicitConstructedResponseNode.configure(props.responseAreaProps),\n DragInTheBlankNode.configure(props.responseAreaProps),\n InlineDropdownNode.configure(props.responseAreaProps),\n MathTemplatedNode.configure(props.responseAreaProps),\n MathNode.configure({\n toolbarOpts: toolbarOptsToUse,\n math: props.pluginProps?.math || {},\n }),\n SubScript,\n SuperScript,\n Image,\n ImageUploadNode.configure({\n toolbarOpts: toolbarOptsToUse,\n imageHandling: {\n disableImageAlignmentButtons: props.disableImageAlignmentButtons,\n onDone: (editor) => props.onDone?.(editor.getHTML()),\n onDelete:\n props.imageSupport &&\n props.imageSupport.delete &&\n ((node) => {\n const { src } = node.attrs;\n\n props.imageSupport.delete(src, (e) => {\n removePendingImage(node.pos);\n });\n }),\n insertImageRequested:\n props.imageSupport &&\n ((editor, imageInfo, getHandler) => {\n const [addedImage, pos] = imageInfo;\n\n const onFinish = (result) => {\n let cb;\n\n if (scheduled && result) {\n // finish editing only on success\n cb = props.onChange;\n }\n\n removePendingImage(pos);\n cb?.(editor.getHTML());\n };\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);\n\n // If the user closes the file picker without choosing a file, the window regains\n // focus while _insertingImage is still true — drop the stale pending entry.\n const focusHandler = debounce(() => {\n const detach = () => window.removeEventListener('focus', focusHandler);\n\n if (!editor._insertingImage) {\n detach();\n return;\n }\n\n removePendingImage(pos);\n editor._insertingImage = false;\n detach();\n }, 500);\n\n window.addEventListener('focus', focusHandler);\n\n props.imageSupport.add(handler);\n };\n\n editor._insertingImage = true;\n setPendingImages((prev) => [...prev, addedImage]);\n callback();\n }),\n maxImageWidth: props.maxImageWidth,\n maxImageHeight: props.maxImageHeight,\n },\n limit: 3,\n }),\n Media.configure({\n uploadSoundSupport: props.uploadSoundSupport,\n }),\n CSSMark.configure({\n extraCSSRules: props.extraCSSRules,\n }),\n ];\n\n const editor = useEditor(\n {\n extensions,\n immediatelyRender: false,\n editorProps: {\n handleKeyDown(view, event) {\n if (props.onKeyDown) {\n return props.onKeyDown(event);\n }\n\n // Return false to let default behavior continue\n return false;\n },\n },\n editable: !props.disabled,\n content: normalizeInitialMarkup(props.markup),\n onUpdate: ({ editor, transaction }) => {\n if (transaction.isDone || props.markup !== editor.getHTML()) {\n props.onChange?.(editor.getHTML());\n }\n },\n onBlur: debounce(({ editor }) => {\n const otherToolbarOpened =\n editor._insertingImage ||\n editor._toolbarOpened ||\n editor.isActive('inline_dropdown') ||\n editor.isActive('explicit_constructed_response');\n\n if (otherToolbarOpened || !editor.schema) {\n return;\n }\n\n const html = editor.getHTML();\n\n if (props.markup !== html) {\n props.onChange?.(html);\n }\n\n if (toolbarOptsToUse.doneOn === 'blur') {\n props.onDone?.(html);\n }\n }, 200),\n },\n [props.charactersLimit],\n );\n\n useEffect(() => {\n if (props.editorRef) {\n props.editorRef(editor);\n }\n }, [props.editorRef, editor]);\n\n useEffect(() => {\n editor?.setEditable(!props.disabled);\n }, [props.disabled, editor]);\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n const nextMarkup = normalizeInitialMarkup(props.markup);\n\n if (nextMarkup !== editor.getHTML()) {\n editor.commands.setContent(nextMarkup, false);\n }\n }, [props.markup, editor]);\n\n useEffect(() => {\n Object.entries(cssVariables).forEach(([key, value]) => {\n document.documentElement.style.setProperty(key, value);\n });\n }, []);\n\n const editorState = useEditorState({\n editor,\n selector: (ctx) => ({\n isFocused: ctx.editor?.isFocused,\n }),\n });\n\n const sizeStyle = useMemo(() => {\n const { minWidth, width, maxWidth, minHeight, height, maxHeight } = props;\n\n return {\n width: valueToSize(width),\n minWidth: valueToSize(minWidth),\n maxWidth: valueToSize(maxWidth),\n height: valueToSize(height),\n minHeight: valueToSize(minHeight),\n maxHeight: valueToSize(maxHeight),\n };\n }, [props]);\n\n return (\n <EditorContainer\n {...{\n ...props,\n activePlugins: activePluginsToUse,\n toolbarOpts: toolbarOptsToUse,\n }}\n editorState={editorState}\n editor={editor}\n >\n {editor && (\n <StyledEditorContent\n style={{\n minHeight: sizeStyle.minHeight,\n height: sizeStyle.height,\n maxHeight: sizeStyle.maxHeight,\n }}\n showParagraph={showParagraphs && !showParagraphs.disabled}\n separateParagraph={separateParagraphs && !separateParagraphs.disabled}\n editor={editor}\n />\n )}\n </EditorContainer>\n );\n};\n\nconst StyledEditorContent = styled(EditorContent, {\n shouldForwardProp: (prop) => !['showParagraph', 'separateParagraph'].includes(prop),\n})(({ showParagraph, separateParagraph }) => ({\n display: 'flex',\n outline: 'none !important',\n '& .ProseMirror': {\n flex: 1,\n padding: '5px',\n maxHeight: '500px',\n outline: 'none !important',\n position: 'initial',\n\n // reset default margins for all block paragraphs/divs in the editor\n '& > p, & > div': {\n margin: '0',\n },\n\n // Out of flow so the caret stays at the start of the block; in-flow ::before pushes the caret after the hint text.\n '& p.is-editor-empty, & div.is-editor-empty': {\n position: 'relative',\n },\n '& p.is-editor-empty::before, & div.is-editor-empty::before': {\n content: 'attr(data-placeholder)',\n position: 'absolute',\n left: 0,\n top: 0,\n color: '#9CA3AF',\n pointerEvents: 'none',\n whiteSpace: 'pre-wrap',\n },\n\n ...(showParagraph && {\n '& > p:has(+ p)::after, & > div:has(+ div)::after': {\n display: 'block',\n content: '\"¶\"',\n fontSize: '1em',\n color: '#146EB3',\n },\n }),\n ...(separateParagraph && {\n '& > p:has(+ p)': {\n marginBottom: '1em',\n },\n }),\n },\n}));\n\nexport default EditableHtml;\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,mBAAA,GAAAN,OAAA;AACA,IAAAO,wBAAA,GAAAP,OAAA;AACA,IAAAQ,qBAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,mBAAA,GAAAP,sBAAA,CAAAF,OAAA;AACA,IAAAU,mBAAA,GAAAR,sBAAA,CAAAF,OAAA;AACA,IAAAW,eAAA,GAAAT,sBAAA,CAAAF,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,UAAAE,KAAA;EAAA,IAAGP,aAAa,GAAAO,KAAA,CAAbP,aAAa;IAAEC,iBAAiB,GAAAM,KAAA,CAAjBN,iBAAiB;EAAA,OAAQ;IAC5CO,OAAO,EAAE,MAAM;IACfC,OAAO,EAAE,iBAAiB;IAC1B,gBAAgB,EAAAxN,aAAA,CAAAA,aAAA;MACdyN,IAAI,EAAE,CAAC;MACPC,OAAO,EAAE,KAAK;MACdhB,SAAS,EAAE,OAAO;MAClBc,OAAO,EAAE,iBAAiB;MAC1BhN,QAAQ,EAAE,SAAS;MAEnB;MACA,gBAAgB,EAAE;QAChBmN,MAAM,EAAE;MACV,CAAC;MAED;MACA,4CAA4C,EAAE;QAC5CnN,QAAQ,EAAE;MACZ,CAAC;MACD,4DAA4D,EAAE;QAC5DuJ,OAAO,EAAE,wBAAwB;QACjCvJ,QAAQ,EAAE,UAAU;QACpBoN,IAAI,EAAE,CAAC;QACPC,GAAG,EAAE,CAAC;QACNC,KAAK,EAAE,SAAS;QAChBC,aAAa,EAAE,MAAM;QACrBC,UAAU,EAAE;MACd;IAAC,GAEGjB,aAAa,IAAI;MACnB,kDAAkD,EAAE;QAClDQ,OAAO,EAAE,OAAO;QAChBxD,OAAO,EAAE,KAAK;QACdkE,QAAQ,EAAE,KAAK;QACfH,KAAK,EAAE;MACT;IACF,CAAC,GACGd,iBAAiB,IAAI;MACvB,gBAAgB,EAAE;QAChBkB,YAAY,EAAE;MAChB;IACF,CAAC;EAEL,CAAC;AAAA,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAA/M,OAAA,cAEWD,YAAY","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "2.1.
|
|
6
|
+
"version": "2.1.2-next.14+ba1028933",
|
|
7
7
|
"description": "",
|
|
8
8
|
"license": "ISC",
|
|
9
9
|
"main": "lib/index.js",
|
|
@@ -59,6 +59,6 @@
|
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"react": "^18.2.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "ba10289337229c4add69b161360b11bde28f5e70",
|
|
63
63
|
"scripts": {}
|
|
64
64
|
}
|
|
@@ -336,6 +336,7 @@ describe('EditableHtml', () => {
|
|
|
336
336
|
const editorConfig = useEditor.mock.calls[useEditor.mock.calls.length - 1][0];
|
|
337
337
|
const blurEditor = {
|
|
338
338
|
getHTML: jest.fn(() => '<p>changed</p>'),
|
|
339
|
+
schema: {},
|
|
339
340
|
_insertingImage: true,
|
|
340
341
|
_toolbarOpened: false,
|
|
341
342
|
isActive: jest.fn(() => false),
|
|
@@ -350,6 +351,85 @@ describe('EditableHtml', () => {
|
|
|
350
351
|
jest.useRealTimers();
|
|
351
352
|
});
|
|
352
353
|
|
|
354
|
+
it('does not run blur onChange/onDone when editor has no schema', async () => {
|
|
355
|
+
jest.useFakeTimers();
|
|
356
|
+
const onChange = jest.fn();
|
|
357
|
+
const onDone = jest.fn();
|
|
358
|
+
|
|
359
|
+
render(
|
|
360
|
+
<EditableHtml
|
|
361
|
+
{...defaultProps}
|
|
362
|
+
markup="<p>Hello World</p>"
|
|
363
|
+
onChange={onChange}
|
|
364
|
+
onDone={onDone}
|
|
365
|
+
toolbarOpts={{ doneOn: 'blur' }}
|
|
366
|
+
/>,
|
|
367
|
+
);
|
|
368
|
+
|
|
369
|
+
await waitFor(() => {
|
|
370
|
+
expect(useEditor).toHaveBeenCalled();
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
const editorConfig = useEditor.mock.calls[useEditor.mock.calls.length - 1][0];
|
|
374
|
+
const getHTML = jest.fn(() => '<p>changed</p>');
|
|
375
|
+
const blurEditor = {
|
|
376
|
+
getHTML,
|
|
377
|
+
schema: undefined,
|
|
378
|
+
_insertingImage: false,
|
|
379
|
+
_toolbarOpened: false,
|
|
380
|
+
isActive: jest.fn(() => false),
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
editorConfig.onBlur({ editor: blurEditor });
|
|
384
|
+
jest.advanceTimersByTime(200);
|
|
385
|
+
|
|
386
|
+
expect(getHTML).not.toHaveBeenCalled();
|
|
387
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
388
|
+
expect(onDone).not.toHaveBeenCalled();
|
|
389
|
+
|
|
390
|
+
jest.useRealTimers();
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
it('calls getHTML once on blur and passes the same html to onChange and onDone', async () => {
|
|
394
|
+
jest.useFakeTimers();
|
|
395
|
+
const onChange = jest.fn();
|
|
396
|
+
const onDone = jest.fn();
|
|
397
|
+
const html = '<p>from editor</p>';
|
|
398
|
+
|
|
399
|
+
render(
|
|
400
|
+
<EditableHtml
|
|
401
|
+
{...defaultProps}
|
|
402
|
+
markup="<p>Hello World</p>"
|
|
403
|
+
onChange={onChange}
|
|
404
|
+
onDone={onDone}
|
|
405
|
+
toolbarOpts={{ doneOn: 'blur' }}
|
|
406
|
+
/>,
|
|
407
|
+
);
|
|
408
|
+
|
|
409
|
+
await waitFor(() => {
|
|
410
|
+
expect(useEditor).toHaveBeenCalled();
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
const editorConfig = useEditor.mock.calls[useEditor.mock.calls.length - 1][0];
|
|
414
|
+
const getHTML = jest.fn(() => html);
|
|
415
|
+
const blurEditor = {
|
|
416
|
+
getHTML,
|
|
417
|
+
schema: {},
|
|
418
|
+
_insertingImage: false,
|
|
419
|
+
_toolbarOpened: false,
|
|
420
|
+
isActive: jest.fn(() => false),
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
editorConfig.onBlur({ editor: blurEditor });
|
|
424
|
+
jest.advanceTimersByTime(200);
|
|
425
|
+
|
|
426
|
+
expect(getHTML).toHaveBeenCalledTimes(1);
|
|
427
|
+
expect(onChange).toHaveBeenCalledWith(html);
|
|
428
|
+
expect(onDone).toHaveBeenCalledWith(html);
|
|
429
|
+
|
|
430
|
+
jest.useRealTimers();
|
|
431
|
+
});
|
|
432
|
+
|
|
353
433
|
describe('onUpdate callback', () => {
|
|
354
434
|
it('calls onChange when transaction.isDone is true', async () => {
|
|
355
435
|
const onChange = jest.fn();
|
|
@@ -29,9 +29,12 @@ export function CharacterPicker({ editor, opts, onClose }) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
const containerRef = useRef(null);
|
|
32
|
+
const onCloseRef = useRef(onClose);
|
|
32
33
|
const [position, setPosition] = useState({ top: 0, left: 0 });
|
|
33
34
|
const [popover, setPopover] = useState(null);
|
|
34
35
|
|
|
36
|
+
onCloseRef.current = onClose;
|
|
37
|
+
|
|
35
38
|
const configToUse = useMemo(() => {
|
|
36
39
|
if (!opts) return spanishConfig;
|
|
37
40
|
|
|
@@ -69,6 +72,9 @@ export function CharacterPicker({ editor, opts, onClose }) {
|
|
|
69
72
|
[],
|
|
70
73
|
);
|
|
71
74
|
|
|
75
|
+
// Keep `onClose` out of the dependency array — parents often pass a new callback each
|
|
76
|
+
// render (e.g. after each keystroke), which would re-run this effect constantly. Use a
|
|
77
|
+
// ref so click-outside always calls the latest close handler.
|
|
72
78
|
useEffect(() => {
|
|
73
79
|
if (!editor) return;
|
|
74
80
|
|
|
@@ -86,14 +92,15 @@ export function CharacterPicker({ editor, opts, onClose }) {
|
|
|
86
92
|
}
|
|
87
93
|
|
|
88
94
|
setPosition({
|
|
89
|
-
// top: start.top + Math.abs(bodyRect.top) - containerRef.current.offsetHeight - 10 + additionalTopOffset, // shift above
|
|
90
95
|
top: top,
|
|
91
96
|
left: start.left,
|
|
92
97
|
});
|
|
93
98
|
|
|
99
|
+
const editorViewDom = editor.view.dom;
|
|
100
|
+
|
|
94
101
|
const handleClickOutside = (e) => {
|
|
95
|
-
if (containerRef.current && !containerRef.current.contains(e.target) && !
|
|
96
|
-
|
|
102
|
+
if (containerRef.current && !containerRef.current.contains(e.target) && !editorViewDom.contains(e.target)) {
|
|
103
|
+
onCloseRef.current();
|
|
97
104
|
}
|
|
98
105
|
};
|
|
99
106
|
|
|
@@ -105,7 +112,7 @@ export function CharacterPicker({ editor, opts, onClose }) {
|
|
|
105
112
|
clearTimeout(timeoutId);
|
|
106
113
|
document.removeEventListener('click', handleClickOutside);
|
|
107
114
|
};
|
|
108
|
-
}, [editor
|
|
115
|
+
}, [editor]);
|
|
109
116
|
|
|
110
117
|
const renderPopOver = (event, el) => setPopover({ anchorEl: event.currentTarget, el });
|
|
111
118
|
|
|
@@ -299,16 +299,18 @@ export const EditableHtml = (props) => {
|
|
|
299
299
|
editor.isActive('inline_dropdown') ||
|
|
300
300
|
editor.isActive('explicit_constructed_response');
|
|
301
301
|
|
|
302
|
-
if (otherToolbarOpened) {
|
|
302
|
+
if (otherToolbarOpened || !editor.schema) {
|
|
303
303
|
return;
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
-
|
|
307
|
-
|
|
306
|
+
const html = editor.getHTML();
|
|
307
|
+
|
|
308
|
+
if (props.markup !== html) {
|
|
309
|
+
props.onChange?.(html);
|
|
308
310
|
}
|
|
309
311
|
|
|
310
312
|
if (toolbarOptsToUse.doneOn === 'blur') {
|
|
311
|
-
props.onDone?.(
|
|
313
|
+
props.onDone?.(html);
|
|
312
314
|
}
|
|
313
315
|
}, 200),
|
|
314
316
|
},
|
|
@@ -428,7 +430,7 @@ const StyledEditorContent = styled(EditorContent, {
|
|
|
428
430
|
},
|
|
429
431
|
}),
|
|
430
432
|
...(separateParagraph && {
|
|
431
|
-
'& >
|
|
433
|
+
'& > p:has(+ p)': {
|
|
432
434
|
marginBottom: '1em',
|
|
433
435
|
},
|
|
434
436
|
}),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { fireEvent, render, waitFor } from '@testing-library/react';
|
|
2
|
+
import { act, fireEvent, render, waitFor } from '@testing-library/react';
|
|
3
3
|
import { CharacterIcon, CharacterPicker } from '../CharacterPicker';
|
|
4
4
|
|
|
5
5
|
jest.mock('react-dom', () => ({
|
|
@@ -128,13 +128,55 @@ describe('CharacterPicker', () => {
|
|
|
128
128
|
};
|
|
129
129
|
render(<CharacterPicker editor={mockEditor} opts={opts} onClose={onClose} />);
|
|
130
130
|
|
|
131
|
+
await act(async () => {
|
|
132
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
133
|
+
});
|
|
134
|
+
fireEvent.click(document.body);
|
|
135
|
+
|
|
131
136
|
await waitFor(() => {
|
|
132
|
-
|
|
133
|
-
fireEvent.click(document.body);
|
|
134
|
-
}, 0);
|
|
137
|
+
expect(onClose).toHaveBeenCalled();
|
|
135
138
|
});
|
|
139
|
+
});
|
|
136
140
|
|
|
137
|
-
|
|
141
|
+
it('does not re-run positioning when only onClose reference changes', async () => {
|
|
142
|
+
const opts = {
|
|
143
|
+
characters: [['á', 'é']],
|
|
144
|
+
};
|
|
145
|
+
const getRect = mockEditor.options.element.getBoundingClientRect;
|
|
146
|
+
const { rerender } = render(<CharacterPicker editor={mockEditor} opts={opts} onClose={jest.fn()} />);
|
|
147
|
+
|
|
148
|
+
await act(async () => {
|
|
149
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const callsAfterMount = getRect.mock.calls.length;
|
|
153
|
+
expect(callsAfterMount).toBeGreaterThan(0);
|
|
154
|
+
|
|
155
|
+
rerender(<CharacterPicker editor={mockEditor} opts={opts} onClose={jest.fn()} />);
|
|
156
|
+
|
|
157
|
+
expect(getRect.mock.calls.length).toBe(callsAfterMount);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('outside click invokes the latest onClose after rerender', async () => {
|
|
161
|
+
const opts = {
|
|
162
|
+
characters: [['á', 'é']],
|
|
163
|
+
};
|
|
164
|
+
const onCloseFirst = jest.fn();
|
|
165
|
+
const { rerender } = render(<CharacterPicker editor={mockEditor} opts={opts} onClose={onCloseFirst} />);
|
|
166
|
+
|
|
167
|
+
await act(async () => {
|
|
168
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const onCloseSecond = jest.fn();
|
|
172
|
+
rerender(<CharacterPicker editor={mockEditor} opts={opts} onClose={onCloseSecond} />);
|
|
173
|
+
|
|
174
|
+
fireEvent.click(document.body);
|
|
175
|
+
|
|
176
|
+
await waitFor(() => {
|
|
177
|
+
expect(onCloseSecond).toHaveBeenCalled();
|
|
178
|
+
});
|
|
179
|
+
expect(onCloseFirst).not.toHaveBeenCalled();
|
|
138
180
|
});
|
|
139
181
|
|
|
140
182
|
it('does not close when clicking inside picker', async () => {
|