@widgetic/editor 4.0.10 → 4.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 +242 -0
- package/dist/components/WidgetPreview.svelte +123 -86
- package/dist/components/WidgetPreview.svelte.d.ts +8 -0
- package/dist/components/color-select/ColorSelect.svelte +4 -4
- package/dist/components/editors/CompositionEditorApp.svelte +562 -0
- package/dist/components/editors/CompositionEditorApp.svelte.d.ts +95 -0
- package/dist/components/editors/EmbedEditor.svelte +33 -22
- package/dist/components/editors/EmbedEditor.svelte.d.ts +1 -1
- package/dist/components/editors/PropsEditor.svelte +267 -850
- package/dist/components/editors/PropsEditor.svelte.d.ts +10 -3
- package/dist/components/ic/AngleInputController.svelte +1 -1
- package/dist/components/ic/BrowserInputController.svelte +58 -31
- package/dist/components/ic/ColorPickerInputController.svelte +55 -21
- package/dist/components/ic/DateFieldInputController.svelte +34 -14
- package/dist/components/ic/DatePickerInputController.svelte +37 -21
- package/dist/components/ic/DropdownInputController.svelte +21 -9
- package/dist/components/ic/DropdownInputController.svelte.d.ts +1 -1
- package/dist/components/ic/FixedPositionInputController.svelte +12 -6
- package/dist/components/ic/FontInputController.svelte +100 -76
- package/dist/components/ic/InputControllerHeader.svelte +16 -9
- package/dist/components/ic/NumberControls.svelte +4 -4
- package/dist/components/ic/NumberInputController.svelte +6 -4
- package/dist/components/ic/PositionInputController.svelte +23 -15
- package/dist/components/ic/RangeCalendarInputController.svelte +36 -20
- package/dist/components/ic/RoundedCornersInputController.svelte +39 -26
- package/dist/components/ic/SliderInputController.svelte +7 -2
- package/dist/components/ic/SwitchInputController.svelte +12 -3
- package/dist/components/ic/TagsInputController.svelte +19 -4
- package/dist/components/ic/TextAreaInputController.svelte +79 -51
- package/dist/components/ic/TextAreaPreviewInputController.svelte +27 -72
- package/dist/components/ic/TextInputController.svelte +17 -1
- package/dist/components/ic/TimeInputController.svelte +11 -4
- package/dist/components/ic/VectorInputController.svelte +101 -70
- package/dist/components/ic/shared/ItemGrid.svelte +12 -4
- package/dist/components/ic/shared/RecentItemsSection.svelte +16 -11
- package/dist/components/ic/shared/RecentItemsSection.svelte.d.ts +1 -1
- package/dist/composition/compositionApi.d.ts +95 -0
- package/dist/composition/compositionApi.js +289 -0
- package/dist/composition/compositionEditorController.d.ts +263 -0
- package/dist/composition/compositionEditorController.js +746 -0
- package/dist/composition/compositionHelpers.d.ts +74 -0
- package/dist/composition/compositionHelpers.js +405 -0
- package/dist/i18n/index.d.ts +4 -0
- package/dist/i18n/index.js +4 -0
- package/dist/i18n/labels.d.ts +15 -0
- package/dist/i18n/labels.js +57 -0
- package/dist/i18n/language.d.ts +228 -0
- package/dist/i18n/language.js +34 -0
- package/dist/i18n/languageKit.d.ts +54 -0
- package/dist/i18n/languageKit.js +102 -0
- package/dist/i18n/messages.d.ts +241 -0
- package/dist/i18n/messages.js +253 -0
- package/dist/i18n/translate.d.ts +6 -0
- package/dist/i18n/translate.js +8 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +8 -0
- package/dist/mediaLibraryContext.d.ts +10 -0
- package/dist/mediaLibraryContext.js +30 -0
- package/dist/utils/FontManager.d.ts +21 -5
- package/dist/utils/FontManager.js +62 -67
- package/dist/utils/VectorManager.d.ts +0 -1
- package/dist/utils/VectorManager.js +10 -12
- package/dist/utils/dockPlacement.d.ts +12 -0
- package/dist/utils/dockPlacement.js +13 -0
- package/dist/utils/editorStorage.d.ts +23 -0
- package/dist/utils/editorStorage.js +95 -0
- package/dist/utils/fieldDirection.d.ts +13 -0
- package/dist/utils/fieldDirection.js +25 -0
- package/dist/utils/fontUtils.js +5 -3
- package/dist/utils/htmlSafety.d.ts +21 -0
- package/dist/utils/htmlSafety.js +38 -0
- package/dist/utils/itemReorder.d.ts +90 -0
- package/dist/utils/itemReorder.js +354 -0
- package/dist/utils/recentColors.js +4 -2
- package/dist/utils/richTextPreview.d.ts +38 -0
- package/dist/utils/richTextPreview.js +207 -0
- package/dist/utils/scrollActivity.d.ts +14 -0
- package/dist/utils/scrollActivity.js +63 -0
- package/dist/utils/shadowDom.d.ts +67 -0
- package/dist/utils/shadowDom.js +211 -0
- package/dist/utils/vectorUtils.js +5 -3
- package/dist/utils/visibilityCondition.d.ts +40 -0
- package/dist/utils/visibilityCondition.js +535 -0
- package/package.json +7 -6
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every word the editor shows to the person using it, in English: the one place to read them, and the keys a page can
|
|
3
|
+
* replace with the `messages` of the editor.
|
|
4
|
+
*
|
|
5
|
+
* A message is plain text. `{name}` is a value the editor puts in; `{count, plural, one {# file} other {# files}}` picks
|
|
6
|
+
* the form that fits a number in the page's language. `\{`, `\}`, `\#` and `\\` write those characters themselves. See
|
|
7
|
+
* `@widgetic/design-system/i18n` for the whole format.
|
|
8
|
+
*
|
|
9
|
+
* Keys are grouped by where the words appear. A key that is left out of a page's `messages` keeps the English text below,
|
|
10
|
+
* so a language can be added a screen at a time.
|
|
11
|
+
*
|
|
12
|
+
* Words that are NOT here, on purpose:
|
|
13
|
+
* - what the widget says about itself: the names, descriptions and options of its settings are written by the person who
|
|
14
|
+
* made the widget, and are shown as they were written;
|
|
15
|
+
* - what the File Browser and the rich text editor inside this editor say: they have their own catalogs
|
|
16
|
+
* (`FILE_BROWSER_MESSAGES`, `SHAD_EDITOR_MESSAGES`), and the same `messages` object can carry all three;
|
|
17
|
+
* - text the editor writes into the composition: the title of a new item ("Item 03"), the name of a composition that has
|
|
18
|
+
* none ("Untitled Composition"). Those are saved with the composition, so they do not change with the language.
|
|
19
|
+
*/
|
|
20
|
+
export declare const EDITOR_MESSAGES: {
|
|
21
|
+
readonly 'editor.app.loading': "Loading editor…";
|
|
22
|
+
readonly 'editor.app.tryAgain': "Try again";
|
|
23
|
+
readonly 'editor.app.retry': "Retry";
|
|
24
|
+
readonly 'editor.failure.widgetNotPublished': "Publish the widget before editing a composition.";
|
|
25
|
+
readonly 'editor.failure.sessionEndedWhileSaving': "Your session has ended, so your changes could not be saved. Reload the page to continue.";
|
|
26
|
+
readonly 'editor.failure.sessionEnded': "Your session has ended. Reload the page to continue.";
|
|
27
|
+
readonly 'editor.failure.compositionNotFound': "This composition could not be found.";
|
|
28
|
+
readonly 'editor.failure.noAccess': "You do not have access to this composition.";
|
|
29
|
+
readonly 'editor.failure.noWidget': "This composition has no widget.";
|
|
30
|
+
readonly 'editor.failure.widgetNotFound': "The widget this composition is made with could not be found.";
|
|
31
|
+
readonly 'editor.failure.saveNeedsConnection': "Your changes could not be saved. Check the connection and try again.";
|
|
32
|
+
readonly 'editor.failure.loadNeedsConnection': "The editor could not be loaded. Check the connection and try again.";
|
|
33
|
+
readonly 'editor.failure.saveFailed': "Your changes could not be saved.";
|
|
34
|
+
readonly 'editor.failure.loadFailed': "The editor could not be loaded.";
|
|
35
|
+
readonly 'editor.failure.settingsLoadFailed': "The editor settings could not be loaded. Try again.";
|
|
36
|
+
readonly 'editor.failure.noSettings': "No editable settings found. Generate and publish the widget first.";
|
|
37
|
+
/** A line under a message that has an error code: "Error code: CONFIG_NOT_FOUND". The code is not translated. */
|
|
38
|
+
readonly 'editor.failure.errorCode': "Error code: {code}";
|
|
39
|
+
readonly 'editor.props.title': "Edit Properties";
|
|
40
|
+
readonly 'editor.props.designTab': "Design";
|
|
41
|
+
readonly 'editor.props.contentTab': "Content";
|
|
42
|
+
/** The title of the card of settings that belong to no item, when the widget gave it none. */
|
|
43
|
+
readonly 'editor.props.contentCard': "Content";
|
|
44
|
+
readonly 'editor.props.save': "Save";
|
|
45
|
+
readonly 'editor.props.saving': "Saving";
|
|
46
|
+
readonly 'editor.props.noConfiguration': "No schema configuration available";
|
|
47
|
+
readonly 'editor.props.noDesignSchema': "No design schema available";
|
|
48
|
+
readonly 'editor.props.noSchemaData': "No schema data available";
|
|
49
|
+
readonly 'editor.props.noComponents': "No components defined in schema";
|
|
50
|
+
readonly 'editor.props.noProperties': "No properties available";
|
|
51
|
+
readonly 'editor.props.addItem': "Add new";
|
|
52
|
+
readonly 'editor.props.deleteItem': "Delete item";
|
|
53
|
+
readonly 'editor.embed.title': "Edit Options";
|
|
54
|
+
readonly 'editor.embed.loading': "Loading...";
|
|
55
|
+
readonly 'editor.embed.noCode': "No embed code available";
|
|
56
|
+
readonly 'editor.embed.codeHeader': "Embed code";
|
|
57
|
+
readonly 'editor.embed.headerArea': "Embed code header area";
|
|
58
|
+
readonly 'editor.embed.readMore': "Read more about embedding";
|
|
59
|
+
readonly 'editor.embed.copy': "Copy to clipboard";
|
|
60
|
+
/** The pop-ups after a copy: the title of the one that worked is the same for the editor's pop-up and the header's. */
|
|
61
|
+
readonly 'editor.embed.copied': "Copied to clipboard";
|
|
62
|
+
readonly 'editor.embed.copiedHint': "Paste it anywhere on your site.";
|
|
63
|
+
readonly 'editor.embed.copiedDone': "Content copied successfully.";
|
|
64
|
+
readonly 'editor.embed.copyFailed': "Copy failed";
|
|
65
|
+
readonly 'editor.embed.copyFailedHint': "Please try manual selection";
|
|
66
|
+
readonly 'editor.preview.title': "Preview";
|
|
67
|
+
readonly 'editor.preview.dragHandle': "Drag preview";
|
|
68
|
+
readonly 'editor.preview.desktop': "Desktop preview";
|
|
69
|
+
readonly 'editor.preview.mobile': "Mobile preview";
|
|
70
|
+
/** The first letters of "width" and "height", beside the two boxes where the size of the preview is typed. */
|
|
71
|
+
readonly 'editor.preview.widthShort': "W";
|
|
72
|
+
readonly 'editor.preview.heightShort': "H";
|
|
73
|
+
readonly 'editor.preview.noUrl': "no URL";
|
|
74
|
+
readonly 'editor.preview.copyUrl': "Copy URL";
|
|
75
|
+
readonly 'editor.preview.refresh': "Refresh preview";
|
|
76
|
+
readonly 'editor.preview.fitToPanel': "Fit preview to panel";
|
|
77
|
+
readonly 'editor.preview.mobileViewport': "Mobile viewport";
|
|
78
|
+
readonly 'editor.preview.desktopViewport': "Desktop viewport (full window)";
|
|
79
|
+
readonly 'editor.preview.openInNewTab': "Open in new tab";
|
|
80
|
+
readonly 'editor.preview.newTab': "↗ New tab";
|
|
81
|
+
readonly 'editor.preview.selectWidget': "Select a widget to preview";
|
|
82
|
+
/** What the name of a widget is when it has none. */
|
|
83
|
+
readonly 'editor.preview.widgetName': "Widget";
|
|
84
|
+
readonly 'editor.preview.notPublished': "Not published yet";
|
|
85
|
+
readonly 'editor.preview.publishToPreview': "Publish the widget in Widget Creator to preview it here.";
|
|
86
|
+
readonly 'editor.preview.frameTitle': "Widget preview";
|
|
87
|
+
readonly 'editor.preview.frameTitleNamed': "Widget preview – {name}";
|
|
88
|
+
readonly 'editor.preview.unavailable': "Preview Unavailable";
|
|
89
|
+
readonly 'editor.preview.loadFailedPreview': "Failed to load widget preview.";
|
|
90
|
+
readonly 'editor.preview.retry': "Retry";
|
|
91
|
+
readonly 'editor.preview.retryBuild': "Retry Build";
|
|
92
|
+
readonly 'editor.preview.retryPreview': "Retry Preview";
|
|
93
|
+
readonly 'editor.preview.fixErrors': "Fix Errors";
|
|
94
|
+
readonly 'editor.preview.viewErrors': "View Errors";
|
|
95
|
+
readonly 'editor.preview.runtimeError': "Widget runtime error";
|
|
96
|
+
readonly 'editor.preview.compilationErrors': "Code Has Compilation Errors";
|
|
97
|
+
/** `{status}` is the HTTP status the preview page answered with. */
|
|
98
|
+
readonly 'editor.preview.compilationErrorsDetail': "The generated code has syntax or compilation errors (HTTP {status}).";
|
|
99
|
+
readonly 'editor.preview.noCodeYet': "No Code Generated Yet";
|
|
100
|
+
readonly 'editor.preview.noPreview': "No Preview Available";
|
|
101
|
+
readonly 'editor.preview.building': "Building Preview...";
|
|
102
|
+
readonly 'editor.preview.loadingWidget': "Loading widget…";
|
|
103
|
+
readonly 'editor.preview.loadingPreview': "Loading Preview…";
|
|
104
|
+
readonly 'editor.preview.checkingWidget': "Checking widget on Worker…";
|
|
105
|
+
readonly 'editor.preview.applyingSettings': "Applying composition settings…";
|
|
106
|
+
readonly 'editor.preview.connecting': "Connecting to the widget preview…";
|
|
107
|
+
readonly 'editor.preview.generatingCode': "Generating code…";
|
|
108
|
+
readonly 'editor.list.recentlyUsed': "Recently used";
|
|
109
|
+
readonly 'editor.list.more': "More";
|
|
110
|
+
readonly 'editor.list.searchResults': "Search results";
|
|
111
|
+
readonly 'editor.list.loadingMore': "Loading more items...";
|
|
112
|
+
readonly 'editor.list.deleteItem': "Delete";
|
|
113
|
+
/** The tabs above a list of fonts or vectors. */
|
|
114
|
+
readonly 'editor.category.all': "All";
|
|
115
|
+
readonly 'editor.category.mine': "Mine";
|
|
116
|
+
readonly 'editor.category.sansSerif': "Sans Serif";
|
|
117
|
+
readonly 'editor.category.serif': "Serif";
|
|
118
|
+
readonly 'editor.category.script': "Script";
|
|
119
|
+
readonly 'editor.category.other': "Other";
|
|
120
|
+
readonly 'editor.category.icons': "Icons";
|
|
121
|
+
readonly 'editor.category.emojis': "Emojis";
|
|
122
|
+
readonly 'editor.category.clipart': "Clipart";
|
|
123
|
+
readonly 'editor.font.select': "Select font...";
|
|
124
|
+
readonly 'editor.font.title': "Fonts";
|
|
125
|
+
readonly 'editor.font.search': "Search fonts...";
|
|
126
|
+
readonly 'editor.font.list': "Font list";
|
|
127
|
+
readonly 'editor.font.loading': "Loading fonts";
|
|
128
|
+
readonly 'editor.font.noneFound': "No fonts found";
|
|
129
|
+
readonly 'editor.font.noneAvailable': "No fonts available";
|
|
130
|
+
readonly 'editor.font.remove': "Remove font";
|
|
131
|
+
readonly 'editor.font.weight': "Font Weight";
|
|
132
|
+
/** The name a screen reader gives the list of weights a font has, when its menu is open. */
|
|
133
|
+
readonly 'editor.font.weightList': "Font weights";
|
|
134
|
+
/** The look of a weight that has a name of its own; `{weight}` is one of the names below ("Bold Italic"). */
|
|
135
|
+
readonly 'editor.fontWeight.withItalic': "{weight} Italic";
|
|
136
|
+
readonly 'editor.fontWeight.italic': "Italic";
|
|
137
|
+
readonly 'editor.fontWeight.thin': "Thin";
|
|
138
|
+
readonly 'editor.fontWeight.extraLight': "ExtraLight";
|
|
139
|
+
readonly 'editor.fontWeight.light': "Light";
|
|
140
|
+
readonly 'editor.fontWeight.regular': "Regular";
|
|
141
|
+
readonly 'editor.fontWeight.medium': "Medium";
|
|
142
|
+
readonly 'editor.fontWeight.semiBold': "SemiBold";
|
|
143
|
+
readonly 'editor.fontWeight.bold': "Bold";
|
|
144
|
+
readonly 'editor.fontWeight.extraBold': "ExtraBold";
|
|
145
|
+
readonly 'editor.fontWeight.black': "Black";
|
|
146
|
+
readonly 'editor.vector.select': "Select vector...";
|
|
147
|
+
readonly 'editor.vector.title': "Vectors";
|
|
148
|
+
readonly 'editor.vector.search': "Search vectors...";
|
|
149
|
+
readonly 'editor.vector.list': "Vector list";
|
|
150
|
+
readonly 'editor.vector.noneFound': "No vectors found";
|
|
151
|
+
readonly 'editor.vector.noneAvailable': "No vectors available";
|
|
152
|
+
readonly 'editor.file.useFile': "Use file";
|
|
153
|
+
readonly 'editor.file.useImage': "Use image";
|
|
154
|
+
readonly 'editor.file.useVideo': "Use video";
|
|
155
|
+
readonly 'editor.file.useAudio': "Use audio";
|
|
156
|
+
readonly 'editor.file.useDocument': "Use document";
|
|
157
|
+
readonly 'editor.file.addFile': "Add file...";
|
|
158
|
+
readonly 'editor.file.addImage': "Add image...";
|
|
159
|
+
readonly 'editor.file.addVideo': "Add video...";
|
|
160
|
+
readonly 'editor.file.addAudio': "Add audio...";
|
|
161
|
+
readonly 'editor.file.addDocument': "Add docs...";
|
|
162
|
+
readonly 'editor.file.play': "Play";
|
|
163
|
+
readonly 'editor.file.pause': "Pause";
|
|
164
|
+
readonly 'editor.file.notFound': "File not found";
|
|
165
|
+
readonly 'editor.file.emptyFolder': "Empty folder";
|
|
166
|
+
readonly 'editor.file.clear': "Clear file";
|
|
167
|
+
readonly 'editor.file.dialogTitle': "Select file";
|
|
168
|
+
readonly 'editor.file.closeDialog': "Close file browser";
|
|
169
|
+
readonly 'editor.color.noRecent': "No recent colors";
|
|
170
|
+
readonly 'editor.color.picker': "Color picker";
|
|
171
|
+
readonly 'editor.date.pick': "Pick a date";
|
|
172
|
+
readonly 'editor.date.pickRange': "Pick a date range";
|
|
173
|
+
readonly 'editor.date.invalid': "Invalid date";
|
|
174
|
+
readonly 'editor.date.selectMonth': "Select month";
|
|
175
|
+
readonly 'editor.date.selectYear': "Select year";
|
|
176
|
+
/**
|
|
177
|
+
* The name a screen reader gives the calendar of one date. The library writes the month and year after it ("Date
|
|
178
|
+
* October 2026"), so a short noun is best.
|
|
179
|
+
*/
|
|
180
|
+
readonly 'editor.date.calendarLabel': "Date";
|
|
181
|
+
/** The same for the calendar of a range of dates ("Date range October - November 2026"). */
|
|
182
|
+
readonly 'editor.date.rangeCalendarLabel': "Date range";
|
|
183
|
+
/** The name a screen reader gives the buttons of a calendar that show the month before and the month after. */
|
|
184
|
+
readonly 'editor.date.previousMonth': "Previous month";
|
|
185
|
+
readonly 'editor.date.nextMonth': "Next month";
|
|
186
|
+
/** What is typed in the three boxes of a date: the hint inside the box, and its name for a screen reader. */
|
|
187
|
+
readonly 'editor.dateField.dayHint': "DD";
|
|
188
|
+
readonly 'editor.dateField.monthHint': "MM";
|
|
189
|
+
readonly 'editor.dateField.yearHint': "YYYY";
|
|
190
|
+
readonly 'editor.dateField.dayLabel': "Day input";
|
|
191
|
+
readonly 'editor.dateField.monthLabel': "Month input";
|
|
192
|
+
readonly 'editor.dateField.yearLabel': "Year input";
|
|
193
|
+
readonly 'editor.dropdown.select': "Select an option";
|
|
194
|
+
readonly 'editor.switch.off': "Off";
|
|
195
|
+
readonly 'editor.switch.on': "On";
|
|
196
|
+
readonly 'editor.tags.add': "Add tag...";
|
|
197
|
+
/** The two letters beside the position of a point in a picture: how far across, and how far down. */
|
|
198
|
+
readonly 'editor.position.x': "X:";
|
|
199
|
+
readonly 'editor.position.y': "Y:";
|
|
200
|
+
/** The buttons of the nine places on a screen; `{position}` is one of the names below. */
|
|
201
|
+
readonly 'editor.fixedPosition.set': "Set position to {position}";
|
|
202
|
+
readonly 'editor.fixedPosition.topLeft': "top-left";
|
|
203
|
+
readonly 'editor.fixedPosition.topCenter': "top-center";
|
|
204
|
+
readonly 'editor.fixedPosition.topRight': "top-right";
|
|
205
|
+
readonly 'editor.fixedPosition.centerLeft': "center-left";
|
|
206
|
+
readonly 'editor.fixedPosition.centerCenter': "center-center";
|
|
207
|
+
readonly 'editor.fixedPosition.centerRight': "center-right";
|
|
208
|
+
readonly 'editor.fixedPosition.bottomLeft': "bottom-left";
|
|
209
|
+
readonly 'editor.fixedPosition.bottomCenter': "bottom-center";
|
|
210
|
+
readonly 'editor.fixedPosition.bottomRight': "bottom-right";
|
|
211
|
+
/** The corners of a box: the name of the group, of each of the four boxes, and of the lock between them. */
|
|
212
|
+
readonly 'editor.corners.group': "Corner radius";
|
|
213
|
+
readonly 'editor.corners.topLeft': "Top left corner radius";
|
|
214
|
+
readonly 'editor.corners.topRight': "Top right corner radius";
|
|
215
|
+
readonly 'editor.corners.bottomLeft': "Bottom left corner radius";
|
|
216
|
+
readonly 'editor.corners.bottomRight': "Bottom right corner radius";
|
|
217
|
+
readonly 'editor.corners.lock': "Lock corner radius values";
|
|
218
|
+
readonly 'editor.corners.unlock': "Unlock corner radius values";
|
|
219
|
+
readonly 'editor.textArea.toolbar': "Text formatting toolbar";
|
|
220
|
+
readonly 'editor.textArea.toggleBold': "Toggle bold";
|
|
221
|
+
readonly 'editor.textArea.toggleItalic': "Toggle italic";
|
|
222
|
+
readonly 'editor.textArea.toggleUnderline': "Toggle underline";
|
|
223
|
+
readonly 'editor.textArea.toggleLink': "Toggle link";
|
|
224
|
+
readonly 'editor.textArea.text': "Text";
|
|
225
|
+
readonly 'editor.textArea.paragraph': "Paragraph";
|
|
226
|
+
readonly 'editor.textArea.heading1': "H1";
|
|
227
|
+
readonly 'editor.textArea.heading2': "H2";
|
|
228
|
+
readonly 'editor.textArea.heading3': "H3";
|
|
229
|
+
readonly 'editor.textArea.bulletList': "Bullet List";
|
|
230
|
+
readonly 'editor.textArea.numberedList': "Numbered List";
|
|
231
|
+
readonly 'editor.textArea.checkList': "Check List";
|
|
232
|
+
/** The name a screen reader gives the list of text styles (paragraph, headings) when its menu is open. */
|
|
233
|
+
readonly 'editor.textArea.textStyles': "Text styles";
|
|
234
|
+
/** The name a screen reader gives the list of list styles (bullets, numbers, checks) when its menu is open. */
|
|
235
|
+
readonly 'editor.textArea.listStyles': "List styles";
|
|
236
|
+
/** The question the browser asks when a link is added. */
|
|
237
|
+
readonly 'editor.textArea.enterUrl': "Enter URL";
|
|
238
|
+
readonly 'editor.schema.subtitleFont': "Subtitle Font";
|
|
239
|
+
};
|
|
240
|
+
/** The name of one message. */
|
|
241
|
+
export type EditorMessageKey = keyof typeof EDITOR_MESSAGES;
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every word the editor shows to the person using it, in English: the one place to read them, and the keys a page can
|
|
3
|
+
* replace with the `messages` of the editor.
|
|
4
|
+
*
|
|
5
|
+
* A message is plain text. `{name}` is a value the editor puts in; `{count, plural, one {# file} other {# files}}` picks
|
|
6
|
+
* the form that fits a number in the page's language. `\{`, `\}`, `\#` and `\\` write those characters themselves. See
|
|
7
|
+
* `@widgetic/design-system/i18n` for the whole format.
|
|
8
|
+
*
|
|
9
|
+
* Keys are grouped by where the words appear. A key that is left out of a page's `messages` keeps the English text below,
|
|
10
|
+
* so a language can be added a screen at a time.
|
|
11
|
+
*
|
|
12
|
+
* Words that are NOT here, on purpose:
|
|
13
|
+
* - what the widget says about itself: the names, descriptions and options of its settings are written by the person who
|
|
14
|
+
* made the widget, and are shown as they were written;
|
|
15
|
+
* - what the File Browser and the rich text editor inside this editor say: they have their own catalogs
|
|
16
|
+
* (`FILE_BROWSER_MESSAGES`, `SHAD_EDITOR_MESSAGES`), and the same `messages` object can carry all three;
|
|
17
|
+
* - text the editor writes into the composition: the title of a new item ("Item 03"), the name of a composition that has
|
|
18
|
+
* none ("Untitled Composition"). Those are saved with the composition, so they do not change with the language.
|
|
19
|
+
*/
|
|
20
|
+
export const EDITOR_MESSAGES = {
|
|
21
|
+
// ===== The editor as a whole: the card that says it is loading, and the buttons that try again =====
|
|
22
|
+
'editor.app.loading': 'Loading editor…',
|
|
23
|
+
'editor.app.tryAgain': 'Try again',
|
|
24
|
+
'editor.app.retry': 'Retry',
|
|
25
|
+
// ===== What went wrong, and what to do about it =====
|
|
26
|
+
'editor.failure.widgetNotPublished': 'Publish the widget before editing a composition.',
|
|
27
|
+
'editor.failure.sessionEndedWhileSaving': 'Your session has ended, so your changes could not be saved. Reload the page to continue.',
|
|
28
|
+
'editor.failure.sessionEnded': 'Your session has ended. Reload the page to continue.',
|
|
29
|
+
'editor.failure.compositionNotFound': 'This composition could not be found.',
|
|
30
|
+
'editor.failure.noAccess': 'You do not have access to this composition.',
|
|
31
|
+
'editor.failure.noWidget': 'This composition has no widget.',
|
|
32
|
+
'editor.failure.widgetNotFound': 'The widget this composition is made with could not be found.',
|
|
33
|
+
'editor.failure.saveNeedsConnection': 'Your changes could not be saved. Check the connection and try again.',
|
|
34
|
+
'editor.failure.loadNeedsConnection': 'The editor could not be loaded. Check the connection and try again.',
|
|
35
|
+
'editor.failure.saveFailed': 'Your changes could not be saved.',
|
|
36
|
+
'editor.failure.loadFailed': 'The editor could not be loaded.',
|
|
37
|
+
'editor.failure.settingsLoadFailed': 'The editor settings could not be loaded. Try again.',
|
|
38
|
+
'editor.failure.noSettings': 'No editable settings found. Generate and publish the widget first.',
|
|
39
|
+
/** A line under a message that has an error code: "Error code: CONFIG_NOT_FOUND". The code is not translated. */
|
|
40
|
+
'editor.failure.errorCode': 'Error code: {code}',
|
|
41
|
+
// ===== The settings editor =====
|
|
42
|
+
'editor.props.title': 'Edit Properties',
|
|
43
|
+
'editor.props.designTab': 'Design',
|
|
44
|
+
'editor.props.contentTab': 'Content',
|
|
45
|
+
/** The title of the card of settings that belong to no item, when the widget gave it none. */
|
|
46
|
+
'editor.props.contentCard': 'Content',
|
|
47
|
+
'editor.props.save': 'Save',
|
|
48
|
+
'editor.props.saving': 'Saving',
|
|
49
|
+
'editor.props.noConfiguration': 'No schema configuration available',
|
|
50
|
+
'editor.props.noDesignSchema': 'No design schema available',
|
|
51
|
+
'editor.props.noSchemaData': 'No schema data available',
|
|
52
|
+
'editor.props.noComponents': 'No components defined in schema',
|
|
53
|
+
'editor.props.noProperties': 'No properties available',
|
|
54
|
+
'editor.props.addItem': 'Add new',
|
|
55
|
+
'editor.props.deleteItem': 'Delete item',
|
|
56
|
+
// ===== The embed options =====
|
|
57
|
+
'editor.embed.title': 'Edit Options',
|
|
58
|
+
'editor.embed.loading': 'Loading...',
|
|
59
|
+
'editor.embed.noCode': 'No embed code available',
|
|
60
|
+
'editor.embed.codeHeader': 'Embed code',
|
|
61
|
+
'editor.embed.headerArea': 'Embed code header area',
|
|
62
|
+
'editor.embed.readMore': 'Read more about embedding',
|
|
63
|
+
'editor.embed.copy': 'Copy to clipboard',
|
|
64
|
+
/** The pop-ups after a copy: the title of the one that worked is the same for the editor's pop-up and the header's. */
|
|
65
|
+
'editor.embed.copied': 'Copied to clipboard',
|
|
66
|
+
'editor.embed.copiedHint': 'Paste it anywhere on your site.',
|
|
67
|
+
'editor.embed.copiedDone': 'Content copied successfully.',
|
|
68
|
+
'editor.embed.copyFailed': 'Copy failed',
|
|
69
|
+
'editor.embed.copyFailedHint': 'Please try manual selection',
|
|
70
|
+
// ===== The preview of the widget =====
|
|
71
|
+
'editor.preview.title': 'Preview',
|
|
72
|
+
'editor.preview.dragHandle': 'Drag preview',
|
|
73
|
+
'editor.preview.desktop': 'Desktop preview',
|
|
74
|
+
'editor.preview.mobile': 'Mobile preview',
|
|
75
|
+
/** The first letters of "width" and "height", beside the two boxes where the size of the preview is typed. */
|
|
76
|
+
'editor.preview.widthShort': 'W',
|
|
77
|
+
'editor.preview.heightShort': 'H',
|
|
78
|
+
'editor.preview.noUrl': 'no URL',
|
|
79
|
+
'editor.preview.copyUrl': 'Copy URL',
|
|
80
|
+
'editor.preview.refresh': 'Refresh preview',
|
|
81
|
+
'editor.preview.fitToPanel': 'Fit preview to panel',
|
|
82
|
+
'editor.preview.mobileViewport': 'Mobile viewport',
|
|
83
|
+
'editor.preview.desktopViewport': 'Desktop viewport (full window)',
|
|
84
|
+
'editor.preview.openInNewTab': 'Open in new tab',
|
|
85
|
+
'editor.preview.newTab': '↗ New tab',
|
|
86
|
+
'editor.preview.selectWidget': 'Select a widget to preview',
|
|
87
|
+
/** What the name of a widget is when it has none. */
|
|
88
|
+
'editor.preview.widgetName': 'Widget',
|
|
89
|
+
'editor.preview.notPublished': 'Not published yet',
|
|
90
|
+
'editor.preview.publishToPreview': 'Publish the widget in Widget Creator to preview it here.',
|
|
91
|
+
'editor.preview.frameTitle': 'Widget preview',
|
|
92
|
+
'editor.preview.frameTitleNamed': 'Widget preview – {name}',
|
|
93
|
+
'editor.preview.unavailable': 'Preview Unavailable',
|
|
94
|
+
'editor.preview.loadFailedPreview': 'Failed to load widget preview.',
|
|
95
|
+
'editor.preview.retry': 'Retry',
|
|
96
|
+
'editor.preview.retryBuild': 'Retry Build',
|
|
97
|
+
'editor.preview.retryPreview': 'Retry Preview',
|
|
98
|
+
'editor.preview.fixErrors': 'Fix Errors',
|
|
99
|
+
'editor.preview.viewErrors': 'View Errors',
|
|
100
|
+
'editor.preview.runtimeError': 'Widget runtime error',
|
|
101
|
+
'editor.preview.compilationErrors': 'Code Has Compilation Errors',
|
|
102
|
+
/** `{status}` is the HTTP status the preview page answered with. */
|
|
103
|
+
'editor.preview.compilationErrorsDetail': 'The generated code has syntax or compilation errors (HTTP {status}).',
|
|
104
|
+
'editor.preview.noCodeYet': 'No Code Generated Yet',
|
|
105
|
+
'editor.preview.noPreview': 'No Preview Available',
|
|
106
|
+
'editor.preview.building': 'Building Preview...',
|
|
107
|
+
'editor.preview.loadingWidget': 'Loading widget…',
|
|
108
|
+
'editor.preview.loadingPreview': 'Loading Preview…',
|
|
109
|
+
'editor.preview.checkingWidget': 'Checking widget on Worker…',
|
|
110
|
+
'editor.preview.applyingSettings': 'Applying composition settings…',
|
|
111
|
+
'editor.preview.connecting': 'Connecting to the widget preview…',
|
|
112
|
+
'editor.preview.generatingCode': 'Generating code…',
|
|
113
|
+
// ===== Lists of fonts and vectors: the words they share =====
|
|
114
|
+
'editor.list.recentlyUsed': 'Recently used',
|
|
115
|
+
'editor.list.more': 'More',
|
|
116
|
+
'editor.list.searchResults': 'Search results',
|
|
117
|
+
'editor.list.loadingMore': 'Loading more items...',
|
|
118
|
+
'editor.list.deleteItem': 'Delete',
|
|
119
|
+
/** The tabs above a list of fonts or vectors. */
|
|
120
|
+
'editor.category.all': 'All',
|
|
121
|
+
'editor.category.mine': 'Mine',
|
|
122
|
+
'editor.category.sansSerif': 'Sans Serif',
|
|
123
|
+
'editor.category.serif': 'Serif',
|
|
124
|
+
'editor.category.script': 'Script',
|
|
125
|
+
'editor.category.other': 'Other',
|
|
126
|
+
'editor.category.icons': 'Icons',
|
|
127
|
+
'editor.category.emojis': 'Emojis',
|
|
128
|
+
'editor.category.clipart': 'Clipart',
|
|
129
|
+
// ===== Fonts =====
|
|
130
|
+
'editor.font.select': 'Select font...',
|
|
131
|
+
'editor.font.title': 'Fonts',
|
|
132
|
+
'editor.font.search': 'Search fonts...',
|
|
133
|
+
'editor.font.list': 'Font list',
|
|
134
|
+
'editor.font.loading': 'Loading fonts',
|
|
135
|
+
'editor.font.noneFound': 'No fonts found',
|
|
136
|
+
'editor.font.noneAvailable': 'No fonts available',
|
|
137
|
+
'editor.font.remove': 'Remove font',
|
|
138
|
+
'editor.font.weight': 'Font Weight',
|
|
139
|
+
/** The name a screen reader gives the list of weights a font has, when its menu is open. */
|
|
140
|
+
'editor.font.weightList': 'Font weights',
|
|
141
|
+
/** The look of a weight that has a name of its own; `{weight}` is one of the names below ("Bold Italic"). */
|
|
142
|
+
'editor.fontWeight.withItalic': '{weight} Italic',
|
|
143
|
+
'editor.fontWeight.italic': 'Italic',
|
|
144
|
+
'editor.fontWeight.thin': 'Thin',
|
|
145
|
+
'editor.fontWeight.extraLight': 'ExtraLight',
|
|
146
|
+
'editor.fontWeight.light': 'Light',
|
|
147
|
+
'editor.fontWeight.regular': 'Regular',
|
|
148
|
+
'editor.fontWeight.medium': 'Medium',
|
|
149
|
+
'editor.fontWeight.semiBold': 'SemiBold',
|
|
150
|
+
'editor.fontWeight.bold': 'Bold',
|
|
151
|
+
'editor.fontWeight.extraBold': 'ExtraBold',
|
|
152
|
+
'editor.fontWeight.black': 'Black',
|
|
153
|
+
// ===== Vectors (icons, emojis and clipart) =====
|
|
154
|
+
'editor.vector.select': 'Select vector...',
|
|
155
|
+
'editor.vector.title': 'Vectors',
|
|
156
|
+
'editor.vector.search': 'Search vectors...',
|
|
157
|
+
'editor.vector.list': 'Vector list',
|
|
158
|
+
'editor.vector.noneFound': 'No vectors found',
|
|
159
|
+
'editor.vector.noneAvailable': 'No vectors available',
|
|
160
|
+
// ===== Files =====
|
|
161
|
+
'editor.file.useFile': 'Use file',
|
|
162
|
+
'editor.file.useImage': 'Use image',
|
|
163
|
+
'editor.file.useVideo': 'Use video',
|
|
164
|
+
'editor.file.useAudio': 'Use audio',
|
|
165
|
+
'editor.file.useDocument': 'Use document',
|
|
166
|
+
'editor.file.addFile': 'Add file...',
|
|
167
|
+
'editor.file.addImage': 'Add image...',
|
|
168
|
+
'editor.file.addVideo': 'Add video...',
|
|
169
|
+
'editor.file.addAudio': 'Add audio...',
|
|
170
|
+
'editor.file.addDocument': 'Add docs...',
|
|
171
|
+
'editor.file.play': 'Play',
|
|
172
|
+
'editor.file.pause': 'Pause',
|
|
173
|
+
'editor.file.notFound': 'File not found',
|
|
174
|
+
'editor.file.emptyFolder': 'Empty folder',
|
|
175
|
+
'editor.file.clear': 'Clear file',
|
|
176
|
+
'editor.file.dialogTitle': 'Select file',
|
|
177
|
+
'editor.file.closeDialog': 'Close file browser',
|
|
178
|
+
// ===== Colours =====
|
|
179
|
+
'editor.color.noRecent': 'No recent colors',
|
|
180
|
+
'editor.color.picker': 'Color picker',
|
|
181
|
+
// ===== Dates =====
|
|
182
|
+
'editor.date.pick': 'Pick a date',
|
|
183
|
+
'editor.date.pickRange': 'Pick a date range',
|
|
184
|
+
'editor.date.invalid': 'Invalid date',
|
|
185
|
+
'editor.date.selectMonth': 'Select month',
|
|
186
|
+
'editor.date.selectYear': 'Select year',
|
|
187
|
+
/**
|
|
188
|
+
* The name a screen reader gives the calendar of one date. The library writes the month and year after it ("Date
|
|
189
|
+
* October 2026"), so a short noun is best.
|
|
190
|
+
*/
|
|
191
|
+
'editor.date.calendarLabel': 'Date',
|
|
192
|
+
/** The same for the calendar of a range of dates ("Date range October - November 2026"). */
|
|
193
|
+
'editor.date.rangeCalendarLabel': 'Date range',
|
|
194
|
+
/** The name a screen reader gives the buttons of a calendar that show the month before and the month after. */
|
|
195
|
+
'editor.date.previousMonth': 'Previous month',
|
|
196
|
+
'editor.date.nextMonth': 'Next month',
|
|
197
|
+
/** What is typed in the three boxes of a date: the hint inside the box, and its name for a screen reader. */
|
|
198
|
+
'editor.dateField.dayHint': 'DD',
|
|
199
|
+
'editor.dateField.monthHint': 'MM',
|
|
200
|
+
'editor.dateField.yearHint': 'YYYY',
|
|
201
|
+
'editor.dateField.dayLabel': 'Day input',
|
|
202
|
+
'editor.dateField.monthLabel': 'Month input',
|
|
203
|
+
'editor.dateField.yearLabel': 'Year input',
|
|
204
|
+
// ===== Small controls =====
|
|
205
|
+
'editor.dropdown.select': 'Select an option',
|
|
206
|
+
'editor.switch.off': 'Off',
|
|
207
|
+
'editor.switch.on': 'On',
|
|
208
|
+
'editor.tags.add': 'Add tag...',
|
|
209
|
+
/** The two letters beside the position of a point in a picture: how far across, and how far down. */
|
|
210
|
+
'editor.position.x': 'X:',
|
|
211
|
+
'editor.position.y': 'Y:',
|
|
212
|
+
/** The buttons of the nine places on a screen; `{position}` is one of the names below. */
|
|
213
|
+
'editor.fixedPosition.set': 'Set position to {position}',
|
|
214
|
+
'editor.fixedPosition.topLeft': 'top-left',
|
|
215
|
+
'editor.fixedPosition.topCenter': 'top-center',
|
|
216
|
+
'editor.fixedPosition.topRight': 'top-right',
|
|
217
|
+
'editor.fixedPosition.centerLeft': 'center-left',
|
|
218
|
+
'editor.fixedPosition.centerCenter': 'center-center',
|
|
219
|
+
'editor.fixedPosition.centerRight': 'center-right',
|
|
220
|
+
'editor.fixedPosition.bottomLeft': 'bottom-left',
|
|
221
|
+
'editor.fixedPosition.bottomCenter': 'bottom-center',
|
|
222
|
+
'editor.fixedPosition.bottomRight': 'bottom-right',
|
|
223
|
+
/** The corners of a box: the name of the group, of each of the four boxes, and of the lock between them. */
|
|
224
|
+
'editor.corners.group': 'Corner radius',
|
|
225
|
+
'editor.corners.topLeft': 'Top left corner radius',
|
|
226
|
+
'editor.corners.topRight': 'Top right corner radius',
|
|
227
|
+
'editor.corners.bottomLeft': 'Bottom left corner radius',
|
|
228
|
+
'editor.corners.bottomRight': 'Bottom right corner radius',
|
|
229
|
+
'editor.corners.lock': 'Lock corner radius values',
|
|
230
|
+
'editor.corners.unlock': 'Unlock corner radius values',
|
|
231
|
+
// ===== The text box =====
|
|
232
|
+
'editor.textArea.toolbar': 'Text formatting toolbar',
|
|
233
|
+
'editor.textArea.toggleBold': 'Toggle bold',
|
|
234
|
+
'editor.textArea.toggleItalic': 'Toggle italic',
|
|
235
|
+
'editor.textArea.toggleUnderline': 'Toggle underline',
|
|
236
|
+
'editor.textArea.toggleLink': 'Toggle link',
|
|
237
|
+
'editor.textArea.text': 'Text',
|
|
238
|
+
'editor.textArea.paragraph': 'Paragraph',
|
|
239
|
+
'editor.textArea.heading1': 'H1',
|
|
240
|
+
'editor.textArea.heading2': 'H2',
|
|
241
|
+
'editor.textArea.heading3': 'H3',
|
|
242
|
+
'editor.textArea.bulletList': 'Bullet List',
|
|
243
|
+
'editor.textArea.numberedList': 'Numbered List',
|
|
244
|
+
'editor.textArea.checkList': 'Check List',
|
|
245
|
+
/** The name a screen reader gives the list of text styles (paragraph, headings) when its menu is open. */
|
|
246
|
+
'editor.textArea.textStyles': 'Text styles',
|
|
247
|
+
/** The name a screen reader gives the list of list styles (bullets, numbers, checks) when its menu is open. */
|
|
248
|
+
'editor.textArea.listStyles': 'List styles',
|
|
249
|
+
/** The question the browser asks when a link is added. */
|
|
250
|
+
'editor.textArea.enterUrl': 'Enter URL',
|
|
251
|
+
// ===== Words the editor adds to the widget's own schema =====
|
|
252
|
+
'editor.schema.subtitleFont': 'Subtitle Font'
|
|
253
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The English `t` of the editor, for code that has no component around it (the controller of the composition editor makes
|
|
3
|
+
* its sentences with it until the page gives another translator). The editor's screens get their words, in the page's
|
|
4
|
+
* language, from `useEditorLanguage` (see `language.ts`).
|
|
5
|
+
*/
|
|
6
|
+
export declare const translateEnglish: any;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createI18n } from '@widgetic/design-system/i18n';
|
|
2
|
+
import { EDITOR_MESSAGES } from './messages.js';
|
|
3
|
+
/**
|
|
4
|
+
* The English `t` of the editor, for code that has no component around it (the controller of the composition editor makes
|
|
5
|
+
* its sentences with it until the page gives another translator). The editor's screens get their words, in the page's
|
|
6
|
+
* language, from `useEditorLanguage` (see `language.ts`).
|
|
7
|
+
*/
|
|
8
|
+
export const { translateEnglish } = createI18n({ catalog: EDITOR_MESSAGES, label: 'Editor' });
|
package/dist/index.d.ts
CHANGED
|
@@ -5,3 +5,7 @@ export { default as WidgetPreview } from './components/WidgetPreview.svelte';
|
|
|
5
5
|
export { setFileBrowserUploadConfig } from '@widgetic/file-browser';
|
|
6
6
|
export { setGoogleFontsApiKey, getGoogleFontsKey } from './config';
|
|
7
7
|
export { default as EmbedEditor } from './components/editors/EmbedEditor.svelte';
|
|
8
|
+
export { default as CompositionEditorApp } from './components/editors/CompositionEditorApp.svelte';
|
|
9
|
+
export { CompositionApiError, createCompositionApi, type CompositionApi, type CompositionApiOptions, type CompositionPreviewInfo, type SaveCompositionBody, type TokenReason } from './composition/compositionApi.js';
|
|
10
|
+
export { failureMessage, type CompositionEditorEvent, type CompositionEditorState, type DeviceView, type EditorFailure } from './composition/compositionEditorController.js';
|
|
11
|
+
export { EDITOR_MESSAGES, ALL_EDITOR_MESSAGES, checkEditorMessages, provideEditorLanguage, useEditorLanguage, type EditorLanguage, type EditorLanguageHandle, type EditorMessageKey } from './i18n/index.js';
|
package/dist/index.js
CHANGED
|
@@ -8,3 +8,11 @@ export { setFileBrowserUploadConfig } from '@widgetic/file-browser';
|
|
|
8
8
|
export { setGoogleFontsApiKey, getGoogleFontsKey } from './config';
|
|
9
9
|
// Embed Editor
|
|
10
10
|
export { default as EmbedEditor } from './components/editors/EmbedEditor.svelte';
|
|
11
|
+
// Composition Editor: one Widgetic composition, loaded, edited beside a live preview, and saved through the API.
|
|
12
|
+
export { default as CompositionEditorApp } from './components/editors/CompositionEditorApp.svelte';
|
|
13
|
+
export { CompositionApiError, createCompositionApi } from './composition/compositionApi.js';
|
|
14
|
+
export { failureMessage } from './composition/compositionEditorController.js';
|
|
15
|
+
// The words of the editor, in the language of the page: the catalog of English messages, a check for a page's own
|
|
16
|
+
// messages, and what a host that mounts PropsEditor, EmbedEditor or WidgetPreview on their own gives them (the composition
|
|
17
|
+
// editor does it for itself, from its `locale` and `messages`).
|
|
18
|
+
export { EDITOR_MESSAGES, ALL_EDITOR_MESSAGES, checkEditorMessages, provideEditorLanguage, useEditorLanguage } from './i18n/index.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MediaLibraryProvider } from '@widgetic/file-browser';
|
|
2
|
+
/** Gives the current media library, or `undefined` for the File Browser's own (Widgetic account) storage. */
|
|
3
|
+
export type MediaLibraryGetter = () => MediaLibraryProvider | undefined;
|
|
4
|
+
/** Called while an editor component is being created: everything below it can reach the library with {@link useEditorMediaLibrary}. */
|
|
5
|
+
export declare function provideEditorMediaLibrary(getMediaLibrary: MediaLibraryGetter): void;
|
|
6
|
+
/**
|
|
7
|
+
* Called while a component is being created. Gives the function that tells which media library the editor above it was
|
|
8
|
+
* given. Outside an editor (a control used on its own) it always gives `undefined`, as the File Browser did before.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useEditorMediaLibrary(): MediaLibraryGetter;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hands the File Browser's media library from the editor down to the file controls inside it.
|
|
3
|
+
*
|
|
4
|
+
* `PropsEditor` is given a `mediaLibrary` (a partner's own storage, for instance). The file control
|
|
5
|
+
* (`BrowserInputController`) sits several components below it and is created from a schema, so passing the library
|
|
6
|
+
* as a prop through every layer would mean threading it through the controller renderer too. A Svelte context
|
|
7
|
+
* reaches it directly, and stays separate for each editor on a page.
|
|
8
|
+
*
|
|
9
|
+
* What is stored is a function that reads the editor's `mediaLibrary` prop, not the library itself.
|
|
10
|
+
*/
|
|
11
|
+
import { getContext, setContext } from 'svelte';
|
|
12
|
+
const MEDIA_LIBRARY_CONTEXT_KEY = Symbol.for('widgetic.editor.mediaLibrary');
|
|
13
|
+
/** Called while an editor component is being created: everything below it can reach the library with {@link useEditorMediaLibrary}. */
|
|
14
|
+
export function provideEditorMediaLibrary(getMediaLibrary) {
|
|
15
|
+
setContext(MEDIA_LIBRARY_CONTEXT_KEY, getMediaLibrary);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Called while a component is being created. Gives the function that tells which media library the editor above it was
|
|
19
|
+
* given. Outside an editor (a control used on its own) it always gives `undefined`, as the File Browser did before.
|
|
20
|
+
*/
|
|
21
|
+
export function useEditorMediaLibrary() {
|
|
22
|
+
try {
|
|
23
|
+
return getContext(MEDIA_LIBRARY_CONTEXT_KEY) ?? (() => undefined);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
// getContext only works while a component is being created; anywhere else there is no editor above to ask.
|
|
27
|
+
console.warn('[editor] useEditorMediaLibrary was called outside a component; using the default media library', error);
|
|
28
|
+
return () => undefined;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -32,6 +32,8 @@ declare class FontManager {
|
|
|
32
32
|
private static readonly WAIT_TIME;
|
|
33
33
|
private static instance;
|
|
34
34
|
private loadedFonts;
|
|
35
|
+
private addedHeadElements;
|
|
36
|
+
private pageWasReleased;
|
|
35
37
|
private observers;
|
|
36
38
|
private scrollTimeout;
|
|
37
39
|
private apiKey;
|
|
@@ -49,9 +51,6 @@ declare class FontManager {
|
|
|
49
51
|
private static readonly CACHE_KEY;
|
|
50
52
|
private static readonly CACHE_DURATION;
|
|
51
53
|
private static readonly LOADED_FONTS_KEY;
|
|
52
|
-
private static readonly LEGACY_CACHE_KEY;
|
|
53
|
-
private static readonly LEGACY_LOADED_FONTS_KEY;
|
|
54
|
-
private static readonly CACHE_CONTROL;
|
|
55
54
|
private visibleFonts;
|
|
56
55
|
private static initialPreloadComplete;
|
|
57
56
|
private static preloadPromise;
|
|
@@ -106,7 +105,7 @@ declare class FontManager {
|
|
|
106
105
|
*/
|
|
107
106
|
getPreInitializedObserver(): IntersectionObserver | null;
|
|
108
107
|
/**
|
|
109
|
-
* Loads previously cached fonts from the durable L1 store
|
|
108
|
+
* Loads previously cached fonts from the durable L1 store
|
|
110
109
|
*/
|
|
111
110
|
private loadCachedFonts;
|
|
112
111
|
/**
|
|
@@ -121,6 +120,23 @@ declare class FontManager {
|
|
|
121
120
|
* Checks if a font is available in Google Fonts
|
|
122
121
|
*/
|
|
123
122
|
private isGoogleFont;
|
|
123
|
+
/**
|
|
124
|
+
* Puts an element in the page's <head> and remembers it, so that it can be taken away again
|
|
125
|
+
* ({@link removeAddedHeadElements}): the editor can be on somebody else's page, which it should leave as it found it.
|
|
126
|
+
*/
|
|
127
|
+
private addToHead;
|
|
128
|
+
/**
|
|
129
|
+
* Takes out of the page's <head> everything this manager put there (the stylesheets of the fonts, their preload
|
|
130
|
+
* hints and the connection hint), and forgets which fonts were loaded, because they are not any more. The next
|
|
131
|
+
* font to be asked for puts its stylesheet back. The page's own links are never touched: only what was added here
|
|
132
|
+
* is removed.
|
|
133
|
+
*/
|
|
134
|
+
removeAddedHeadElements(): void;
|
|
135
|
+
/**
|
|
136
|
+
* Leaves the page as the editor found it as far as fonts go. Meant for when the editor is taken away; does nothing
|
|
137
|
+
* if no font was ever asked for.
|
|
138
|
+
*/
|
|
139
|
+
static releasePageResources(): void;
|
|
124
140
|
/**
|
|
125
141
|
* Inserts a font stylesheet into the document
|
|
126
142
|
* @param family - Font family name
|
|
@@ -161,7 +177,7 @@ declare class FontManager {
|
|
|
161
177
|
*/
|
|
162
178
|
private saveFontListToCache;
|
|
163
179
|
/**
|
|
164
|
-
* Gets font list from the durable L1 cache
|
|
180
|
+
* Gets font list from the durable L1 cache
|
|
165
181
|
*/
|
|
166
182
|
private getFontListFromCache;
|
|
167
183
|
/**
|