@tfw.in/structura-lib 0.2.0
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/PRODUCTION_ARCHITECTURE.md +511 -0
- package/README.md +379 -0
- package/SAVE_FUNCTIONALITY_COMPLETE.md +448 -0
- package/dist/cjs/EditableContent.js +150 -0
- package/dist/cjs/HtmlViewer.js +587 -0
- package/dist/cjs/PdfComponents.js +16 -0
- package/dist/cjs/PdfDocumentViewer.js +281 -0
- package/dist/cjs/Structura.js +806 -0
- package/dist/cjs/Table.js +164 -0
- package/dist/cjs/TableCell.js +115 -0
- package/dist/cjs/accuracyMetrics.js +39 -0
- package/dist/cjs/helpers/preprocessData.js +143 -0
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/lib/polyfills.js +15 -0
- package/dist/cjs/lib/utils.js +10 -0
- package/dist/cjs/node_modules/react-icons/fa/index.esm.js +14 -0
- package/dist/cjs/node_modules/react-icons/lib/esm/iconBase.js +69 -0
- package/dist/cjs/node_modules/react-icons/lib/esm/iconContext.js +15 -0
- package/dist/cjs/polyfills.js +19 -0
- package/dist/cjs/route.js +102 -0
- package/dist/cjs/styles.css +7 -0
- package/dist/cjs/styles.css.map +1 -0
- package/dist/cjs/ui/badge.js +34 -0
- package/dist/cjs/ui/button.js +71 -0
- package/dist/cjs/ui/card.js +86 -0
- package/dist/cjs/ui/progress.js +45 -0
- package/dist/cjs/ui/scroll-area.js +62 -0
- package/dist/cjs/ui/tabs.js +60 -0
- package/dist/cjs/worker.js +36 -0
- package/dist/esm/EditableContent.js +161 -0
- package/dist/esm/HtmlViewer.js +640 -0
- package/dist/esm/PdfComponents.js +21 -0
- package/dist/esm/PdfDocumentViewer.js +294 -0
- package/dist/esm/Structura.js +951 -0
- package/dist/esm/Table.js +182 -0
- package/dist/esm/TableCell.js +122 -0
- package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +305 -0
- package/dist/esm/accuracyMetrics.js +41 -0
- package/dist/esm/helpers/preprocessData.js +152 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/lib/polyfills.js +13 -0
- package/dist/esm/lib/utils.js +8 -0
- package/dist/esm/node_modules/react-icons/fa/index.esm.js +11 -0
- package/dist/esm/node_modules/react-icons/lib/esm/iconBase.js +66 -0
- package/dist/esm/node_modules/react-icons/lib/esm/iconContext.js +12 -0
- package/dist/esm/polyfills.js +17 -0
- package/dist/esm/route.js +154 -0
- package/dist/esm/styles.css +7 -0
- package/dist/esm/styles.css.map +1 -0
- package/dist/esm/types/EditableContent.d.ts +9 -0
- package/dist/esm/types/HtmlViewer.d.ts +10 -0
- package/dist/esm/types/PdfComponents.d.ts +35 -0
- package/dist/esm/types/PdfDocumentViewer.d.ts +22 -0
- package/dist/esm/types/Structura.d.ts +11 -0
- package/dist/esm/types/Table.d.ts +12 -0
- package/dist/esm/types/TableCell.d.ts +13 -0
- package/dist/esm/types/accuracy.d.ts +23 -0
- package/dist/esm/types/accuracyMetrics.d.ts +5 -0
- package/dist/esm/types/helpers/flattenJSON.d.ts +1 -0
- package/dist/esm/types/helpers/hardMerging.d.ts +2 -0
- package/dist/esm/types/helpers/index.d.ts +6 -0
- package/dist/esm/types/helpers/jsonToHtml.d.ts +40 -0
- package/dist/esm/types/helpers/preprocessData.d.ts +3 -0
- package/dist/esm/types/helpers/removeMetadata.d.ts +1 -0
- package/dist/esm/types/helpers/tableProcessor.d.ts +1 -0
- package/dist/esm/types/index.d.ts +3 -0
- package/dist/esm/types/lib/polyfills.d.ts +1 -0
- package/dist/esm/types/lib/utils.d.ts +2 -0
- package/dist/esm/types/polyfills.d.ts +1 -0
- package/dist/esm/types/route.d.ts +45 -0
- package/dist/esm/types/test-app/src/App.d.ts +4 -0
- package/dist/esm/types/test-app/src/main.d.ts +1 -0
- package/dist/esm/types/test-app/vite.config.d.ts +2 -0
- package/dist/esm/types/types.d.ts +23 -0
- package/dist/esm/types/ui/alert.d.ts +8 -0
- package/dist/esm/types/ui/badge.d.ts +9 -0
- package/dist/esm/types/ui/button.d.ts +11 -0
- package/dist/esm/types/ui/card.d.ts +8 -0
- package/dist/esm/types/ui/progress.d.ts +6 -0
- package/dist/esm/types/ui/scroll-area.d.ts +5 -0
- package/dist/esm/types/ui/skeleton.d.ts +2 -0
- package/dist/esm/types/ui/tabs.d.ts +7 -0
- package/dist/esm/types/worker.d.ts +1 -0
- package/dist/esm/ui/badge.js +31 -0
- package/dist/esm/ui/button.js +50 -0
- package/dist/esm/ui/card.js +67 -0
- package/dist/esm/ui/progress.js +26 -0
- package/dist/esm/ui/scroll-area.js +45 -0
- package/dist/esm/ui/tabs.js +39 -0
- package/dist/esm/worker.js +50 -0
- package/dist/index.d.ts +38 -0
- package/package.json +85 -0
- package/server/README.md +203 -0
- package/server/db.js +142 -0
- package/server/server.js +165 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { slicedToArray as _slicedToArray, toConsumableArray as _toConsumableArray } from './_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import TableCell from './TableCell.js';
|
|
5
|
+
|
|
6
|
+
// Utility function to clean HTML content
|
|
7
|
+
var cleanHtml = function cleanHtml(html) {
|
|
8
|
+
if (!html) return "";
|
|
9
|
+
// Log original HTML content
|
|
10
|
+
if (html.includes("strikethrough")) {
|
|
11
|
+
console.log("Table - Original HTML with strikethrough:", html);
|
|
12
|
+
}
|
|
13
|
+
// Remove newline characters
|
|
14
|
+
var cleanedHtml = html.replace(/\n/g, " ").replace(/<br\s*\/?>/g, " ")
|
|
15
|
+
// Replace non-standard strikethrough tag with standard HTML5 <s> tag
|
|
16
|
+
.replace(/<strikethrough>/g, "<s>").replace(/<\/strikethrough>/g, "</s>")
|
|
17
|
+
// Remove consecutive spaces
|
|
18
|
+
.replace(/\s+/g, " ")
|
|
19
|
+
// Trim leading and trailing spaces
|
|
20
|
+
.trim();
|
|
21
|
+
// Log transformed HTML content
|
|
22
|
+
if (html.includes("strikethrough")) {
|
|
23
|
+
console.log("Table - Transformed HTML with <s> tags:", cleanedHtml);
|
|
24
|
+
}
|
|
25
|
+
return cleanedHtml;
|
|
26
|
+
};
|
|
27
|
+
function Table(_ref) {
|
|
28
|
+
var node = _ref.node,
|
|
29
|
+
selectedBboxId = _ref.selectedBboxId,
|
|
30
|
+
_onJsonClick = _ref.onJsonClick,
|
|
31
|
+
onContentChange = _ref.onContentChange,
|
|
32
|
+
_ref$mergedTables = _ref.mergedTables,
|
|
33
|
+
mergedTables = _ref$mergedTables === void 0 ? [] : _ref$mergedTables,
|
|
34
|
+
_ref$hasLlmHtml = _ref.hasLlmHtml,
|
|
35
|
+
hasLlmHtml = _ref$hasLlmHtml === void 0 ? false : _ref$hasLlmHtml,
|
|
36
|
+
_ref$showJsonIcons = _ref.showJsonIcons,
|
|
37
|
+
showJsonIcons = _ref$showJsonIcons === void 0 ? true : _ref$showJsonIcons,
|
|
38
|
+
onNodeClick = _ref.onNodeClick;
|
|
39
|
+
var _useState = useState(false),
|
|
40
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
41
|
+
useLlmHtml = _useState2[0],
|
|
42
|
+
setUseLlmHtml = _useState2[1];
|
|
43
|
+
// Get the appropriate HTML content
|
|
44
|
+
var getHtmlContent = function getHtmlContent(node) {
|
|
45
|
+
if (useLlmHtml && node.llm_table_html) {
|
|
46
|
+
return cleanHtml(node.llm_table_html);
|
|
47
|
+
}
|
|
48
|
+
return cleanHtml(node.html || "");
|
|
49
|
+
};
|
|
50
|
+
// Check if we should use individual TableCell contents
|
|
51
|
+
var shouldUseTableCellContents = function shouldUseTableCellContents() {
|
|
52
|
+
// Check if any of the TableCell children has llm_table_html
|
|
53
|
+
if (!node.children) return false;
|
|
54
|
+
// TODO: to be fixed later
|
|
55
|
+
return node.children.some(function (child) {
|
|
56
|
+
return child.block_type === "TableCell" && child.llm_table_html !== undefined;
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
// Process the main table
|
|
60
|
+
var processTable = function processTable(tableNode) {
|
|
61
|
+
var tempDiv = document.createElement("div");
|
|
62
|
+
tempDiv.innerHTML = getHtmlContent(tableNode);
|
|
63
|
+
var tableElement = tempDiv.querySelector("table");
|
|
64
|
+
if (!tableElement) return null;
|
|
65
|
+
// Get all rows
|
|
66
|
+
var rows = Array.from(tableElement.querySelectorAll("tr"));
|
|
67
|
+
return {
|
|
68
|
+
rows: rows,
|
|
69
|
+
tableElement: tableElement,
|
|
70
|
+
tempDiv: tempDiv
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
var mainTable = processTable(node);
|
|
74
|
+
if (!mainTable) return null;
|
|
75
|
+
// Process merged tables if any
|
|
76
|
+
var mergedRows = [];
|
|
77
|
+
mergedTables.forEach(function (table) {
|
|
78
|
+
var processedTable = processTable(table);
|
|
79
|
+
if (processedTable) {
|
|
80
|
+
mergedRows.push.apply(mergedRows, _toConsumableArray(processedTable.rows));
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
// Combine rows from main table and merged tables
|
|
84
|
+
var allRows = [].concat(_toConsumableArray(mainTable.rows), mergedRows);
|
|
85
|
+
// Map cells to children
|
|
86
|
+
var processedRows = allRows.map(function (row, rowIndex) {
|
|
87
|
+
var cells = Array.from(row.querySelectorAll("th, td"));
|
|
88
|
+
return cells.map(function (cell, colIndex) {
|
|
89
|
+
var _a;
|
|
90
|
+
var globalCellIndex = rowIndex * cells.length + colIndex;
|
|
91
|
+
var childNode = (_a = node.children) === null || _a === void 0 ? void 0 : _a[globalCellIndex];
|
|
92
|
+
var cellContent = cleanHtml(cell.innerHTML);
|
|
93
|
+
var isHeaderCell = cell.tagName.toLowerCase() === "th"; // Check if this is a header cell
|
|
94
|
+
// If we should use TableCell content and we have a childNode with llm_table_html
|
|
95
|
+
if (shouldUseTableCellContents() && childNode && childNode.llm_table_html !== undefined) {
|
|
96
|
+
cellContent = useLlmHtml && childNode.llm_table_html ? cleanHtml(childNode.llm_table_html) : cleanHtml(childNode.html || "");
|
|
97
|
+
}
|
|
98
|
+
// TODO: to be fixed later - only apply dubious highlighting if the cell has llm_table_html
|
|
99
|
+
var isDubious = (childNode === null || childNode === void 0 ? void 0 : childNode.dubious) && (childNode === null || childNode === void 0 ? void 0 : childNode.llm_table_html) !== undefined ? true : false;
|
|
100
|
+
return {
|
|
101
|
+
id: (childNode === null || childNode === void 0 ? void 0 : childNode.id) || "".concat(node.id, "-cell-").concat(globalCellIndex),
|
|
102
|
+
content: cellContent,
|
|
103
|
+
isHeader: isHeaderCell,
|
|
104
|
+
isDubious: isDubious,
|
|
105
|
+
nodeData: childNode || {
|
|
106
|
+
id: "".concat(node.id, "-cell-").concat(globalCellIndex),
|
|
107
|
+
html: cellContent,
|
|
108
|
+
block_type: "TableCell"
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
var handleCellContentChange = function handleCellContentChange(cellId, newContent) {
|
|
114
|
+
if (onContentChange) {
|
|
115
|
+
onContentChange(cellId, newContent);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
var handleTableClick = function handleTableClick(e) {
|
|
119
|
+
// Only process clicks directly on the table container, not bubbled events from cells
|
|
120
|
+
if (e.target === e.currentTarget && node.id && onNodeClick) {
|
|
121
|
+
onNodeClick(node.id);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
return jsxs("div", {
|
|
125
|
+
onClick: handleTableClick,
|
|
126
|
+
className: onNodeClick ? "cursor-pointer" : "",
|
|
127
|
+
children: [hasLlmHtml && jsx("div", {
|
|
128
|
+
className: "mb-2 flex justify-end",
|
|
129
|
+
onClick: function onClick(e) {
|
|
130
|
+
return e.stopPropagation();
|
|
131
|
+
},
|
|
132
|
+
children: jsxs("label", {
|
|
133
|
+
className: "inline-flex items-center cursor-pointer",
|
|
134
|
+
children: [jsx("input", {
|
|
135
|
+
type: "checkbox",
|
|
136
|
+
checked: useLlmHtml,
|
|
137
|
+
onChange: function onChange() {
|
|
138
|
+
return setUseLlmHtml(!useLlmHtml);
|
|
139
|
+
},
|
|
140
|
+
className: "sr-only peer"
|
|
141
|
+
}), jsx("div", {
|
|
142
|
+
className: "relative w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"
|
|
143
|
+
}), jsx("span", {
|
|
144
|
+
className: "ms-3 text-sm font-medium text-gray-900",
|
|
145
|
+
children: "Agentic"
|
|
146
|
+
})]
|
|
147
|
+
})
|
|
148
|
+
}), jsx("div", {
|
|
149
|
+
className: "w-full overflow-x-auto",
|
|
150
|
+
children: jsx("table", {
|
|
151
|
+
className: "min-w-full divide-y divide-gray-200",
|
|
152
|
+
children: jsx("tbody", {
|
|
153
|
+
children: processedRows.map(function (row, rowIndex) {
|
|
154
|
+
return jsx("tr", {
|
|
155
|
+
children: row.map(function (cell) {
|
|
156
|
+
return jsx(TableCell, {
|
|
157
|
+
id: cell.id,
|
|
158
|
+
content: cell.content,
|
|
159
|
+
onJsonClick: function onJsonClick() {
|
|
160
|
+
return _onJsonClick(cell.nodeData);
|
|
161
|
+
},
|
|
162
|
+
isSelected: cell.id === selectedBboxId,
|
|
163
|
+
isHeader: cell.isHeader,
|
|
164
|
+
isDubious: cell.isDubious,
|
|
165
|
+
onContentChange: onContentChange ? function (newContent) {
|
|
166
|
+
return handleCellContentChange(cell.id, newContent);
|
|
167
|
+
} : undefined,
|
|
168
|
+
showJsonIcons: showJsonIcons,
|
|
169
|
+
onNodeClick: onNodeClick ? function () {
|
|
170
|
+
return onNodeClick(cell.id);
|
|
171
|
+
} : undefined
|
|
172
|
+
}, cell.id);
|
|
173
|
+
})
|
|
174
|
+
}, rowIndex);
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
})
|
|
178
|
+
})]
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export { Table as default };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { slicedToArray as _slicedToArray } from './_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
import { VscJson } from 'react-icons/vsc';
|
|
5
|
+
|
|
6
|
+
// Utility function to clean HTML content
|
|
7
|
+
var cleanHtml = function cleanHtml(html) {
|
|
8
|
+
if (!html) return "";
|
|
9
|
+
// Log original HTML content
|
|
10
|
+
if (html.includes("strikethrough")) {
|
|
11
|
+
console.log("TableCell - Original HTML with strikethrough:", html);
|
|
12
|
+
}
|
|
13
|
+
// Remove newline characters
|
|
14
|
+
var cleanedHtml = html.replace(/\n/g, " ").replace(/<br\s*\/?>/g, " ")
|
|
15
|
+
// Replace non-standard strikethrough tag with standard HTML5 <s> tag
|
|
16
|
+
.replace(/<strikethrough>/g, "<s>").replace(/<\/strikethrough>/g, "</s>")
|
|
17
|
+
// Remove consecutive spaces
|
|
18
|
+
.replace(/\s+/g, " ")
|
|
19
|
+
// Trim leading and trailing spaces
|
|
20
|
+
.trim();
|
|
21
|
+
// Log transformed HTML content
|
|
22
|
+
if (html.includes("strikethrough")) {
|
|
23
|
+
console.log("TableCell - Transformed HTML with <s> tags:", cleanedHtml);
|
|
24
|
+
}
|
|
25
|
+
return cleanedHtml;
|
|
26
|
+
};
|
|
27
|
+
function TableCell(_ref) {
|
|
28
|
+
var id = _ref.id,
|
|
29
|
+
content = _ref.content,
|
|
30
|
+
onJsonClick = _ref.onJsonClick,
|
|
31
|
+
isSelected = _ref.isSelected,
|
|
32
|
+
_ref$isHeader = _ref.isHeader,
|
|
33
|
+
isHeader = _ref$isHeader === void 0 ? false : _ref$isHeader,
|
|
34
|
+
onContentChange = _ref.onContentChange,
|
|
35
|
+
_ref$showJsonIcons = _ref.showJsonIcons,
|
|
36
|
+
showJsonIcons = _ref$showJsonIcons === void 0 ? true : _ref$showJsonIcons,
|
|
37
|
+
onNodeClick = _ref.onNodeClick,
|
|
38
|
+
_ref$isDubious = _ref.isDubious,
|
|
39
|
+
isDubious = _ref$isDubious === void 0 ? false : _ref$isDubious;
|
|
40
|
+
var _useState = useState(false),
|
|
41
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
42
|
+
isEditing = _useState2[0],
|
|
43
|
+
setIsEditing = _useState2[1];
|
|
44
|
+
var _useState3 = useState(cleanHtml(content)),
|
|
45
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
46
|
+
editedContent = _useState4[0],
|
|
47
|
+
setEditedContent = _useState4[1];
|
|
48
|
+
var _useState5 = useState(false),
|
|
49
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
50
|
+
isEdited = _useState6[0],
|
|
51
|
+
setIsEdited = _useState6[1];
|
|
52
|
+
var CellComponent = isHeader ? "th" : "td";
|
|
53
|
+
// Update content when props change, but preserve edited state
|
|
54
|
+
useEffect(function () {
|
|
55
|
+
if (!isEdited) {
|
|
56
|
+
setEditedContent(cleanHtml(content));
|
|
57
|
+
}
|
|
58
|
+
}, [content, isEdited]);
|
|
59
|
+
// Log content that contains strikethrough when component renders
|
|
60
|
+
useEffect(function () {
|
|
61
|
+
if (content.includes("strikethrough")) {
|
|
62
|
+
console.log("TableCell rendering - Cell ID:", id);
|
|
63
|
+
console.log("Original content:", content);
|
|
64
|
+
console.log("Edited content being displayed:", editedContent);
|
|
65
|
+
}
|
|
66
|
+
}, [id, content, editedContent]);
|
|
67
|
+
var handleDoubleClick = function handleDoubleClick() {
|
|
68
|
+
if (onContentChange) {
|
|
69
|
+
setIsEditing(true);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var handleBlur = function handleBlur() {
|
|
73
|
+
setIsEditing(false);
|
|
74
|
+
if (editedContent !== content && onContentChange) {
|
|
75
|
+
setIsEdited(true);
|
|
76
|
+
onContentChange(id, editedContent);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
var handleClick = function handleClick(e) {
|
|
80
|
+
if (!isEditing && onNodeClick) {
|
|
81
|
+
onNodeClick();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
return jsx(CellComponent, {
|
|
85
|
+
id: id,
|
|
86
|
+
className: "structura-px-4 structura-py-2 structura-border structura-border-gray-200 structura-transition-colors structura-relative structura-group \n ".concat(isSelected ? "structura-bg-blue-100 structura-border-2 structura-border-blue-500" : "", " \n ").concat(isHeader ? "structura-bg-gray-100 structura-font-bold structura-text-gray-800" : "", "\n ").concat(isEdited ? "structura-bg-yellow-100" : "", "\n ").concat(isDubious ? "structura-bg-red-500/20" : "", "\n ").concat(onNodeClick && !isEditing ? "structura-cursor-pointer hover:structura-bg-gray-50" : ""),
|
|
87
|
+
onDoubleClick: handleDoubleClick,
|
|
88
|
+
onClick: handleClick,
|
|
89
|
+
children: jsxs("div", {
|
|
90
|
+
className: "structura-w-full structura-relative",
|
|
91
|
+
children: [showJsonIcons && jsx("button", {
|
|
92
|
+
onClick: function onClick(e) {
|
|
93
|
+
e.stopPropagation();
|
|
94
|
+
onJsonClick();
|
|
95
|
+
},
|
|
96
|
+
className: "structura-absolute -structura-right-1 structura-top-0 structura-opacity-0 group-hover:structura-opacity-100 structura-transition-opacity structura-text-gray-500 hover:structura-text-gray-700",
|
|
97
|
+
title: "View JSON",
|
|
98
|
+
children: jsx(VscJson, {
|
|
99
|
+
size: 16
|
|
100
|
+
})
|
|
101
|
+
}), isEditing ? jsx("textarea", {
|
|
102
|
+
value: editedContent,
|
|
103
|
+
onChange: function onChange(e) {
|
|
104
|
+
return setEditedContent(e.target.value);
|
|
105
|
+
},
|
|
106
|
+
onBlur: handleBlur,
|
|
107
|
+
autoFocus: true,
|
|
108
|
+
className: "structura-w-full structura-min-h-[24px] structura-p-1 structura-border structura-border-blue-400 structura-rounded focus:structura-outline-none focus:structura-ring-2 focus:structura-ring-blue-500",
|
|
109
|
+
onClick: function onClick(e) {
|
|
110
|
+
return e.stopPropagation();
|
|
111
|
+
}
|
|
112
|
+
}) : jsx("div", {
|
|
113
|
+
dangerouslySetInnerHTML: {
|
|
114
|
+
__html: editedContent
|
|
115
|
+
},
|
|
116
|
+
className: "structura-min-w-0 structura-break-words"
|
|
117
|
+
})]
|
|
118
|
+
})
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export { TableCell as default };
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
function _arrayLikeToArray(r, a) {
|
|
2
|
+
(null == a || a > r.length) && (a = r.length);
|
|
3
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
4
|
+
return n;
|
|
5
|
+
}
|
|
6
|
+
function _arrayWithHoles(r) {
|
|
7
|
+
if (Array.isArray(r)) return r;
|
|
8
|
+
}
|
|
9
|
+
function _arrayWithoutHoles(r) {
|
|
10
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
11
|
+
}
|
|
12
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
13
|
+
try {
|
|
14
|
+
var i = n[a](c),
|
|
15
|
+
u = i.value;
|
|
16
|
+
} catch (n) {
|
|
17
|
+
return void e(n);
|
|
18
|
+
}
|
|
19
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
20
|
+
}
|
|
21
|
+
function _asyncToGenerator(n) {
|
|
22
|
+
return function () {
|
|
23
|
+
var t = this,
|
|
24
|
+
e = arguments;
|
|
25
|
+
return new Promise(function (r, o) {
|
|
26
|
+
var a = n.apply(t, e);
|
|
27
|
+
function _next(n) {
|
|
28
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
29
|
+
}
|
|
30
|
+
function _throw(n) {
|
|
31
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
32
|
+
}
|
|
33
|
+
_next(void 0);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function _createForOfIteratorHelper(r, e) {
|
|
38
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
39
|
+
if (!t) {
|
|
40
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
|
|
41
|
+
t && (r = t);
|
|
42
|
+
var n = 0,
|
|
43
|
+
F = function () {};
|
|
44
|
+
return {
|
|
45
|
+
s: F,
|
|
46
|
+
n: function () {
|
|
47
|
+
return n >= r.length ? {
|
|
48
|
+
done: true
|
|
49
|
+
} : {
|
|
50
|
+
done: false,
|
|
51
|
+
value: r[n++]
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
e: function (r) {
|
|
55
|
+
throw r;
|
|
56
|
+
},
|
|
57
|
+
f: F
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
61
|
+
}
|
|
62
|
+
var o,
|
|
63
|
+
a = true,
|
|
64
|
+
u = false;
|
|
65
|
+
return {
|
|
66
|
+
s: function () {
|
|
67
|
+
t = t.call(r);
|
|
68
|
+
},
|
|
69
|
+
n: function () {
|
|
70
|
+
var r = t.next();
|
|
71
|
+
return a = r.done, r;
|
|
72
|
+
},
|
|
73
|
+
e: function (r) {
|
|
74
|
+
u = true, o = r;
|
|
75
|
+
},
|
|
76
|
+
f: function () {
|
|
77
|
+
try {
|
|
78
|
+
a || null == t.return || t.return();
|
|
79
|
+
} finally {
|
|
80
|
+
if (u) throw o;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function _defineProperty(e, r, t) {
|
|
86
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
87
|
+
value: t,
|
|
88
|
+
enumerable: true,
|
|
89
|
+
configurable: true,
|
|
90
|
+
writable: true
|
|
91
|
+
}) : e[r] = t, e;
|
|
92
|
+
}
|
|
93
|
+
function _iterableToArray(r) {
|
|
94
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
95
|
+
}
|
|
96
|
+
function _iterableToArrayLimit(r, l) {
|
|
97
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
98
|
+
if (null != t) {
|
|
99
|
+
var e,
|
|
100
|
+
n,
|
|
101
|
+
i,
|
|
102
|
+
u,
|
|
103
|
+
a = [],
|
|
104
|
+
f = true,
|
|
105
|
+
o = false;
|
|
106
|
+
try {
|
|
107
|
+
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
108
|
+
} catch (r) {
|
|
109
|
+
o = true, n = r;
|
|
110
|
+
} finally {
|
|
111
|
+
try {
|
|
112
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
113
|
+
} finally {
|
|
114
|
+
if (o) throw n;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return a;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function _nonIterableRest() {
|
|
121
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
122
|
+
}
|
|
123
|
+
function _nonIterableSpread() {
|
|
124
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
125
|
+
}
|
|
126
|
+
function ownKeys(e, r) {
|
|
127
|
+
var t = Object.keys(e);
|
|
128
|
+
if (Object.getOwnPropertySymbols) {
|
|
129
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
130
|
+
r && (o = o.filter(function (r) {
|
|
131
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
132
|
+
})), t.push.apply(t, o);
|
|
133
|
+
}
|
|
134
|
+
return t;
|
|
135
|
+
}
|
|
136
|
+
function _objectSpread2(e) {
|
|
137
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
138
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
139
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
140
|
+
_defineProperty(e, r, t[r]);
|
|
141
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
142
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return e;
|
|
146
|
+
}
|
|
147
|
+
function _objectWithoutProperties(e, t) {
|
|
148
|
+
if (null == e) return {};
|
|
149
|
+
var o,
|
|
150
|
+
r,
|
|
151
|
+
i = _objectWithoutPropertiesLoose(e, t);
|
|
152
|
+
if (Object.getOwnPropertySymbols) {
|
|
153
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
154
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
155
|
+
}
|
|
156
|
+
return i;
|
|
157
|
+
}
|
|
158
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
159
|
+
if (null == r) return {};
|
|
160
|
+
var t = {};
|
|
161
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
162
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
163
|
+
t[n] = r[n];
|
|
164
|
+
}
|
|
165
|
+
return t;
|
|
166
|
+
}
|
|
167
|
+
function _regenerator() {
|
|
168
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
169
|
+
var e,
|
|
170
|
+
t,
|
|
171
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
172
|
+
n = r.iterator || "@@iterator",
|
|
173
|
+
o = r.toStringTag || "@@toStringTag";
|
|
174
|
+
function i(r, n, o, i) {
|
|
175
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
176
|
+
u = Object.create(c.prototype);
|
|
177
|
+
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
178
|
+
var i,
|
|
179
|
+
c,
|
|
180
|
+
u,
|
|
181
|
+
f = 0,
|
|
182
|
+
p = o || [],
|
|
183
|
+
y = false,
|
|
184
|
+
G = {
|
|
185
|
+
p: 0,
|
|
186
|
+
n: 0,
|
|
187
|
+
v: e,
|
|
188
|
+
a: d,
|
|
189
|
+
f: d.bind(e, 4),
|
|
190
|
+
d: function (t, r) {
|
|
191
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
function d(r, n) {
|
|
195
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
196
|
+
var o,
|
|
197
|
+
i = p[t],
|
|
198
|
+
d = G.p,
|
|
199
|
+
l = i[2];
|
|
200
|
+
r > 3 ? (o = l === n) && (c = i[4] || 3, u = i[5] === e ? i[3] : i[5], i[4] = 3, i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
201
|
+
}
|
|
202
|
+
if (o || r > 1) return a;
|
|
203
|
+
throw y = true, n;
|
|
204
|
+
}
|
|
205
|
+
return function (o, p, l) {
|
|
206
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
207
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
208
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
209
|
+
try {
|
|
210
|
+
if (f = 2, i) {
|
|
211
|
+
if (c || (o = "next"), t = i[o]) {
|
|
212
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
213
|
+
if (!t.done) return t;
|
|
214
|
+
u = t.value, c < 2 && (c = 0);
|
|
215
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
216
|
+
i = e;
|
|
217
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
218
|
+
} catch (t) {
|
|
219
|
+
i = e, c = 1, u = t;
|
|
220
|
+
} finally {
|
|
221
|
+
f = 1;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
value: t,
|
|
226
|
+
done: y
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
}(r, o, i), true), u;
|
|
230
|
+
}
|
|
231
|
+
var a = {};
|
|
232
|
+
function Generator() {}
|
|
233
|
+
function GeneratorFunction() {}
|
|
234
|
+
function GeneratorFunctionPrototype() {}
|
|
235
|
+
t = Object.getPrototypeOf;
|
|
236
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
237
|
+
return this;
|
|
238
|
+
}), t),
|
|
239
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
240
|
+
function f(e) {
|
|
241
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
242
|
+
}
|
|
243
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|
244
|
+
return this;
|
|
245
|
+
}), _regeneratorDefine(u, "toString", function () {
|
|
246
|
+
return "[object Generator]";
|
|
247
|
+
}), (_regenerator = function () {
|
|
248
|
+
return {
|
|
249
|
+
w: i,
|
|
250
|
+
m: f
|
|
251
|
+
};
|
|
252
|
+
})();
|
|
253
|
+
}
|
|
254
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
255
|
+
var i = Object.defineProperty;
|
|
256
|
+
try {
|
|
257
|
+
i({}, "", {});
|
|
258
|
+
} catch (e) {
|
|
259
|
+
i = 0;
|
|
260
|
+
}
|
|
261
|
+
_regeneratorDefine = function (e, r, n, t) {
|
|
262
|
+
if (r) i ? i(e, r, {
|
|
263
|
+
value: n,
|
|
264
|
+
enumerable: !t,
|
|
265
|
+
configurable: !t,
|
|
266
|
+
writable: !t
|
|
267
|
+
}) : e[r] = n;else {
|
|
268
|
+
function o(r, n) {
|
|
269
|
+
_regeneratorDefine(e, r, function (e) {
|
|
270
|
+
return this._invoke(r, n, e);
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
o("next", 0), o("throw", 1), o("return", 2);
|
|
274
|
+
}
|
|
275
|
+
}, _regeneratorDefine(e, r, n, t);
|
|
276
|
+
}
|
|
277
|
+
function _slicedToArray(r, e) {
|
|
278
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
279
|
+
}
|
|
280
|
+
function _toConsumableArray(r) {
|
|
281
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
282
|
+
}
|
|
283
|
+
function _toPrimitive(t, r) {
|
|
284
|
+
if ("object" != typeof t || !t) return t;
|
|
285
|
+
var e = t[Symbol.toPrimitive];
|
|
286
|
+
if (void 0 !== e) {
|
|
287
|
+
var i = e.call(t, r);
|
|
288
|
+
if ("object" != typeof i) return i;
|
|
289
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
290
|
+
}
|
|
291
|
+
return ("string" === r ? String : Number)(t);
|
|
292
|
+
}
|
|
293
|
+
function _toPropertyKey(t) {
|
|
294
|
+
var i = _toPrimitive(t, "string");
|
|
295
|
+
return "symbol" == typeof i ? i : i + "";
|
|
296
|
+
}
|
|
297
|
+
function _unsupportedIterableToArray(r, a) {
|
|
298
|
+
if (r) {
|
|
299
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
300
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
301
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export { _arrayLikeToArray as arrayLikeToArray, _arrayWithHoles as arrayWithHoles, _arrayWithoutHoles as arrayWithoutHoles, _asyncToGenerator as asyncToGenerator, _createForOfIteratorHelper as createForOfIteratorHelper, _defineProperty as defineProperty, _iterableToArray as iterableToArray, _iterableToArrayLimit as iterableToArrayLimit, _nonIterableRest as nonIterableRest, _nonIterableSpread as nonIterableSpread, _objectSpread2 as objectSpread2, _objectWithoutProperties as objectWithoutProperties, _objectWithoutPropertiesLoose as objectWithoutPropertiesLoose, _regenerator as regenerator, _regeneratorDefine as regeneratorDefine, _slicedToArray as slicedToArray, _toConsumableArray as toConsumableArray, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey, _unsupportedIterableToArray as unsupportedIterableToArray };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var calculateDifferences = function calculateDifferences(original, updated) {
|
|
2
|
+
var cleanText = function cleanText(text) {
|
|
3
|
+
return text.replace(/<[^>]*>/g, "").trim();
|
|
4
|
+
};
|
|
5
|
+
var originalClean = cleanText(original);
|
|
6
|
+
var updatedClean = cleanText(updated);
|
|
7
|
+
var originalWords = originalClean.split(/\s+/);
|
|
8
|
+
var updatedWords = updatedClean.split(/\s+/);
|
|
9
|
+
return {
|
|
10
|
+
charactersDifferent: Math.abs(updatedClean.length - originalClean.length),
|
|
11
|
+
wordsDifferent: Math.abs(updatedWords.length - originalWords.length),
|
|
12
|
+
// Levenshtein distance for more accurate character difference
|
|
13
|
+
editDistance: levenshteinDistance(originalClean, updatedClean)
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
function levenshteinDistance(str1, str2) {
|
|
17
|
+
var m = str1.length;
|
|
18
|
+
var n = str2.length;
|
|
19
|
+
var dp = Array(m + 1).fill(0).map(function () {
|
|
20
|
+
return Array(n + 1).fill(0);
|
|
21
|
+
});
|
|
22
|
+
for (var i = 0; i <= m; i++) dp[i][0] = i;
|
|
23
|
+
for (var j = 0; j <= n; j++) dp[0][j] = j;
|
|
24
|
+
for (var _i = 1; _i <= m; _i++) {
|
|
25
|
+
for (var _j = 1; _j <= n; _j++) {
|
|
26
|
+
if (str1[_i - 1] === str2[_j - 1]) {
|
|
27
|
+
dp[_i][_j] = dp[_i - 1][_j - 1];
|
|
28
|
+
} else {
|
|
29
|
+
dp[_i][_j] = 1 + Math.min(dp[_i - 1][_j],
|
|
30
|
+
// deletion
|
|
31
|
+
dp[_i][_j - 1],
|
|
32
|
+
// insertion
|
|
33
|
+
dp[_i - 1][_j - 1] // substitution
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return dp[m][n];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { calculateDifferences };
|