@docling/docling-components 0.0.5 → 0.0.7

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 CHANGED
@@ -24,76 +24,96 @@ Either download the package and serve it as part of the rest of the website, or
24
24
  <head>
25
25
  ...
26
26
 
27
- <script type="module" src="https://unpkg.com/@docling/docling-components" />
27
+ <script type="module" src="https://unpkg.com/@docling/docling-components/dist/index.es.js" />
28
28
  </head>
29
29
 
30
30
  ...
31
31
  </html>
32
32
  ```
33
33
 
34
- ## Components
34
+ ## Document components
35
35
 
36
36
  ### docling-img
37
37
 
38
38
  This component displays the converted document in context of its original form, by showing the full page renderings that are embedded in the conversion JSON (for specific input document formats). Each document item is shown as a bounding box on top of the page.
39
39
 
40
40
  #### Plain use
41
+
41
42
  Similar to `<img>` you can point the component to the Docling JSON file.
42
43
 
43
44
  ```html
44
- <docling-img src="conversion.json" />
45
+ <docling-img src="conversion.json"></docling-img>
45
46
  ```
46
47
 
47
48
  Or load the document programmatically:
48
49
 
49
50
  ```html
50
51
  <script type="module">
51
- const cmp = document.getElementById("cmp");
52
+ const cmp = document.getElementById('cmp');
52
53
 
53
- const fetched = await fetch("conversion.json")
54
+ const fetched = await fetch('conversion.json');
54
55
  const doc = await fetched.json();
55
56
  cmp.src = doc;
56
57
  </script>
57
58
  ...
58
- <docling-img id="cmp" pagenumbers />
59
+ <docling-img id="cmp" pagenumbers></docling-img>
59
60
  ```
60
61
 
61
-
62
62
  #### Item filter and highlight
63
63
 
64
64
  Narrow down the marked document items according to their reference path in the converted document:
65
65
 
66
66
  ```html
67
- <docling-img src="conversion.json" items="#/pictures/3" />
67
+ <docling-img src="conversion.json" items="#/pictures/3"></docling-img>
68
68
  ```
69
69
 
70
70
  Select entire item categories with `items="#/pictures"`, full pages with `items="#/pages/2"`, and unions with `items="#/pictures, #/tables"`.
71
71
 
72
72
  Or select specific items programmatically:
73
+
73
74
  ```html
74
75
  <script type="module">
75
- const cmp = document.getElementById("cmp");
76
- const fetched = await fetch("conversion.json")
77
- const doc = await fetched.json();
78
- cmp.src = doc;
76
+ const cmp = document.getElementById('cmp');
77
+ const fetched = await fetch('conversion.json');
78
+ const doc = await fetched.json();
79
+ cmp.src = doc;
79
80
 
80
- // Select the first three tables.
81
- cmp.items = doc.tables.slice(0, 3);
81
+ // Select the first three tables.
82
+ cmp.items = doc.tables.slice(0, 3);
82
83
  </script>
83
84
  ...
84
- <docling-img id="cmp" pagenumbers />
85
+ <docling-img id="cmp" pagenumbers></docling-img>
85
86
  ```
86
87
 
87
88
  To emphasize item selections, you can suppress the non-selection into a page backdrop and/or trim out the pages without any selected items:
88
89
 
89
90
  ```html
90
- <docling-img src="conversion.json" items="#/pictures" trim="pages" backdrop />
91
+ <docling-img
92
+ src="conversion.json"
93
+ items="#/pictures"
94
+ trim="pages"
95
+ backdrop
96
+ ></docling-img>
91
97
  ```
92
98
 
93
- #### Tooltips
94
- Overlay a tooltip when you hover a parsed item on a page, showing its contents:
99
+ #### Tooltip
100
+
101
+ Pops up a tooltip besides an item when you hover it on a page. This tooltip shows the item's parsed content and annotations if matching web components are available:
102
+
95
103
  ```html
