@hamster-note/reader 0.2.0-beta.1
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/LICENSE +21 -0
- package/README.md +267 -0
- package/dist/components/IntermediateDocumentViewer/IntermediateDocumentPageContent.d.ts +40 -0
- package/dist/components/IntermediateDocumentViewer/IntermediateDocumentPageContent.d.ts.map +1 -0
- package/dist/components/IntermediateDocumentViewer/IntermediateDocumentViewer.d.ts +356 -0
- package/dist/components/IntermediateDocumentViewer/IntermediateDocumentViewer.d.ts.map +1 -0
- package/dist/components/IntermediateDocumentViewer/index.d.ts +7 -0
- package/dist/components/IntermediateDocumentViewer/index.d.ts.map +1 -0
- package/dist/components/IntermediateDocumentViewer/pageContentGeometry.d.ts +84 -0
- package/dist/components/IntermediateDocumentViewer/pageContentGeometry.d.ts.map +1 -0
- package/dist/components/IntermediateDocumentViewer/rangeJumpHelpers.d.ts +131 -0
- package/dist/components/IntermediateDocumentViewer/rangeJumpHelpers.d.ts.map +1 -0
- package/dist/components/IntermediateDocumentViewer/renderTiming.d.ts +44 -0
- package/dist/components/IntermediateDocumentViewer/renderTiming.d.ts.map +1 -0
- package/dist/components/IntermediateDocumentViewer/selectionAdapter.d.ts +25 -0
- package/dist/components/IntermediateDocumentViewer/selectionAdapter.d.ts.map +1 -0
- package/dist/components/IntermediateDocumentViewer/textSpanStyle.d.ts +4 -0
- package/dist/components/IntermediateDocumentViewer/textSpanStyle.d.ts.map +1 -0
- package/dist/components/IntermediateDocumentViewer/useLazyPageQueue.d.ts +73 -0
- package/dist/components/IntermediateDocumentViewer/useLazyPageQueue.d.ts.map +1 -0
- package/dist/components/IntermediateDocumentViewer.d.ts +2 -0
- package/dist/components/IntermediateDocumentViewer.d.ts.map +1 -0
- package/dist/components/PopoverPortal.d.ts +21 -0
- package/dist/components/PopoverPortal.d.ts.map +1 -0
- package/dist/components/Reader.d.ts +122 -0
- package/dist/components/Reader.d.ts.map +1 -0
- package/dist/components/gestureRouting.d.ts +73 -0
- package/dist/components/gestureRouting.d.ts.map +1 -0
- package/dist/components/selection/caretResolver.d.ts +33 -0
- package/dist/components/selection/caretResolver.d.ts.map +1 -0
- package/dist/components/selection/index.d.ts +2 -0
- package/dist/components/selection/index.d.ts.map +1 -0
- package/dist/components/selection/savedSelection.d.ts +71 -0
- package/dist/components/selection/savedSelection.d.ts.map +1 -0
- package/dist/components/selection/selectionComposer.d.ts +3 -0
- package/dist/components/selection/selectionComposer.d.ts.map +1 -0
- package/dist/components/selection/selectionPayloadSerializer.d.ts +21 -0
- package/dist/components/selection/selectionPayloadSerializer.d.ts.map +1 -0
- package/dist/components/selection/wordRange.d.ts +17 -0
- package/dist/components/selection/wordRange.d.ts.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2933 -0
- package/dist/style.css +323 -0
- package/dist/types/selection.d.ts +42 -0
- package/dist/types/selection.d.ts.map +1 -0
- package/dist/vendor/clipper-lib.d.ts +3 -0
- package/dist/vendor/clipper-lib.d.ts.map +1 -0
- package/package.json +99 -0
package/dist/style.css
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
/* dev 模式下 Vite 会通过 package export inline selection CSS;
|
|
3
|
+
lib build 时 scripts/build-styles.mjs 会解析同一个 export,移除此 @import 并追加真实 CSS,
|
|
4
|
+
保证发布的 @hamster-note/reader/style.css 是自包含的。 */
|
|
5
|
+
|
|
6
|
+
.hamster-reader {
|
|
7
|
+
display: block;
|
|
8
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
|
|
9
|
+
}
|
|
10
|
+
.hamster-reader__upload-zone {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
padding: 48px 24px;
|
|
16
|
+
border: 2px dashed #d1d5db;
|
|
17
|
+
border-radius: 12px;
|
|
18
|
+
background-color: #f9fafb;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
transition: all 0.2s ease;
|
|
21
|
+
width: 100%;
|
|
22
|
+
min-height: 200px;
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
}
|
|
25
|
+
.hamster-reader__upload-zone:hover {
|
|
26
|
+
border-color: #9ca3af;
|
|
27
|
+
background-color: #f3f4f6;
|
|
28
|
+
}
|
|
29
|
+
.hamster-reader__upload-zone:focus {
|
|
30
|
+
outline: none;
|
|
31
|
+
border-color: #3b82f6;
|
|
32
|
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
|
33
|
+
}
|
|
34
|
+
.hamster-reader__upload-zone--dragging {
|
|
35
|
+
border-color: #3b82f6;
|
|
36
|
+
background-color: #eff6ff;
|
|
37
|
+
border-style: solid;
|
|
38
|
+
}
|
|
39
|
+
.hamster-reader__file-input {
|
|
40
|
+
position: absolute;
|
|
41
|
+
width: 1px;
|
|
42
|
+
height: 1px;
|
|
43
|
+
padding: 0;
|
|
44
|
+
margin: -1px;
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
clip: rect(0, 0, 0, 0);
|
|
47
|
+
white-space: nowrap;
|
|
48
|
+
border: 0;
|
|
49
|
+
}
|
|
50
|
+
.hamster-reader__upload-content {
|
|
51
|
+
display: flex;
|
|
52
|
+
flex-direction: column;
|
|
53
|
+
align-items: center;
|
|
54
|
+
gap: 12px;
|
|
55
|
+
}
|
|
56
|
+
.hamster-reader__upload-icon {
|
|
57
|
+
width: 48px;
|
|
58
|
+
height: 48px;
|
|
59
|
+
color: #6b7280;
|
|
60
|
+
}
|
|
61
|
+
.hamster-reader__upload-text {
|
|
62
|
+
margin: 0;
|
|
63
|
+
font-size: 16px;
|
|
64
|
+
font-weight: 500;
|
|
65
|
+
color: #374151;
|
|
66
|
+
}
|
|
67
|
+
.hamster-reader__upload-hint {
|
|
68
|
+
margin: 0;
|
|
69
|
+
font-size: 14px;
|
|
70
|
+
color: #9ca3af;
|
|
71
|
+
}
|
|
72
|
+
.hamster-reader__content {
|
|
73
|
+
font-size: 16px;
|
|
74
|
+
color: #374151;
|
|
75
|
+
height: 100%;
|
|
76
|
+
box-sizing: border-box;
|
|
77
|
+
}
|
|
78
|
+
.hamster-reader__file-info {
|
|
79
|
+
display: flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
gap: 16px;
|
|
82
|
+
padding: 16px;
|
|
83
|
+
border: 1px solid #e5e7eb;
|
|
84
|
+
border-radius: 8px;
|
|
85
|
+
background-color: #ffffff;
|
|
86
|
+
}
|
|
87
|
+
.hamster-reader__file-icon {
|
|
88
|
+
width: 40px;
|
|
89
|
+
height: 40px;
|
|
90
|
+
color: #3b82f6;
|
|
91
|
+
flex-shrink: 0;
|
|
92
|
+
}
|
|
93
|
+
.hamster-reader__file-details {
|
|
94
|
+
flex: 1;
|
|
95
|
+
min-width: 0;
|
|
96
|
+
}
|
|
97
|
+
.hamster-reader__file-name {
|
|
98
|
+
margin: 0;
|
|
99
|
+
font-size: 14px;
|
|
100
|
+
font-weight: 500;
|
|
101
|
+
color: #111827;
|
|
102
|
+
white-space: nowrap;
|
|
103
|
+
overflow: hidden;
|
|
104
|
+
text-overflow: ellipsis;
|
|
105
|
+
}
|
|
106
|
+
.hamster-reader__file-meta {
|
|
107
|
+
margin: 4px 0 0;
|
|
108
|
+
font-size: 12px;
|
|
109
|
+
color: #6b7280;
|
|
110
|
+
}
|
|
111
|
+
.hamster-reader__upload-another {
|
|
112
|
+
padding: 8px 16px;
|
|
113
|
+
font-size: 14px;
|
|
114
|
+
font-weight: 500;
|
|
115
|
+
color: #3b82f6;
|
|
116
|
+
background-color: #eff6ff;
|
|
117
|
+
border: 1px solid #dbeafe;
|
|
118
|
+
border-radius: 6px;
|
|
119
|
+
cursor: pointer;
|
|
120
|
+
transition: all 0.2s ease;
|
|
121
|
+
white-space: nowrap;
|
|
122
|
+
}
|
|
123
|
+
.hamster-reader__upload-another:hover {
|
|
124
|
+
background-color: #dbeafe;
|
|
125
|
+
border-color: #bfdbfe;
|
|
126
|
+
}
|
|
127
|
+
.hamster-reader__upload-another:focus {
|
|
128
|
+
outline: none;
|
|
129
|
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
|
130
|
+
}
|
|
131
|
+
.hamster-reader__intermediate-document-viewer {
|
|
132
|
+
position: relative;
|
|
133
|
+
display: flex;
|
|
134
|
+
flex-direction: column;
|
|
135
|
+
align-items: center;
|
|
136
|
+
gap: 16px;
|
|
137
|
+
overflow: hidden;
|
|
138
|
+
box-sizing: border-box;
|
|
139
|
+
height: var(--hamster-reader-viewer-height, 100vh);
|
|
140
|
+
max-height: var(--hamster-reader-viewer-max-height, 100vh);
|
|
141
|
+
scroll-behavior: smooth;
|
|
142
|
+
}
|
|
143
|
+
.hamster-reader__intermediate-document-viewer .virtual-paper-wrapper {
|
|
144
|
+
flex: 1 1 auto;
|
|
145
|
+
width: 100%;
|
|
146
|
+
min-height: 0;
|
|
147
|
+
touch-action: none;
|
|
148
|
+
}
|
|
149
|
+
.hamster-reader__html-parser-output {
|
|
150
|
+
width: 100%;
|
|
151
|
+
box-sizing: border-box;
|
|
152
|
+
}
|
|
153
|
+
.hamster-reader__html-parser-output .hamster-note-document {
|
|
154
|
+
position: relative;
|
|
155
|
+
display: block;
|
|
156
|
+
contain: layout style;
|
|
157
|
+
width: 100%;
|
|
158
|
+
}
|
|
159
|
+
.hamster-reader__html-parser-output .hamster-note-page {
|
|
160
|
+
position: relative;
|
|
161
|
+
overflow: visible;
|
|
162
|
+
background-repeat: no-repeat;
|
|
163
|
+
background-position: top center;
|
|
164
|
+
background-size: contain;
|
|
165
|
+
}
|
|
166
|
+
.hamster-reader__html-parser-output .hamster-note-text {
|
|
167
|
+
position: absolute;
|
|
168
|
+
white-space: pre;
|
|
169
|
+
transform-origin: 0 0;
|
|
170
|
+
}
|
|
171
|
+
.hamster-reader__html-parser-output .hamster-note-image {
|
|
172
|
+
position: absolute;
|
|
173
|
+
}
|
|
174
|
+
.hamster-reader__html-parser-output {
|
|
175
|
+
user-select: text;
|
|
176
|
+
-webkit-user-select: text;
|
|
177
|
+
}
|
|
178
|
+
.hamster-reader__html-parser-output .hamster-note-page,
|
|
179
|
+
.hamster-reader__html-parser-output .hamster-note-page * {
|
|
180
|
+
user-select: text;
|
|
181
|
+
-webkit-user-select: text;
|
|
182
|
+
}
|
|
183
|
+
.hamster-reader__intermediate-page {
|
|
184
|
+
position: relative;
|
|
185
|
+
box-sizing: border-box;
|
|
186
|
+
background-color: #ffffff;
|
|
187
|
+
outline: 1px solid #e5e7eb;
|
|
188
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
189
|
+
overflow: hidden;
|
|
190
|
+
flex-shrink: 0;
|
|
191
|
+
user-select: none;
|
|
192
|
+
-webkit-user-select: none;
|
|
193
|
+
}
|
|
194
|
+
.hamster-reader__intermediate-page--loading {
|
|
195
|
+
background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
|
|
196
|
+
background-size: 200% 100%;
|
|
197
|
+
animation: skeleton-shimmer 1.5s ease-in-out infinite;
|
|
198
|
+
}
|
|
199
|
+
.hamster-reader__intermediate-page-status {
|
|
200
|
+
position: absolute;
|
|
201
|
+
inset: 0;
|
|
202
|
+
display: flex;
|
|
203
|
+
align-items: center;
|
|
204
|
+
justify-content: center;
|
|
205
|
+
padding: 24px;
|
|
206
|
+
box-sizing: border-box;
|
|
207
|
+
color: #6b7280;
|
|
208
|
+
font-size: 14px;
|
|
209
|
+
text-align: center;
|
|
210
|
+
}
|
|
211
|
+
.hamster-reader__intermediate-page-status--error {
|
|
212
|
+
color: #b91c1c;
|
|
213
|
+
background-color: #fef2f2;
|
|
214
|
+
}
|
|
215
|
+
.hamster-reader__intermediate-page-base-image {
|
|
216
|
+
position: absolute;
|
|
217
|
+
inset: 0;
|
|
218
|
+
width: 100%;
|
|
219
|
+
height: 100%;
|
|
220
|
+
object-fit: fill;
|
|
221
|
+
user-select: none;
|
|
222
|
+
-webkit-user-select: none;
|
|
223
|
+
-webkit-touch-callout: none;
|
|
224
|
+
pointer-events: none;
|
|
225
|
+
z-index: 0;
|
|
226
|
+
}
|
|
227
|
+
.hamster-reader__intermediate-text {
|
|
228
|
+
position: absolute;
|
|
229
|
+
display: inline-block;
|
|
230
|
+
white-space: pre;
|
|
231
|
+
box-sizing: border-box;
|
|
232
|
+
user-select: text;
|
|
233
|
+
-webkit-user-select: text;
|
|
234
|
+
z-index: 1;
|
|
235
|
+
}
|
|
236
|
+
.hamster-reader .hsn-selection-percent-overlay {
|
|
237
|
+
mix-blend-mode: multiply;
|
|
238
|
+
opacity: 1;
|
|
239
|
+
}
|
|
240
|
+
.hamster-reader .hsn-selection-rect--highlight {
|
|
241
|
+
mix-blend-mode: multiply;
|
|
242
|
+
}
|
|
243
|
+
.hamster-reader .hsn-selection-container,
|
|
244
|
+
.hamster-reader .hsn-selection-content {
|
|
245
|
+
height: 100%;
|
|
246
|
+
}
|
|
247
|
+
@media (pointer: coarse) {
|
|
248
|
+
.hamster-reader__intermediate-text, .hsn-selection-content .hamster-reader__intermediate-text, .hamster-reader__html-parser-output, .hamster-reader__html-parser-output .hamster-note-page, .hamster-reader__html-parser-output .hamster-note-page * {
|
|
249
|
+
user-select: none;
|
|
250
|
+
-webkit-user-select: none;
|
|
251
|
+
-webkit-touch-callout: none;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
@keyframes skeleton-shimmer {
|
|
256
|
+
0% {
|
|
257
|
+
background-position: 200% 0;
|
|
258
|
+
}
|
|
259
|
+
100% {
|
|
260
|
+
background-position: -200% 0;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
.hamster-demo-shell {
|
|
264
|
+
display: flex;
|
|
265
|
+
width: 100vw;
|
|
266
|
+
height: 100vh;
|
|
267
|
+
overflow: hidden;
|
|
268
|
+
box-sizing: border-box;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.hamster-demo-sidebar {
|
|
272
|
+
width: 300px;
|
|
273
|
+
background-color: #f9fafb; /* gray-50 */
|
|
274
|
+
border-right: 1px solid #e5e7eb;
|
|
275
|
+
overflow-y: auto;
|
|
276
|
+
flex-shrink: 0;
|
|
277
|
+
display: flex;
|
|
278
|
+
flex-direction: column;
|
|
279
|
+
padding: 16px;
|
|
280
|
+
box-sizing: border-box;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.hamster-demo-main {
|
|
284
|
+
flex: 1;
|
|
285
|
+
display: flex;
|
|
286
|
+
flex-direction: column;
|
|
287
|
+
width: 100%;
|
|
288
|
+
height: 100%;
|
|
289
|
+
min-width: 0;
|
|
290
|
+
}
|
|
291
|
+
.hamster-demo-main .hamster-reader {
|
|
292
|
+
height: 100%;
|
|
293
|
+
width: 100%;
|
|
294
|
+
display: flex;
|
|
295
|
+
flex-direction: column;
|
|
296
|
+
}
|
|
297
|
+
.hamster-demo-main .hamster-reader__upload-zone {
|
|
298
|
+
flex: 1;
|
|
299
|
+
height: 100%;
|
|
300
|
+
min-height: 0;
|
|
301
|
+
}
|
|
302
|
+
.hamster-demo-main .hamster-reader__intermediate-document-viewer {
|
|
303
|
+
height: 100%;
|
|
304
|
+
max-height: 100%;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.hamster-demo-action-group {
|
|
308
|
+
display: flex;
|
|
309
|
+
flex-direction: row;
|
|
310
|
+
gap: 8px;
|
|
311
|
+
align-items: center;
|
|
312
|
+
}
|
|
313
|
+
.hamster-demo-action-group button:hover {
|
|
314
|
+
background-color: #f3f4f6 !important; /* overrides inline styles for hover */
|
|
315
|
+
}
|
|
316
|
+
.hamster-demo-action-group button:focus-visible {
|
|
317
|
+
outline: none;
|
|
318
|
+
box-shadow: 0 0 0 2px #3b82f6;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/* @hamster-note/selection/style.css */
|
|
322
|
+
.hsn-selection-container{cursor:text;word-break:break-word;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;touch-action:manipulation;line-height:1.8;position:relative}.hsn-selection-content{z-index:1;-webkit-user-select:text;user-select:text;-webkit-touch-callout:none;touch-action:manipulation;position:relative}@media (pointer:coarse){.hsn-selection-content{-webkit-user-select:none;user-select:none}}.hsn-selection-content::selection{color:inherit;background:0 0}.hsn-selection-content ::selection{color:inherit;background:0 0}.hsn-selection-content::-moz-selection{color:inherit;background:0 0}.hsn-selection-content ::-moz-selection{color:inherit;background:0 0}.hsn-selection-overlay{pointer-events:none;z-index:2;width:100%;height:100%;position:absolute;inset:0;overflow:visible}.hsn-selection-rect{pointer-events:none;transition:fill .15s}.hsn-selection-rect--highlight{fill:#ffd54f66}.hsn-selection-rect--selected{fill:#ffc1078c;stroke:#ff9800e6;stroke-width:1.5px}.hsn-selection-rect--active{fill:#ff69b473}.hsn-selection-percent-overlay{pointer-events:none;z-index:2;width:100%;height:100%;position:absolute;inset:0;overflow:visible}.hsn-selection-percent-rect{pointer-events:none;border-radius:2px;transition:background-color .15s,border-color .15s,opacity .15s,transform .15s;position:absolute}.hsn-selection-percent-rect-highlight{background-color:#ffd54f66}.hsn-selection-percent-rect-selected{background-color:#ffc1078c;border:1.5px solid #ff9800e6}.hsn-selection-percent-rect-active{background-color:#ff69b473}.hsn-selection-popover{z-index:3;pointer-events:auto;-webkit-user-select:none;user-select:none;margin-top:-6px;position:absolute;transform:translate(-50%,-100%)}.hsn-selection-toolbar{z-index:1000;-webkit-user-select:none;user-select:none;background:#2d2d2d;border-radius:6px;align-items:center;gap:4px;padding:4px 8px;display:inline-flex;position:absolute;transform:translate(-50%);box-shadow:0 2px 8px #00000026,0 0 1px #0003}.hsn-selection-toolbar-btn{color:#fff;cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:4px;padding:2px 8px;font-size:13px}.hsn-selection-toolbar-btn:hover{background:#ffffff26}.hsn-selection-handle{z-index:4;cursor:ew-resize;pointer-events:auto;-webkit-user-select:none;user-select:none;touch-action:none;background:#ff4fa3;border:2px solid #fff;border-radius:50%;width:12px;height:12px;margin:0;padding:0;position:absolute;transform:translate(-50%,-50%);box-shadow:0 1px 4px #00000040}.hsn-selection-handle:focus{outline:none}.hsn-selection-handle--dragging{pointer-events:none}
|
|
323
|
+
/*$vite$:1*/
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { LinkedSelectionData, LinkedSelectionRange, MousePosition, OverlayRect, OverlayRectType, SelectionEndpoint } from '@hamster-note/selection';
|
|
2
|
+
/**
|
|
3
|
+
* Reader 公开 linked selection 端点。
|
|
4
|
+
*
|
|
5
|
+
* `selectionId` 只使用稳定的公开页面 ID(例如 `page-2`)。Reader 后续在
|
|
6
|
+
* 运行时传给 @hamster-note/selection 的 scoped ID 是内部 adapter 细节,
|
|
7
|
+
* 不能出现在这个公开类型、回调 payload 或持久化数据里。
|
|
8
|
+
*/
|
|
9
|
+
export type ReaderSelectionEndpoint = SelectionEndpoint;
|
|
10
|
+
/** Reader 公开 selection 矩形;linked ranges 按页面 ID 分组保存这些矩形。 */
|
|
11
|
+
export type ReaderSelectionRect = OverlayRect;
|
|
12
|
+
export type ReaderLinkedSelectionRange = Omit<LinkedSelectionRange, 'start' | 'end' | 'rectsBySelectionId'> & {
|
|
13
|
+
start: ReaderSelectionEndpoint;
|
|
14
|
+
end: ReaderSelectionEndpoint;
|
|
15
|
+
rectsBySelectionId: Record<string, ReaderSelectionRect[]>;
|
|
16
|
+
};
|
|
17
|
+
/** html-parser highlight API 的公开 range 契约:只接受 linked/page-scoped 形状。 */
|
|
18
|
+
export type ReaderSelectionRange = ReaderLinkedSelectionRange & {
|
|
19
|
+
readonly __readerSelectionRangeBrand?: never;
|
|
20
|
+
};
|
|
21
|
+
export type ReaderLinkedSelectionData = Omit<LinkedSelectionData, 'items' | 'activeRange'> & {
|
|
22
|
+
items: ReaderLinkedSelectionRange[];
|
|
23
|
+
activeRange?: ReaderLinkedSelectionRange | null;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Reader 公开 selection ref 接口。
|
|
27
|
+
*
|
|
28
|
+
* 由 Reader 自己实现,不是上游 @hamster-note/selection 的 `SelectionRef`。
|
|
29
|
+
* Reader 在内部将 `highlight()` / `clear()` 分发到各页面的上游
|
|
30
|
+
* `SelectionRef`,并新增 `scrollToRange()` 来滚动到指定 range。
|
|
31
|
+
*/
|
|
32
|
+
export interface ReaderSelectionRef {
|
|
33
|
+
/** 执行高亮:将当前用户选中的文本确认为一个持久高亮 range。 */
|
|
34
|
+
highlight: () => void;
|
|
35
|
+
/** 清除所有页面的高亮和选区状态。 */
|
|
36
|
+
clear: () => void;
|
|
37
|
+
/** 滚动视图到指定 range(按 range id 查找)。实现细节留给 Reader 内部。 */
|
|
38
|
+
scrollToRange: (id: string) => void;
|
|
39
|
+
}
|
|
40
|
+
export type ReaderMousePosition = MousePosition;
|
|
41
|
+
export type ReaderSelectionOverlayRectType = OverlayRectType;
|
|
42
|
+
//# sourceMappingURL=selection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../../src/types/selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,eAAe,EACf,iBAAiB,EAClB,MAAM,yBAAyB,CAAA;AAEhC;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,CAAA;AAEvD,4DAA4D;AAC5D,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAA;AAE7C,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,oBAAoB,EACpB,OAAO,GAAG,KAAK,GAAG,oBAAoB,CACvC,GAAG;IACF,KAAK,EAAE,uBAAuB,CAAA;IAC9B,GAAG,EAAE,uBAAuB,CAAA;IAC5B,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAA;CAC1D,CAAA;AAED,wEAAwE;AACxE,MAAM,MAAM,oBAAoB,GAAG,0BAA0B,GAAG;IAC9D,QAAQ,CAAC,2BAA2B,CAAC,EAAE,KAAK,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,mBAAmB,EACnB,OAAO,GAAG,aAAa,CACxB,GAAG;IACF,KAAK,EAAE,0BAA0B,EAAE,CAAA;IACnC,WAAW,CAAC,EAAE,0BAA0B,GAAG,IAAI,CAAA;CAChD,CAAA;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB,sBAAsB;IACtB,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,qDAAqD;IACrD,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;CACpC;AACD,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAA;AAC/C,MAAM,MAAM,8BAA8B,GAAG,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clipper-lib.d.ts","sourceRoot":"","sources":["../../src/vendor/clipper-lib.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,UAAU,KAA6C,CAAA;AAM7D,eAAe,UAAU,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hamster-note/reader",
|
|
3
|
+
"version": "0.2.0-beta.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./style.css": "./dist/style.css"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/HamsterNote/reader.git"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/HamsterNote/reader#readme",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/HamsterNote/reader/issues"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"dev": "vite",
|
|
30
|
+
"build:lib": "yarn build:lib:js && yarn build:lib:types && yarn build:lib:styles",
|
|
31
|
+
"build:lib:js": "vite build --config vite.lib.config.ts",
|
|
32
|
+
"build:lib:types": "tsc --project tsconfig.build.json",
|
|
33
|
+
"build:lib:styles": "node scripts/build-styles.mjs",
|
|
34
|
+
"build:demo": "vite build",
|
|
35
|
+
"build:all": "yarn build:lib && yarn build:demo",
|
|
36
|
+
"build": "yarn build:all",
|
|
37
|
+
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
38
|
+
"lint": "eslint .",
|
|
39
|
+
"test": "vitest",
|
|
40
|
+
"test:run": "vitest run",
|
|
41
|
+
"preview": "vite preview",
|
|
42
|
+
"prepublishOnly": "yarn build:lib",
|
|
43
|
+
"pack:check": "node scripts/check-pack.mjs"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@hamster-note/docx-parser": "^0.1.0",
|
|
47
|
+
"@hamster-note/html-parser": "0.9.0-beta",
|
|
48
|
+
"@hamster-note/image-parser": "^0.3.0",
|
|
49
|
+
"@hamster-note/markdown-parser": "0.1.2-beta.2",
|
|
50
|
+
"@hamster-note/pdf-parser": "^1.0.0",
|
|
51
|
+
"@hamster-note/txt-parser": "^0.3.0",
|
|
52
|
+
"@hamster-note/types": "^0.8.0",
|
|
53
|
+
"@hamster-note/virtual-paper": "0.1.0-beta.2",
|
|
54
|
+
"@system-ui-js/multi-drag": "^0.4.0"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"@hamster-note/selection": "0.0.2-beta.1",
|
|
58
|
+
"react": "^19.0.0",
|
|
59
|
+
"react-dom": "^19.0.0"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@eslint/js": "^9.39.2",
|
|
63
|
+
"@hamster-note/selection": "0.0.2-beta.1",
|
|
64
|
+
"@system-ui-js/development-base": "^0.1.2",
|
|
65
|
+
"@testing-library/dom": "^10.0.0",
|
|
66
|
+
"@testing-library/jest-dom": "^6.0.0",
|
|
67
|
+
"@testing-library/react": "^16.0.0",
|
|
68
|
+
"@testing-library/user-event": "^14.0.0",
|
|
69
|
+
"@types/node": "^25.6.0",
|
|
70
|
+
"@types/react": "^19.0.0",
|
|
71
|
+
"@types/react-dom": "^19.0.0",
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^8.50.0",
|
|
73
|
+
"@typescript-eslint/parser": "^8.50.0",
|
|
74
|
+
"@vitejs/plugin-react": "^5.0.0",
|
|
75
|
+
"eslint": "^9.39.2",
|
|
76
|
+
"eslint-config-prettier": "^10.1.8",
|
|
77
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
78
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
79
|
+
"eslint-plugin-react": "^7.37.5",
|
|
80
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
81
|
+
"eslint-plugin-sonarjs": "^4.0.3",
|
|
82
|
+
"globals": "^15.14.0",
|
|
83
|
+
"jsdom": "^27.0.0",
|
|
84
|
+
"prettier": "^3.7.4",
|
|
85
|
+
"prettier-config-standard": "^7.0.0",
|
|
86
|
+
"react": "^19.0.0",
|
|
87
|
+
"react-dom": "^19.0.0",
|
|
88
|
+
"sass": "^1.0.0",
|
|
89
|
+
"typescript": "^5.0.2",
|
|
90
|
+
"typescript-eslint": "^8.50.0",
|
|
91
|
+
"vite": "^7.0.0",
|
|
92
|
+
"vitest": "^3.0.0"
|
|
93
|
+
},
|
|
94
|
+
"publishConfig": {
|
|
95
|
+
"access": "public",
|
|
96
|
+
"registry": "https://registry.npmjs.org/"
|
|
97
|
+
},
|
|
98
|
+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
99
|
+
}
|