@productcloudos/editor 1.0.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/CHANGELOG.md +95 -0
- package/LICENSE +21 -0
- package/README.md +377 -0
- package/dist/pc-editor.esm.js +24820 -0
- package/dist/pc-editor.esm.js.map +1 -0
- package/dist/pc-editor.js +24877 -0
- package/dist/pc-editor.js.map +1 -0
- package/dist/pc-editor.min.js +2 -0
- package/dist/pc-editor.min.js.map +1 -0
- package/dist/types/lib/clipboard/ClipboardManager.d.ts +77 -0
- package/dist/types/lib/clipboard/ClipboardManager.d.ts.map +1 -0
- package/dist/types/lib/clipboard/HtmlConverter.d.ts +43 -0
- package/dist/types/lib/clipboard/HtmlConverter.d.ts.map +1 -0
- package/dist/types/lib/clipboard/index.d.ts +9 -0
- package/dist/types/lib/clipboard/index.d.ts.map +1 -0
- package/dist/types/lib/clipboard/types.d.ts +76 -0
- package/dist/types/lib/clipboard/types.d.ts.map +1 -0
- package/dist/types/lib/controls/BaseControl.d.ts +72 -0
- package/dist/types/lib/controls/BaseControl.d.ts.map +1 -0
- package/dist/types/lib/controls/index.d.ts +11 -0
- package/dist/types/lib/controls/index.d.ts.map +1 -0
- package/dist/types/lib/controls/rulers/HorizontalRuler.d.ts +55 -0
- package/dist/types/lib/controls/rulers/HorizontalRuler.d.ts.map +1 -0
- package/dist/types/lib/controls/rulers/RulerControl.d.ts +98 -0
- package/dist/types/lib/controls/rulers/RulerControl.d.ts.map +1 -0
- package/dist/types/lib/controls/rulers/VerticalRuler.d.ts +65 -0
- package/dist/types/lib/controls/rulers/VerticalRuler.d.ts.map +1 -0
- package/dist/types/lib/controls/rulers/index.d.ts +8 -0
- package/dist/types/lib/controls/rulers/index.d.ts.map +1 -0
- package/dist/types/lib/controls/rulers/types.d.ts +62 -0
- package/dist/types/lib/controls/rulers/types.d.ts.map +1 -0
- package/dist/types/lib/controls/types.d.ts +51 -0
- package/dist/types/lib/controls/types.d.ts.map +1 -0
- package/dist/types/lib/core/Document.d.ts +34 -0
- package/dist/types/lib/core/Document.d.ts.map +1 -0
- package/dist/types/lib/core/PCEditor.d.ts +761 -0
- package/dist/types/lib/core/PCEditor.d.ts.map +1 -0
- package/dist/types/lib/core/Page.d.ts +40 -0
- package/dist/types/lib/core/Page.d.ts.map +1 -0
- package/dist/types/lib/data/DataBinder.d.ts +11 -0
- package/dist/types/lib/data/DataBinder.d.ts.map +1 -0
- package/dist/types/lib/events/EventEmitter.d.ts +11 -0
- package/dist/types/lib/events/EventEmitter.d.ts.map +1 -0
- package/dist/types/lib/hit-test/HitTestManager.d.ts +81 -0
- package/dist/types/lib/hit-test/HitTestManager.d.ts.map +1 -0
- package/dist/types/lib/hit-test/index.d.ts +32 -0
- package/dist/types/lib/hit-test/index.d.ts.map +1 -0
- package/dist/types/lib/hit-test/types.d.ts +113 -0
- package/dist/types/lib/hit-test/types.d.ts.map +1 -0
- package/dist/types/lib/import/ContentAnalyzer.d.ts +76 -0
- package/dist/types/lib/import/ContentAnalyzer.d.ts.map +1 -0
- package/dist/types/lib/import/DocumentBuilder.d.ts +44 -0
- package/dist/types/lib/import/DocumentBuilder.d.ts.map +1 -0
- package/dist/types/lib/import/PDFImporter.d.ts +65 -0
- package/dist/types/lib/import/PDFImporter.d.ts.map +1 -0
- package/dist/types/lib/import/PDFParser.d.ts +46 -0
- package/dist/types/lib/import/PDFParser.d.ts.map +1 -0
- package/dist/types/lib/import/index.d.ts +9 -0
- package/dist/types/lib/import/index.d.ts.map +1 -0
- package/dist/types/lib/import/types.d.ts +182 -0
- package/dist/types/lib/import/types.d.ts.map +1 -0
- package/dist/types/lib/index.d.ts +16 -0
- package/dist/types/lib/index.d.ts.map +1 -0
- package/dist/types/lib/layout/FlowManager.d.ts +29 -0
- package/dist/types/lib/layout/FlowManager.d.ts.map +1 -0
- package/dist/types/lib/layout/LayoutEngine.d.ts +39 -0
- package/dist/types/lib/layout/LayoutEngine.d.ts.map +1 -0
- package/dist/types/lib/objects/BaseEmbeddedObject.d.ts +133 -0
- package/dist/types/lib/objects/BaseEmbeddedObject.d.ts.map +1 -0
- package/dist/types/lib/objects/EmbeddedObjectFactory.d.ts +57 -0
- package/dist/types/lib/objects/EmbeddedObjectFactory.d.ts.map +1 -0
- package/dist/types/lib/objects/ImageObject.d.ts +60 -0
- package/dist/types/lib/objects/ImageObject.d.ts.map +1 -0
- package/dist/types/lib/objects/TextBoxObject.d.ts +208 -0
- package/dist/types/lib/objects/TextBoxObject.d.ts.map +1 -0
- package/dist/types/lib/objects/index.d.ts +9 -0
- package/dist/types/lib/objects/index.d.ts.map +1 -0
- package/dist/types/lib/objects/table/TableCell.d.ts +165 -0
- package/dist/types/lib/objects/table/TableCell.d.ts.map +1 -0
- package/dist/types/lib/objects/table/TableCellMerger.d.ts +66 -0
- package/dist/types/lib/objects/table/TableCellMerger.d.ts.map +1 -0
- package/dist/types/lib/objects/table/TableObject.d.ts +434 -0
- package/dist/types/lib/objects/table/TableObject.d.ts.map +1 -0
- package/dist/types/lib/objects/table/TableResizeHandler.d.ts +80 -0
- package/dist/types/lib/objects/table/TableResizeHandler.d.ts.map +1 -0
- package/dist/types/lib/objects/table/TableRow.d.ts +65 -0
- package/dist/types/lib/objects/table/TableRow.d.ts.map +1 -0
- package/dist/types/lib/objects/table/index.d.ts +12 -0
- package/dist/types/lib/objects/table/index.d.ts.map +1 -0
- package/dist/types/lib/objects/table/types.d.ts +239 -0
- package/dist/types/lib/objects/table/types.d.ts.map +1 -0
- package/dist/types/lib/objects/types.d.ts +135 -0
- package/dist/types/lib/objects/types.d.ts.map +1 -0
- package/dist/types/lib/rendering/CanvasManager.d.ts +282 -0
- package/dist/types/lib/rendering/CanvasManager.d.ts.map +1 -0
- package/dist/types/lib/rendering/FlowingTextRenderer.d.ts +348 -0
- package/dist/types/lib/rendering/FlowingTextRenderer.d.ts.map +1 -0
- package/dist/types/lib/rendering/PDFGenerator.d.ts +103 -0
- package/dist/types/lib/rendering/PDFGenerator.d.ts.map +1 -0
- package/dist/types/lib/rendering/pdf-utils.d.ts +54 -0
- package/dist/types/lib/rendering/pdf-utils.d.ts.map +1 -0
- package/dist/types/lib/text/EditableTextRegion.d.ts +105 -0
- package/dist/types/lib/text/EditableTextRegion.d.ts.map +1 -0
- package/dist/types/lib/text/EmbeddedObjectManager.d.ts +97 -0
- package/dist/types/lib/text/EmbeddedObjectManager.d.ts.map +1 -0
- package/dist/types/lib/text/FieldFormatter.d.ts +26 -0
- package/dist/types/lib/text/FieldFormatter.d.ts.map +1 -0
- package/dist/types/lib/text/FlowingTextContent.d.ts +571 -0
- package/dist/types/lib/text/FlowingTextContent.d.ts.map +1 -0
- package/dist/types/lib/text/HyperlinkManager.d.ts +110 -0
- package/dist/types/lib/text/HyperlinkManager.d.ts.map +1 -0
- package/dist/types/lib/text/MarkdownParser.d.ts +55 -0
- package/dist/types/lib/text/MarkdownParser.d.ts.map +1 -0
- package/dist/types/lib/text/ParagraphFormatting.d.ts +123 -0
- package/dist/types/lib/text/ParagraphFormatting.d.ts.map +1 -0
- package/dist/types/lib/text/RegionManager.d.ts +75 -0
- package/dist/types/lib/text/RegionManager.d.ts.map +1 -0
- package/dist/types/lib/text/RepeatingSectionManager.d.ts +99 -0
- package/dist/types/lib/text/RepeatingSectionManager.d.ts.map +1 -0
- package/dist/types/lib/text/SubstitutionFieldManager.d.ts +153 -0
- package/dist/types/lib/text/SubstitutionFieldManager.d.ts.map +1 -0
- package/dist/types/lib/text/TextFormatting.d.ts +85 -0
- package/dist/types/lib/text/TextFormatting.d.ts.map +1 -0
- package/dist/types/lib/text/TextLayout.d.ts +126 -0
- package/dist/types/lib/text/TextLayout.d.ts.map +1 -0
- package/dist/types/lib/text/TextMeasurer.d.ts +107 -0
- package/dist/types/lib/text/TextMeasurer.d.ts.map +1 -0
- package/dist/types/lib/text/TextPositionCalculator.d.ts +72 -0
- package/dist/types/lib/text/TextPositionCalculator.d.ts.map +1 -0
- package/dist/types/lib/text/TextState.d.ts +236 -0
- package/dist/types/lib/text/TextState.d.ts.map +1 -0
- package/dist/types/lib/text/index.d.ts +27 -0
- package/dist/types/lib/text/index.d.ts.map +1 -0
- package/dist/types/lib/text/regions/BodyTextRegion.d.ts +68 -0
- package/dist/types/lib/text/regions/BodyTextRegion.d.ts.map +1 -0
- package/dist/types/lib/text/regions/FooterTextRegion.d.ts +68 -0
- package/dist/types/lib/text/regions/FooterTextRegion.d.ts.map +1 -0
- package/dist/types/lib/text/regions/HeaderTextRegion.d.ts +68 -0
- package/dist/types/lib/text/regions/HeaderTextRegion.d.ts.map +1 -0
- package/dist/types/lib/text/regions/index.d.ts +7 -0
- package/dist/types/lib/text/regions/index.d.ts.map +1 -0
- package/dist/types/lib/text/types.d.ts +268 -0
- package/dist/types/lib/text/types.d.ts.map +1 -0
- package/dist/types/lib/types/index.d.ts +206 -0
- package/dist/types/lib/types/index.d.ts.map +1 -0
- package/dist/types/lib/undo/index.d.ts +8 -0
- package/dist/types/lib/undo/index.d.ts.map +1 -0
- package/dist/types/lib/undo/transaction/ContentDiscovery.d.ts +101 -0
- package/dist/types/lib/undo/transaction/ContentDiscovery.d.ts.map +1 -0
- package/dist/types/lib/undo/transaction/FocusTracker.d.ts +49 -0
- package/dist/types/lib/undo/transaction/FocusTracker.d.ts.map +1 -0
- package/dist/types/lib/undo/transaction/MutationUndo.d.ts +57 -0
- package/dist/types/lib/undo/transaction/MutationUndo.d.ts.map +1 -0
- package/dist/types/lib/undo/transaction/ObjectMutationObserver.d.ts +79 -0
- package/dist/types/lib/undo/transaction/ObjectMutationObserver.d.ts.map +1 -0
- package/dist/types/lib/undo/transaction/TextMutationObserver.d.ts +60 -0
- package/dist/types/lib/undo/transaction/TextMutationObserver.d.ts.map +1 -0
- package/dist/types/lib/undo/transaction/TransactionManager.d.ts +148 -0
- package/dist/types/lib/undo/transaction/TransactionManager.d.ts.map +1 -0
- package/dist/types/lib/undo/transaction/index.d.ts +17 -0
- package/dist/types/lib/undo/transaction/index.d.ts.map +1 -0
- package/dist/types/lib/undo/transaction/types.d.ts +269 -0
- package/dist/types/lib/undo/transaction/types.d.ts.map +1 -0
- package/dist/types/lib/utils/blob-utils.d.ts +2 -0
- package/dist/types/lib/utils/blob-utils.d.ts.map +1 -0
- package/package.json +88 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2024-01-13
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Core Editor**
|
|
15
|
+
- Canvas-based WYSIWYG document editor
|
|
16
|
+
- Multi-page document support with automatic page creation
|
|
17
|
+
- Configurable page sizes (A4, Letter, Legal, A3) and orientations
|
|
18
|
+
- Zoom controls (zoom in/out, fit to page, fit to width)
|
|
19
|
+
- Grid overlay for design assistance
|
|
20
|
+
- Undo/redo with full transaction support
|
|
21
|
+
|
|
22
|
+
- **Text System**
|
|
23
|
+
- Flowing text content with automatic wrapping across pages
|
|
24
|
+
- Rich text formatting (bold, italic, underline, strikethrough)
|
|
25
|
+
- Font family, size, and color customization
|
|
26
|
+
- Paragraph alignment (left, center, right, justify)
|
|
27
|
+
- Line height and paragraph spacing controls
|
|
28
|
+
- Bullet and numbered lists with nesting up to 8 levels
|
|
29
|
+
- Tab and shift+tab for list indentation
|
|
30
|
+
|
|
31
|
+
- **Tables**
|
|
32
|
+
- Table insertion with configurable rows and columns
|
|
33
|
+
- Cell merging (horizontal and vertical)
|
|
34
|
+
- Cell borders and background colors
|
|
35
|
+
- Multi-page table support with automatic row splitting
|
|
36
|
+
- Table properties panel for editing
|
|
37
|
+
|
|
38
|
+
- **Images**
|
|
39
|
+
- Image insertion from files or URLs
|
|
40
|
+
- Fit modes: cover, contain, stretch, tile
|
|
41
|
+
- Resize handles for interactive sizing
|
|
42
|
+
|
|
43
|
+
- **Text Boxes**
|
|
44
|
+
- Inline and block text box insertion
|
|
45
|
+
- Independent text formatting within boxes
|
|
46
|
+
|
|
47
|
+
- **Hyperlinks**
|
|
48
|
+
- Hyperlink insertion with URL and title
|
|
49
|
+
- Customizable link styling
|
|
50
|
+
- Click handling for navigation
|
|
51
|
+
|
|
52
|
+
- **Data Binding**
|
|
53
|
+
- Substitution fields for dynamic content
|
|
54
|
+
- Page number fields (numeric and roman numerals)
|
|
55
|
+
- Repeating sections for array data
|
|
56
|
+
- Merge data application
|
|
57
|
+
|
|
58
|
+
- **PDF Export**
|
|
59
|
+
- Full document export to PDF
|
|
60
|
+
- Text formatting preservation
|
|
61
|
+
- Image embedding
|
|
62
|
+
- Table rendering
|
|
63
|
+
- Hyperlink support
|
|
64
|
+
|
|
65
|
+
- **PDF Import**
|
|
66
|
+
- Import existing PDFs to editable documents
|
|
67
|
+
- Text extraction with formatting detection
|
|
68
|
+
- Table detection (optional)
|
|
69
|
+
- Image extraction (optional)
|
|
70
|
+
|
|
71
|
+
- **Copy/Paste**
|
|
72
|
+
- Proprietary format for full fidelity
|
|
73
|
+
- HTML format support
|
|
74
|
+
- Plain text fallback
|
|
75
|
+
- Image paste support
|
|
76
|
+
|
|
77
|
+
- **Document Serialization**
|
|
78
|
+
- JSON-based document format
|
|
79
|
+
- Save/load to files
|
|
80
|
+
- Full round-trip fidelity
|
|
81
|
+
|
|
82
|
+
- **TypeScript Support**
|
|
83
|
+
- Full type definitions
|
|
84
|
+
- Strict type checking
|
|
85
|
+
- Exported types for consumers
|
|
86
|
+
|
|
87
|
+
### Developer Experience
|
|
88
|
+
|
|
89
|
+
- ESM and CommonJS builds
|
|
90
|
+
- UMD build for script tag usage
|
|
91
|
+
- Comprehensive API documentation
|
|
92
|
+
- Demo application for testing
|
|
93
|
+
|
|
94
|
+
[Unreleased]: https://github.com/nickmitchko/pc-editor/compare/v0.1.0...HEAD
|
|
95
|
+
[0.1.0]: https://github.com/nickmitchko/pc-editor/releases/tag/v0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 PC Editor Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
# PC Editor
|
|
2
|
+
|
|
3
|
+
A powerful browser-based WYSIWYG document editor library for creating pixel-perfect documents with data binding and PDF export capabilities.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@productcloudos/editor)
|
|
6
|
+
[](https://github.com/ProductCloudOS/editor/actions)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
**[Live Demo](https://productcloudos.github.io/editor/)**
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Canvas-based rendering** for pixel-perfect positioning
|
|
14
|
+
- **Multi-page documents** with automatic content flow
|
|
15
|
+
- **Rich text formatting** - bold, italic, colors, fonts, sizes
|
|
16
|
+
- **Bullet and numbered lists** with nesting up to 8 levels
|
|
17
|
+
- **Tables** with cell merging, borders, styling, and multi-page support
|
|
18
|
+
- **Images** with fit modes (cover, contain, stretch, tile)
|
|
19
|
+
- **Hyperlinks** with customizable styling
|
|
20
|
+
- **Data binding** with substitution fields for dynamic content
|
|
21
|
+
- **Repeating sections** for data-driven content generation
|
|
22
|
+
- **PDF generation** with full formatting support
|
|
23
|
+
- **PDF import** to convert existing PDFs to editable documents
|
|
24
|
+
- **Undo/redo** with full transaction support
|
|
25
|
+
- **Copy/paste** supporting proprietary format, HTML, plain text, and images
|
|
26
|
+
- **Optional rulers** for visual guides
|
|
27
|
+
- **TypeScript-first** with full type definitions
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install @productcloudos/editor
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { PCEditor } from '@productcloudos/editor';
|
|
39
|
+
|
|
40
|
+
// Create editor instance
|
|
41
|
+
const container = document.getElementById('editor-container');
|
|
42
|
+
const editor = new PCEditor(container, {
|
|
43
|
+
pageSize: 'A4',
|
|
44
|
+
pageOrientation: 'portrait',
|
|
45
|
+
units: 'mm',
|
|
46
|
+
showGrid: true
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Wait for editor to be ready
|
|
50
|
+
editor.on('ready', () => {
|
|
51
|
+
// Set initial text
|
|
52
|
+
editor.setFlowingText('Hello, World!');
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Configuration Options
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
const editor = new PCEditor(container, {
|
|
60
|
+
pageSize: 'A4', // 'A4' | 'Letter' | 'Legal' | 'A3'
|
|
61
|
+
pageOrientation: 'portrait', // 'portrait' | 'landscape'
|
|
62
|
+
units: 'mm', // 'mm' | 'in' | 'pt' | 'px'
|
|
63
|
+
showGrid: true, // Show grid overlay
|
|
64
|
+
showRulers: true, // Show rulers
|
|
65
|
+
showControlCharacters: false, // Show paragraph marks, page breaks
|
|
66
|
+
defaultFont: 'Arial',
|
|
67
|
+
defaultFontSize: 12,
|
|
68
|
+
theme: 'light' // 'light' | 'dark'
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Basic Usage
|
|
73
|
+
|
|
74
|
+
### Text Operations
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// Set content
|
|
78
|
+
editor.setFlowingText('Document content goes here...');
|
|
79
|
+
|
|
80
|
+
// Get content
|
|
81
|
+
const text = editor.getFlowingText();
|
|
82
|
+
|
|
83
|
+
// Insert text at cursor
|
|
84
|
+
editor.insertText('Inserted text');
|
|
85
|
+
|
|
86
|
+
// Apply formatting to selection
|
|
87
|
+
editor.applyTextFormatting(startIndex, endIndex, {
|
|
88
|
+
fontWeight: 'bold',
|
|
89
|
+
color: '#0066cc',
|
|
90
|
+
fontSize: 14
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Set paragraph alignment
|
|
94
|
+
editor.setAlignment('center'); // 'left' | 'center' | 'right' | 'justify'
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Lists
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
// Toggle bullet list
|
|
101
|
+
editor.toggleBulletList();
|
|
102
|
+
|
|
103
|
+
// Toggle numbered list
|
|
104
|
+
editor.toggleNumberedList();
|
|
105
|
+
|
|
106
|
+
// Indent/outdent (also works with Tab/Shift+Tab)
|
|
107
|
+
editor.indentParagraph();
|
|
108
|
+
editor.outdentParagraph();
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Inserting Objects
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { ImageObject, TextBoxObject, TableObject } from '@productcloudos/editor';
|
|
115
|
+
|
|
116
|
+
// Insert image
|
|
117
|
+
const image = new ImageObject({
|
|
118
|
+
id: 'img-1',
|
|
119
|
+
textIndex: 0,
|
|
120
|
+
size: { width: 200, height: 150 },
|
|
121
|
+
src: 'data:image/png;base64,...',
|
|
122
|
+
fit: 'contain' // 'cover' | 'contain' | 'stretch' | 'tile'
|
|
123
|
+
});
|
|
124
|
+
editor.insertEmbeddedObject(image, 'block');
|
|
125
|
+
|
|
126
|
+
// Insert table
|
|
127
|
+
const table = new TableObject({
|
|
128
|
+
id: 'table-1',
|
|
129
|
+
textIndex: 0,
|
|
130
|
+
size: { width: 400, height: 200 },
|
|
131
|
+
rows: 3,
|
|
132
|
+
columns: 3
|
|
133
|
+
});
|
|
134
|
+
editor.insertEmbeddedObject(table, 'block');
|
|
135
|
+
|
|
136
|
+
// Insert text box
|
|
137
|
+
const textBox = new TextBoxObject({
|
|
138
|
+
id: 'textbox-1',
|
|
139
|
+
textIndex: 0,
|
|
140
|
+
size: { width: 150, height: 50 }
|
|
141
|
+
});
|
|
142
|
+
editor.insertEmbeddedObject(textBox, 'inline');
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Data Binding
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
// Insert substitution field
|
|
149
|
+
editor.insertSubstitutionField('customerName', {
|
|
150
|
+
displayText: 'Customer Name',
|
|
151
|
+
fieldType: 'text'
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// Insert page number field (for headers/footers)
|
|
155
|
+
editor.insertPageNumberField('numeric'); // or 'roman'
|
|
156
|
+
|
|
157
|
+
// Apply merge data
|
|
158
|
+
editor.applyMergeData({
|
|
159
|
+
customerName: 'John Doe',
|
|
160
|
+
invoiceNumber: 'INV-001',
|
|
161
|
+
items: [
|
|
162
|
+
{ name: 'Widget', price: 9.99 },
|
|
163
|
+
{ name: 'Gadget', price: 19.99 }
|
|
164
|
+
]
|
|
165
|
+
});
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Repeating Sections
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
// Create a repeating section for arrays in merge data
|
|
172
|
+
editor.createRepeatingSection(startIndex, endIndex, 'items');
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Hyperlinks
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
// Insert hyperlink
|
|
179
|
+
editor.insertHyperlink('https://example.com', {
|
|
180
|
+
title: 'Example Website'
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Update hyperlink
|
|
184
|
+
editor.updateHyperlink(hyperlinkId, {
|
|
185
|
+
url: 'https://new-url.com'
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// Remove hyperlink
|
|
189
|
+
editor.removeHyperlink(hyperlinkId);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### PDF Export
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
// Export to PDF
|
|
196
|
+
const pdfBlob = await editor.exportPDF({
|
|
197
|
+
applyMergeData: true,
|
|
198
|
+
mergeData: { customerName: 'Jane Doe' }
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// Download the PDF
|
|
202
|
+
const url = URL.createObjectURL(pdfBlob);
|
|
203
|
+
const link = document.createElement('a');
|
|
204
|
+
link.href = url;
|
|
205
|
+
link.download = 'document.pdf';
|
|
206
|
+
link.click();
|
|
207
|
+
URL.revokeObjectURL(url);
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### PDF Import
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
// Import from file
|
|
214
|
+
const result = await editor.importPDF(file, {
|
|
215
|
+
detectTables: true,
|
|
216
|
+
extractImages: true
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// Import from URL
|
|
220
|
+
const result = await editor.importPDF('https://example.com/document.pdf');
|
|
221
|
+
|
|
222
|
+
// Check for warnings
|
|
223
|
+
if (result.warnings.length > 0) {
|
|
224
|
+
console.log('Import warnings:', result.warnings);
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Save/Load Documents
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
// Save to JSON string
|
|
232
|
+
const json = editor.saveDocument();
|
|
233
|
+
|
|
234
|
+
// Load from JSON string
|
|
235
|
+
editor.loadDocumentFromJSON(json);
|
|
236
|
+
|
|
237
|
+
// Save to file (triggers download)
|
|
238
|
+
editor.saveDocumentToFile('my-document.pceditor.json');
|
|
239
|
+
|
|
240
|
+
// Load from file
|
|
241
|
+
await editor.loadDocumentFromFile(file);
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Undo/Redo
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
// Undo last action
|
|
248
|
+
editor.undo();
|
|
249
|
+
|
|
250
|
+
// Redo
|
|
251
|
+
editor.redo();
|
|
252
|
+
|
|
253
|
+
// Check availability
|
|
254
|
+
if (editor.canUndo()) { /* ... */ }
|
|
255
|
+
if (editor.canRedo()) { /* ... */ }
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Copy/Paste
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
// Copy selection
|
|
262
|
+
await editor.copy();
|
|
263
|
+
|
|
264
|
+
// Cut selection
|
|
265
|
+
await editor.cut();
|
|
266
|
+
|
|
267
|
+
// Paste from clipboard
|
|
268
|
+
await editor.paste();
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### View Controls
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
// Zoom
|
|
275
|
+
editor.zoomIn();
|
|
276
|
+
editor.zoomOut();
|
|
277
|
+
editor.setZoom(1.5); // 150%
|
|
278
|
+
editor.fitToWidth();
|
|
279
|
+
editor.fitToPage();
|
|
280
|
+
|
|
281
|
+
// Toggle features
|
|
282
|
+
editor.setShowGrid(true);
|
|
283
|
+
editor.setShowControlCharacters(true);
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Events
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
// Editor ready
|
|
290
|
+
editor.on('ready', () => { /* ... */ });
|
|
291
|
+
|
|
292
|
+
// Content changed
|
|
293
|
+
editor.on('content-changed', (event) => { /* ... */ });
|
|
294
|
+
|
|
295
|
+
// Selection changed
|
|
296
|
+
editor.on('selection-change', (event) => { /* ... */ });
|
|
297
|
+
|
|
298
|
+
// Cursor position changed
|
|
299
|
+
editor.on('cursor-changed', (event) => { /* ... */ });
|
|
300
|
+
|
|
301
|
+
// Zoom changed
|
|
302
|
+
editor.on('zoom-changed', (event) => { /* ... */ });
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## TypeScript Support
|
|
306
|
+
|
|
307
|
+
PC Editor is written in TypeScript and provides full type definitions:
|
|
308
|
+
|
|
309
|
+
```typescript
|
|
310
|
+
import {
|
|
311
|
+
PCEditor,
|
|
312
|
+
EditorOptions,
|
|
313
|
+
DocumentData,
|
|
314
|
+
TextFormattingStyle,
|
|
315
|
+
ImageObject,
|
|
316
|
+
TableObject,
|
|
317
|
+
TextBoxObject
|
|
318
|
+
} from '@productcloudos/editor';
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
## Documentation
|
|
322
|
+
|
|
323
|
+
- [Getting Started Guide](./docs/getting-started.md)
|
|
324
|
+
- [API Reference](./docs/api-reference.md)
|
|
325
|
+
|
|
326
|
+
## Development
|
|
327
|
+
|
|
328
|
+
### Setup
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
git clone https://github.com/ProductCloudOS/editor.git
|
|
332
|
+
cd pc-editor
|
|
333
|
+
npm install
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### Development Server
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
npm run dev
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Opens the demo application at http://localhost:5173
|
|
343
|
+
|
|
344
|
+
### Building
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
npm run build
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
Creates:
|
|
351
|
+
- `dist/pc-editor.js` - CommonJS build
|
|
352
|
+
- `dist/pc-editor.esm.js` - ES module build
|
|
353
|
+
- `dist/pc-editor.min.js` - UMD build (minified)
|
|
354
|
+
- `dist/types/` - TypeScript declarations
|
|
355
|
+
|
|
356
|
+
### Testing
|
|
357
|
+
|
|
358
|
+
```bash
|
|
359
|
+
npm test # Watch mode
|
|
360
|
+
npm run test:run # Single run
|
|
361
|
+
npm run test:coverage # With coverage
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
## Browser Support
|
|
365
|
+
|
|
366
|
+
- Chrome (latest)
|
|
367
|
+
- Firefox (latest)
|
|
368
|
+
- Safari (latest)
|
|
369
|
+
- Edge (latest)
|
|
370
|
+
|
|
371
|
+
## Contributing
|
|
372
|
+
|
|
373
|
+
Contributions are welcome! Please read our [Contributing Guide](./CONTRIBUTING.md) for details.
|
|
374
|
+
|
|
375
|
+
## License
|
|
376
|
+
|
|
377
|
+
MIT - see [LICENSE](./LICENSE) for details.
|