@tfw.in/structura-lib 0.2.0 → 0.2.2
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/README.md +72 -323
- package/dist/cjs/EditableContent.js +46 -18
- package/dist/cjs/HtmlViewer.js +238 -85
- package/dist/cjs/MathRenderer.js +88 -0
- package/dist/cjs/PdfDocumentViewer.js +1 -1
- package/dist/cjs/SemanticTagParser.js +189 -0
- package/dist/cjs/SemanticTagRenderer.js +135 -0
- package/dist/cjs/Structura.js +49 -76
- package/dist/cjs/Table.js +75 -8
- package/dist/cjs/TableCell.js +34 -10
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/node_modules/react-icons/fa/index.esm.js +6 -0
- package/dist/cjs/styles.css +2 -4
- package/dist/cjs/styles.css.map +1 -1
- package/dist/esm/EditableContent.js +51 -19
- package/dist/esm/HtmlViewer.js +287 -103
- package/dist/esm/MathRenderer.js +85 -0
- package/dist/esm/PdfDocumentViewer.js +1 -1
- package/dist/esm/SemanticTagParser.js +187 -0
- package/dist/esm/SemanticTagRenderer.js +140 -0
- package/dist/esm/Structura.js +57 -80
- package/dist/esm/Table.js +85 -8
- package/dist/esm/TableCell.js +34 -6
- package/dist/esm/index.js +3 -0
- package/dist/esm/node_modules/react-icons/fa/index.esm.js +5 -1
- package/dist/esm/styles.css +2 -4
- package/dist/esm/styles.css.map +1 -1
- package/dist/esm/types/DocumentOutline.d.ts +7 -0
- package/dist/esm/types/EditableContent.d.ts +8 -1
- package/dist/esm/types/HtmlViewer.d.ts +9 -2
- package/dist/esm/types/MathRenderer.d.ts +25 -0
- package/dist/esm/types/SemanticTagParser.d.ts +33 -0
- package/dist/esm/types/SemanticTagRenderer.d.ts +17 -0
- package/dist/esm/types/Structura.d.ts +13 -8
- package/dist/esm/types/Table.d.ts +4 -1
- package/dist/esm/types/TableCell.d.ts +7 -1
- package/dist/esm/types/helpers/index.d.ts +0 -1
- package/dist/esm/types/index.d.ts +3 -0
- package/dist/esm/types/test-app/src/App.d.ts +1 -2
- package/dist/index.d.ts +90 -10
- package/package.json +9 -16
- package/PRODUCTION_ARCHITECTURE.md +0 -511
- package/SAVE_FUNCTIONALITY_COMPLETE.md +0 -448
- package/dist/cjs/ui/badge.js +0 -34
- package/dist/esm/types/helpers/jsonToHtml.d.ts +0 -40
- package/dist/esm/ui/badge.js +0 -31
- package/server/README.md +0 -203
- package/server/db.js +0 -142
- package/server/server.js +0 -165
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SemanticTag } from './SemanticTagParser';
|
|
2
|
+
interface SemanticTagRendererProps {
|
|
3
|
+
content: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
showTooltips?: boolean;
|
|
6
|
+
onTagClick?: (tag: SemanticTag) => void;
|
|
7
|
+
}
|
|
8
|
+
export default function SemanticTagRenderer({ content, className, showTooltips, onTagClick, }: SemanticTagRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
interface SmartContentProps {
|
|
10
|
+
content: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
enableSemanticTags?: boolean;
|
|
13
|
+
showTooltips?: boolean;
|
|
14
|
+
onTagClick?: (tag: SemanticTag) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function SmartContent({ content, className, enableSemanticTags, showTooltips, onTagClick, }: SmartContentProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export type { SemanticTag } from './SemanticTagParser';
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
interface
|
|
1
|
+
interface StructuraProps {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
baseUrl?: string;
|
|
2
4
|
initialPdfPath?: string | null;
|
|
3
|
-
initialJsonData?: any
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
initialJsonData?: any;
|
|
6
|
+
editMode?: boolean;
|
|
7
|
+
jsonMode?: boolean;
|
|
8
|
+
mathRendering?: boolean;
|
|
9
|
+
semanticTags?: boolean;
|
|
10
|
+
headerFooterBadges?: boolean;
|
|
11
|
+
defaultViewMode?: 'read' | 'edit' | 'json';
|
|
12
|
+
onContentChange?: (blockId: string, oldContent: string, newContent: string) => void;
|
|
13
|
+
onExport?: (data: any) => void;
|
|
9
14
|
}
|
|
10
|
-
export default function Structura({ initialPdfPath, initialJsonData,
|
|
15
|
+
export default function Structura({ apiKey, baseUrl, initialPdfPath, initialJsonData, editMode, jsonMode, mathRendering, semanticTags, headerFooterBadges, defaultViewMode, onContentChange, onExport }: StructuraProps): import("react/jsx-runtime").JSX.Element;
|
|
11
16
|
export {};
|
|
@@ -7,6 +7,9 @@ interface TableProps {
|
|
|
7
7
|
hasLlmHtml?: boolean;
|
|
8
8
|
showJsonIcons?: boolean;
|
|
9
9
|
onNodeClick?: (nodeId: string) => void;
|
|
10
|
+
isEditMode?: boolean;
|
|
11
|
+
isJsonMode?: boolean;
|
|
12
|
+
enableMathRendering?: boolean;
|
|
10
13
|
}
|
|
11
|
-
export default function Table({ node, selectedBboxId, onJsonClick, onContentChange, mergedTables, hasLlmHtml, showJsonIcons, onNodeClick, }: TableProps): import("react/jsx-runtime").JSX.Element | null;
|
|
14
|
+
export default function Table({ node, selectedBboxId, onJsonClick, onContentChange, mergedTables, hasLlmHtml, showJsonIcons, onNodeClick, isEditMode, isJsonMode, enableMathRendering, }: TableProps): import("react/jsx-runtime").JSX.Element | null;
|
|
12
15
|
export {};
|
|
@@ -8,6 +8,12 @@ interface TableCellProps {
|
|
|
8
8
|
showJsonIcons?: boolean;
|
|
9
9
|
onNodeClick?: () => void;
|
|
10
10
|
isDubious?: boolean;
|
|
11
|
+
rowSpan?: number;
|
|
12
|
+
colSpan?: number;
|
|
13
|
+
style?: Record<string, string>;
|
|
14
|
+
isEditMode?: boolean;
|
|
15
|
+
isJsonMode?: boolean;
|
|
16
|
+
enableMathRendering?: boolean;
|
|
11
17
|
}
|
|
12
|
-
export default function TableCell({ id, content, onJsonClick, isSelected, isHeader, onContentChange, showJsonIcons, onNodeClick, isDubious, }: TableCellProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export default function TableCell({ id, content, onJsonClick, isSelected, isHeader, onContentChange, showJsonIcons, onNodeClick, isDubious, rowSpan, colSpan, style, isEditMode, isJsonMode, enableMathRendering, }: TableCellProps): import("react/jsx-runtime").JSX.Element;
|
|
13
19
|
export {};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import './styles.css';
|
|
2
2
|
export { default as Structura } from './Structura';
|
|
3
3
|
export * from './types';
|
|
4
|
+
export { parseSemanticTags, hasSemanticTags, getTagTypeInfo, type SemanticTag, type TagType, type ParsedContent, type ContentSegment } from './SemanticTagParser';
|
|
5
|
+
export { default as SemanticTagRenderer, SmartContent } from './SemanticTagRenderer';
|
|
6
|
+
export { default as MathContent, renderMathInHtml, containsMath, useMathHtml } from './MathRenderer';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
export { Block, BlockOutput, BlockSchema, DocumentOutput } from '@tfw.in/structura-sdk';
|
|
3
3
|
|
|
4
|
-
interface
|
|
4
|
+
interface StructuraProps {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
baseUrl?: string;
|
|
5
7
|
initialPdfPath?: string | null;
|
|
6
|
-
initialJsonData?: any
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
initialJsonData?: any;
|
|
9
|
+
editMode?: boolean;
|
|
10
|
+
jsonMode?: boolean;
|
|
11
|
+
mathRendering?: boolean;
|
|
12
|
+
semanticTags?: boolean;
|
|
13
|
+
headerFooterBadges?: boolean;
|
|
14
|
+
defaultViewMode?: 'read' | 'edit' | 'json';
|
|
15
|
+
onContentChange?: (blockId: string, oldContent: string, newContent: string) => void;
|
|
16
|
+
onExport?: (data: any) => void;
|
|
12
17
|
}
|
|
13
|
-
declare function Structura({ initialPdfPath, initialJsonData,
|
|
18
|
+
declare function Structura({ apiKey, baseUrl, initialPdfPath, initialJsonData, editMode, jsonMode, mathRendering, semanticTags, headerFooterBadges, defaultViewMode, onContentChange, onExport }: StructuraProps): react_jsx_runtime.JSX.Element;
|
|
14
19
|
|
|
15
20
|
interface PdfHighlighterProps {
|
|
16
21
|
initialPdfPath?: string | null;
|
|
@@ -34,5 +39,80 @@ interface EditableContentProps {
|
|
|
34
39
|
isEditing?: boolean;
|
|
35
40
|
}
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
type TagType = 'MEASUREMENT' | 'VALUE' | 'FILE' | 'IMAGE' | 'DATETIME' | 'HIDDEN_MEASUREMENT';
|
|
43
|
+
interface SemanticTag {
|
|
44
|
+
type: TagType;
|
|
45
|
+
value: string;
|
|
46
|
+
rawMatch: string;
|
|
47
|
+
startIndex: number;
|
|
48
|
+
endIndex: number;
|
|
49
|
+
attributes: {
|
|
50
|
+
uom?: string;
|
|
51
|
+
id?: string;
|
|
52
|
+
format?: string;
|
|
53
|
+
filter?: string;
|
|
54
|
+
};
|
|
55
|
+
isHidden: boolean;
|
|
56
|
+
}
|
|
57
|
+
interface ParsedContent {
|
|
58
|
+
originalText: string;
|
|
59
|
+
tags: SemanticTag[];
|
|
60
|
+
segments: ContentSegment[];
|
|
61
|
+
}
|
|
62
|
+
interface ContentSegment {
|
|
63
|
+
type: 'text' | 'tag';
|
|
64
|
+
content: string;
|
|
65
|
+
tag?: SemanticTag;
|
|
66
|
+
}
|
|
67
|
+
declare function parseSemanticTags(text: string): ParsedContent;
|
|
68
|
+
declare function hasSemanticTags(text: string): boolean;
|
|
69
|
+
declare function getTagTypeInfo(type: TagType): {
|
|
70
|
+
color: string;
|
|
71
|
+
bgColor: string;
|
|
72
|
+
icon: string;
|
|
73
|
+
label: string;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
interface SemanticTagRendererProps {
|
|
77
|
+
content: string;
|
|
78
|
+
className?: string;
|
|
79
|
+
showTooltips?: boolean;
|
|
80
|
+
onTagClick?: (tag: SemanticTag) => void;
|
|
81
|
+
}
|
|
82
|
+
declare function SemanticTagRenderer({ content, className, showTooltips, onTagClick, }: SemanticTagRendererProps): react_jsx_runtime.JSX.Element;
|
|
83
|
+
interface SmartContentProps {
|
|
84
|
+
content: string;
|
|
85
|
+
className?: string;
|
|
86
|
+
enableSemanticTags?: boolean;
|
|
87
|
+
showTooltips?: boolean;
|
|
88
|
+
onTagClick?: (tag: SemanticTag) => void;
|
|
89
|
+
}
|
|
90
|
+
declare function SmartContent({ content, className, enableSemanticTags, showTooltips, onTagClick, }: SmartContentProps): react_jsx_runtime.JSX.Element;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Process HTML content and render all math expressions
|
|
94
|
+
*/
|
|
95
|
+
declare function renderMathInHtml(html: string): string;
|
|
96
|
+
/**
|
|
97
|
+
* Check if content contains any math expressions
|
|
98
|
+
*/
|
|
99
|
+
declare function containsMath(html: string): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* React component props
|
|
102
|
+
*/
|
|
103
|
+
interface MathContentProps {
|
|
104
|
+
html: string;
|
|
105
|
+
className?: string;
|
|
106
|
+
as?: keyof JSX.IntrinsicElements;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* React component that renders HTML with math expressions
|
|
110
|
+
*/
|
|
111
|
+
declare function MathContent({ html, className, as: Component }: MathContentProps): react_jsx_runtime.JSX.Element;
|
|
112
|
+
/**
|
|
113
|
+
* Hook to get rendered math HTML
|
|
114
|
+
*/
|
|
115
|
+
declare function useMathHtml(html: string): string;
|
|
116
|
+
|
|
117
|
+
export { MathContent, SemanticTagRenderer, SmartContent, Structura, containsMath, getTagTypeInfo, hasSemanticTags, parseSemanticTags, renderMathInHtml, useMathHtml };
|
|
118
|
+
export type { ContentSegment, EditableContentProps, ParsedContent, PdfHighlighterProps, SemanticTag, TableCellProps, TableProps, TagType };
|
package/package.json
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tfw.in/structura-lib",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Structura Library Components",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
10
|
-
"dist/pdf.worker.mjs"
|
|
11
|
-
"server",
|
|
12
|
-
"README.md",
|
|
13
|
-
"PRODUCTION_ARCHITECTURE.md",
|
|
14
|
-
"SAVE_FUNCTIONALITY_COMPLETE.md"
|
|
10
|
+
"dist/pdf.worker.mjs"
|
|
15
11
|
],
|
|
16
12
|
"scripts": {
|
|
17
13
|
"build": "rollup -c",
|
|
18
14
|
"dev": "rollup -c -w",
|
|
19
15
|
"clean": "rimraf dist",
|
|
20
16
|
"tw:init": "tailwindcss init",
|
|
21
|
-
"build:css": "postcss styles.css -o dist/styles.css --minify"
|
|
22
|
-
"server": "node server/server.js",
|
|
23
|
-
"server:dev": "nodemon server/server.js"
|
|
17
|
+
"build:css": "postcss styles.css -o dist/styles.css --minify"
|
|
24
18
|
},
|
|
25
19
|
"peerDependencies": {
|
|
26
20
|
"react": "^18.2.0",
|
|
@@ -34,13 +28,9 @@
|
|
|
34
28
|
"@radix-ui/react-tabs": "^1.0.4",
|
|
35
29
|
"@tailwindcss/postcss": "^4.1.8",
|
|
36
30
|
"@tfw.in/structura-sdk": "^0.1.0",
|
|
37
|
-
"@types/
|
|
38
|
-
"@types/cors": "^2.8.19",
|
|
39
|
-
"@types/express": "^5.0.5",
|
|
40
|
-
"better-sqlite3": "^12.4.1",
|
|
31
|
+
"@types/katex": "^0.16.7",
|
|
41
32
|
"class-variance-authority": "^0.7.0",
|
|
42
|
-
"
|
|
43
|
-
"express": "^5.1.0",
|
|
33
|
+
"katex": "^0.16.27",
|
|
44
34
|
"lucide-react": "^0.509.0",
|
|
45
35
|
"pdfjs-dist": "4.8.69",
|
|
46
36
|
"postcss-cli": "^11.0.1",
|
|
@@ -81,5 +71,8 @@
|
|
|
81
71
|
"structura"
|
|
82
72
|
],
|
|
83
73
|
"author": "TFW",
|
|
84
|
-
"license": "MIT"
|
|
74
|
+
"license": "MIT",
|
|
75
|
+
"publishConfig": {
|
|
76
|
+
"access": "public"
|
|
77
|
+
}
|
|
85
78
|
}
|