@docvyu/sdk 0.0.5 → 0.1.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/README.md +174 -209
- package/dist/cdn/docvyu.js +5060 -0
- package/dist/cdn/docvyu.min.js +10 -4
- package/dist/cjs/DocvyuEditor-BOTw6i4d.js +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/react/index.js +1 -1
- package/dist/esm/DocvyuEditor-CDLqMpaq.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/react/index.js +1 -1
- package/dist/types/app/DocvyuApp.d.ts +187 -0
- package/dist/types/app/index.d.ts +0 -2
- package/dist/types/core/DocvyuEditor.d.ts +409 -57
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/i18n/types.d.ts +131 -0
- package/dist/types/index.d.ts +19 -5
- package/dist/types/react/index.d.ts +2 -1
- package/dist/wasm/docvyu_core.d.ts +8 -182
- package/dist/wasm/docvyu_core.js +1 -1
- package/dist/wasm/docvyu_core_bg.wasm +0 -0
- package/dist/wasm/docvyu_core_bg.wasm.d.ts +0 -56
- package/package.json +2 -2
- package/wasm/docvyu_core.d.ts +8 -182
- package/wasm/docvyu_core.js +1297 -200
- package/wasm/docvyu_core_bg.wasm +0 -0
- package/wasm/docvyu_core_bg.wasm.d.ts +0 -56
- package/dist/cjs/DocvyuEditor-Bh9EkDQb.js +0 -1
- package/dist/esm/DocvyuEditor-DlUB7weZ.js +0 -1
- package/dist/types/app/DocvyuApp.test.d.ts +0 -1
- package/dist/types/app/styles.d.ts +0 -10
- package/dist/types/app/template.d.ts +0 -9
- package/dist/types/core/DocvyuEditor.test.d.ts +0 -4
- package/dist/types/i18n/I18nManager.test.d.ts +0 -4
- package/dist/types/license/LicenseManager.test.d.ts +0 -4
- package/dist/wasm/docuweave_core.d.ts +0 -207
- package/dist/wasm/docuweave_core.js +0 -988
- package/dist/wasm/docuweave_core_bg.wasm +0 -0
- package/dist/wasm/docuweave_core_bg.wasm.d.ts +0 -59
package/dist/esm/react/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{createContext as t,forwardRef as n,useRef as r,useState as a,useEffect as s,useCallback as l,useImperativeHandle as i,useContext as c}from"react";import{o as u,s as d,t as m,D as g,
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{createContext as t,forwardRef as n,useRef as r,useState as a,useEffect as s,useCallback as l,useImperativeHandle as i,useContext as c}from"react";import{o as u,s as d,t as m,D as g,g as f}from"../DocvyuEditor-CDLqMpaq.js";const v=t({editor:null,isReady:!1,licenseInfo:null,selectionState:null,locale:"en",setLocale:()=>{},t:e=>e});function w(){const e=c(v);if(!e)throw new Error("useDocvyu must be used within a DocvyuEditorProvider");return e}const L=n(function(t,n){const{apiKey:c,licenseServerUrl:f,offlineMode:w,zoom:L,rulerUnit:y,locale:h,autoDetectLocale:S,customTranslations:b,onLocaleChange:D,className:p,style:E,onReady:z,onLoad:C,onSave:U,onSelectionChange:N,onLicenseChange:k,onUsageLimitExceeded:A,onError:F,wasmInit:I,EditorClass:M}=t,B=r(null),x=r(null),[R,P]=a(!1),[j,K]=a(null),[T,O]=a(null),[Z,$]=a(h||"en");s(()=>u(e=>{$(e),D?.(e)}),[D]);const q=l(e=>{d(e),$(e)},[]);s(()=>{if(B.current&&!x.current)return(async()=>{try{const e=new g({canvas:B.current,apiKey:c,licenseServerUrl:f,offlineMode:w,zoom:L,rulerUnit:y,locale:h,autoDetectLocale:S,customTranslations:b,onLocaleChange:D,onLoad:C,onSave:U,onSelectionChange:e=>{O(e),N?.(e)},onLicenseChange:e=>{K(e),k?.(e)},onUsageLimitExceeded:A}),o=await e.initialize(I,M);x.current=e,K(o),P(!0),z?.(e)}catch(e){F?.(e)}})(),()=>{x.current?.destroy(),x.current=null,P(!1)}},[]);const G=l(e=>{if(!x.current||!B.current)return;const o=B.current.getBoundingClientRect();x.current.handleMouseClick(e.clientX-o.left,e.clientY-o.top)},[]),H=l(e=>{if(!x.current||!B.current||1!==e.buttons)return;const o=B.current.getBoundingClientRect();x.current.handleMouseDrag(e.clientX-o.left,e.clientY-o.top)},[]);return s(()=>{const e=e=>{if(!x.current)return;if(e.ctrlKey||e.metaKey)switch(e.key.toLowerCase()){case"b":e.preventDefault();const o=x.current.getSelectionState();return void x.current.setBold(!o.bold);case"i":e.preventDefault();const t=x.current.getSelectionState();return void x.current.setItalic(!t.italic);case"u":e.preventDefault();const n=x.current.getSelectionState();return void x.current.setUnderline(!n.underline);case"s":return e.preventDefault(),void x.current.downloadDocument()}const o=new Set(["Backspace","Delete","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]);(1===e.key.length||o.has(e.key))&&(e.preventDefault(),x.current.handleKeyDown(e.key))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),i(n,()=>({editor:x.current,loadDocument:e=>{x.current?.loadDocument(e)},saveDocument:()=>x.current?.saveDocument()??null,downloadDocument:e=>{x.current?.downloadDocument(e)},setLocale:q,getLocale:()=>Z}),[R,Z,q]),e(v.Provider,{value:{editor:x.current,isReady:R,licenseInfo:j,selectionState:T,locale:Z,setLocale:q,t:m},children:o("div",{className:`docvyu-container ${p||""}`,style:E,children:[e("canvas",{ref:B,onMouseDown:G,onMouseMove:H,style:{display:"block"},"aria-label":m("accessibility.editorLabel")}),j?.watermark&&e("div",{className:"docvyu-watermark",children:m("watermark.poweredBy")})]})})});function y(){const{editor:e,selectionState:o}=w(),t=l(()=>{e&&o&&e.setBold(!o.bold)},[e,o]),n=l(()=>{e&&o&&e.setItalic(!o.italic)},[e,o]),r=l(()=>{e&&o&&e.setUnderline(!o.underline)},[e,o]),a=l(o=>{e?.setFontSize(o)},[e]),s=l(o=>{e?.setFontFamily(o)},[e]),i=l(o=>{e?.setFontColor(o)},[e]),c=l(o=>{e?.setAlignment(o)},[e]);return{state:o,toggleBold:t,toggleItalic:n,toggleUnderline:r,setFontSize:a,setFontFamily:s,setFontColor:i,setAlignment:c}}function h(){const{editor:e,selectionState:o}=w(),t=l(()=>{e&&o&&e.setBulletList(!o.hasBulletList)},[e,o]),n=l(()=>{e&&o&&e.setNumberedList(!o.hasNumberedList)},[e,o]),r=l(o=>{e?.setNumberedListFormat(o)},[e]),a=l(()=>{e?.removeNumbering()},[e]);return{hasBulletList:o?.hasBulletList??!1,hasNumberedList:o?.hasNumberedList??!1,numberingFormatId:o?.numberingFormatId,toggleBulletList:t,toggleNumberedList:n,setNumberingFormat:r,removeNumbering:a}}function S(){const{editor:e}=w();return{setMargins:l(o=>{e?.setMargins(o)},[e]),setPageSize:l(o=>{e?.setPageSize(o)},[e]),getPageSize:l(()=>e?.getPageSize()??"letter",[e])}}function b(){const{editor:e}=w(),[o,t]=a(1),n=l(o=>{e?.setZoom(o),t(o)},[e]),r=l(()=>{e?.zoomIn(),t(e?.getZoom()??1)},[e]),i=l(()=>{e?.zoomOut(),t(e?.getZoom()??1)},[e]);return s(()=>{e&&t(e.getZoom())},[e]),{zoom:o,setZoom:n,zoomIn:r,zoomOut:i}}function D(){const{locale:e,setLocale:o,t:t}=w(),[n]=a(f());return{locale:e,setLocale:o,t:t,availableLocales:n,isLocaleAvailable:e=>n.includes(e)}}export{L as DocvyuEditor,L as DocvyuEditorComponent,L as default,w as useDocvyu,D as useDocvyuI18n,y as useEditorFormatting,h as useEditorLists,S as useEditorPageSettings,b as useEditorZoom};
|
|
@@ -50,11 +50,21 @@ export declare class DocvyuApp {
|
|
|
50
50
|
private editor;
|
|
51
51
|
private currentFileName;
|
|
52
52
|
private licenseInfo;
|
|
53
|
+
private copiedFormat;
|
|
54
|
+
private lastKnownSelectionFormat;
|
|
53
55
|
private elements;
|
|
54
56
|
private isMouseDown;
|
|
57
|
+
private isDraggingImage;
|
|
55
58
|
private multiClickCount;
|
|
56
59
|
private multiClickResetId;
|
|
57
60
|
private readonly MULTI_CLICK_RESET_MS;
|
|
61
|
+
private boundHandleMouseDown;
|
|
62
|
+
private boundHandleMouseMove;
|
|
63
|
+
private boundHandleMouseUp;
|
|
64
|
+
private boundHandleKeyDown;
|
|
65
|
+
private boundHandleDocumentClick;
|
|
66
|
+
private boundHandleContextMenu;
|
|
67
|
+
private boundHandleScroll;
|
|
58
68
|
constructor(config: DocvyuAppConfig);
|
|
59
69
|
/**
|
|
60
70
|
* Initialize the editor with WASM module
|
|
@@ -64,8 +74,14 @@ export declare class DocvyuApp {
|
|
|
64
74
|
init(wasmInit: () => Promise<any>, EditorClass: any): Promise<void>;
|
|
65
75
|
/**
|
|
66
76
|
* Cache DOM element references
|
|
77
|
+
* Validates that critical elements exist and provides helpful error messages
|
|
67
78
|
*/
|
|
68
79
|
private cacheElements;
|
|
80
|
+
/**
|
|
81
|
+
* Validates that critical DOM elements exist
|
|
82
|
+
* Throws descriptive errors if required elements are missing
|
|
83
|
+
*/
|
|
84
|
+
private validateCriticalElements;
|
|
69
85
|
/**
|
|
70
86
|
* Attach all event listeners
|
|
71
87
|
*/
|
|
@@ -74,14 +90,30 @@ export declare class DocvyuApp {
|
|
|
74
90
|
* Handle mouse down on canvas
|
|
75
91
|
*/
|
|
76
92
|
private handleMouseDown;
|
|
93
|
+
/**
|
|
94
|
+
* Open a hyperlink URL
|
|
95
|
+
*/
|
|
96
|
+
private openHyperlink;
|
|
77
97
|
/**
|
|
78
98
|
* Handle mouse move on canvas
|
|
79
99
|
*/
|
|
80
100
|
private handleMouseMove;
|
|
101
|
+
/**
|
|
102
|
+
* Update hyperlink tooltip visibility and position
|
|
103
|
+
*/
|
|
104
|
+
private updateHyperlinkTooltip;
|
|
105
|
+
/**
|
|
106
|
+
* Escape HTML characters for safe display
|
|
107
|
+
*/
|
|
108
|
+
private escapeHtml;
|
|
81
109
|
/**
|
|
82
110
|
* Handle mouse up
|
|
83
111
|
*/
|
|
84
112
|
private handleMouseUp;
|
|
113
|
+
/**
|
|
114
|
+
* Handle scroll events for viewport-aware rendering
|
|
115
|
+
*/
|
|
116
|
+
private handleScroll;
|
|
85
117
|
/**
|
|
86
118
|
* Handle keyboard input
|
|
87
119
|
*/
|
|
@@ -110,6 +142,14 @@ export declare class DocvyuApp {
|
|
|
110
142
|
* Handle document click to close popovers
|
|
111
143
|
*/
|
|
112
144
|
private handleDocumentClick;
|
|
145
|
+
/**
|
|
146
|
+
* Handle right-click context menu
|
|
147
|
+
*/
|
|
148
|
+
private handleContextMenu;
|
|
149
|
+
/**
|
|
150
|
+
* Handle context menu action clicks
|
|
151
|
+
*/
|
|
152
|
+
private handleContextMenuAction;
|
|
113
153
|
/**
|
|
114
154
|
* Handle file selection
|
|
115
155
|
*/
|
|
@@ -118,6 +158,84 @@ export declare class DocvyuApp {
|
|
|
118
158
|
* Toggle a text style
|
|
119
159
|
*/
|
|
120
160
|
private toggleStyle;
|
|
161
|
+
private toggleStrikethrough;
|
|
162
|
+
/**
|
|
163
|
+
* Copy selected text to clipboard
|
|
164
|
+
*/
|
|
165
|
+
private copyText;
|
|
166
|
+
/**
|
|
167
|
+
* Cut selected text to clipboard
|
|
168
|
+
*/
|
|
169
|
+
private cutText;
|
|
170
|
+
/**
|
|
171
|
+
* Paste text from clipboard
|
|
172
|
+
*/
|
|
173
|
+
private pasteText;
|
|
174
|
+
/**
|
|
175
|
+
* Copy format from current cursor position or start of selection
|
|
176
|
+
*/
|
|
177
|
+
private copyFormat;
|
|
178
|
+
/**
|
|
179
|
+
* Apply copied format to current selection
|
|
180
|
+
*/
|
|
181
|
+
private applyFormat;
|
|
182
|
+
/**
|
|
183
|
+
* Update format painter button state
|
|
184
|
+
*/
|
|
185
|
+
private updateFormatPainterButton;
|
|
186
|
+
/**
|
|
187
|
+
* Fallback copy method for older browsers
|
|
188
|
+
*/
|
|
189
|
+
private fallbackCopyToClipboard;
|
|
190
|
+
/**
|
|
191
|
+
* Check if search bar is currently visible
|
|
192
|
+
*/
|
|
193
|
+
private isSearchBarVisible;
|
|
194
|
+
/**
|
|
195
|
+
* Show the search bar and focus the input
|
|
196
|
+
* @param showReplace Whether to show the replace row
|
|
197
|
+
*/
|
|
198
|
+
private showSearchBar;
|
|
199
|
+
/**
|
|
200
|
+
* Hide the search bar and clear search
|
|
201
|
+
*/
|
|
202
|
+
private hideSearchBar;
|
|
203
|
+
/**
|
|
204
|
+
* Perform search with the current query
|
|
205
|
+
*/
|
|
206
|
+
private performSearch;
|
|
207
|
+
/**
|
|
208
|
+
* Navigate to next search match
|
|
209
|
+
*/
|
|
210
|
+
private searchNext;
|
|
211
|
+
/**
|
|
212
|
+
* Navigate to previous search match
|
|
213
|
+
*/
|
|
214
|
+
private searchPrevious;
|
|
215
|
+
/**
|
|
216
|
+
* Replace the current search match
|
|
217
|
+
*/
|
|
218
|
+
private replaceCurrentMatch;
|
|
219
|
+
/**
|
|
220
|
+
* Replace all search matches
|
|
221
|
+
*/
|
|
222
|
+
private replaceAllMatches;
|
|
223
|
+
/**
|
|
224
|
+
* Update search count display from editor state
|
|
225
|
+
*/
|
|
226
|
+
private updateSearchCountFromState;
|
|
227
|
+
/**
|
|
228
|
+
* Update the search count display
|
|
229
|
+
*/
|
|
230
|
+
private updateSearchCount;
|
|
231
|
+
/**
|
|
232
|
+
* Set up search bar event listeners
|
|
233
|
+
*/
|
|
234
|
+
private setupSearchListeners;
|
|
235
|
+
/**
|
|
236
|
+
* Set status bar message
|
|
237
|
+
*/
|
|
238
|
+
private setStatus;
|
|
121
239
|
/**
|
|
122
240
|
* Toggle a popover
|
|
123
241
|
*/
|
|
@@ -126,10 +244,71 @@ export declare class DocvyuApp {
|
|
|
126
244
|
* Close all popovers
|
|
127
245
|
*/
|
|
128
246
|
private closeAllPopovers;
|
|
247
|
+
/**
|
|
248
|
+
* Update numbering popover selection to highlight current format
|
|
249
|
+
*/
|
|
250
|
+
private updateNumberingSelection;
|
|
251
|
+
/**
|
|
252
|
+
* Handle click on numbering format option
|
|
253
|
+
*/
|
|
254
|
+
private handleNumberingFormatClick;
|
|
129
255
|
/**
|
|
130
256
|
* Apply margins from the popover inputs
|
|
131
257
|
*/
|
|
132
258
|
private applyMargins;
|
|
259
|
+
/**
|
|
260
|
+
* Insert a table at the current cursor position
|
|
261
|
+
*/
|
|
262
|
+
private insertTable;
|
|
263
|
+
/**
|
|
264
|
+
* Setup table grid event handlers
|
|
265
|
+
*/
|
|
266
|
+
private setupTableGridEvents;
|
|
267
|
+
/**
|
|
268
|
+
* Trigger image file upload
|
|
269
|
+
*/
|
|
270
|
+
private triggerImageUpload;
|
|
271
|
+
/**
|
|
272
|
+
* Insert an image from a file
|
|
273
|
+
*/
|
|
274
|
+
private insertImage;
|
|
275
|
+
/**
|
|
276
|
+
* Scale the currently selected image by a factor
|
|
277
|
+
*/
|
|
278
|
+
private scaleSelectedImage;
|
|
279
|
+
/**
|
|
280
|
+
* Reset image to its original scale (100%)
|
|
281
|
+
* Note: This doesn't restore original size, just sets current as baseline
|
|
282
|
+
*/
|
|
283
|
+
private resetImageScale;
|
|
284
|
+
/**
|
|
285
|
+
* Show dialog for custom image dimensions
|
|
286
|
+
*/
|
|
287
|
+
private showCustomImageScale;
|
|
288
|
+
/**
|
|
289
|
+
* Update image scale controls visibility based on cursor position
|
|
290
|
+
*/
|
|
291
|
+
private updateImageScaleControls;
|
|
292
|
+
/**
|
|
293
|
+
* Set the wrap mode of the selected image
|
|
294
|
+
*/
|
|
295
|
+
private setImageWrapMode;
|
|
296
|
+
/**
|
|
297
|
+
* Insert a comment at the current selection
|
|
298
|
+
*/
|
|
299
|
+
private insertComment;
|
|
300
|
+
/**
|
|
301
|
+
* Toggle comments panel visibility
|
|
302
|
+
*/
|
|
303
|
+
private toggleCommentsPanel;
|
|
304
|
+
/**
|
|
305
|
+
* Insert or edit header
|
|
306
|
+
*/
|
|
307
|
+
private editHeader;
|
|
308
|
+
/**
|
|
309
|
+
* Insert or edit footer
|
|
310
|
+
*/
|
|
311
|
+
private editFooter;
|
|
133
312
|
/**
|
|
134
313
|
* Update page size selection in popover
|
|
135
314
|
*/
|
|
@@ -187,5 +366,13 @@ export declare class DocvyuApp {
|
|
|
187
366
|
/**
|
|
188
367
|
* Destroy the app and clean up
|
|
189
368
|
*/
|
|
369
|
+
private promptInsertBookmark;
|
|
370
|
+
private acceptNextRevision;
|
|
371
|
+
private rejectNextRevision;
|
|
372
|
+
private updateRevisionCount;
|
|
373
|
+
private updateZoomDisplay;
|
|
374
|
+
private showDocumentProperties;
|
|
375
|
+
private showBookmarksPanel;
|
|
376
|
+
private showTocPanel;
|
|
190
377
|
destroy(): void;
|
|
191
378
|
}
|