@pie-lib/editable-html-tip-tap 1.2.0-next.35 → 1.2.0-next.36

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/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.2.0-next.36](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html-tip-tap@1.2.0-next.35...@pie-lib/editable-html-tip-tap@1.2.0-next.36) (2026-04-23)
7
+
8
+ ### Bug Fixes
9
+
10
+ - made sure colspan elements match the number of columns on removing [PIE-168] ([0ee3056](https://github.com/pie-framework/pie-lib/commit/0ee3056f2c00d71eb83ee2f56ad0efb75dc3b21b))
11
+ - made sure custom toolbar is shown for inline dropdown response areas [PIE-130] ([d3cb03d](https://github.com/pie-framework/pie-lib/commit/d3cb03d45eb716d700f1202aa1cc223c169cfde5))
12
+
6
13
  # [1.2.0-next.35](https://github.com/pie-framework/pie-lib/compare/@pie-lib/editable-html-tip-tap@1.2.0-next.34...@pie-lib/editable-html-tip-tap@1.2.0-next.35) (2026-04-17)
7
14
 
8
15
  ### Bug Fixes
@@ -96,13 +96,13 @@ var ExplicitConstructedResponse = function ExplicitConstructedResponse(props) {
96
96
  dangerouslySetInnerHTML: {
97
97
  __html: value || '<div>&nbsp;</div>'
98
98
  }
99
- })), showToolbar && /*#__PURE__*/_react["default"].createElement("div", {
99
+ })), showToolbar && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
100
100
  ref: toolbarRef,
101
101
  className: "absolute z-50 bg-white shadow-lg rounded p-2",
102
102
  style: {
103
103
  zIndex: 1
104
104
  }
105
- }, /*#__PURE__*/_react["default"].createElement(EcrToolbar, null)), showToolbar && editor._tiptapContainerEl && /*#__PURE__*/_reactDom["default"].createPortal(/*#__PURE__*/_react["default"].createElement(_customToolbarWrapper["default"], {
105
+ }, /*#__PURE__*/_react["default"].createElement(EcrToolbar, null)), editor._tiptapContainerEl && /*#__PURE__*/_reactDom["default"].createPortal(/*#__PURE__*/_react["default"].createElement(_customToolbarWrapper["default"], {
106
106
  deletable: true,
107
107
  toolbarOpts: {
108
108
  minWidth: 'auto'
@@ -124,7 +124,7 @@ var ExplicitConstructedResponse = function ExplicitConstructedResponse(props) {
124
124
  editor.commands.focus();
125
125
  },
126
126
  showDone: false
127
- }), editor._tiptapContainerEl));
127
+ }), editor._tiptapContainerEl)));
128
128
  };
