@softwarity/geojson-editor 1.0.17 → 1.0.18
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 +8 -5
- package/dist/geojson-editor.js +2 -2
- package/package.json +2 -2
- package/src/constants.ts +74 -0
- package/src/geojson-editor.css +15 -3
- package/src/geojson-editor.d.ts +155 -0
- package/src/geojson-editor.ts +665 -765
- package/src/internal-types.ts +111 -0
- package/src/syntax-highlighter.ts +197 -0
- package/src/types.ts +48 -0
- package/src/utils.ts +59 -0
- package/src/validation.ts +90 -0
- package/types/geojson-editor.d.ts +146 -488
- package/types/types.d.ts +44 -0
- package/types/geojson-editor.template.d.ts +0 -4
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import type { Feature, FeatureCollection } from 'geojson';
|
|
2
|
+
import type { SetOptions, ThemeSettings } from './types.js';
|
|
3
|
+
|
|
4
|
+
export type { SetOptions, ThemeConfig, ThemeSettings } from './types.js';
|
|
5
|
+
|
|
6
|
+
/** Input types accepted by API methods */
|
|
7
|
+
export type FeatureInput = Feature | Feature[] | FeatureCollection;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* GeoJSON Editor Web Component
|
|
11
|
+
* A feature-rich GeoJSON editor with syntax highlighting, collapsible nodes, and inline controls.
|
|
12
|
+
*/
|
|
13
|
+
declare class GeoJsonEditor extends HTMLElement {
|
|
14
|
+
/** Current editor content as string */
|
|
15
|
+
get value(): string;
|
|
16
|
+
|
|
17
|
+
/** Placeholder text when editor is empty */
|
|
18
|
+
get placeholder(): string;
|
|
19
|
+
|
|
20
|
+
/** Prefix text displayed before editor content */
|
|
21
|
+
get prefix(): string;
|
|
22
|
+
|
|
23
|
+
/** Suffix text displayed after editor content */
|
|
24
|
+
get suffix(): string;
|
|
25
|
+
|
|
26
|
+
/** Whether the editor is in readonly mode */
|
|
27
|
+
get readonly(): boolean;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Set the editor content from a string value
|
|
31
|
+
* @param value - JSON string content
|
|
32
|
+
* @param autoCollapse - Whether to auto-collapse coordinates (default: true)
|
|
33
|
+
*/
|
|
34
|
+
setValue(value: string | null, autoCollapse?: boolean): void;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Get full content as string (expanded, no hidden markers)
|
|
38
|
+
*/
|
|
39
|
+
getContent(): string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Replace all features in the editor
|
|
43
|
+
* @param input - FeatureCollection, Feature[], or single Feature
|
|
44
|
+
* @param options - Optional settings (collapsed attributes)
|
|
45
|
+
* @throws Error if input is invalid
|
|
46
|
+
*/
|
|
47
|
+
set(input: FeatureInput, options?: SetOptions): void;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Add features to the end of the editor
|
|
51
|
+
* @param input - FeatureCollection, Feature[], or single Feature
|
|
52
|
+
* @param options - Optional settings (collapsed attributes)
|
|
53
|
+
* @throws Error if input is invalid
|
|
54
|
+
*/
|
|
55
|
+
add(input: FeatureInput, options?: SetOptions): void;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Insert features at a specific index
|
|
59
|
+
* @param input - FeatureCollection, Feature[], or single Feature
|
|
60
|
+
* @param index - Index to insert at (negative = from end)
|
|
61
|
+
* @param options - Optional settings (collapsed attributes)
|
|
62
|
+
* @throws Error if input is invalid
|
|
63
|
+
*/
|
|
64
|
+
insertAt(input: FeatureInput, index: number, options?: SetOptions): void;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Remove feature at index
|
|
68
|
+
* @param index - Index to remove (negative = from end)
|
|
69
|
+
* @returns The removed feature, or undefined if index is out of bounds
|
|
70
|
+
*/
|
|
71
|
+
removeAt(index: number): Feature | undefined;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Remove all features
|
|
75
|
+
* @returns Array of all removed features
|
|
76
|
+
*/
|
|
77
|
+
removeAll(): Feature[];
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Get feature at index
|
|
81
|
+
* @param index - Index to get (negative = from end)
|
|
82
|
+
* @returns The feature, or undefined if index is out of bounds
|
|
83
|
+
*/
|
|
84
|
+
get(index: number): Feature | undefined;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get all features as an array
|
|
88
|
+
*/
|
|
89
|
+
getAll(): Feature[];
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Emit the current document on the change event
|
|
93
|
+
*/
|
|
94
|
+
emit(): void;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Save GeoJSON to a file (triggers download)
|
|
98
|
+
* @param filename - Filename for download (default: 'features.geojson')
|
|
99
|
+
* @returns true if save was successful
|
|
100
|
+
*/
|
|
101
|
+
save(filename?: string): boolean;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Open a GeoJSON file from the client filesystem
|
|
105
|
+
* @param options - Optional settings (collapsed attributes)
|
|
106
|
+
* @returns Promise that resolves to true if file was loaded successfully
|
|
107
|
+
*/
|
|
108
|
+
open(options?: SetOptions): Promise<boolean>;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Undo last action
|
|
112
|
+
* @returns true if undo was performed
|
|
113
|
+
*/
|
|
114
|
+
undo(): boolean;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Redo previously undone action
|
|
118
|
+
* @returns true if redo was performed
|
|
119
|
+
*/
|
|
120
|
+
redo(): boolean;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Check if undo is available
|
|
124
|
+
*/
|
|
125
|
+
canUndo(): boolean;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Check if redo is available
|
|
129
|
+
*/
|
|
130
|
+
canRedo(): boolean;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Clear undo/redo history
|
|
134
|
+
*/
|
|
135
|
+
clearHistory(): void;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Set custom theme colors
|
|
139
|
+
* @param theme - Theme settings for dark and light modes
|
|
140
|
+
*/
|
|
141
|
+
setTheme(theme: ThemeSettings): void;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Reset theme to defaults
|
|
145
|
+
*/
|
|
146
|
+
resetTheme(): void;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Get current theme settings
|
|
150
|
+
* @returns Copy of current theme settings
|
|
151
|
+
*/
|
|
152
|
+
getTheme(): ThemeSettings;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export default GeoJsonEditor;
|