@appquality/unguess-design-system 3.1.91-highlight-7 → 3.1.91-highlight-9
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/build/index.js
CHANGED
|
@@ -7484,9 +7484,44 @@ const useTypeSpec = (type) => {
|
|
|
7484
7484
|
};
|
|
7485
7485
|
}
|
|
7486
7486
|
};
|
|
7487
|
+
function findNodePosition(doc, targetNode) {
|
|
7488
|
+
let foundPos = null;
|
|
7489
|
+
doc.descendants((node, pos) => {
|
|
7490
|
+
if (node === targetNode) {
|
|
7491
|
+
foundPos = pos;
|
|
7492
|
+
return false; // Interrompe la ricerca
|
|
7493
|
+
}
|
|
7494
|
+
return true;
|
|
7495
|
+
});
|
|
7496
|
+
return foundPos;
|
|
7497
|
+
}
|
|
7498
|
+
function findAllAncestorsOfType(state, pos, nodeType) {
|
|
7499
|
+
const ancestors = [];
|
|
7500
|
+
let { doc } = state;
|
|
7501
|
+
let currentPos = pos;
|
|
7502
|
+
while (currentPos > 0) {
|
|
7503
|
+
const resolvedPos = doc.resolve(currentPos);
|
|
7504
|
+
const parent = resolvedPos.node(resolvedPos.depth);
|
|
7505
|
+
if (parent.type === nodeType) {
|
|
7506
|
+
ancestors.push(parent);
|
|
7507
|
+
}
|
|
7508
|
+
if (resolvedPos.depth === 0) {
|
|
7509
|
+
break;
|
|
7510
|
+
}
|
|
7511
|
+
currentPos = resolvedPos.before(); // Move to the previous depth level
|
|
7512
|
+
}
|
|
7513
|
+
return ancestors;
|
|
7514
|
+
}
|
|
7487
7515
|
const Component$1 = ({ node, editor, }) => {
|
|
7488
7516
|
const { background } = useTypeSpec(node.attrs["type"]);
|
|
7489
|
-
|
|
7517
|
+
const nodePos = findNodePosition(editor.state.doc, node);
|
|
7518
|
+
if (!nodePos)
|
|
7519
|
+
return null;
|
|
7520
|
+
const ancestors = findAllAncestorsOfType(editor.state, nodePos, editor.state.schema.nodes.Observation);
|
|
7521
|
+
const title = ancestors.length
|
|
7522
|
+
? [node, ...ancestors].map((ancestor) => ancestor.attrs["title"])
|
|
7523
|
+
: [node.attrs["title"]];
|
|
7524
|
+
return (jsxRuntime.jsx(react.NodeViewWrapper, Object.assign({ as: "span", className: "react-component" }, { children: jsxRuntime.jsx("span", Object.assign({ "data-title": node.attrs["title"], style: { background } }, { children: jsxRuntime.jsx(Tooltip, Object.assign({ content: title.join(" and ") }, { children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(react.NodeViewContent, { as: "span", className: "content is-editable" }) }) })) })) })));
|
|
7490
7525
|
};
|
|
7491
7526
|
|
|
7492
7527
|
const Observation = core.Node.create({
|