129
129
  ExplicitConstructedResponse.propTypes = {
130
130
  attributes: _propTypes["default"].object,
@@ -1 +1 @@
1
- {"version":3,"file":"ExplicitConstructedResponse.js","names":["_react","_interopRequireWildcard","require","_react2","_reactDom","_interopRequireDefault","_propTypes","_customToolbarWrapper","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ExplicitConstructedResponse","props","editor","node","getPos","options","selected","attributes","attrs","value","respAreaToolbar","errorFn","error","pos","_useState","useState","_useState2","_slicedToArray2","showToolbar","setShowToolbar","EcrToolbar","toolbarRef","useRef","_errorValue$respIndex","errorValue","respIndex","parseInt","index","useEffect","selection","state","onlyThisNodeSelected","from","nodeSize","to","handleClickOutside","event","insideCharacterPicker","target","closest","current","contains","document","addEventListener","removeEventListener","createElement","NodeViewWrapper","className","style","display","minHeight","position","cursor","_extends2","width","height","backgroundColor","border","concat","boxSizing","borderRadius","overflow","padding","margin","minWidth","visibility","onClick","dangerouslySetInnerHTML","__html","ref","zIndex","_tiptapContainerEl","ReactDOM","createPortal","deletable","toolbarOpts","autoWidth","top","left","right","onDelete","tr","_toolbarOpened","view","dispatch","commands","focus","showDone","propTypes","PropTypes","object","any","string","isFocused","bool","_default","exports"],"sources":["../../../src/components/respArea/ExplicitConstructedResponse.jsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { NodeViewWrapper } from '@tiptap/react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport CustomToolbarWrapper from '../../extensions/custom-toolbar-wrapper';\n\nconst ExplicitConstructedResponse = (props) => {\n const { editor, node, getPos, options, selected } = props;\n const { attrs: attributes } = node;\n const { value } = attributes;\n const { respAreaToolbar, error: errorFn } = options;\n const pos = getPos();\n const [showToolbar, setShowToolbar] = useState(false);\n const EcrToolbar = respAreaToolbar([node, pos], editor, () => { });\n const toolbarRef = useRef(null);\n\n let error;\n\n if (errorFn) {\n const errorValue = errorFn();\n const respIndex = parseInt(attributes.index, 10);\n\n error = !!errorValue?.[respIndex]?.[0];\n }\n\n useEffect(() => {\n const { selection } = editor.state;\n const onlyThisNodeSelected = selection.from + node.nodeSize === selection.to;\n\n if (selected) {\n if (onlyThisNodeSelected) {\n setShowToolbar(selected);\n }\n } else {\n setShowToolbar(selected);\n }\n }, [editor, node, selected]);\n\n useEffect(() => {\n const handleClickOutside = (event) => {\n const insideCharacterPicker = event.target.closest('.insert-character-dialog') || event.target.closest('[data-toolbar-for]');\n\n if (\n !insideCharacterPicker &&\n toolbarRef.current &&\n !toolbarRef.current.contains(event.target) &&\n !event.target.closest('[data-inline-node]')\n ) {\n setShowToolbar(false);\n }\n };\n\n if (showToolbar) {\n document.addEventListener('mousedown', handleClickOutside);\n } else {\n document.removeEventListener('mousedown', handleClickOutside);\n }\n\n return () => document.removeEventListener('mousedown', handleClickOutside);\n }, [showToolbar]);\n\n return (\n <NodeViewWrapper\n className=\"drag-in-the-blank\"\n data-selected={selected}\n style={{\n display: 'inline-flex',\n minHeight: '55px',\n position: 'relative',\n cursor: 'pointer',\n }}\n >\n <div\n {...attributes}\n style={{\n display: 'inline-flex',\n width: '100%',\n minHeight: '46px',\n height: '46px',\n backgroundColor: '#FFF',\n border: `1px solid ${error ? 'red' : '#C0C3CF'}`,\n boxSizing: 'border-box',\n borderRadius: '4px',\n overflow: 'hidden',\n padding: '12px 21px',\n margin: '0 4px',\n minWidth: '178px',\n visibility: showToolbar ? 'hidden' : 'visible',\n }}\n onClick={() => setShowToolbar(true)}\n dangerouslySetInnerHTML={{\n __html: value || '<div>&nbsp;</div>',\n }}\n />\n {showToolbar && (\n <div ref={toolbarRef} className=\"absolute z-50 bg-white shadow-lg rounded p-2\" style={{ zIndex: 1 }}>\n <EcrToolbar />\n </div>\n )}\n {showToolbar && editor._tiptapContainerEl && ReactDOM.createPortal(\n <CustomToolbarWrapper\n deletable\n toolbarOpts={{ minWidth: 'auto' }}\n autoWidth\n style={{ top: -40, left: 0, right: 0 }}\n onDelete={() => {\n const { tr } = editor.state;\n tr.delete(pos, pos + node.nodeSize);\n // Prevent the debounced onBlur/onDone from firing into the\n // now-deleted node's stale position\n editor._toolbarOpened = false;\n editor.view.dispatch(tr);\n setShowToolbar(false);\n editor.commands.focus();\n }}\n showDone={false}\n />,\n editor._tiptapContainerEl,\n )}\n </NodeViewWrapper>\n );\n};\n\nExplicitConstructedResponse.propTypes = {\n attributes: PropTypes.object,\n error: PropTypes.any,\n value: PropTypes.string,\n isFocused: PropTypes.bool,\n};\n\nexport default ExplicitConstructedResponse;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,UAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,qBAAA,GAAAF,sBAAA,CAAAH,OAAA;AAA2E,SAAAD,wBAAAO,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,wBAAAO,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SA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BACT,CACe,CAAC;AAEtB,CAAC;AAEDvE,2BAA2B,CAACwF,SAAS,GAAG;EACtCjF,UAAU,EAAEkF,qBAAS,CAACC,MAAM;EAC5B9E,KAAK,EAAE6E,qBAAS,CAACE,GAAG;EACpBlF,KAAK,EAAEgF,qBAAS,CAACG,MAAM;EACvBC,SAAS,EAAEJ,qBAAS,CAACK;AACvB,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,cAEahG,2BAA2B","ignoreList":[]}
1
+ {"version":3,"file":"ExplicitConstructedResponse.js","names":["_react","_interopRequireWildcard","require","_react2","_reactDom","_interopRequireDefault","_propTypes","_customToolbarWrapper","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ExplicitConstructedResponse","props","editor","node","getPos","options","selected","attributes","attrs","value","respAreaToolbar","errorFn","error","pos","_useState","useState","_useState2","_slicedToArray2","showToolbar","setShowToolbar","EcrToolbar","toolbarRef","useRef","_errorValue$respIndex","errorValue","respIndex","parseInt","index","useEffect","selection","state","onlyThisNodeSelected","from","nodeSize","to","handleClickOutside","event","insideCharacterPicker","target","closest","current","contains","document","addEventListener","removeEventListener","createElement","NodeViewWrapper","className","style","display","minHeight","position","cursor","_extends2","width","height","backgroundColor","border","concat","boxSizing","borderRadius","overflow","padding","margin","minWidth","visibility","onClick","dangerouslySetInnerHTML","__html","Fragment","ref","zIndex","_tiptapContainerEl","ReactDOM","createPortal","deletable","toolbarOpts","autoWidth","top","left","right","onDelete","tr","_toolbarOpened","view","dispatch","commands","focus","showDone","propTypes","PropTypes","object","any","string","isFocused","bool","_default","exports"],"sources":["../../../src/components/respArea/ExplicitConstructedResponse.jsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { NodeViewWrapper } from '@tiptap/react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport CustomToolbarWrapper from '../../extensions/custom-toolbar-wrapper';\n\nconst ExplicitConstructedResponse = (props) => {\n const { editor, node, getPos, options, selected } = props;\n const { attrs: attributes } = node;\n const { value } = attributes;\n const { respAreaToolbar, error: errorFn } = options;\n const pos = getPos();\n const [showToolbar, setShowToolbar] = useState(false);\n const EcrToolbar = respAreaToolbar([node, pos], editor, () => {});\n const toolbarRef = useRef(null);\n\n let error;\n\n if (errorFn) {\n const errorValue = errorFn();\n const respIndex = parseInt(attributes.index, 10);\n\n error = !!errorValue?.[respIndex]?.[0];\n }\n\n useEffect(() => {\n const { selection } = editor.state;\n const onlyThisNodeSelected = selection.from + node.nodeSize === selection.to;\n\n if (selected) {\n if (onlyThisNodeSelected) {\n setShowToolbar(selected);\n }\n } else {\n setShowToolbar(selected);\n }\n }, [editor, node, selected]);\n\n useEffect(() => {\n const handleClickOutside = (event) => {\n const insideCharacterPicker =\n event.target.closest('.insert-character-dialog') || event.target.closest('[data-toolbar-for]');\n\n if (\n !insideCharacterPicker &&\n toolbarRef.current &&\n !toolbarRef.current.contains(event.target) &&\n !event.target.closest('[data-inline-node]')\n ) {\n setShowToolbar(false);\n }\n };\n\n if (showToolbar) {\n document.addEventListener('mousedown', handleClickOutside);\n } else {\n document.removeEventListener('mousedown', handleClickOutside);\n }\n\n return () => document.removeEventListener('mousedown', handleClickOutside);\n }, [showToolbar]);\n\n return (\n <NodeViewWrapper\n className=\"drag-in-the-blank\"\n data-selected={selected}\n style={{\n display: 'inline-flex',\n minHeight: '55px',\n position: 'relative',\n cursor: 'pointer',\n }}\n >\n <div\n {...attributes}\n style={{\n display: 'inline-flex',\n width: '100%',\n minHeight: '46px',\n height: '46px',\n backgroundColor: '#FFF',\n border: `1px solid ${error ? 'red' : '#C0C3CF'}`,\n boxSizing: 'border-box',\n borderRadius: '4px',\n overflow: 'hidden',\n padding: '12px 21px',\n margin: '0 4px',\n minWidth: '178px',\n visibility: showToolbar ? 'hidden' : 'visible',\n }}\n onClick={() => setShowToolbar(true)}\n dangerouslySetInnerHTML={{\n __html: value || '<div>&nbsp;</div>',\n }}\n />\n {showToolbar && (\n <React.Fragment>\n <div ref={toolbarRef} className=\"absolute z-50 bg-white shadow-lg rounded p-2\" style={{ zIndex: 1 }}>\n <EcrToolbar />\n </div>\n {editor._tiptapContainerEl &&\n ReactDOM.createPortal(\n <CustomToolbarWrapper\n deletable\n toolbarOpts={{ minWidth: 'auto' }}\n autoWidth\n style={{ top: -40, left: 0, right: 0 }}\n onDelete={() => {\n const { tr } = editor.state;\n tr.delete(pos, pos + node.nodeSize);\n // Prevent the debounced onBlur/onDone from firing into the\n // now-deleted node's stale position\n editor._toolbarOpened = false;\n editor.view.dispatch(tr);\n setShowToolbar(false);\n editor.commands.focus();\n }}\n showDone={false}\n />,\n editor._tiptapContainerEl,\n )}\n </React.Fragment>\n )}\n </NodeViewWrapper>\n );\n};\n\nExplicitConstructedResponse.propTypes = {\n attributes: PropTypes.object,\n error: PropTypes.any,\n value: PropTypes.string,\n isFocused: PropTypes.bool,\n};\n\nexport default ExplicitConstructedResponse;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,UAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,qBAAA,GAAAF,sBAAA,CAAAH,OAAA;AAA2E,SAAAD,wBAAAO,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,wBAAAO,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,mBAAAT,CAAA,iBAAAA,CAAA,gBAAAU,OAAA,CAAAV,CAAA,0BAAAA,CAAA,SAAAQ,CAAA,MAAAF,C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A2B,CAACyF,SAAS,GAAG;EACtClF,UAAU,EAAEmF,qBAAS,CAACC,MAAM;EAC5B/E,KAAK,EAAE8E,qBAAS,CAACE,GAAG;EACpBnF,KAAK,EAAEiF,qBAAS,CAACG,MAAM;EACvBC,SAAS,EAAEJ,qBAAS,CAACK;AACvB,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,cAEajG,2BAA2B","ignoreList":[]}
@@ -12,6 +12,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
12
12
  var _react2 = require("@tiptap/react");
13
13
  var _RespArea = require("../icons/RespArea");
14
14
  var _reactDom = _interopRequireDefault(require("react-dom"));
15
+ var _customToolbarWrapper = _interopRequireDefault(require("../../extensions/custom-toolbar-wrapper"));
15
16
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
16
17
  var InlineDropdown = function InlineDropdown(props) {
17
18
  var editor = props.editor,
@@ -123,7 +124,7 @@ var InlineDropdown = function InlineDropdown(props) {
123
124
  top: '5px',
124
125
  right: '5px'
125
126
  }
126
- })), showToolbar && /*#__PURE__*/_reactDom["default"].createPortal(/*#__PURE__*/_react["default"].createElement("div", {
127
+ })), showToolbar && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_reactDom["default"].createPortal(/*#__PURE__*/_react["default"].createElement("div", {
127
128
  ref: toolbarRef,
128
129
  style: {
129
130
  zIndex: 1
@@ -132,7 +133,29 @@ var InlineDropdown = function InlineDropdown(props) {
132
133
  editorCallback: function editorCallback(instance) {
133
134
  toolbarEditor.current = instance;
134
135
  }
135
- })), document.body));
136
+ })), document.body), editor._tiptapContainerEl && /*#__PURE__*/_reactDom["default"].createPortal(/*#__PURE__*/_react["default"].createElement(_customToolbarWrapper["default"], {
137
+ deletable: true,
138
+ toolbarOpts: {
139
+ minWidth: 'auto'
140
+ },
141
+ autoWidth: true,
142
+ style: {
143
+ top: -40,
144
+ left: 0,
145
+ right: 0
146
+ },
147
+ onDelete: function onDelete() {
148
+ var tr = editor.state.tr;
149
+ tr["delete"](pos, pos + node.nodeSize);
150
+ // Prevent the debounced onBlur/onDone from firing into the
151
+ // now-deleted node's stale position
152
+ editor._toolbarOpened = false;
153
+ editor.view.dispatch(tr);
154
+ setShowToolbar(false);
155
+ editor.commands.focus();
156
+ },
157
+ showDone: false
158
+ }), editor._tiptapContainerEl)));
136
159
  };
