@pie-lib/editable-html-tip-tap 1.2.0-next.0 → 1.2.0-next.12
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 +61 -22
- package/lib/components/CharacterPicker.js +4 -4
- package/lib/components/CharacterPicker.js.map +1 -1
- package/lib/components/EditableHtml.js +22 -5
- package/lib/components/EditableHtml.js.map +1 -1
- package/lib/components/MenuBar.js +30 -12
- package/lib/components/MenuBar.js.map +1 -1
- package/lib/components/TiptapContainer.js +10 -5
- package/lib/components/TiptapContainer.js.map +1 -1
- package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js +8 -3
- package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js.map +1 -1
- package/lib/components/respArea/DragInTheBlank/choice.js +13 -6
- package/lib/components/respArea/DragInTheBlank/choice.js.map +1 -1
- package/lib/components/respArea/MathTemplated.js +130 -0
- package/lib/components/respArea/MathTemplated.js.map +1 -0
- package/lib/extensions/image-component.js +4 -4
- package/lib/extensions/image-component.js.map +1 -1
- package/lib/extensions/index.js +7 -4
- package/lib/extensions/index.js.map +1 -1
- package/lib/extensions/media.js +14 -11
- package/lib/extensions/media.js.map +1 -1
- package/lib/extensions/responseArea.js +11 -8
- package/lib/extensions/responseArea.js.map +1 -1
- package/package.json +12 -14
- package/src/__tests__/EditableHtml.test.jsx +3 -0
- package/src/components/CharacterPicker.jsx +1 -1
- package/src/components/EditableHtml.jsx +28 -5
- package/src/components/MenuBar.jsx +37 -6
- package/src/components/TiptapContainer.jsx +6 -4
- package/src/components/respArea/DragInTheBlank/DragInTheBlank.jsx +7 -2
- package/src/components/respArea/DragInTheBlank/choice.jsx +31 -4
- package/src/components/respArea/MathTemplated.jsx +124 -0
- package/src/components/respArea/__tests__/MathTemplated.test.jsx +210 -0
- package/src/extensions/__tests__/media-node-view.test.jsx +296 -0
- package/src/extensions/__tests__/media.test.js +1 -0
- package/src/extensions/image-component.jsx +1 -1
- package/src/extensions/index.js +4 -1
- package/src/extensions/media.js +17 -14
- package/src/extensions/responseArea.js +3 -7
|
@@ -13,6 +13,7 @@ var _react2 = require("@tiptap/react");
|
|
|
13
13
|
var _ExplicitConstructedResponse = _interopRequireDefault(require("../components/respArea/ExplicitConstructedResponse"));
|
|
14
14
|
var _DragInTheBlank = _interopRequireDefault(require("../components/respArea/DragInTheBlank/DragInTheBlank"));
|
|
15
15
|
var _InlineDropdown = _interopRequireDefault(require("../components/respArea/InlineDropdown"));
|
|
16
|
+
var _MathTemplated = _interopRequireDefault(require("../components/respArea/MathTemplated"));
|
|
16
17
|
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
18
|
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
19
|
var lastIndexMap = {};
|
|
@@ -190,10 +191,9 @@ var ResponseAreaExtension = exports.ResponseAreaExtension = _core.Extension.crea
|
|
|
190
191
|
// tr.setSelection(NodeSelection.create(tr.doc, usedPos))
|
|
191
192
|
|
|
192
193
|
// --- Cursor move behavior for certain types (Slate: moveFocusTo next text) ---
|
|
193
|
-
if (['math_templated', 'inline_dropdown', '
|
|
194
|
+
if (['math_templated', 'inline_dropdown', 'explicit_constructed_response'].includes(typeName)) {
|
|
194
195
|
tr.setSelection(_prosemirrorState.NodeSelection.create(tr.doc, usedPos));
|
|
195
196
|
} else {
|
|
196
|
-
// Default: put cursor after inserted node
|
|
197
197
|
var after = usedPos + newInline.nodeSize;
|
|
198
198
|
tr.setSelection(selectionAfterPos(tr.doc, after));
|
|
199
199
|
}
|
|
@@ -319,8 +319,11 @@ var MathTemplatedNode = exports.MathTemplatedNode = _react2.Node.create({
|
|
|
319
319
|
}];
|
|
320
320
|
},
|
|
321
321
|
addNodeView: function addNodeView() {
|
|
322
|
-
|
|
323
|
-
|
|
322
|
+
var _this4 = this;
|
|
323
|
+
return (0, _react2.ReactNodeViewRenderer)(function (props) {
|
|
324
|
+
return /*#__PURE__*/_react["default"].createElement(_MathTemplated["default"], _objectSpread(_objectSpread({}, props), {}, {
|
|
325
|
+
options: _this4.options
|
|
326
|
+
}));
|
|
324
327
|
});
|
|
325
328
|
}
|
|
326
329
|
});
|
|
@@ -376,10 +379,10 @@ var DragInTheBlankNode = exports.DragInTheBlankNode = _react2.Node.create({
|
|
|
376
379
|
}];
|
|
377
380
|
},
|
|
378
381
|
addNodeView: function addNodeView() {
|
|
379
|
-
var
|
|
382
|
+
var _this5 = this;
|
|
380
383
|
return (0, _react2.ReactNodeViewRenderer)(function (props) {
|
|
381
384
|
return /*#__PURE__*/_react["default"].createElement(_DragInTheBlank["default"], _objectSpread(_objectSpread({}, props), {}, {
|
|
382
|
-
options:
|
|
385
|
+
options: _this5.options
|
|
383
386
|
}));
|
|
384
387
|
});
|
|
385
388
|
}
|
|
@@ -426,10 +429,10 @@ var InlineDropdownNode = exports.InlineDropdownNode = _react2.Node.create({
|
|
|
426
429
|
}];
|
|
427
430
|
},
|
|
428
431
|
addNodeView: function addNodeView() {
|
|
429
|
-
var
|
|
432
|
+
var _this6 = this;
|
|
430
433
|
return (0, _react2.ReactNodeViewRenderer)(function (props) {
|
|
431
434
|
return /*#__PURE__*/_react["default"].createElement(_InlineDropdown["default"], _objectSpread(_objectSpread({}, props), {}, {
|
|
432
|
-
options:
|
|
435
|
+
options: _this6.options
|
|
433
436
|
}));
|
|
434
437
|
});
|
|
435
438
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responseArea.js","names":["_react","_interopRequireDefault","require","_prosemirrorState","_core","_react2","_ExplicitConstructedResponse","_DragInTheBlank","_InlineDropdown","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","lastIndexMap","normalizeType","type","String","replace","getAttrIndex","node","attrs","index","collectNodesOfType","doc","typeName","results","descendants","pos","name","countNodesOfType","count","getDefaultNode","_ref","schema","nodeType","nodes","create","id","value","selectionAfterPos","$pos","resolve","Math","min","content","size","TextSelection","near","ResponseAreaExtension","exports","Extension","addOptions","maxResponseAreas","error","options","respAreaToolbar","onHandleAreaChange","addProseMirrorPlugins","_this","key","PluginKey","concat","Plugin","view","undefined","state","idx","n","parseInt","Number","isNaN","update","prevState","eq","currentList","oldList","toolbar","disabled","currentIndexSet","Set","map","x","removed","has","addCommands","_this2","insertResponseArea","_ref2","tr","dispatch","commands","currentCount","prevIndex","newIndex","newInline","selection","insertPos","from","tryInsertAt","insert","usedPos","includes","setSelection","NodeSelection","after","nodeSize","focus","refreshResponseArea","_ref3","$from","nodeAfter","nodePos","setNodeMarkup","updated","Date","now","ExplicitConstructedResponseNode","Node","group","inline","atom","addAttributes","parseHTML","tag","getAttrs","el","dataset","renderHTML","_ref4","HTMLAttributes","addNodeView","_this3","ReactNodeViewRenderer","props","createElement","MathTemplatedNode","_ref5","DragInTheBlankNode","inTable","_ref6","_this4","InlineDropdownNode","_ref7","_this5"],"sources":["../../src/extensions/responseArea.js"],"sourcesContent":["import React from 'react';\nimport { NodeSelection, Plugin, PluginKey, TextSelection } from 'prosemirror-state';\nimport { Extension } from '@tiptap/core';\nimport { Node, ReactNodeViewRenderer } from '@tiptap/react';\nimport ExplicitConstructedResponse from '../components/respArea/ExplicitConstructedResponse';\nimport DragInTheBlank from '../components/respArea/DragInTheBlank/DragInTheBlank';\nimport InlineDropdown from '../components/respArea/InlineDropdown';\n\nconst lastIndexMap = {};\n\nconst normalizeType = (type) => String(type || '').replace(/-/g, '_');\n\nconst getAttrIndex = (node) => (node && node.attrs && node.attrs.index != null ? String(node.attrs.index) : null);\n\nconst collectNodesOfType = (doc, typeName) => {\n const results = [];\n\n doc.descendants((node, pos) => {\n if (node.type && node.type.name === typeName) {\n const index = getAttrIndex(node);\n if (index != null) results.push({ index, pos, node });\n }\n return true;\n });\n\n return results;\n};\n\nconst countNodesOfType = (doc, typeName) => {\n let count = 0;\n doc.descendants((node) => {\n if (node.type && node.type.name === typeName) count += 1;\n return true;\n });\n return count;\n};\n\nconst getDefaultNode = ({ schema, typeName, index }) => {\n const nodeType = schema.nodes[typeName];\n if (!nodeType) return null;\n\n // mirror your Slate \"getDefaultElement(opts, newIndex)\"\n // customize attrs as needed:\n return nodeType.create({\n index: String(index),\n id: String(index),\n value: '',\n });\n};\n\n// Find a good cursor position *after* an inserted node.\nconst selectionAfterPos = (doc, pos) => {\n const $pos = doc.resolve(Math.min(pos, doc.content.size));\n return TextSelection.near($pos, 1);\n};\n\nexport const ResponseAreaExtension = Extension.create({\n name: 'responseArea',\n\n addOptions() {\n return {\n maxResponseAreas: null,\n error: null,\n options: null,\n respAreaToolbar: null,\n onHandleAreaChange: null,\n };\n },\n\n addProseMirrorPlugins() {\n if (!this.options.type) {\n return [];\n }\n\n const typeName = normalizeType(this.options.type);\n const key = new PluginKey(`response-area-watcher:${typeName}`);\n\n return [\n new Plugin({\n key,\n\n view: (view) => {\n // Lazy init lastIndexMap[typeName]\n if (lastIndexMap[typeName] === undefined) {\n lastIndexMap[typeName] = 0;\n\n view.state.doc.descendants((node) => {\n if (node.type && node.type.name === typeName) {\n const idx = getAttrIndex(node);\n if (idx != null) {\n const n = parseInt(idx, 10);\n if (!Number.isNaN(n) && n > lastIndexMap[typeName]) {\n lastIndexMap[typeName] = n;\n }\n }\n }\n return true;\n });\n }\n\n return {\n update: (view, prevState) => {\n const state = view.state;\n if (prevState.doc.eq(state.doc)) return;\n\n const currentList = collectNodesOfType(state.doc, typeName);\n const oldList = collectNodesOfType(prevState.doc, typeName);\n\n if (this.options.toolbar) {\n this.options.toolbar.disabled = currentList.length >= this.options.maxResponseAreas;\n }\n\n // Removed elements (same logic as Slate)\n if (oldList.length > currentList.length) {\n const currentIndexSet = new Set(currentList.map((x) => x.index));\n\n const removed = oldList.filter((x) => !currentIndexSet.has(x.index));\n\n if (removed.length && typeof this.options.onHandleAreaChange === 'function') {\n this.options.onHandleAreaChange(removed);\n }\n }\n },\n };\n },\n }),\n ];\n },\n\n addCommands() {\n return {\n insertResponseArea:\n (type) =>\n ({ tr, state, dispatch, commands }) => {\n const typeName = normalizeType(type);\n\n // --- Slate: currentRespAreaList + max check ---\n const currentCount = countNodesOfType(state.doc, typeName);\n if (currentCount >= this.options.maxResponseAreas) {\n return false;\n }\n\n // --- Slate: indexing logic (kept identical) ---\n if (lastIndexMap[typeName] === undefined) lastIndexMap[typeName] = 0;\n\n const prevIndex = lastIndexMap[typeName];\n const newIndex = prevIndex === 0 ? prevIndex : prevIndex + 1;\n\n // Slate increments map even if newIndex === 0\n lastIndexMap[typeName] += 1;\n\n const newInline = getDefaultNode({\n schema: state.schema,\n typeName,\n index: newIndex,\n });\n\n if (!newInline) return false;\n\n // --- Insert logic ---\n const { selection } = state;\n let insertPos = selection.from;\n\n // If we're in a NodeSelection, insert before/after is ambiguous;\n // We'll insert at its \"from\" (like your current code).\n // If insertion fails, we fallback to end of doc.\n const tryInsertAt = (pos) => {\n try {\n tr.insert(pos, newInline);\n return pos;\n } catch (e) {\n return null;\n }\n };\n\n let usedPos = tryInsertAt(insertPos);\n\n // Slate branch: \"markup empty and there's no focus\"\n // ProseMirror doesn't expose \"no focus\" the same way, so the closest\n // equivalent fallback is inserting at end of document.\n if (usedPos == null) {\n usedPos = tryInsertAt(tr.doc.content.size);\n }\n if (usedPos == null) return false;\n\n // Optionally select the node you just inserted (like your original command)\n // tr.setSelection(NodeSelection.create(tr.doc, usedPos))\n\n // --- Cursor move behavior for certain types (Slate: moveFocusTo next text) ---\n if (\n ['math_templated', 'inline_dropdown', 'drag_in_the_blank', 'explicit_constructed_response'].includes(\n typeName,\n )\n ) {\n tr.setSelection(NodeSelection.create(tr.doc, usedPos));\n } else {\n // Default: put cursor after inserted node\n const after = usedPos + newInline.nodeSize;\n tr.setSelection(selectionAfterPos(tr.doc, after));\n }\n\n if (dispatch) {\n commands.focus();\n dispatch(tr);\n }\n\n return true;\n },\n refreshResponseArea:\n () =>\n ({ tr, state, commands, dispatch }) => {\n const { selection } = state;\n const node = selection.$from.nodeAfter;\n const nodePos = selection.from;\n\n tr.setNodeMarkup(nodePos, undefined, { ...node.attrs, updated: `${Date.now()}` });\n tr.setSelection(NodeSelection.create(tr.doc, nodePos));\n\n if (dispatch) {\n commands.focus();\n dispatch(tr);\n }\n\n return true;\n },\n };\n },\n});\n\n/**\n * ExplicitConstructedResponse Node\n */\nexport const ExplicitConstructedResponseNode = Node.create({\n name: 'explicit_constructed_response',\n group: 'inline',\n inline: true,\n atom: true,\n addAttributes() {\n return {\n index: { default: null },\n value: { default: '' },\n updated: { default: '' },\n };\n },\n parseHTML() {\n return [\n {\n tag: 'span[data-type=\"explicit_constructed_response\"]',\n getAttrs: (el) => ({\n index: el.dataset.index,\n value: el.dataset.value,\n }),\n },\n ];\n },\n renderHTML({ HTMLAttributes }) {\n return [\n 'span',\n {\n 'data-type': 'explicit_constructed_response',\n 'data-index': HTMLAttributes.index,\n 'data-value': HTMLAttributes.value,\n },\n ];\n },\n addNodeView() {\n return ReactNodeViewRenderer((props) => <ExplicitConstructedResponse {...{ ...props, options: this.options }} />);\n },\n});\n\n/**\n * MathTemplated Node\n */\nexport const MathTemplatedNode = Node.create({\n name: 'math_templated',\n group: 'inline',\n inline: true,\n atom: true,\n addAttributes() {\n return {\n index: { default: null },\n value: { default: '' },\n updated: { default: '' },\n };\n },\n parseHTML() {\n return [\n {\n tag: 'span[data-type=\"math_templated\"]',\n getAttrs: (el) => ({\n index: el.dataset.index,\n value: el.dataset.value,\n }),\n },\n ];\n },\n renderHTML({ HTMLAttributes }) {\n return [\n 'span',\n {\n 'data-type': 'math_templated',\n 'data-index': HTMLAttributes.index,\n 'data-value': HTMLAttributes.value,\n },\n ];\n },\n addNodeView() {\n return ReactNodeViewRenderer(() => <div></div>);\n },\n});\n\n/**\n * DragInTheBlank Node\n */\nexport const DragInTheBlankNode = Node.create({\n name: 'drag_in_the_blank',\n group: 'inline',\n inline: true,\n atom: true,\n addAttributes() {\n return {\n index: { default: null },\n id: { default: null },\n value: { default: '' },\n inTable: { default: null },\n updated: { default: '' },\n };\n },\n parseHTML() {\n return [\n {\n tag: 'span[data-type=\"drag_in_the_blank\"]',\n getAttrs: (el) => ({\n index: el.dataset.index,\n id: el.dataset.id,\n value: el.dataset.value,\n inTable: el.dataset.inTable,\n }),\n },\n ];\n },\n renderHTML({ HTMLAttributes }) {\n return [\n 'span',\n {\n 'data-type': 'drag_in_the_blank',\n 'data-index': HTMLAttributes.index,\n 'data-id': HTMLAttributes.id,\n 'data-value': HTMLAttributes.value,\n 'data-in-table': HTMLAttributes.inTable,\n },\n ];\n },\n addNodeView() {\n return ReactNodeViewRenderer((props) => <DragInTheBlank {...{ ...props, options: this.options }} />);\n },\n});\n\n/**\n * InlineDropdown Node\n */\nexport const InlineDropdownNode = Node.create({\n name: 'inline_dropdown',\n group: 'inline',\n inline: true,\n atom: true,\n addAttributes() {\n return {\n index: { default: null },\n value: { default: '' },\n updated: { default: '' },\n };\n },\n parseHTML() {\n return [\n {\n tag: 'span[data-type=\"inline_dropdown\"]',\n getAttrs: (el) => ({\n index: el.dataset.index,\n value: el.dataset.value,\n }),\n },\n ];\n },\n renderHTML({ HTMLAttributes }) {\n return [\n 'span',\n {\n 'data-type': 'inline_dropdown',\n 'data-index': HTMLAttributes.index,\n 'data-value': HTMLAttributes.value,\n },\n ];\n },\n addNodeView() {\n return ReactNodeViewRenderer((props) => <InlineDropdown {...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yF,UAAU,WAAVA,UAAUA,CAAAe,KAAA,EAAqB;IAAA,IAAlBb,cAAc,GAAAa,KAAA,CAAdb,cAAc;IACzB,OAAO,CACL,MAAM,EACN;MACE,WAAW,EAAE,iBAAiB;MAC9B,YAAY,EAAEA,cAAc,CAAC5G,KAAK;MAClC,YAAY,EAAE4G,cAAc,CAAC3F;IAC/B,CAAC,CACF;EACH,CAAC;EACD4F,WAAW,WAAXA,WAAWA,CAAA,EAAG;IAAA,IAAAa,MAAA;IACZ,OAAO,IAAAX,6BAAqB,EAAC,UAACC,KAAK;MAAA,oBAAKtJ,MAAA,YAAAuJ,aAAA,CAAC/I,eAAA,WAAc,EAAAc,aAAA,CAAAA,aAAA,KAAUgI,KAAK;QAAE/E,OAAO,EAAEyF,MAAI,CAACzF;MAAO,EAAK,CAAC;IAAA,EAAC;EACtG;AACF,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"responseArea.js","names":["_react","_interopRequireDefault","require","_prosemirrorState","_core","_react2","_ExplicitConstructedResponse","_DragInTheBlank","_InlineDropdown","_MathTemplated","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","lastIndexMap","normalizeType","type","String","replace","getAttrIndex","node","attrs","index","collectNodesOfType","doc","typeName","results","descendants","pos","name","countNodesOfType","count","getDefaultNode","_ref","schema","nodeType","nodes","create","id","value","selectionAfterPos","$pos","resolve","Math","min","content","size","TextSelection","near","ResponseAreaExtension","exports","Extension","addOptions","maxResponseAreas","error","options","respAreaToolbar","onHandleAreaChange","addProseMirrorPlugins","_this","key","PluginKey","concat","Plugin","view","undefined","state","idx","n","parseInt","Number","isNaN","update","prevState","eq","currentList","oldList","toolbar","disabled","currentIndexSet","Set","map","x","removed","has","addCommands","_this2","insertResponseArea","_ref2","tr","dispatch","commands","currentCount","prevIndex","newIndex","newInline","selection","insertPos","from","tryInsertAt","insert","usedPos","includes","setSelection","NodeSelection","after","nodeSize","focus","refreshResponseArea","_ref3","$from","nodeAfter","nodePos","setNodeMarkup","updated","Date","now","ExplicitConstructedResponseNode","Node","group","inline","atom","addAttributes","parseHTML","tag","getAttrs","el","dataset","renderHTML","_ref4","HTMLAttributes","addNodeView","_this3","ReactNodeViewRenderer","props","createElement","MathTemplatedNode","_ref5","_this4","DragInTheBlankNode","inTable","_ref6","_this5","InlineDropdownNode","_ref7","_this6"],"sources":["../../src/extensions/responseArea.js"],"sourcesContent":["import React from 'react';\nimport { NodeSelection, Plugin, PluginKey, TextSelection } from 'prosemirror-state';\nimport { Extension } from '@tiptap/core';\nimport { Node, ReactNodeViewRenderer } from '@tiptap/react';\nimport ExplicitConstructedResponse from '../components/respArea/ExplicitConstructedResponse';\nimport DragInTheBlank from '../components/respArea/DragInTheBlank/DragInTheBlank';\nimport InlineDropdown from '../components/respArea/InlineDropdown';\nimport MathTemplated from '../components/respArea/MathTemplated';\n\nconst lastIndexMap = {};\n\nconst normalizeType = (type) => String(type || '').replace(/-/g, '_');\n\nconst getAttrIndex = (node) => (node && node.attrs && node.attrs.index != null ? String(node.attrs.index) : null);\n\nconst collectNodesOfType = (doc, typeName) => {\n const results = [];\n\n doc.descendants((node, pos) => {\n if (node.type && node.type.name === typeName) {\n const index = getAttrIndex(node);\n if (index != null) results.push({ index, pos, node });\n }\n return true;\n });\n\n return results;\n};\n\nconst countNodesOfType = (doc, typeName) => {\n let count = 0;\n doc.descendants((node) => {\n if (node.type && node.type.name === typeName) count += 1;\n return true;\n });\n return count;\n};\n\nconst getDefaultNode = ({ schema, typeName, index }) => {\n const nodeType = schema.nodes[typeName];\n if (!nodeType) return null;\n\n // mirror your Slate \"getDefaultElement(opts, newIndex)\"\n // customize attrs as needed:\n return nodeType.create({\n index: String(index),\n id: String(index),\n value: '',\n });\n};\n\n// Find a good cursor position *after* an inserted node.\nconst selectionAfterPos = (doc, pos) => {\n const $pos = doc.resolve(Math.min(pos, doc.content.size));\n return TextSelection.near($pos, 1);\n};\n\nexport const ResponseAreaExtension = Extension.create({\n name: 'responseArea',\n\n addOptions() {\n return {\n maxResponseAreas: null,\n error: null,\n options: null,\n respAreaToolbar: null,\n onHandleAreaChange: null,\n };\n },\n\n addProseMirrorPlugins() {\n if (!this.options.type) {\n return [];\n }\n\n const typeName = normalizeType(this.options.type);\n const key = new PluginKey(`response-area-watcher:${typeName}`);\n\n return [\n new Plugin({\n key,\n\n view: (view) => {\n // Lazy init lastIndexMap[typeName]\n if (lastIndexMap[typeName] === undefined) {\n lastIndexMap[typeName] = 0;\n\n view.state.doc.descendants((node) => {\n if (node.type && node.type.name === typeName) {\n const idx = getAttrIndex(node);\n if (idx != null) {\n const n = parseInt(idx, 10);\n if (!Number.isNaN(n) && n > lastIndexMap[typeName]) {\n lastIndexMap[typeName] = n;\n }\n }\n }\n return true;\n });\n }\n\n return {\n update: (view, prevState) => {\n const state = view.state;\n if (prevState.doc.eq(state.doc)) return;\n\n const currentList = collectNodesOfType(state.doc, typeName);\n const oldList = collectNodesOfType(prevState.doc, typeName);\n\n if (this.options.toolbar) {\n this.options.toolbar.disabled = currentList.length >= this.options.maxResponseAreas;\n }\n\n // Removed elements (same logic as Slate)\n if (oldList.length > currentList.length) {\n const currentIndexSet = new Set(currentList.map((x) => x.index));\n\n const removed = oldList.filter((x) => !currentIndexSet.has(x.index));\n\n if (removed.length && typeof this.options.onHandleAreaChange === 'function') {\n this.options.onHandleAreaChange(removed);\n }\n }\n },\n };\n },\n }),\n ];\n },\n\n addCommands() {\n return {\n insertResponseArea:\n (type) =>\n ({ tr, state, dispatch, commands }) => {\n const typeName = normalizeType(type);\n\n // --- Slate: currentRespAreaList + max check ---\n const currentCount = countNodesOfType(state.doc, typeName);\n if (currentCount >= this.options.maxResponseAreas) {\n return false;\n }\n\n // --- Slate: indexing logic (kept identical) ---\n if (lastIndexMap[typeName] === undefined) lastIndexMap[typeName] = 0;\n\n const prevIndex = lastIndexMap[typeName];\n const newIndex = prevIndex === 0 ? prevIndex : prevIndex + 1;\n\n // Slate increments map even if newIndex === 0\n lastIndexMap[typeName] += 1;\n\n const newInline = getDefaultNode({\n schema: state.schema,\n typeName,\n index: newIndex,\n });\n\n if (!newInline) return false;\n\n // --- Insert logic ---\n const { selection } = state;\n let insertPos = selection.from;\n\n // If we're in a NodeSelection, insert before/after is ambiguous;\n // We'll insert at its \"from\" (like your current code).\n // If insertion fails, we fallback to end of doc.\n const tryInsertAt = (pos) => {\n try {\n tr.insert(pos, newInline);\n return pos;\n } catch (e) {\n return null;\n }\n };\n\n let usedPos = tryInsertAt(insertPos);\n\n // Slate branch: \"markup empty and there's no focus\"\n // ProseMirror doesn't expose \"no focus\" the same way, so the closest\n // equivalent fallback is inserting at end of document.\n if (usedPos == null) {\n usedPos = tryInsertAt(tr.doc.content.size);\n }\n if (usedPos == null) return false;\n\n // Optionally select the node you just inserted (like your original command)\n // tr.setSelection(NodeSelection.create(tr.doc, usedPos))\n\n // --- Cursor move behavior for certain types (Slate: moveFocusTo next text) ---\n if (['math_templated', 'inline_dropdown', 'explicit_constructed_response'].includes(typeName)) {\n tr.setSelection(NodeSelection.create(tr.doc, usedPos));\n } else {\n const after = usedPos + newInline.nodeSize;\n tr.setSelection(selectionAfterPos(tr.doc, after));\n }\n\n if (dispatch) {\n commands.focus();\n dispatch(tr);\n }\n\n return true;\n },\n refreshResponseArea:\n () =>\n ({ tr, state, commands, dispatch }) => {\n const { selection } = state;\n const node = selection.$from.nodeAfter;\n const nodePos = selection.from;\n\n tr.setNodeMarkup(nodePos, undefined, { ...node.attrs, updated: `${Date.now()}` });\n tr.setSelection(NodeSelection.create(tr.doc, nodePos));\n\n if (dispatch) {\n commands.focus();\n dispatch(tr);\n }\n\n return true;\n },\n };\n },\n});\n\n/**\n * ExplicitConstructedResponse Node\n */\nexport const ExplicitConstructedResponseNode = Node.create({\n name: 'explicit_constructed_response',\n group: 'inline',\n inline: true,\n atom: true,\n addAttributes() {\n return {\n index: { default: null },\n value: { default: '' },\n updated: { default: '' },\n };\n },\n parseHTML() {\n return [\n {\n tag: 'span[data-type=\"explicit_constructed_response\"]',\n getAttrs: (el) => ({\n index: el.dataset.index,\n value: el.dataset.value,\n }),\n },\n ];\n },\n renderHTML({ HTMLAttributes }) {\n return [\n 'span',\n {\n 'data-type': 'explicit_constructed_response',\n 'data-index': HTMLAttributes.index,\n 'data-value': HTMLAttributes.value,\n },\n ];\n },\n addNodeView() {\n return ReactNodeViewRenderer((props) => <ExplicitConstructedResponse {...{ ...props, options: this.options }} />);\n },\n});\n\n/**\n * MathTemplated Node\n */\nexport const MathTemplatedNode = Node.create({\n name: 'math_templated',\n group: 'inline',\n inline: true,\n atom: true,\n addAttributes() {\n return {\n index: { default: null },\n value: { default: '' },\n updated: { default: '' },\n };\n },\n parseHTML() {\n return [\n {\n tag: 'span[data-type=\"math_templated\"]',\n getAttrs: (el) => ({\n index: el.dataset.index,\n value: el.dataset.value,\n }),\n },\n ];\n },\n renderHTML({ HTMLAttributes }) {\n return [\n 'span',\n {\n 'data-type': 'math_templated',\n 'data-index': HTMLAttributes.index,\n 'data-value': HTMLAttributes.value,\n },\n ];\n },\n addNodeView() {\n return ReactNodeViewRenderer((props) => <MathTemplated {...{ ...props, options: this.options }} />);\n },\n});\n\n/**\n * DragInTheBlank Node\n */\nexport const DragInTheBlankNode = Node.create({\n name: 'drag_in_the_blank',\n group: 'inline',\n inline: true,\n atom: true,\n addAttributes() {\n return {\n index: { default: null },\n id: { default: null },\n value: { default: '' },\n inTable: { default: null },\n updated: { default: '' },\n };\n },\n parseHTML() {\n return [\n {\n tag: 'span[data-type=\"drag_in_the_blank\"]',\n getAttrs: (el) => ({\n index: el.dataset.index,\n id: el.dataset.id,\n value: el.dataset.value,\n inTable: el.dataset.inTable,\n }),\n },\n ];\n },\n renderHTML({ HTMLAttributes }) {\n return [\n 'span',\n {\n 'data-type': 'drag_in_the_blank',\n 'data-index': HTMLAttributes.index,\n 'data-id': HTMLAttributes.id,\n 'data-value': HTMLAttributes.value,\n 'data-in-table': HTMLAttributes.inTable,\n },\n ];\n },\n addNodeView() {\n return ReactNodeViewRenderer((props) => <DragInTheBlank {...{ ...props, options: this.options }} />);\n },\n});\n\n/**\n * InlineDropdown Node\n */\nexport const InlineDropdownNode = Node.create({\n name: 'inline_dropdown',\n group: 'inline',\n inline: true,\n atom: true,\n addAttributes() {\n return {\n index: { default: null },\n value: { default: '' },\n updated: { default: '' },\n };\n },\n parseHTML() {\n return [\n {\n tag: 'span[data-type=\"inline_dropdown\"]',\n getAttrs: (el) => ({\n index: el.dataset.index,\n value: el.dataset.value,\n }),\n },\n ];\n },\n renderHTML({ HTMLAttributes }) {\n return [\n 'span',\n {\n 'data-type': 'inline_dropdown',\n 'data-index': HTMLAttributes.index,\n 'data-value': HTMLAttributes.value,\n },\n ];\n },\n addNodeView() {\n return ReactNodeViewRenderer((props) => <InlineDropdown {...{ ...props, options: this.options }} />);\n },\n});\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,4BAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,eAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,eAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,cAAA,GAAAR,sBAAA,CAAAC,OAAA;AAAiE,SAAAQ,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,CAA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E0F,MAAI,CAAC1F;MAAO,EAAK,CAAC;IAAA,EAAC;EACtG;AACF,CAAC,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/editable-html-tip-tap",
|
|
3
|
-
"
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "1.2.0-next.12",
|
|
4
7
|
"description": "",
|
|
5
8
|
"license": "ISC",
|
|
6
9
|
"main": "lib/index.js",
|
|
7
10
|
"module": "src/index.jsx",
|
|
8
11
|
"author": "pie-framework developers",
|
|
9
|
-
"repository":
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "https://github.com/pie-framework/pie-lib"
|
|
12
|
-
},
|
|
12
|
+
"repository": "pie-framework/pie-lib",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@dnd-kit/core": "6.3.1",
|
|
15
15
|
"@dnd-kit/modifiers": "9.0.0",
|
|
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.
|
|
20
|
-
"@pie-lib/math-input": "^7.2.0-next.
|
|
21
|
-
"@pie-lib/math-rendering": "^4.2.0-next.
|
|
22
|
-
"@pie-lib/math-toolbar": "^2.2.0-next.
|
|
23
|
-
"@pie-lib/render-ui": "^5.2.0-next.
|
|
19
|
+
"@pie-lib/drag": "^3.2.0-next.4",
|
|
20
|
+
"@pie-lib/math-input": "^7.2.0-next.5",
|
|
21
|
+
"@pie-lib/math-rendering": "^4.2.0-next.3",
|
|
22
|
+
"@pie-lib/math-toolbar": "^2.2.0-next.6",
|
|
23
|
+
"@pie-lib/render-ui": "^5.2.0-next.4",
|
|
24
24
|
"@tiptap/core": "3.0.9",
|
|
25
25
|
"@tiptap/extension-character-count": "3.0.9",
|
|
26
26
|
"@tiptap/extension-color": "3.0.9",
|
|
27
27
|
"@tiptap/extension-image": "3.0.9",
|
|
28
28
|
"@tiptap/extension-list-item": "3.0.9",
|
|
29
|
+
"@tiptap/extension-placeholder": "3.20.0",
|
|
29
30
|
"@tiptap/extension-subscript": "3.0.9",
|
|
30
31
|
"@tiptap/extension-superscript": "3.0.9",
|
|
31
32
|
"@tiptap/extension-table": "3.0.9",
|
|
@@ -58,9 +59,6 @@
|
|
|
58
59
|
"peerDependencies": {
|
|
59
60
|
"react": "^18.2.0"
|
|
60
61
|
},
|
|
61
|
-
"
|
|
62
|
-
"access": "public"
|
|
63
|
-
},
|
|
64
|
-
"gitHead": "c7578cae82de46ec0dae41b7d1ef924401e6226d",
|
|
62
|
+
"gitHead": "09270ba99e0887119a5ecb5b6670c965a1573347",
|
|
65
63
|
"scripts": {}
|
|
66
64
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import
|
|
4
|
+
import get from 'lodash-es/get';
|
|
5
5
|
|
|
6
6
|
import { PureToolbar } from '@pie-lib/math-toolbar';
|
|
7
7
|
|
|
@@ -7,7 +7,9 @@ import SuperScript from '@tiptap/extension-superscript';
|
|
|
7
7
|
import SubScript from '@tiptap/extension-subscript';
|
|
8
8
|
import TextAlign from '@tiptap/extension-text-align';
|
|
9
9
|
import Image from '@tiptap/extension-image';
|
|
10
|
+
import Placeholder from '@tiptap/extension-placeholder';
|
|
10
11
|
import { styled } from '@mui/material/styles';
|
|
12
|
+
import debounce from 'lodash-es/debounce';
|
|
11
13
|
|
|
12
14
|
import ExtendedTable from '../extensions/extended-table';
|
|
13
15
|
import { TableRow } from '@tiptap/extension-table-row';
|
|
@@ -17,6 +19,7 @@ import {
|
|
|
17
19
|
DragInTheBlankNode,
|
|
18
20
|
ExplicitConstructedResponseNode,
|
|
19
21
|
InlineDropdownNode,
|
|
22
|
+
MathTemplatedNode,
|
|
20
23
|
ResponseAreaExtension,
|
|
21
24
|
} from '../extensions/responseArea';
|
|
22
25
|
import { MathNode } from '../extensions/math';
|
|
@@ -137,6 +140,13 @@ export const EditableHtml = (props) => {
|
|
|
137
140
|
limit: props.charactersLimit || 1000000,
|
|
138
141
|
}),
|
|
139
142
|
StarterKit,
|
|
143
|
+
Placeholder.configure({
|
|
144
|
+
placeholder: props.placeholder,
|
|
145
|
+
// show placeholder even when editor is focused
|
|
146
|
+
showOnlyWhenEditable: true,
|
|
147
|
+
showOnlyCurrent: false, // show on all empty nodes, not only the current one
|
|
148
|
+
includeChildren: true,
|
|
149
|
+
}),
|
|
140
150
|
ExtendedTable,
|
|
141
151
|
TableRow,
|
|
142
152
|
TableHeader,
|
|
@@ -145,6 +155,7 @@ export const EditableHtml = (props) => {
|
|
|
145
155
|
ExplicitConstructedResponseNode.configure(props.responseAreaProps),
|
|
146
156
|
DragInTheBlankNode.configure(props.responseAreaProps),
|
|
147
157
|
InlineDropdownNode.configure(props.responseAreaProps),
|
|
158
|
+
MathTemplatedNode.configure(props.responseAreaProps),
|
|
148
159
|
MathNode.configure({
|
|
149
160
|
toolbarOpts: toolbarOptsToUse,
|
|
150
161
|
}),
|
|
@@ -247,11 +258,13 @@ export const EditableHtml = (props) => {
|
|
|
247
258
|
props.onChange?.(editor.getHTML());
|
|
248
259
|
}
|
|
249
260
|
},
|
|
250
|
-
onBlur: ({ editor }) => {
|
|
251
|
-
const
|
|
252
|
-
editor.
|
|
261
|
+
onBlur: debounce(({ editor }) => {
|
|
262
|
+
const otherToolbarOpened =
|
|
263
|
+
editor._toolbarOpened ||
|
|
264
|
+
editor.isActive('inline_dropdown') ||
|
|
265
|
+
editor.isActive('explicit_constructed_response');
|
|
253
266
|
|
|
254
|
-
if (
|
|
267
|
+
if (otherToolbarOpened) {
|
|
255
268
|
return;
|
|
256
269
|
}
|
|
257
270
|
|
|
@@ -262,7 +275,7 @@ export const EditableHtml = (props) => {
|
|
|
262
275
|
if (toolbarOptsToUse.doneOn === 'blur') {
|
|
263
276
|
props.onDone?.(editor.getHTML());
|
|
264
277
|
}
|
|
265
|
-
},
|
|
278
|
+
}, 200),
|
|
266
279
|
},
|
|
267
280
|
[props.charactersLimit],
|
|
268
281
|
);
|
|
@@ -345,6 +358,16 @@ const StyledEditorContent = styled(EditorContent, {
|
|
|
345
358
|
'& > p': {
|
|
346
359
|
margin: '0',
|
|
347
360
|
},
|
|
361
|
+
|
|
362
|
+
'& p.is-editor-empty:first-child::before': {
|
|
363
|
+
content: 'attr(data-placeholder)',
|
|
364
|
+
float: 'left',
|
|
365
|
+
height: 0,
|
|
366
|
+
color: '#9CA3AF',
|
|
367
|
+
pointerEvents: 'none',
|
|
368
|
+
whiteSpace: 'pre-wrap',
|
|
369
|
+
},
|
|
370
|
+
|
|
348
371
|
...(showParagraph && {
|
|
349
372
|
'& > p:has(+ p)::after': {
|
|
350
373
|
display: 'block',
|
|
@@ -18,6 +18,7 @@ import Undo from '@mui/icons-material/Undo';
|
|
|
18
18
|
import TheatersIcon from '@mui/icons-material/Theaters';
|
|
19
19
|
import VolumeUpIcon from '@mui/icons-material/VolumeUp';
|
|
20
20
|
import BorderAll from '@mui/icons-material/BorderAll';
|
|
21
|
+
import Delete from '@mui/icons-material/Delete';
|
|
21
22
|
|
|
22
23
|
import { useEditorState } from '@tiptap/react';
|
|
23
24
|
|
|
@@ -65,7 +66,15 @@ const HeadingIcon = () => (
|
|
|
65
66
|
</svg>
|
|
66
67
|
);
|
|
67
68
|
|
|
68
|
-
function MenuBar({
|
|
69
|
+
function MenuBar({
|
|
70
|
+
editor,
|
|
71
|
+
classes,
|
|
72
|
+
activePlugins,
|
|
73
|
+
toolbarOpts: toolOpts,
|
|
74
|
+
responseAreaProps,
|
|
75
|
+
onChange,
|
|
76
|
+
autoWidthToolbar,
|
|
77
|
+
}) {
|
|
69
78
|
const [showPicker, setShowPicker] = useState(false);
|
|
70
79
|
const toolbarOpts = toolOpts ?? {};
|
|
71
80
|
|
|
@@ -83,7 +92,8 @@ function MenuBar({ editor, classes, activePlugins, toolbarOpts: toolOpts, respon
|
|
|
83
92
|
const hideDefaultToolbar =
|
|
84
93
|
ctx.editor?.isActive('math') ||
|
|
85
94
|
ctx.editor?.isActive('explicit_constructed_response') ||
|
|
86
|
-
ctx.editor?.isActive('imageUploadNode')
|
|
95
|
+
ctx.editor?.isActive('imageUploadNode') ||
|
|
96
|
+
ctx.editor?.isActive('drag_in_the_blank');
|
|
87
97
|
|
|
88
98
|
return {
|
|
89
99
|
currentNode,
|
|
@@ -122,7 +132,7 @@ function MenuBar({ editor, classes, activePlugins, toolbarOpts: toolOpts, respon
|
|
|
122
132
|
});
|
|
123
133
|
|
|
124
134
|
const hasDoneButton = false;
|
|
125
|
-
const autoWidth =
|
|
135
|
+
const autoWidth = !!autoWidthToolbar;
|
|
126
136
|
|
|
127
137
|
const names = classNames(classes.toolbar, PIE_TOOLBAR__CLASS, {
|
|
128
138
|
[classes.toolbarWithNoDone]: !hasDoneButton,
|
|
@@ -248,7 +258,7 @@ function MenuBar({ editor, classes, activePlugins, toolbarOpts: toolOpts, respon
|
|
|
248
258
|
},
|
|
249
259
|
{
|
|
250
260
|
icon: <ImageIcon />,
|
|
251
|
-
hidden: (
|
|
261
|
+
hidden: () => !activePlugins?.includes('image'),
|
|
252
262
|
onClick: (editor) => editor.chain().focus().setImageUploadNode().run(),
|
|
253
263
|
},
|
|
254
264
|
{
|
|
@@ -279,12 +289,12 @@ function MenuBar({ editor, classes, activePlugins, toolbarOpts: toolOpts, respon
|
|
|
279
289
|
},
|
|
280
290
|
{
|
|
281
291
|
icon: <CharacterIcon letter="ñ" />,
|
|
282
|
-
hidden: (
|
|
292
|
+
hidden: () => !activePlugins?.includes('languageCharacters'),
|
|
283
293
|
onClick: () => setShowPicker(spanishConfig),
|
|
284
294
|
},
|
|
285
295
|
{
|
|
286
296
|
icon: <CharacterIcon letter="€" />,
|
|
287
|
-
hidden: (
|
|
297
|
+
hidden: () => activePlugins?.filter((p) => p === 'languageCharacters').length !== 2,
|
|
288
298
|
onClick: () => setShowPicker(specialConfig),
|
|
289
299
|
},
|
|
290
300
|
{
|
|
@@ -320,8 +330,29 @@ function MenuBar({ editor, classes, activePlugins, toolbarOpts: toolOpts, respon
|
|
|
320
330
|
[activePlugins, editor],
|
|
321
331
|
);
|
|
322
332
|
|
|
333
|
+
const isDragInTheBlankSelected =
|
|
334
|
+
editorState.hideDefaultToolbar && editorState.currentNode?.type?.name === 'drag_in_the_blank';
|
|
335
|
+
|
|
323
336
|
return (
|
|
324
337
|
<div className={names} style={{ ...customStyles }} onMouseDown={handleMouseDown}>
|
|
338
|
+
{isDragInTheBlankSelected && (
|
|
339
|
+
<div className={classes.defaultToolbar} tabIndex="1">
|
|
340
|
+
<div className={classes.buttonsContainer}>
|
|
341
|
+
<button
|
|
342
|
+
type="button"
|
|
343
|
+
className={classes.button}
|
|
344
|
+
onClick={(e) => {
|
|
345
|
+
e.preventDefault();
|
|
346
|
+
editor.chain().focus().deleteSelection().run();
|
|
347
|
+
onChange?.(editor.getHTML());
|
|
348
|
+
}}
|
|
349
|
+
aria-label="Delete response area"
|
|
350
|
+
>
|
|
351
|
+
<Delete />
|
|
352
|
+
</button>
|
|
353
|
+
</div>
|
|
354
|
+
</div>
|
|
355
|
+
)}
|
|
325
356
|
{!editorState.hideDefaultToolbar && (
|
|
326
357
|
<div className={classes.defaultToolbar} tabIndex="1">
|
|
327
358
|
<div className={classes.buttonsContainer}>
|
|
@@ -108,13 +108,13 @@ const StyledRoot = styled('div', {
|
|
|
108
108
|
}));
|
|
109
109
|
|
|
110
110
|
const StyledEditorHolder = styled('div', {
|
|
111
|
-
shouldForwardProp: (prop) =>
|
|
112
|
-
})(({ disableScrollbar }) => ({
|
|
111
|
+
shouldForwardProp: (prop) => !['disableScrollbar', 'highlightShape'].includes(prop),
|
|
112
|
+
})(({ theme, disableScrollbar, highlightShape }) => ({
|
|
113
113
|
position: 'relative',
|
|
114
114
|
padding: '0px',
|
|
115
115
|
overflowY: 'auto',
|
|
116
116
|
color: color.text(),
|
|
117
|
-
backgroundColor: color.background(),
|
|
117
|
+
backgroundColor: highlightShape ? theme.palette.action.selected : color.background(),
|
|
118
118
|
...(disableScrollbar && {
|
|
119
119
|
'&::-webkit-scrollbar': {
|
|
120
120
|
display: 'none',
|
|
@@ -148,6 +148,7 @@ function TiptapContainer(props) {
|
|
|
148
148
|
minHeight,
|
|
149
149
|
height,
|
|
150
150
|
maxHeight,
|
|
151
|
+
highlightShape,
|
|
151
152
|
ref,
|
|
152
153
|
} = props;
|
|
153
154
|
|
|
@@ -195,7 +196,7 @@ function TiptapContainer(props) {
|
|
|
195
196
|
style={{ width: sizeStyle.width, minWidth: sizeStyle.minWidth, maxWidth: sizeStyle.maxWidth }}
|
|
196
197
|
ref={rootRef}
|
|
197
198
|
>
|
|
198
|
-
<StyledEditorHolder disableScrollbar={disableScrollbar}>
|
|
199
|
+
<StyledEditorHolder disableScrollbar={disableScrollbar} highlightShape={highlightShape}>
|
|
199
200
|
<StyledChildren noPadding={toolbarOpts && toolbarOpts.noPadding}>{children}</StyledChildren>
|
|
200
201
|
</StyledEditorHolder>
|
|
201
202
|
|
|
@@ -206,6 +207,7 @@ function TiptapContainer(props) {
|
|
|
206
207
|
toolbarOpts={toolbarOpts}
|
|
207
208
|
activePlugins={activePlugins}
|
|
208
209
|
onChange={props.onChange}
|
|
210
|
+
autoWidthToolbar={props.autoWidthToolbar}
|
|
209
211
|
/>
|
|
210
212
|
)}
|
|
211
213
|
</StyledRoot>
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { NodeViewWrapper } from '@tiptap/react';
|
|
4
4
|
import DragDropTile from './choice';
|
|
5
|
-
import
|
|
5
|
+
import omit from 'lodash-es/omit';
|
|
6
6
|
|
|
7
7
|
export const onValueChange = (editor, node, pos, choice) => {
|
|
8
8
|
const { tr } = editor.state;
|
|
@@ -33,7 +33,11 @@ const DragDrop = (props) => {
|
|
|
33
33
|
|
|
34
34
|
// console.log({nodeProps.children})
|
|
35
35
|
return (
|
|
36
|
-
<NodeViewWrapper
|
|
36
|
+
<NodeViewWrapper
|
|
37
|
+
className="drag-in-the-blank"
|
|
38
|
+
data-selected={selected}
|
|
39
|
+
style={{ display: 'inline', whiteSpace: 'normal' }}
|
|
40
|
+
>
|
|
37
41
|
<span
|
|
38
42
|
{...attributes}
|
|
39
43
|
style={{
|
|
@@ -52,6 +56,7 @@ const DragDrop = (props) => {
|
|
|
52
56
|
pos={pos}
|
|
53
57
|
value={attributes}
|
|
54
58
|
duplicates={options.duplicates}
|
|
59
|
+
selected={selected}
|
|
55
60
|
onChange={(choice) => onValueChange(editor, node, pos, choice)}
|
|
56
61
|
removeResponse={(choice) => onRemoveResponse(editor, node, choice)}
|
|
57
62
|
></DragDropTile>
|
|
@@ -15,7 +15,7 @@ const StyledContent = styled('span')(({ theme }) => ({
|
|
|
15
15
|
},
|
|
16
16
|
}));
|
|
17
17
|
|
|
18
|
-
export function BlankContent({ n, children, isDragging, isOver, dragItem, value }) {
|
|
18
|
+
export function BlankContent({ n, children, isDragging, isOver, dragItem, value, selected }) {
|
|
19
19
|
const [hoveredElementSize, setHoveredElementSize] = useState(null);
|
|
20
20
|
const elementRef = useRef(null);
|
|
21
21
|
|
|
@@ -56,15 +56,22 @@ export function BlankContent({ n, children, isDragging, isOver, dragItem, value
|
|
|
56
56
|
const hasGrip = finalLabel !== '\u00A0';
|
|
57
57
|
const isPreview = dragItem && isOver;
|
|
58
58
|
|
|
59
|
+
const borderStyle = selected
|
|
60
|
+
? `2px solid ${color.primaryDark()}`
|
|
61
|
+
: isPreview
|
|
62
|
+
? `1px solid ${color.defaults.BORDER_DARK}`
|
|
63
|
+
: `1px solid ${color.defaults.BORDER_LIGHT}`;
|
|
64
|
+
|
|
59
65
|
return (
|
|
60
66
|
<div
|
|
61
67
|
ref={elementRef}
|
|
68
|
+
className={selected ? 'selected' : undefined}
|
|
62
69
|
style={{
|
|
63
70
|
display: 'inline-flex',
|
|
64
71
|
minWidth: '178px',
|
|
65
72
|
minHeight: '36px',
|
|
66
73
|
background: isPreview ? `${color.defaults.BORDER_LIGHT}` : `${color.defaults.WHITE}`,
|
|
67
|
-
border:
|
|
74
|
+
border: borderStyle,
|
|
68
75
|
boxSizing: 'border-box',
|
|
69
76
|
borderRadius: '3px',
|
|
70
77
|
overflow: 'hidden',
|
|
@@ -104,9 +111,21 @@ BlankContent.propTypes = {
|
|
|
104
111
|
isOver: PropTypes.bool,
|
|
105
112
|
dragItem: PropTypes.object,
|
|
106
113
|
value: PropTypes.object,
|
|
114
|
+
selected: PropTypes.bool,
|
|
107
115
|
};
|
|
108
116
|
|
|
109
|
-
function DragDropChoice({
|
|
117
|
+
function DragDropChoice({
|
|
118
|
+
value,
|
|
119
|
+
disabled,
|
|
120
|
+
instanceId,
|
|
121
|
+
children,
|
|
122
|
+
n,
|
|
123
|
+
onChange,
|
|
124
|
+
removeResponse,
|
|
125
|
+
duplicates,
|
|
126
|
+
pos,
|
|
127
|
+
selected,
|
|
128
|
+
}) {
|
|
110
129
|
const {
|
|
111
130
|
attributes: dragAttributes,
|
|
112
131
|
listeners: dragListeners,
|
|
@@ -196,7 +215,14 @@ function DragDropChoice({ value, disabled, instanceId, children, n, onChange, re
|
|
|
196
215
|
};
|
|
197
216
|
|
|
198
217
|
const dragContent = (
|
|
199
|
-
<BlankContent
|
|
218
|
+
<BlankContent
|
|
219
|
+
n={n}
|
|
220
|
+
isDragging={isDragging}
|
|
221
|
+
isOver={isOver}
|
|
222
|
+
dragItem={dragItem?.data?.current}
|
|
223
|
+
value={value}
|
|
224
|
+
selected={selected}
|
|
225
|
+
>
|
|
200
226
|
{children}
|
|
201
227
|
</BlankContent>
|
|
202
228
|
);
|
|
@@ -223,6 +249,7 @@ DragDropChoice.propTypes = {
|
|
|
223
249
|
onChange: PropTypes.func.isRequired,
|
|
224
250
|
removeResponse: PropTypes.func.isRequired,
|
|
225
251
|
duplicates: PropTypes.bool,
|
|
252
|
+
selected: PropTypes.bool,
|
|
226
253
|
};
|
|
227
254
|
|
|
228
255
|
export default DragDropChoice;
|