96
- <docling-img src="conversion.json" tooltip="parsed" />
104
+ <docling-img src="conversion.json">
105
+ <docling-tooltip></docling-tooltip>
106
+ </docling-img>
107
+ ```
108
+
109
+ #### Overlay
110
+
111
+ Overlays parsed content and annotations directly on top of items (potentially occluding them).
112
+
113
+ ```html
114
+ <docling-img src="conversion.json">
115
+ <docling-overlay></docling-overlay>
116
+ </docling-img>
97
117
  ```
98
118
 
99
119
  ### docling-table
@@ -103,18 +123,68 @@ This component displays the converted document as a table of parsed document ite
103
123
  #### Plain use
104
124
 
105
125
  ```html
106
- <docling-table src="conversion.json" />
126
+ <docling-table src="conversion.json"></docling-table>
107
127
  ```
108
128
 
109
129
  You can select items with the `items` attributes, as described for the `docling-img` component. Selecting items will trim all non-selected items from view.
110
130
 
111
131
  #### Configure columns
132
+
112
133
  Select the columns that you want to have shown and in what order:
134
+
113
135
  ```html
114
- <docling-table src="conversion.json" columns="parsed,image" />
136
+ <docling-table src="conversion.json">
137
+ <docling-column>
138
+ <docling-item-text></docling-item-text>
139
+ <docling-item-table></docling-item-table>
140
+ </docling-column>
141
+ <docling-column>
142
+ <docling-item-provenance></docling-item-provenance>
143
+ </docling-column>
144
+ </docling-table>
115
145
  ```
116
146
 
117
147
  You can use this to display the cropped image of a single document item as well:
148
+
118
149
  ```html
119
- <docling-table src="conversion.json" columns="image" items="#/tables/2" />
150
+ <docling-table
151
+ src="conversion.json"
152
+ items="#/tables/2"
153
+ >
154
+ <docling-column>
155
+ <docling-item-provenance></docling-item-provenance>
156
+ </docling-column>
157
+ </docling-table>
158
+ ```
159
+
160
+ ## Item components
161
+ Most types of document item have a prepackaged component that will be used to visualize it:
162
+ | Tag | Item label |
163
+ | ---------- | ---------- |
164
+ | `<docling-item-text>` | checkbox_selected<br /> checkbox_unselected<br /> footnote<br /> page_footer<br /> page_header<br /> paragraph<br /> text<br /> reference |
165
+ | `<docling-item-table>` | table |
166
+
167
+ You can use these tags directly with elements like `<docling-tooltip>` to specify what components will be used, including optional parameters. For example, to exclusively show tooltips for table components:
168
+ ```
169
+ <docling-tooltip>
170
+ <docling-item-table></docling-item-table>
171
+ </docling-tooltip>
120
172
  ```
173
+
174
+ You can create your own item components by extending from the `DoclingItemElement` class at `/src/item/ItemElement.ts` and annotating the class with `@customDoclingItemElement('docling-my-first-item-component')` to have it registered as both a custom web element and as a default component for rendering document items.
175
+
176
+ ## Annotation components
177
+ Some types of document item annotation have a prepackaged component that will be used to visualize it:
178
+ | Tag | Item label | Annotation kind |
179
+ | ---------- | ---------- | --------------- |
180
+ | `<docling-picture-classification>` | chart <br /> picture | classification |
181
+ | `<docling-picture-description>` | chart <br /> picture | description |
182
+
183
+ You can use these tags directly with elements like `<docling-tooltip>` to specify what components will be used. For example, to overlay pictures with their classification, if any:
184
+ ```
185
+ <docling-overlay>
186
+ <docling-picture-classification></docling-picture-classification>
187
+ </docling-overlay>
188
+ ```
189
+
190
+ You can create your own annotation components by extending from the `DoclingAnnotationElement` class at `/src/annotation/AnnotationElement.ts` and annotating the class with `@customDoclingAnnotationElement('docling-my-first-annotation-component')` to have it registered as both a custom web element and as a default component for rendering document annotations.