137
160
  InlineDropdown.propTypes = {
138
161
  attributes: _propTypes["default"].object,
@@ -1 +1 @@
1
- {"version":3,"file":"InlineDropdown.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_react2","_RespArea","_reactDom","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","InlineDropdown","props","editor","node","getPos","options","selected","attributes","attrs","value","error","html","pos","toolbarRef","useRef","toolbarEditor","_useState","useState","_useState2","_slicedToArray2","showToolbar","setShowToolbar","_useState3","top","left","_useState4","position","setPosition","InlineDropdownToolbar","respAreaToolbar","useEffect","selection","state","onlyThisNodeSelected","from","nodeSize","to","bodyRect","document","body","getBoundingClientRect","start","view","coordsAtPos","Math","abs","handleClickOutside","event","insideSomeEditor","target","closest","dataset","toolbarFor","current","instanceId","_toolbarOpened","contains","addEventListener","removeEventListener","createElement","NodeViewWrapper","className","style","display","height","cursor","minWidth","background","border","boxSizing","borderRadius","margin","alignItems","onClick","flex","overflow","padding","whiteSpace","textOverflow","verticalAlign","dangerouslySetInnerHTML","__html","Chevron","direction","right","ReactDOM","createPortal","ref","zIndex","editorCallback","instance","propTypes","PropTypes","object","selectedItem","oneOfType","string","_default","exports"],"sources":["../../../src/components/respArea/InlineDropdown.jsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { NodeViewWrapper } from '@tiptap/react';\nimport { Chevron } from '../icons/RespArea';\nimport ReactDOM from 'react-dom';\n\nconst InlineDropdown = (props) => {\n const { editor, node, getPos, options, selected } = props;\n const { attrs: attributes } = node;\n const { value, error } = attributes;\n // TODO: Investigate\n // Needed because items with values inside have different positioning for some reason\n const html = value || '<div>&nbsp</div>';\n const pos = getPos();\n const toolbarRef = useRef(null);\n const toolbarEditor = useRef(null);\n const [showToolbar, setShowToolbar] = useState(false);\n const [position, setPosition] = useState({ top: 0, left: 0 });\n const InlineDropdownToolbar = options.respAreaToolbar([node, pos], editor, () => {});\n\n useEffect(() => {\n const { selection } = editor.state;\n const onlyThisNodeSelected = selection.from + node.nodeSize === selection.to;\n\n if (selected) {\n if (onlyThisNodeSelected) {\n setShowToolbar(selected);\n }\n } else {\n setShowToolbar(selected);\n }\n }, [editor, node, selected]);\n\n useEffect(() => {\n // Calculate position relative to selection\n const bodyRect = document.body.getBoundingClientRect();\n const { from } = editor.state.selection;\n const start = editor.view.coordsAtPos(from);\n\n setPosition({\n top: start.top + Math.abs(bodyRect.top) + 40, // shift above\n left: start.left,\n });\n\n const handleClickOutside = (event) => {\n const insideSomeEditor = event.target.closest('[data-toolbar-for]');\n\n if (\n (!insideSomeEditor || insideSomeEditor.dataset.toolbarFor !== toolbarEditor.current.instanceId) &&\n !editor._toolbarOpened &&\n toolbarRef.current &&\n !toolbarRef.current.contains(event.target) &&\n !event.target.closest('[data-inline-node]')\n ) {\n setShowToolbar(false);\n }\n };\n\n if (showToolbar) {\n document.addEventListener('mousedown', handleClickOutside);\n } else {\n document.removeEventListener('mousedown', handleClickOutside);\n }\n\n return () => document.removeEventListener('mousedown', handleClickOutside);\n }, [showToolbar]);\n\n return (\n <NodeViewWrapper\n className=\"inline-dropdown\"\n data-selected={selected}\n style={{\n display: 'inline-flex',\n height: '50px',\n cursor: 'pointer',\n }}\n >\n <div\n style={{\n display: 'inline-flex',\n minWidth: '178px',\n height: '36px',\n background: '#FFF',\n border: '1px solid #C0C3CF',\n boxSizing: 'border-box',\n borderRadius: '3px',\n margin: '0 2px',\n position: 'relative',\n alignItems: 'center',\n }}\n onClick={() => setShowToolbar(true)}\n >\n <div\n style={{\n flex: 1,\n overflow: 'hidden',\n padding: '0 25px 0 8px',\n whiteSpace: 'nowrap',\n textOverflow: 'ellipsis',\n }}\n >\n <span\n style={{\n display: 'inline-block',\n verticalAlign: 'middle',\n }}\n dangerouslySetInnerHTML={{\n __html: html,\n }}\n />\n </div>\n <Chevron\n direction=\"down\"\n style={{\n position: 'absolute',\n top: '5px',\n right: '5px',\n }}\n />\n </div>\n {showToolbar &&\n ReactDOM.createPortal(\n <div ref={toolbarRef} style={{ zIndex: 1 }}>\n <InlineDropdownToolbar\n editorCallback={(instance) => {\n toolbarEditor.current = instance;\n }}\n />\n </div>,\n document.body,\n )}\n </NodeViewWrapper>\n );\n};\n\nInlineDropdown.propTypes = {\n attributes: PropTypes.object,\n selectedItem: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),\n};\n\nexport default InlineDropdown;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAH,sBAAA,CAAAF,OAAA;AAAiC,SAAAD,wBAAAO,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,wBAAAO,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AAE;IAAE;EAAE,gBACzCpH,MAAA,YAAAuF,aAAA,CAAC/B,qBAAqB;IACpB6D,cAAc,EAAE,SAAhBA,cAAcA,CAAGC,QAAQ,EAAK;MAC5B3E,aAAa,CAACsC,OAAO,GAAGqC,QAAQ;IAClC;EAAE,CACH,CACE,CAAC,EACNpD,QAAQ,CAACC,IACX,CACa,CAAC;AAEtB,CAAC;AAEDvC,cAAc,CAAC2F,SAAS,GAAG;EACzBpF,UAAU,EAAEqF,qBAAS,CAACC,MAAM;EAC5BC,YAAY,EAAEF,qBAAS,CAACG,SAAS,CAAC,CAACH,qBAAS,CAACI,MAAM,EAAEJ,qBAAS,CAACC,MAAM,CAAC;AACxE,CAAC;AAAC,IAAAI,QAAA,GAAAC,OAAA,cAEalG,cAAc","ignoreList":[]}
1
+ {"version":3,"file":"InlineDropdown.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_react2","_RespArea","_reactDom","_customToolbarWrapper","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","InlineDropdown","props","editor","node","getPos","options","selected","attributes","attrs","value","error","html","pos","toolbarRef","useRef","toolbarEditor","_useState","useState","_useState2","_slicedToArray2","showToolbar","setShowToolbar","_useState3","top","left","_useState4","position","setPosition","InlineDropdownToolbar","respAreaToolbar","useEffect","selection","state","onlyThisNodeSelected","from","nodeSize","to","bodyRect","document","body","getBoundingClientRect","start","view","coordsAtPos","Math","abs","handleClickOutside","event","insideSomeEditor","target","closest","dataset","toolbarFor","current","instanceId","_toolbarOpened","contains","addEventListener","removeEventListener","createElement","NodeViewWrapper","className","style","display","height","cursor","minWidth","background","border","boxSizing","borderRadius","margin","alignItems","onClick","flex","overflow","padding","whiteSpace","textOverflow","verticalAlign","dangerouslySetInnerHTML","__html","Chevron","direction","right","Fragment","ReactDOM","createPortal","ref","zIndex","editorCallback","instance","_tiptapContainerEl","deletable","toolbarOpts","autoWidth","onDelete","tr","dispatch","commands","focus","showDone","propTypes","PropTypes","object","selectedItem","oneOfType","string","_default","exports"],"sources":["../../../src/components/respArea/InlineDropdown.jsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { NodeViewWrapper } from '@tiptap/react';\nimport { Chevron } from '../icons/RespArea';\nimport ReactDOM from 'react-dom';\nimport CustomToolbarWrapper from '../../extensions/custom-toolbar-wrapper';\n\nconst InlineDropdown = (props) => {\n const { editor, node, getPos, options, selected } = props;\n const { attrs: attributes } = node;\n const { value, error } = attributes;\n // TODO: Investigate\n // Needed because items with values inside have different positioning for some reason\n const html = value || '<div>&nbsp</div>';\n const pos = getPos();\n const toolbarRef = useRef(null);\n const toolbarEditor = useRef(null);\n const [showToolbar, setShowToolbar] = useState(false);\n const [position, setPosition] = useState({ top: 0, left: 0 });\n const InlineDropdownToolbar = options.respAreaToolbar([node, pos], editor, () => {});\n\n useEffect(() => {\n const { selection } = editor.state;\n const onlyThisNodeSelected = selection.from + node.nodeSize === selection.to;\n\n if (selected) {\n if (onlyThisNodeSelected) {\n setShowToolbar(selected);\n }\n } else {\n setShowToolbar(selected);\n }\n }, [editor, node, selected]);\n\n useEffect(() => {\n // Calculate position relative to selection\n const bodyRect = document.body.getBoundingClientRect();\n const { from } = editor.state.selection;\n const start = editor.view.coordsAtPos(from);\n\n setPosition({\n top: start.top + Math.abs(bodyRect.top) + 40, // shift above\n left: start.left,\n });\n\n const handleClickOutside = (event) => {\n const insideSomeEditor = event.target.closest('[data-toolbar-for]');\n\n if (\n (!insideSomeEditor || insideSomeEditor.dataset.toolbarFor !== toolbarEditor.current.instanceId) &&\n !editor._toolbarOpened &&\n toolbarRef.current &&\n !toolbarRef.current.contains(event.target) &&\n !event.target.closest('[data-inline-node]')\n ) {\n setShowToolbar(false);\n }\n };\n\n if (showToolbar) {\n document.addEventListener('mousedown', handleClickOutside);\n } else {\n document.removeEventListener('mousedown', handleClickOutside);\n }\n\n return () => document.removeEventListener('mousedown', handleClickOutside);\n }, [showToolbar]);\n\n return (\n <NodeViewWrapper\n className=\"inline-dropdown\"\n data-selected={selected}\n style={{\n display: 'inline-flex',\n height: '50px',\n cursor: 'pointer',\n }}\n >\n <div\n style={{\n display: 'inline-flex',\n minWidth: '178px',\n height: '36px',\n background: '#FFF',\n border: '1px solid #C0C3CF',\n boxSizing: 'border-box',\n borderRadius: '3px',\n margin: '0 2px',\n position: 'relative',\n alignItems: 'center',\n }}\n onClick={() => setShowToolbar(true)}\n >\n <div\n style={{\n flex: 1,\n overflow: 'hidden',\n padding: '0 25px 0 8px',\n whiteSpace: 'nowrap',\n textOverflow: 'ellipsis',\n }}\n >\n <span\n style={{\n display: 'inline-block',\n verticalAlign: 'middle',\n }}\n dangerouslySetInnerHTML={{\n __html: html,\n }}\n />\n </div>\n <Chevron\n direction=\"down\"\n style={{\n position: 'absolute',\n top: '5px',\n right: '5px',\n }}\n />\n </div>\n {showToolbar && (\n <React.Fragment>\n {ReactDOM.createPortal(\n <div ref={toolbarRef} style={{ zIndex: 1 }}>\n <InlineDropdownToolbar\n editorCallback={(instance) => {\n toolbarEditor.current = instance;\n }}\n />\n </div>,\n document.body,\n )}\n\n {editor._tiptapContainerEl &&\n ReactDOM.createPortal(\n <CustomToolbarWrapper\n deletable\n toolbarOpts={{ minWidth: 'auto' }}\n autoWidth\n style={{ top: -40, left: 0, right: 0 }}\n onDelete={() => {\n const { tr } = editor.state;\n tr.delete(pos, pos + node.nodeSize);\n // Prevent the debounced onBlur/onDone from firing into the\n // now-deleted node's stale position\n editor._toolbarOpened = false;\n editor.view.dispatch(tr);\n setShowToolbar(false);\n editor.commands.focus();\n }}\n showDone={false}\n />,\n editor._tiptapContainerEl,\n )}\n </React.Fragment>\n )}\n </NodeViewWrapper>\n );\n};\n\nInlineDropdown.propTypes = {\n attributes: PropTypes.object,\n selectedItem: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),\n};\n\nexport default InlineDropdown;\n"],"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AC7BrD,MAAM,CAACwC,IAAI,CAACwD,QAAQ,CAACD,EAAE,CAAC;MACxB5E,cAAc,CAAC,KAAK,CAAC;MACrBnB,MAAM,CAACiG,QAAQ,CAACC,KAAK,CAAC,CAAC;IACzB,CAAE;IACFC,QAAQ,EAAE;EAAM,CACjB,CAAC,EACFnG,MAAM,CAAC0F,kBACT,CACY,CAEH,CAAC;AAEtB,CAAC;AAED5F,cAAc,CAACsG,SAAS,GAAG;EACzB/F,UAAU,EAAEgG,qBAAS,CAACC,MAAM;EAC5BC,YAAY,EAAEF,qBAAS,CAACG,SAAS,CAAC,CAACH,qBAAS,CAACI,MAAM,EAAEJ,qBAAS,CAACC,MAAM,CAAC;AACxE,CAAC;AAAC,IAAAI,QAAA,GAAAC,OAAA,cAEa7G,cAAc","ignoreList":[]}
@@ -1,11 +1,60 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
- exports["default"] = void 0;
7
+ exports["default"] = exports.applyPresentationToTableElement = exports.ExtendedTableView = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
12
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
13
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
14
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
7
15
  var _extensionTable = require("@tiptap/extension-table");
16
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
+ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
19
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
20
+ function _superPropGet(t, o, e, r) { var p = (0, _get2["default"])((0, _getPrototypeOf2["default"])(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
21
+ var applyPresentationToTableElement = exports.applyPresentationToTableElement = function applyPresentationToTableElement(table, attrs) {
22
+ var border = (attrs === null || attrs === void 0 ? void 0 : attrs.border) != null && attrs.border !== '' ? attrs.border : '1';
23
+ table.setAttribute('border', border);
24
+ table.style.setProperty('color', 'var(--pie-text, black)');
25
+ table.style.setProperty('background-color', 'var(--pie-background, rgba(255, 255, 255))');
26
+ };
27
+ var ExtendedTableView = exports.ExtendedTableView = /*#__PURE__*/function (_TableView) {
28
+ function ExtendedTableView(node, cellMinWidth, view) {
29
+ var _this;
30
+ (0, _classCallCheck2["default"])(this, ExtendedTableView);
31
+ _this = _callSuper(this, ExtendedTableView, [node, cellMinWidth, view]);
32
+ applyPresentationToTableElement(_this.table, node.attrs);
33
+ return _this;
34
+ }
35
+ (0, _inherits2["default"])(ExtendedTableView, _TableView);
36
+ return (0, _createClass2["default"])(ExtendedTableView, [{
37
+ key: "update",
38
+ value: function update(node) {
39
+ var ok = _superPropGet(ExtendedTableView, "update", this, 3)([node]);
40
+ if (ok) {
41
+ applyPresentationToTableElement(this.table, node.attrs);
42
+ }
43
+ return ok;
44
+ }
45
+ }]);
46
+ }(_extensionTable.TableView);
8
47
  var ExtendedTable = _extensionTable.Table.extend({
48
+ addOptions: function addOptions() {
49
+ var _this$parent;
50
+ return _objectSpread(_objectSpread({}, (_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.call(this)), {}, {
51
+ // ProseMirror's default table DOM does not prune extra <col> nodes when a column
52
+ // is removed; TableView (via column resizing) does.
53
+ resizable: true,
54
+ handleWidth: 0,
55
+ View: ExtendedTableView
56
+ });
57
+ },
9
58
  addAttributes: function addAttributes() {
10
59
  return {
11
60
  border: {
@@ -1 +1 @@
1
- {"version":3,"file":"extended-table.js","names":["_extensionTable","require","ExtendedTable","Table","extend","addAttributes","border","renderHTML","props","originalTable","parent","HTMLAttributes","previousStyle","concat","style","match","_default","exports"],"sources":["../../src/extensions/extended-table.js"],"sourcesContent":["import { Table } from '@tiptap/extension-table';\n\nconst ExtendedTable = Table.extend({\n addAttributes() {\n return {\n border: { default: '1' },\n };\n },\n renderHTML(props) {\n const originalTable = this.parent(props);\n const { border } = props.HTMLAttributes;\n\n const previousStyle = `${originalTable[1].style}${originalTable[1].style.match(/.*; */) ? '' : ';'}`;\n\n originalTable[1].style = `${previousStyle}\n color: var(--pie-text, black);\n background-color: var(--pie-background, rgba(255, 255, 255))`;\n originalTable[1].border = border ? border : '1';\n\n return originalTable;\n },\n});\n\nexport default ExtendedTable;\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAMC,aAAa,GAAGC,qBAAK,CAACC,MAAM,CAAC;EACjCC,aAAa,WAAbA,aAAaA,CAAA,EAAG;IACd,OAAO;MACLC,MAAM,EAAE;QAAE,WAAS;MAAI;IACzB,CAAC;EACH,CAAC;EACDC,UAAU,WAAVA,UAAUA,CAACC,KAAK,EAAE;IAChB,IAAMC,aAAa,GAAG,IAAI,CAACC,MAAM,CAACF,KAAK,CAAC;IACxC,IAAQF,MAAM,GAAKE,KAAK,CAACG,cAAc,CAA/BL,MAAM;IAEd,IAAMM,aAAa,MAAAC,MAAA,CAAMJ,aAAa,CAAC,CAAC,CAAC,CAACK,KAAK,EAAAD,MAAA,CAAGJ,aAAa,CAAC,CAAC,CAAC,CAACK,KAAK,CAACC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,CAAE;IAEpGN,aAAa,CAAC,CAAC,CAAC,CAACK,KAAK,MAAAD,MAAA,CAAMD,aAAa,2GAEoB;IAC7DH,aAAa,CAAC,CAAC,CAAC,CAACH,MAAM,GAAGA,MAAM,GAAGA,MAAM,GAAG,GAAG;IAE/C,OAAOG,aAAa;EACtB;AACF,CAAC,CAAC;AAAC,IAAAO,QAAA,GAAAC,OAAA,cAEYf,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"extended-table.js","names":["_extensionTable","require","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_callSuper","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","Boolean","prototype","valueOf","call","_superPropGet","p","_get2","applyPresentationToTableElement","exports","table","attrs","border","setAttribute","style","setProperty","ExtendedTableView","_TableView","node","cellMinWidth","view","_this","_classCallCheck2","_inherits2","_createClass2","key","value","update","ok","TableView","ExtendedTable","Table","extend","addOptions","_this$parent","parent","resizable","handleWidth","View","addAttributes","renderHTML","props","originalTable","HTMLAttributes","previousStyle","concat","match","_default"],"sources":["../../src/extensions/extended-table.js"],"sourcesContent":["import { Table, TableView } from '@tiptap/extension-table';\n\nconst applyPresentationToTableElement = (table, attrs) => {\n const border = attrs?.border != null && attrs.border !== '' ? attrs.border : '1';\n\n table.setAttribute('border', border);\n table.style.setProperty('color', 'var(--pie-text, black)');\n table.style.setProperty('background-color', 'var(--pie-background, rgba(255, 255, 255))');\n};\n\nclass ExtendedTableView extends TableView {\n constructor(node, cellMinWidth, view) {\n super(node, cellMinWidth, view);\n applyPresentationToTableElement(this.table, node.attrs);\n }\n\n update(node) {\n const ok = super.update(node);\n\n if (ok) {\n applyPresentationToTableElement(this.table, node.attrs);\n }\n\n return ok;\n }\n}\n\nconst ExtendedTable = Table.extend({\n addOptions() {\n return {\n ...this.parent?.(),\n // ProseMirror's default table DOM does not prune extra <col> nodes when a column\n // is removed; TableView (via column resizing) does.\n resizable: true,\n handleWidth: 0,\n View: ExtendedTableView,\n };\n },\n addAttributes() {\n return {\n border: { default: '1' },\n };\n },\n renderHTML(props) {\n const originalTable = this.parent(props);\n const { border } = props.HTMLAttributes;\n\n const previousStyle = `${originalTable[1].style}${originalTable[1].style.match(/.*; */) ? '' : ';'}`;\n\n originalTable[1].style = `${previousStyle}\n color: var(--pie-text, black);\n background-color: var(--pie-background, rgba(255, 255, 255))`;\n originalTable[1].border = border ? border : '1';\n\n return originalTable;\n },\n});\n\nexport { applyPresentationToTableElement, ExtendedTableView };\nexport default ExtendedTable;\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAA2D,SAAAC,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAA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AAC;AAAC,IAAAK,QAAA,GAAAtC,OAAA,cAGYqB,aAAa","ignoreList":[]}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.2.0-next.35",
6
+ "version": "1.2.0-next.36",
7
7
  "description": "",
8
8
  "license": "ISC",
9
9
  "main": "lib/index.js",
@@ -16,11 +16,11 @@
16
16
  "@dnd-kit/utilities": "3.2.2",
17
17
  "@mui/icons-material": "^7.3.4",
18
18
  "@mui/material": "^7.3.4",
19
- "@pie-lib/drag": "^3.2.0-next.9",
19
+ "@pie-lib/drag": "^3.2.0-next.10",
20
20
  "@pie-lib/math-input": "^7.2.0-next.12",
21
- "@pie-lib/math-rendering": "^4.2.0-next.3",
22
- "@pie-lib/math-toolbar": "^2.2.0-next.15",
23
- "@pie-lib/render-ui": "^5.2.0-next.8",
21
+ "@pie-lib/math-rendering": "^4.2.0-next.4",
22
+ "@pie-lib/math-toolbar": "^2.2.0-next.16",
23
+ "@pie-lib/render-ui": "^5.2.0-next.9",
24
24
  "@tiptap/core": "3.0.9",
25
25
  "@tiptap/extension-character-count": "3.0.9",
26
26
  "@tiptap/extension-color": "3.0.9",
@@ -59,6 +59,6 @@
59
59
  "peerDependencies": {
60
60
  "react": "^18.2.0"
61
61
  },
62
- "gitHead": "6ddaea6108b6c515e163fb530c7f833b0f233f5e",
62
+ "gitHead": "6ed326bed124056a8f5a7ff52386f8b12fbf650b",
63
63
  "scripts": {}
64
64
  }
@@ -10,19 +10,37 @@ jest.mock('@tiptap/react', () => ({
10
10
  ),
11
11
  }));
12
12
 
13
+ jest.mock('react-dom', () => ({
14
+ ...jest.requireActual('react-dom'),
15
+ createPortal: (node) => node,
16
+ }));
17
+
13
18
  describe('ExplicitConstructedResponse', () => {
14
- const mockEditor = {
15
- state: {
16
- selection: {
17
- from: 0,
18
- to: 1,
19
+ const buildMockEditor = (overrides = {}) => {
20
+ const mockTr = {
21
+ delete: jest.fn(),
22
+ };
23
+ return {
24
+ state: {
25
+ selection: {
26
+ from: 0,
27
+ to: 1,
28
+ },
29
+ tr: mockTr,
19
30
  },
20
- },
21
- commands: {
22
- focus: jest.fn(),
23
- },
31
+ view: {
32
+ dispatch: jest.fn(),
33
+ },
34
+ commands: {
35
+ focus: jest.fn(),
36
+ },
37
+ _tiptapContainerEl: document.createElement('div'),
38
+ ...overrides,
39
+ };
24
40
  };
25
41
 
42
+ let mockEditor;
43
+
26
44
  const mockNode = {
27
45
  attrs: {
28
46
  index: '0',
@@ -46,6 +64,8 @@ describe('ExplicitConstructedResponse', () => {
46
64
 
47
65
  beforeEach(() => {
48
66
  jest.clearAllMocks();
67
+ mockEditor = buildMockEditor();
68
+ defaultProps.editor = mockEditor;
49
69
  });
50
70
 
51
71
  it('renders without crashing', () => {
@@ -97,8 +117,7 @@ describe('ExplicitConstructedResponse', () => {
97
117
  const clickableDiv = container.querySelector('div[style*="border"]');
98
118
  fireEvent.click(clickableDiv);
99
119
  await waitFor(() => {
100
- // After click, toolbar should be shown
101
- expect(container).toBeInTheDocument();
120
+ expect(queryByTestId('toolbar')).toBeInTheDocument();
102
121
  });
103
122
  });
104
123
 
@@ -158,4 +177,28 @@ describe('ExplicitConstructedResponse', () => {
158
177
  const contentDiv = container.querySelector('div[style*="padding"]');
159
178
  expect(contentDiv).toHaveStyle({ minWidth: '178px' });
160
179
  });
180
+
181
+ it('renders delete control on portaled custom toolbar when container el is set', async () => {
182
+ const { findByLabelText } = render(<ExplicitConstructedResponse {...defaultProps} selected />);
183
+ expect(await findByLabelText('Delete')).toBeInTheDocument();
184
+ });
185
+
186
+ it('does not render portaled delete control when _tiptapContainerEl is missing', async () => {
187
+ const editor = buildMockEditor({ _tiptapContainerEl: undefined });
188
+ const { queryByLabelText, findByTestId } = render(
189
+ <ExplicitConstructedResponse {...defaultProps} editor={editor} selected />,
190
+ );
191
+ expect(await findByTestId('toolbar')).toBeInTheDocument();
192
+ expect(queryByLabelText('Delete')).not.toBeInTheDocument();
193
+ });
194
+
195
+ it('delete clears toolbar flag, removes node range, dispatches, and focuses', async () => {
196
+ mockEditor._toolbarOpened = true;
197
+ const { findByLabelText } = render(<ExplicitConstructedResponse {...defaultProps} selected />);
198
+ fireEvent.mouseDown(await findByLabelText('Delete'));
199
+ expect(mockEditor.state.tr.delete).toHaveBeenCalledWith(5, 6);
200
+ expect(mockEditor.view.dispatch).toHaveBeenCalledWith(mockEditor.state.tr);
201
+ expect(mockEditor._toolbarOpened).toBe(false);
202
+ expect(mockEditor.commands.focus).toHaveBeenCalled();
203
+ });
161
204
  });
@@ -16,18 +16,33 @@ jest.mock('react-dom', () => ({
16
16
  }));
17
17
 
18
18
  describe('InlineDropdown', () => {
19
- const mockEditor = {
20
- state: {
21
- selection: {
22
- from: 0,
23
- to: 1,
19
+ const buildMockEditor = (overrides = {}) => {
20
+ const mockTr = {
21
+ delete: jest.fn(),
22
+ };
23
+ return {
24
+ state: {
25
+ selection: {
26
+ from: 0,
27
+ to: 1,
28
+ },
29
+ tr: mockTr,
24
30
  },
25
- },
26
- view: {
27
- coordsAtPos: jest.fn(() => ({ top: 100, left: 50 })),
28
- },
31
+ view: {
32
+ coordsAtPos: jest.fn(() => ({ top: 100, left: 50 })),
33
+ dispatch: jest.fn(),
34
+ },
35
+ commands: {
36
+ focus: jest.fn(),
37
+ },
38
+ _tiptapContainerEl: document.createElement('div'),
39
+ _toolbarOpened: false,
40
+ ...overrides,
41
+ };
29
42
  };
30
43
 
44
+ let mockEditor;
45
+
31
46
  const mockNode = {
32
47
  attrs: {
33
48
  index: '0',
@@ -51,6 +66,8 @@ describe('InlineDropdown', () => {
51
66
 
52
67
  beforeEach(() => {
53
68
  jest.clearAllMocks();
69
+ mockEditor = buildMockEditor();
70
+ defaultProps.editor = mockEditor;
54
71
  Object.defineProperty(document.body, 'getBoundingClientRect', {
55
72
  value: jest.fn(() => ({ top: 0, left: 0 })),
56
73
  configurable: true,
@@ -322,10 +339,7 @@ describe('InlineDropdown', () => {
322
339
  });
323
340
 
324
341
  it('checks editor._toolbarOpened in click outside handler', async () => {
325
- const editorWithToolbarOpened = {
326
- ...mockEditor,
327
- _toolbarOpened: true,
328
- };
342
+ const editorWithToolbarOpened = buildMockEditor({ _toolbarOpened: true });
329
343
 
330
344
  const { queryByTestId } = render(
331
345
  <InlineDropdown {...defaultProps} editor={editorWithToolbarOpened} selected={true} />,
@@ -341,4 +355,26 @@ describe('InlineDropdown', () => {
341
355
  // Toolbar should still be visible
342
356
  expect(queryByTestId('inline-dropdown-toolbar')).toBeInTheDocument();
343
357
  });
358
+
359
+ it('renders delete control on portaled custom toolbar when container el is set', async () => {
360
+ const { findByLabelText } = render(<InlineDropdown {...defaultProps} selected />);
361
+ expect(await findByLabelText('Delete')).toBeInTheDocument();
362
+ });
363
+
364
+ it('does not render portaled delete control when _tiptapContainerEl is missing', async () => {
365
+ const editor = buildMockEditor({ _tiptapContainerEl: undefined });
366
+ const { queryByLabelText, findByTestId } = render(<InlineDropdown {...defaultProps} editor={editor} selected />);
367
+ expect(await findByTestId('inline-dropdown-toolbar')).toBeInTheDocument();
368
+ expect(queryByLabelText('Delete')).not.toBeInTheDocument();
369
+ });
370
+
371
+ it('delete clears toolbar flag, removes node range, dispatches, and focuses', async () => {
372
+ mockEditor._toolbarOpened = true;
373
+ const { findByLabelText } = render(<InlineDropdown {...defaultProps} selected />);
374
+ fireEvent.mouseDown(await findByLabelText('Delete'));
375
+ expect(mockEditor.state.tr.delete).toHaveBeenCalledWith(5, 6);
376
+ expect(mockEditor.view.dispatch).toHaveBeenCalledWith(mockEditor.state.tr);
377
+ expect(mockEditor._toolbarOpened).toBe(false);
378
+ expect(mockEditor.commands.focus).toHaveBeenCalled();
379
+ });
344
380
  });
@@ -11,7 +11,7 @@ const ExplicitConstructedResponse = (props) => {
11
11
  const { respAreaToolbar, error: errorFn } = options;
12
12
  const pos = getPos();
13
13
  const [showToolbar, setShowToolbar] = useState(false);
14
- const EcrToolbar = respAreaToolbar([node, pos], editor, () => { });
14
+ const EcrToolbar = respAreaToolbar([node, pos], editor, () => {});
15
15
  const toolbarRef = useRef(null);
16
16
 
17
17
  let error;
@@ -38,7 +38,8 @@ const ExplicitConstructedResponse = (props) => {
38
38
 
39
39
  useEffect(() => {
40
40
  const handleClickOutside = (event) => {
41
- const insideCharacterPicker = event.target.closest('.insert-character-dialog') || event.target.closest('[data-toolbar-for]');
41
+ const insideCharacterPicker =
42
+ event.target.closest('.insert-character-dialog') || event.target.closest('[data-toolbar-for]');
42
43
 
43
44
  if (
44
45
  !insideCharacterPicker &&
@@ -93,29 +94,32 @@ const ExplicitConstructedResponse = (props) => {
93
94
  }}
94
95
  />
95
96
  {showToolbar && (
96
- <div ref={toolbarRef} className="absolute z-50 bg-white shadow-lg rounded p-2" style={{ zIndex: 1 }}>
97
- <EcrToolbar />
98
- </div>
99
- )}
100
- {showToolbar && editor._tiptapContainerEl && ReactDOM.createPortal(
101
- <CustomToolbarWrapper
102
- deletable
103
- toolbarOpts={{ minWidth: 'auto' }}
104
- autoWidth
105
- style={{ top: -40, left: 0, right: 0 }}
106
- onDelete={() => {
107
- const { tr } = editor.state;
108
- tr.delete(pos, pos + node.nodeSize);
109
- // Prevent the debounced onBlur/onDone from firing into the
110
- // now-deleted node's stale position
111
- editor._toolbarOpened = false;
112
- editor.view.dispatch(tr);
113
- setShowToolbar(false);
114
- editor.commands.focus();
115
- }}
116
- showDone={false}
117
- />,
118
- editor._tiptapContainerEl,
97
+ <React.Fragment>
98
+ <div ref={toolbarRef} className="absolute z-50 bg-white shadow-lg rounded p-2" style={{ zIndex: 1 }}>
99
+ <EcrToolbar />
100
+ </div>
101
+ {editor._tiptapContainerEl &&
102
+ ReactDOM.createPortal(
103
+ <CustomToolbarWrapper
104
+ deletable
105
+ toolbarOpts={{ minWidth: 'auto' }}
106
+ autoWidth
107
+ style={{ top: -40, left: 0, right: 0 }}
108
+ onDelete={() => {
109
+ const { tr } = editor.state;
110
+ tr.delete(pos, pos + node.nodeSize);
111
+ // Prevent the debounced onBlur/onDone from firing into the
112
+ // now-deleted node's stale position
113
+ editor._toolbarOpened = false;
114
+ editor.view.dispatch(tr);
115
+ setShowToolbar(false);
116
+ editor.commands.focus();
117
+ }}
118
+ showDone={false}
119
+ />,
120
+ editor._tiptapContainerEl,
121
+ )}
122
+ </React.Fragment>
119
123
  )}
120
124
  </NodeViewWrapper>
121
125
  );
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import { NodeViewWrapper } from '@tiptap/react';
4
4
  import { Chevron } from '../icons/RespArea';
5
5
  import ReactDOM from 'react-dom';
6
+ import CustomToolbarWrapper from '../../extensions/custom-toolbar-wrapper';
6
7
 
7
8
  const InlineDropdown = (props) => {
8
9
  const { editor, node, getPos, options, selected } = props;
@@ -118,17 +119,42 @@ const InlineDropdown = (props) => {
118
119
  }}
119
120
  />
120
121
  </div>
121
- {showToolbar &&
122
- ReactDOM.createPortal(
123
- <div ref={toolbarRef} style={{ zIndex: 1 }}>
124
- <InlineDropdownToolbar
125
- editorCallback={(instance) => {
126
- toolbarEditor.current = instance;
127
- }}
128
- />
129
- </div>,
130
- document.body,
131
- )}
122
+ {showToolbar && (
123
+ <React.Fragment>
124
+ {ReactDOM.createPortal(
125
+ <div ref={toolbarRef} style={{ zIndex: 1 }}>
126
+ <InlineDropdownToolbar
127
+ editorCallback={(instance) => {
128
+ toolbarEditor.current = instance;
129
+ }}
130
+ />
131
+ </div>,
132
+ document.body,
133
+ )}
134
+
135
+ {editor._tiptapContainerEl &&
136
+ ReactDOM.createPortal(
137
+ <CustomToolbarWrapper
138
+ deletable
139
+ toolbarOpts={{ minWidth: 'auto' }}
140
+ autoWidth
141
+ style={{ top: -40, left: 0, right: 0 }}
142
+ onDelete={() => {
143
+ const { tr } = editor.state;
144
+ tr.delete(pos, pos + node.nodeSize);
145
+ // Prevent the debounced onBlur/onDone from firing into the
146
+ // now-deleted node's stale position
147
+ editor._toolbarOpened = false;
148
+ editor.view.dispatch(tr);
149
+ setShowToolbar(false);
150
+ editor.commands.focus();
151
+ }}
152
+ showDone={false}
153
+ />,
154
+ editor._tiptapContainerEl,
155
+ )}
156
+ </React.Fragment>
157
+ )}
132
158
  </NodeViewWrapper>
133
159
  );
134
160
  };
@@ -1,12 +1,109 @@
1
- import ExtendedTable from '../extended-table';
1
+ import ExtendedTable, { applyPresentationToTableElement, ExtendedTableView } from '../extended-table';
2
+
3
+ const mockTableViewState = { updateReturns: true };
2
4
 
3
5
  jest.mock('@tiptap/extension-table', () => ({
4
6
  Table: {
5
7
  extend: jest.fn((config) => config),
6
8
  },
9
+ TableView: class TableView {
10
+ constructor() {
11
+ this.table = {
12
+ style: { setProperty: jest.fn() },
13
+ setAttribute: jest.fn(),
14
+ };
15
+ }
16
+
17
+ update() {
18
+ return mockTableViewState.updateReturns;
19
+ }
20
+ },
7
21
  }));
8
22
 
9
23
  describe('ExtendedTable', () => {
24
+ beforeEach(() => {
25
+ mockTableViewState.updateReturns = true;
26
+ });
27
+
28
+ describe('applyPresentationToTableElement', () => {
29
+ it('sets default border and theme styles', () => {
30
+ const table = document.createElement('table');
31
+ const setProperty = jest.spyOn(table.style, 'setProperty');
32
+
33
+ applyPresentationToTableElement(table, {});
34
+
35
+ expect(table.getAttribute('border')).toBe('1');
36
+ expect(setProperty).toHaveBeenCalledWith('color', 'var(--pie-text, black)');
37
+ expect(setProperty).toHaveBeenCalledWith('background-color', 'var(--pie-background, rgba(255, 255, 255))');
38
+ setProperty.mockRestore();
39
+ });
40
+
41
+ it('uses explicit border from attrs', () => {
42
+ const table = document.createElement('table');
43
+ applyPresentationToTableElement(table, { border: '0' });
44
+
45
+ expect(table.getAttribute('border')).toBe('0');
46
+ });
47
+
48
+ it('treats empty border as default', () => {
49
+ const table = document.createElement('table');
50
+ applyPresentationToTableElement(table, { border: '' });
51
+
52
+ expect(table.getAttribute('border')).toBe('1');
53
+ });
54
+ });
55
+
56
+ describe('ExtendedTableView', () => {
57
+ it('applies presentation after construction', () => {
58
+ const node = { attrs: { border: '2' } };
59
+ const view = new ExtendedTableView(node, 25);
60
+
61
+ expect(view.table.setAttribute).toHaveBeenCalledWith('border', '2');
62
+ expect(view.table.style.setProperty).toHaveBeenCalledWith('color', 'var(--pie-text, black)');
63
+ expect(view.table.style.setProperty).toHaveBeenCalledWith(
64
+ 'background-color',
65
+ 'var(--pie-background, rgba(255, 255, 255))',
66
+ );
67
+ });
68
+
69
+ it('reapplies presentation when super.update returns true', () => {
70
+ const view = new ExtendedTableView({ attrs: { border: '1' } }, 25);
71
+ view.table.setAttribute.mockClear();
72
+ view.table.style.setProperty.mockClear();
73
+
74
+ view.update({ attrs: { border: '0' } });
75
+
76
+ expect(view.table.setAttribute).toHaveBeenCalledWith('border', '0');
77
+ expect(view.table.style.setProperty).toHaveBeenCalledWith('color', 'var(--pie-text, black)');
78
+ expect(view.table.style.setProperty).toHaveBeenCalledWith(
79
+ 'background-color',
80
+ 'var(--pie-background, rgba(255, 255, 255))',
81
+ );
82
+ });
83
+
84
+ it('does not reapply presentation when super.update returns false', () => {
85
+ mockTableViewState.updateReturns = false;
86
+ const view = new ExtendedTableView({ attrs: { border: '1' } }, 25);
87
+ view.table.setAttribute.mockClear();
88
+ view.table.style.setProperty.mockClear();
89
+
90
+ const ok = view.update({ attrs: { border: '0' } });
91
+
92
+ expect(ok).toBe(false);
93
+ expect(view.table.setAttribute).not.toHaveBeenCalled();
94
+ expect(view.table.style.setProperty).not.toHaveBeenCalled();
95
+ });
96
+ });
97
+
98
+ describe('addOptions', () => {
99
+ it('enables resizable table view with zero handle width for colgroup sync', () => {
100
+ const options = ExtendedTable.addOptions();
101
+ expect(options.resizable).toBe(true);
102
+ expect(options.handleWidth).toBe(0);
103
+ expect(options.View).toBe(ExtendedTableView);
104
+ });
105
+ });
106
+
10
107
  describe('addAttributes', () => {
11
108
  it('returns border attribute with default value', () => {
12
109
  const attributes = ExtendedTable.addAttributes();
@@ -1,6 +1,41 @@
1
- import { Table } from '@tiptap/extension-table';
1
+ import { Table, TableView } from '@tiptap/extension-table';
2
+
3
+ const applyPresentationToTableElement = (table, attrs) => {
4
+ const border = attrs?.border != null && attrs.border !== '' ? attrs.border : '1';
5
+
6
+ table.setAttribute('border', border);
7
+ table.style.setProperty('color', 'var(--pie-text, black)');
8
+ table.style.setProperty('background-color', 'var(--pie-background, rgba(255, 255, 255))');
9
+ };
10
+
11
+ class ExtendedTableView extends TableView {
12
+ constructor(node, cellMinWidth, view) {
13
+ super(node, cellMinWidth, view);
14
+ applyPresentationToTableElement(this.table, node.attrs);
15
+ }
16
+
17
+ update(node) {
18
+ const ok = super.update(node);
19
+
20
+ if (ok) {
21
+ applyPresentationToTableElement(this.table, node.attrs);
22
+ }
23
+
24
+ return ok;
25
+ }
26
+ }
2
27
 
3
28
  const ExtendedTable = Table.extend({
29
+ addOptions() {
30
+ return {
31
+ ...this.parent?.(),
32
+ // ProseMirror's default table DOM does not prune extra <col> nodes when a column
33
+ // is removed; TableView (via column resizing) does.
34
+ resizable: true,
35
+ handleWidth: 0,
36
+ View: ExtendedTableView,
37
+ };
38
+ },
4
39
  addAttributes() {
5
40
  return {
6
41
  border: { default: '1' },
@@ -21,4 +56,5 @@ const ExtendedTable = Table.extend({
21
56
  },
22
57
  });
23
58
 
59
+ export { applyPresentationToTableElement, ExtendedTableView };
24
60
  export default ExtendedTable;