kirby-types 1.4.7 → 1.4.9
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/package.json +8 -8
- package/src/panel/api.d.ts +42 -38
- package/src/panel/base.d.ts +42 -54
- package/src/panel/features.d.ts +139 -114
- package/src/panel/helpers.d.ts +90 -68
- package/src/panel/index.d.ts +131 -23
- package/src/panel/libraries.d.ts +45 -66
- package/src/panel/textarea.d.ts +18 -50
- package/src/panel/writer.d.ts +66 -35
package/src/panel/libraries.d.ts
CHANGED
|
@@ -14,14 +14,10 @@ import type { ConfigType, Dayjs, OpUnitType, PluginFunc } from "dayjs";
|
|
|
14
14
|
// Color Types
|
|
15
15
|
// -----------------------------------------------------------------------------
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Color format identifiers.
|
|
19
|
-
*/
|
|
17
|
+
/** Color format identifiers. */
|
|
20
18
|
export type PanelColorFormat = "hex" | "rgb" | "hsl" | "hsv";
|
|
21
19
|
|
|
22
|
-
/**
|
|
23
|
-
* RGB color object.
|
|
24
|
-
*/
|
|
20
|
+
/** RGB color object. */
|
|
25
21
|
export interface PanelColorRGB {
|
|
26
22
|
/** Red channel (0-255) */
|
|
27
23
|
r: number;
|
|
@@ -33,9 +29,7 @@ export interface PanelColorRGB {
|
|
|
33
29
|
a?: number;
|
|
34
30
|
}
|
|
35
31
|
|
|
36
|
-
/**
|
|
37
|
-
* HSL color object.
|
|
38
|
-
*/
|
|
32
|
+
/** HSL color object. */
|
|
39
33
|
export interface PanelColorHSL {
|
|
40
34
|
/** Hue (0-360) */
|
|
41
35
|
h: number;
|
|
@@ -47,9 +41,7 @@ export interface PanelColorHSL {
|
|
|
47
41
|
a?: number;
|
|
48
42
|
}
|
|
49
43
|
|
|
50
|
-
/**
|
|
51
|
-
* HSV color object.
|
|
52
|
-
*/
|
|
44
|
+
/** HSV color object. */
|
|
53
45
|
export interface PanelColorHSV {
|
|
54
46
|
/** Hue (0-360) */
|
|
55
47
|
h: number;
|
|
@@ -61,22 +53,14 @@ export interface PanelColorHSV {
|
|
|
61
53
|
a?: number;
|
|
62
54
|
}
|
|
63
55
|
|
|
64
|
-
/**
|
|
65
|
-
* Any color object type.
|
|
66
|
-
*/
|
|
56
|
+
/** Any color object type. */
|
|
67
57
|
export type PanelColorObject = PanelColorRGB | PanelColorHSL | PanelColorHSV;
|
|
68
58
|
|
|
69
|
-
/**
|
|
70
|
-
* Color input (string or object).
|
|
71
|
-
*/
|
|
59
|
+
/** Color input (string or object). */
|
|
72
60
|
export type PanelColorInput = string | PanelColorObject;
|
|
73
61
|
|
|
74
62
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* Provides comprehensive color manipulation including
|
|
78
|
-
* parsing CSS color strings and converting between
|
|
79
|
-
* HEX, RGB, HSL, and HSV color spaces.
|
|
63
|
+
* Parses CSS color strings and converts between HEX, RGB, HSL, and HSV color spaces.
|
|
80
64
|
*
|
|
81
65
|
* @example
|
|
82
66
|
* ```ts
|
|
@@ -87,6 +71,8 @@ export type PanelColorInput = string | PanelColorObject;
|
|
|
87
71
|
*
|
|
88
72
|
* @see https://github.com/getkirby/kirby/blob/main/panel/src/libraries/colors.js
|
|
89
73
|
* @since 4.0.0
|
|
74
|
+
* @source panel/src/libraries/colors.js
|
|
75
|
+
* @source panel/src/libraries/colors-checks.js
|
|
90
76
|
*/
|
|
91
77
|
export interface PanelLibraryColors {
|
|
92
78
|
/**
|
|
@@ -124,7 +110,7 @@ export interface PanelLibraryColors {
|
|
|
124
110
|
* Parses a CSS color string to HEX string or color object.
|
|
125
111
|
*
|
|
126
112
|
* Supports:
|
|
127
|
-
* - HEX: `#fff`, `#ffffff`, `#ffffffff`
|
|
113
|
+
* - HEX: `#fff`, `#ffff`, `#ffffff`, `#ffffffff`
|
|
128
114
|
* - RGB: `rgb(255 255 255)`, `rgb(255, 255, 255)`, `rgba(255 255 255 / 0.5)`
|
|
129
115
|
* - HSL: `hsl(180 50% 50%)`, `hsl(180deg 50% 50% / 0.5)`
|
|
130
116
|
*
|
|
@@ -143,14 +129,14 @@ export interface PanelLibraryColors {
|
|
|
143
129
|
* @returns Converted color or `false` if invalid
|
|
144
130
|
*/
|
|
145
131
|
parseAs: {
|
|
146
|
-
(string: string, format: "hex"): string | false;
|
|
147
|
-
(string: string, format: "rgb"): PanelColorRGB | false;
|
|
148
|
-
(string: string, format: "hsl"): PanelColorHSL | false;
|
|
149
|
-
(string: string, format: "hsv"): PanelColorHSV | false;
|
|
132
|
+
(string: string, format: "hex"): string | null | false;
|
|
133
|
+
(string: string, format: "rgb"): PanelColorRGB | null | false;
|
|
134
|
+
(string: string, format: "hsl"): PanelColorHSL | null | false;
|
|
135
|
+
(string: string, format: "hsv"): PanelColorHSV | null | false;
|
|
150
136
|
(
|
|
151
137
|
string: string,
|
|
152
138
|
format?: PanelColorFormat,
|
|
153
|
-
): string | PanelColorObject | false;
|
|
139
|
+
): string | PanelColorObject | null | false;
|
|
154
140
|
};
|
|
155
141
|
|
|
156
142
|
/**
|
|
@@ -173,9 +159,7 @@ export interface PanelLibraryColors {
|
|
|
173
159
|
// Dayjs Types
|
|
174
160
|
// -----------------------------------------------------------------------------
|
|
175
161
|
|
|
176
|
-
/**
|
|
177
|
-
* Pattern part information.
|
|
178
|
-
*/
|
|
162
|
+
/** Pattern part information. */
|
|
179
163
|
export interface PanelDayjsPatternPart {
|
|
180
164
|
/** Part index in pattern */
|
|
181
165
|
index: number;
|
|
@@ -189,6 +173,7 @@ export interface PanelDayjsPatternPart {
|
|
|
189
173
|
|
|
190
174
|
/**
|
|
191
175
|
* Pattern analyzer object returned by `dayjs.pattern()`.
|
|
176
|
+
* @source panel/src/libraries/dayjs-pattern.js
|
|
192
177
|
*/
|
|
193
178
|
export interface PanelDayjsPattern {
|
|
194
179
|
/** Original pattern string */
|
|
@@ -214,8 +199,10 @@ export interface PanelDayjsPattern {
|
|
|
214
199
|
|
|
215
200
|
/**
|
|
216
201
|
* Kirby plugin extensions for dayjs instances.
|
|
217
|
-
*
|
|
218
|
-
*
|
|
202
|
+
* @source panel/src/libraries/dayjs-iso.js
|
|
203
|
+
* @source panel/src/libraries/dayjs-validate.js
|
|
204
|
+
* @source panel/src/libraries/dayjs-merge.js
|
|
205
|
+
* @source panel/src/libraries/dayjs-round.js
|
|
219
206
|
*/
|
|
220
207
|
export interface PanelDayjsExtensions {
|
|
221
208
|
/**
|
|
@@ -229,13 +216,13 @@ export interface PanelDayjsExtensions {
|
|
|
229
216
|
/**
|
|
230
217
|
* Validates datetime against an upper or lower (min/max) boundary.
|
|
231
218
|
*
|
|
232
|
-
* @param boundary - Boundary as ISO string
|
|
219
|
+
* @param boundary - Boundary as ISO string. If falsy, returns `true` when the dayjs instance is valid.
|
|
233
220
|
* @param type - `"min"` or `"max"`
|
|
234
221
|
* @param unit - Comparison unit (default: `"day"`)
|
|
235
222
|
* @returns Whether the date is valid against the boundary
|
|
236
223
|
*/
|
|
237
224
|
validate: (
|
|
238
|
-
boundary: string,
|
|
225
|
+
boundary: string | null | undefined,
|
|
239
226
|
type: "min" | "max",
|
|
240
227
|
unit?: OpUnitType,
|
|
241
228
|
) => boolean;
|
|
@@ -272,15 +259,14 @@ export interface PanelDayjsExtensions {
|
|
|
272
259
|
) => Dayjs & PanelDayjsExtensions;
|
|
273
260
|
}
|
|
274
261
|
|
|
275
|
-
/**
|
|
276
|
-
* Kirby-extended dayjs instance type.
|
|
277
|
-
*
|
|
278
|
-
* Combines the standard dayjs `Dayjs` class with Kirby's plugin extensions.
|
|
279
|
-
*/
|
|
262
|
+
/** Kirby-extended dayjs instance type. */
|
|
280
263
|
export type PanelDayjsInstance = Dayjs & PanelDayjsExtensions;
|
|
281
264
|
|
|
282
265
|
/**
|
|
283
266
|
* Kirby plugin extensions for the dayjs function (static methods).
|
|
267
|
+
* @source panel/src/libraries/dayjs-interpret.js
|
|
268
|
+
* @source panel/src/libraries/dayjs-iso.js
|
|
269
|
+
* @source panel/src/libraries/dayjs-pattern.js
|
|
284
270
|
*/
|
|
285
271
|
export interface PanelDayjsStaticExtensions {
|
|
286
272
|
/**
|
|
@@ -334,11 +320,12 @@ export interface PanelDayjsStaticExtensions {
|
|
|
334
320
|
*
|
|
335
321
|
* @see https://github.com/getkirby/kirby/blob/main/panel/src/libraries/dayjs.js
|
|
336
322
|
* @since 4.0.0
|
|
323
|
+
* @source panel/src/libraries/dayjs.js
|
|
324
|
+
* @source panel/src/libraries/dayjs-interpret.js
|
|
325
|
+
* @source panel/src/libraries/dayjs-iso.js
|
|
326
|
+
* @source panel/src/libraries/dayjs-pattern.js
|
|
337
327
|
*/
|
|
338
328
|
export interface PanelLibraryDayjs extends PanelDayjsStaticExtensions {
|
|
339
|
-
/**
|
|
340
|
-
* Creates a dayjs instance.
|
|
341
|
-
*/
|
|
342
329
|
(date?: ConfigType): PanelDayjsInstance;
|
|
343
330
|
(date?: ConfigType, format?: string, strict?: boolean): PanelDayjsInstance;
|
|
344
331
|
(
|
|
@@ -348,16 +335,13 @@ export interface PanelLibraryDayjs extends PanelDayjsStaticExtensions {
|
|
|
348
335
|
strict?: boolean,
|
|
349
336
|
): PanelDayjsInstance;
|
|
350
337
|
|
|
351
|
-
/** Extends dayjs with a plugin */
|
|
352
338
|
extend: <T = unknown>(
|
|
353
339
|
plugin: PluginFunc<T>,
|
|
354
340
|
option?: T,
|
|
355
341
|
) => typeof import("dayjs");
|
|
356
342
|
|
|
357
|
-
/** Gets or sets the global locale */
|
|
358
343
|
locale: (preset?: string, object?: object, isLocal?: boolean) => string;
|
|
359
344
|
|
|
360
|
-
/** Type guard for dayjs instances */
|
|
361
345
|
isDayjs: (value: unknown) => value is PanelDayjsInstance;
|
|
362
346
|
|
|
363
347
|
/** Creates a dayjs instance from Unix timestamp (seconds) */
|
|
@@ -374,6 +358,8 @@ export interface PanelLibraryDayjs extends PanelDayjsStaticExtensions {
|
|
|
374
358
|
* Automatically adjusts textarea height based on content.
|
|
375
359
|
*
|
|
376
360
|
* @see https://www.npmjs.com/package/autosize
|
|
361
|
+
* @source panel/src/libraries/index.js
|
|
362
|
+
* @source @types/autosize/index.d.ts
|
|
377
363
|
*/
|
|
378
364
|
export interface PanelLibraryAutosize {
|
|
379
365
|
/**
|
|
@@ -390,19 +376,21 @@ export interface PanelLibraryAutosize {
|
|
|
390
376
|
* Triggers a resize update.
|
|
391
377
|
*
|
|
392
378
|
* @param element - Element(s) to update
|
|
379
|
+
* @returns The input element(s)
|
|
393
380
|
*/
|
|
394
|
-
update: (
|
|
395
|
-
element:
|
|
396
|
-
) =>
|
|
381
|
+
update: <T extends HTMLTextAreaElement | HTMLTextAreaElement[] | NodeList>(
|
|
382
|
+
element: T,
|
|
383
|
+
) => T;
|
|
397
384
|
|
|
398
385
|
/**
|
|
399
|
-
*
|
|
386
|
+
* Removes autosize behavior and restores the original textarea styling.
|
|
400
387
|
*
|
|
401
388
|
* @param element - Element(s) to destroy
|
|
389
|
+
* @returns The input element(s)
|
|
402
390
|
*/
|
|
403
|
-
destroy: (
|
|
404
|
-
element:
|
|
405
|
-
) =>
|
|
391
|
+
destroy: <T extends HTMLTextAreaElement | HTMLTextAreaElement[] | NodeList>(
|
|
392
|
+
element: T,
|
|
393
|
+
) => T;
|
|
406
394
|
}
|
|
407
395
|
|
|
408
396
|
// -----------------------------------------------------------------------------
|
|
@@ -412,9 +400,6 @@ export interface PanelLibraryAutosize {
|
|
|
412
400
|
/**
|
|
413
401
|
* Panel libraries available on the Vue prototype as `$library`.
|
|
414
402
|
*
|
|
415
|
-
* Provides utilities for color manipulation, date handling,
|
|
416
|
-
* and textarea auto-resizing.
|
|
417
|
-
*
|
|
418
403
|
* @example
|
|
419
404
|
* ```ts
|
|
420
405
|
* // In a Vue component
|
|
@@ -424,20 +409,14 @@ export interface PanelLibraryAutosize {
|
|
|
424
409
|
* ```
|
|
425
410
|
*
|
|
426
411
|
* @see https://github.com/getkirby/kirby/blob/main/panel/src/libraries/index.js
|
|
412
|
+
* @source panel/src/libraries/index.js
|
|
413
|
+
* @source panel/src/libraries/colors.js
|
|
414
|
+
* @source panel/src/libraries/dayjs.js
|
|
427
415
|
*/
|
|
428
416
|
export interface PanelLibrary {
|
|
429
|
-
/**
|
|
430
|
-
* Textarea auto-resize library.
|
|
431
|
-
*/
|
|
432
417
|
autosize: PanelLibraryAutosize;
|
|
433
418
|
|
|
434
|
-
/**
|
|
435
|
-
* Color manipulation library.
|
|
436
|
-
*/
|
|
437
419
|
colors: PanelLibraryColors;
|
|
438
420
|
|
|
439
|
-
/**
|
|
440
|
-
* Date manipulation library (extended dayjs).
|
|
441
|
-
*/
|
|
442
421
|
dayjs: PanelLibraryDayjs;
|
|
443
422
|
}
|
package/src/panel/textarea.d.ts
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* The toolbar component context available as `this` in button click handlers.
|
|
17
17
|
*
|
|
18
18
|
* @see https://github.com/getkirby/kirby/blob/main/panel/src/components/Forms/Toolbar.vue
|
|
19
|
+
* @source panel/src/components/Forms/Toolbar/TextareaToolbar.vue
|
|
20
|
+
* @source panel/src/components/Forms/Input/TextareaInput.vue
|
|
19
21
|
*/
|
|
20
22
|
export interface TextareaToolbarContext {
|
|
21
23
|
/**
|
|
@@ -24,7 +26,7 @@ export interface TextareaToolbarContext {
|
|
|
24
26
|
* Available commands:
|
|
25
27
|
* - `"dialog"` - Opens a dialog component
|
|
26
28
|
* - `"insert"` - Inserts the given text at the current selection
|
|
27
|
-
* - `"prepend"` - Prepends the given text to the current selection
|
|
29
|
+
* - `"prepend"` - Prepends the given text to the current selection
|
|
28
30
|
* - `"toggle"` - Toggles wrapping of current selection (accepts before, after texts)
|
|
29
31
|
* - `"upload"` - Opens the file upload dialog
|
|
30
32
|
* - `"wrap"` - Wraps the current selection with the given text
|
|
@@ -53,14 +55,10 @@ export interface TextareaToolbarContext {
|
|
|
53
55
|
...args: any[]
|
|
54
56
|
) => void;
|
|
55
57
|
|
|
56
|
-
/**
|
|
57
|
-
* Closes all dropdowns.
|
|
58
|
-
*/
|
|
58
|
+
/** Closes all dropdowns. */
|
|
59
59
|
close: () => void;
|
|
60
60
|
|
|
61
|
-
/**
|
|
62
|
-
* Vue translation function.
|
|
63
|
-
*/
|
|
61
|
+
/** Translates a Kirby translation key, with optional placeholder values. */
|
|
64
62
|
$t: (key: string, ...args: any[]) => string;
|
|
65
63
|
}
|
|
66
64
|
|
|
@@ -92,32 +90,18 @@ export interface TextareaToolbarContext {
|
|
|
92
90
|
* ```
|
|
93
91
|
*
|
|
94
92
|
* @see https://getkirby.com/docs/reference/plugins/extensions/textarea-buttons
|
|
93
|
+
* @source panel/src/components/Forms/Toolbar/TextareaToolbar.vue
|
|
94
|
+
* @source panel/src/components/Forms/Toolbar/Toolbar.vue
|
|
95
95
|
*/
|
|
96
96
|
export interface TextareaButton {
|
|
97
|
-
/**
|
|
98
|
-
* Display label for the button (appears in tooltip).
|
|
99
|
-
*/
|
|
97
|
+
/** Display label for the button (appears in tooltip). */
|
|
100
98
|
label: string;
|
|
101
99
|
|
|
102
|
-
/**
|
|
103
|
-
* Icon name from Kirby's icon set.
|
|
104
|
-
*/
|
|
100
|
+
/** Icon name from Kirby's icon set. */
|
|
105
101
|
icon: string;
|
|
106
102
|
|
|
107
103
|
/**
|
|
108
|
-
* Click handler.
|
|
109
|
-
*
|
|
110
|
-
* Called with `this` bound to the toolbar component, which provides:
|
|
111
|
-
* - `this.command(name, ...args)` - Execute a textarea command
|
|
112
|
-
*
|
|
113
|
-
* Available commands:
|
|
114
|
-
* - `dialog` - Opens a dialog component
|
|
115
|
-
* - `insert` - Inserts text at the cursor (can be a function receiving input and selection)
|
|
116
|
-
* - `prepend` - Prepends text to the current line
|
|
117
|
-
* - `toggle` - Toggles wrapping of selection with before/after text
|
|
118
|
-
* - `upload` - Opens the file upload dialog
|
|
119
|
-
* - `wrap` - Wraps the selection with given text
|
|
120
|
-
* - `file` - Opens the file picker
|
|
104
|
+
* Click handler. `this` is bound to the toolbar component (see {@link TextareaToolbarContext}), so `this.command(...)` is available.
|
|
121
105
|
*
|
|
122
106
|
* @example
|
|
123
107
|
* ```js
|
|
@@ -167,29 +151,19 @@ export interface TextareaButton {
|
|
|
167
151
|
*/
|
|
168
152
|
dropdown?: TextareaDropdownItem[];
|
|
169
153
|
|
|
170
|
-
/**
|
|
171
|
-
* Conditional rendering. If false, the button won't be shown.
|
|
172
|
-
*/
|
|
154
|
+
/** Conditional rendering. If false, the button won't be shown. */
|
|
173
155
|
when?: boolean;
|
|
174
156
|
|
|
175
|
-
/**
|
|
176
|
-
* Disables the button.
|
|
177
|
-
*/
|
|
157
|
+
/** Disables the button. */
|
|
178
158
|
disabled?: boolean;
|
|
179
159
|
|
|
180
|
-
/**
|
|
181
|
-
* Sets the aria-current attribute for active state styling.
|
|
182
|
-
*/
|
|
160
|
+
/** Sets the aria-current attribute for active state styling. */
|
|
183
161
|
current?: boolean | string;
|
|
184
162
|
|
|
185
|
-
/**
|
|
186
|
-
* Alternative tooltip text (defaults to label).
|
|
187
|
-
*/
|
|
163
|
+
/** Tooltip text used as a fallback when `label` is not set. */
|
|
188
164
|
title?: string;
|
|
189
165
|
|
|
190
|
-
/**
|
|
191
|
-
* Custom CSS class for the button.
|
|
192
|
-
*/
|
|
166
|
+
/** Custom CSS class for the button. */
|
|
193
167
|
class?: string;
|
|
194
168
|
}
|
|
195
169
|
|
|
@@ -237,18 +211,12 @@ export interface TextareaDropdownItem {
|
|
|
237
211
|
*/
|
|
238
212
|
click: () => void;
|
|
239
213
|
|
|
240
|
-
/**
|
|
241
|
-
* Conditional rendering. If false, the item won't be shown.
|
|
242
|
-
*/
|
|
214
|
+
/** Conditional rendering. If false, the item won't be shown. */
|
|
243
215
|
when?: boolean;
|
|
244
216
|
|
|
245
|
-
/**
|
|
246
|
-
* Disables the dropdown item.
|
|
247
|
-
*/
|
|
217
|
+
/** Disables the dropdown item. */
|
|
248
218
|
disabled?: boolean;
|
|
249
219
|
|
|
250
|
-
/**
|
|
251
|
-
* Sets the aria-current attribute for active state styling.
|
|
252
|
-
*/
|
|
220
|
+
/** Sets the aria-current attribute for active state styling. */
|
|
253
221
|
current?: boolean | string;
|
|
254
222
|
}
|
package/src/panel/writer.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ import type {
|
|
|
47
47
|
* when using class-based extensions, or that is passed to event handlers.
|
|
48
48
|
*
|
|
49
49
|
* @see https://github.com/getkirby/kirby/blob/main/panel/src/components/Forms/Writer/Editor.js
|
|
50
|
+
* @source panel/src/components/Forms/Writer/Editor.js
|
|
51
|
+
* @source panel/src/components/Forms/Writer/Emitter.js
|
|
50
52
|
*/
|
|
51
53
|
export interface WriterEditor {
|
|
52
54
|
// ---------------------------------------------------------------------------
|
|
@@ -65,7 +67,7 @@ export interface WriterEditor {
|
|
|
65
67
|
commands: Record<string, (attrs?: any) => any>;
|
|
66
68
|
/** The DOM element the editor is mounted to */
|
|
67
69
|
element: HTMLElement | null;
|
|
68
|
-
/**
|
|
70
|
+
/** Event handlers passed via `options.events` */
|
|
69
71
|
events: Record<string, (...args: any[]) => any>;
|
|
70
72
|
/** The extensions manager instance */
|
|
71
73
|
extensions: WriterExtensions;
|
|
@@ -233,7 +235,7 @@ export interface WriterEditorOptions {
|
|
|
233
235
|
export interface WriterExtensions {
|
|
234
236
|
/** All registered extension instances */
|
|
235
237
|
extensions: (WriterExtension | WriterMarkExtension | WriterNodeExtension)[];
|
|
236
|
-
/** ProseMirror EditorView
|
|
238
|
+
/** ProseMirror EditorView assigned by the editor after initialization */
|
|
237
239
|
view: EditorView;
|
|
238
240
|
|
|
239
241
|
/** Returns toolbar buttons for the given type */
|
|
@@ -260,6 +262,10 @@ export interface WriterExtensions {
|
|
|
260
262
|
* Buttons appear in the Writer toolbar and trigger commands when clicked.
|
|
261
263
|
*
|
|
262
264
|
* @see https://github.com/getkirby/kirby/blob/main/panel/src/components/Forms/Writer/Toolbar.vue
|
|
265
|
+
* @source panel/src/components/Forms/Writer/Extensions.js
|
|
266
|
+
* @source panel/src/components/Forms/Writer/Toolbar.vue
|
|
267
|
+
* @source panel/src/components/Forms/Writer/Nodes/Heading.js
|
|
268
|
+
* @source panel/src/components/Forms/Writer/Marks/Link.js
|
|
263
269
|
*/
|
|
264
270
|
export interface WriterToolbarButton {
|
|
265
271
|
/** Unique identifier (defaults to extension name) */
|
|
@@ -278,7 +284,7 @@ export interface WriterToolbarButton {
|
|
|
278
284
|
separator?: boolean;
|
|
279
285
|
/** Whether this is an inline node button (shown inline, not in dropdown) */
|
|
280
286
|
inline?: boolean;
|
|
281
|
-
/**
|
|
287
|
+
/** Names of active node types under which this dropdown button stays enabled */
|
|
282
288
|
when?: string[];
|
|
283
289
|
}
|
|
284
290
|
|
|
@@ -294,6 +300,7 @@ export interface WriterToolbarButton {
|
|
|
294
300
|
* extension methods via the context object.
|
|
295
301
|
*
|
|
296
302
|
* @see https://github.com/getkirby/kirby/tree/main/panel/src/components/Forms/Writer/Utils
|
|
303
|
+
* @source panel/src/components/Forms/Writer/Utils/index.js
|
|
297
304
|
*/
|
|
298
305
|
export interface WriterUtils {
|
|
299
306
|
// ---------------------------------------------------------------------------
|
|
@@ -364,9 +371,16 @@ export interface WriterUtils {
|
|
|
364
371
|
*
|
|
365
372
|
* @param type - The node type to insert
|
|
366
373
|
* @param attrs - Optional attributes for the node
|
|
374
|
+
* @param content - Optional initial content for the node
|
|
375
|
+
* @param marks - Optional marks to apply to the node
|
|
367
376
|
* @returns A ProseMirror command
|
|
368
377
|
*/
|
|
369
|
-
insertNode: (
|
|
378
|
+
insertNode: (
|
|
379
|
+
type: NodeType,
|
|
380
|
+
attrs?: Record<string, any>,
|
|
381
|
+
content?: Fragment | ProseMirrorNode | ProseMirrorNode[] | null,
|
|
382
|
+
marks?: Mark[] | null,
|
|
383
|
+
) => Command;
|
|
370
384
|
|
|
371
385
|
/**
|
|
372
386
|
* Creates an input rule that applies a mark when the pattern matches.
|
|
@@ -402,7 +416,7 @@ export interface WriterUtils {
|
|
|
402
416
|
markPasteRule: (
|
|
403
417
|
regexp: RegExp,
|
|
404
418
|
type: MarkType,
|
|
405
|
-
getAttrs?: (match:
|
|
419
|
+
getAttrs?: (match: RegExpMatchArray) => Record<string, any>,
|
|
406
420
|
) => Plugin;
|
|
407
421
|
|
|
408
422
|
/**
|
|
@@ -444,11 +458,11 @@ export interface WriterUtils {
|
|
|
444
458
|
) => boolean;
|
|
445
459
|
|
|
446
460
|
/**
|
|
447
|
-
* Creates a paste rule that applies a mark to pasted
|
|
461
|
+
* Creates a paste rule that applies a mark to pasted text matching the pattern.
|
|
448
462
|
*
|
|
449
|
-
* @param regexp - The pattern to match
|
|
463
|
+
* @param regexp - The pattern to match
|
|
450
464
|
* @param type - The mark type to apply
|
|
451
|
-
* @param getAttrs - Optional function to compute mark attributes from the
|
|
465
|
+
* @param getAttrs - Optional function to compute mark attributes from the matched string
|
|
452
466
|
* @returns A ProseMirror plugin
|
|
453
467
|
*/
|
|
454
468
|
pasteRule: (
|
|
@@ -533,6 +547,7 @@ export interface WriterUtils {
|
|
|
533
547
|
* ```
|
|
534
548
|
*
|
|
535
549
|
* @see https://github.com/getkirby/kirby/blob/main/panel/src/components/Forms/Writer/Extensions.js
|
|
550
|
+
* @source panel/src/components/Forms/Writer/Extensions.js
|
|
536
551
|
*/
|
|
537
552
|
export interface WriterMarkContext {
|
|
538
553
|
/** The ProseMirror schema with all registered nodes and marks */
|
|
@@ -544,9 +559,7 @@ export interface WriterMarkContext {
|
|
|
544
559
|
}
|
|
545
560
|
|
|
546
561
|
/**
|
|
547
|
-
* Context passed to node extension methods.
|
|
548
|
-
*
|
|
549
|
-
* Similar to WriterMarkContext but provides a NodeType instead of MarkType.
|
|
562
|
+
* Context passed to node extension methods (`commands`, `keys`, `inputRules`, `pasteRules`, `plugins`).
|
|
550
563
|
*
|
|
551
564
|
* @example
|
|
552
565
|
* ```js
|
|
@@ -558,6 +571,7 @@ export interface WriterMarkContext {
|
|
|
558
571
|
* ```
|
|
559
572
|
*
|
|
560
573
|
* @see https://github.com/getkirby/kirby/blob/main/panel/src/components/Forms/Writer/Extensions.js
|
|
574
|
+
* @source panel/src/components/Forms/Writer/Extensions.js
|
|
561
575
|
*/
|
|
562
576
|
export interface WriterNodeContext {
|
|
563
577
|
/** The ProseMirror schema with all registered nodes and marks */
|
|
@@ -575,6 +589,7 @@ export interface WriterNodeContext {
|
|
|
575
589
|
* are provided.
|
|
576
590
|
*
|
|
577
591
|
* @see https://github.com/getkirby/kirby/blob/main/panel/src/components/Forms/Writer/Extensions.js
|
|
592
|
+
* @source panel/src/components/Forms/Writer/Extensions.js
|
|
578
593
|
*/
|
|
579
594
|
export interface WriterExtensionContext {
|
|
580
595
|
/** The ProseMirror schema with all registered nodes and marks */
|
|
@@ -613,34 +628,29 @@ export interface WriterExtensionContext {
|
|
|
613
628
|
* ```
|
|
614
629
|
*
|
|
615
630
|
* @see https://github.com/getkirby/kirby/blob/main/panel/src/components/Forms/Writer/Extension.js
|
|
631
|
+
* @source panel/src/components/Forms/Writer/Extension.js
|
|
632
|
+
* @source panel/src/components/Forms/Writer/Extensions/History.js
|
|
633
|
+
* @source panel/src/components/Forms/Writer/Extensions/Insert.js
|
|
634
|
+
* @source panel/src/components/Forms/Writer/Extensions/Keys.js
|
|
635
|
+
* @source panel/src/components/Forms/Writer/Extensions/Toolbar.js
|
|
616
636
|
*/
|
|
617
637
|
export interface WriterExtension {
|
|
618
|
-
/**
|
|
619
|
-
* Unique name of the extension.
|
|
620
|
-
*/
|
|
638
|
+
/** Unique name of the extension. */
|
|
621
639
|
name?: string;
|
|
622
640
|
|
|
623
|
-
/**
|
|
641
|
+
/** Discriminator value, always "extension" for generic extensions */
|
|
624
642
|
type?: string;
|
|
625
643
|
|
|
626
|
-
/**
|
|
627
|
-
* The editor instance, available after `bindEditor()` is called.
|
|
628
|
-
*/
|
|
644
|
+
/** The editor instance, available after `bindEditor()` is called. */
|
|
629
645
|
editor?: WriterEditor;
|
|
630
646
|
|
|
631
|
-
/**
|
|
632
|
-
* Merged extension options from `defaults` and constructor options.
|
|
633
|
-
*/
|
|
647
|
+
/** Merged extension options from `defaults` and constructor options. */
|
|
634
648
|
options?: Record<string, any>;
|
|
635
649
|
|
|
636
|
-
/**
|
|
637
|
-
* Default options for the extension.
|
|
638
|
-
*/
|
|
650
|
+
/** Default options for the extension. */
|
|
639
651
|
defaults?: Record<string, any>;
|
|
640
652
|
|
|
641
|
-
/**
|
|
642
|
-
* Called after the editor is bound to the extension.
|
|
643
|
-
*/
|
|
653
|
+
/** Called after the editor is bound to the extension. */
|
|
644
654
|
init?: () => null | void;
|
|
645
655
|
|
|
646
656
|
/**
|
|
@@ -722,6 +732,19 @@ export interface WriterExtension {
|
|
|
722
732
|
* ```
|
|
723
733
|
*
|
|
724
734
|
* @see https://getkirby.com/docs/reference/plugins/extensions/writer-marks-nodes
|
|
735
|
+
* @source panel/src/components/Forms/Writer/Mark.js
|
|
736
|
+
* @source panel/src/components/Forms/Writer/Extension.js
|
|
737
|
+
* @source panel/src/components/Forms/Writer/Extensions.js
|
|
738
|
+
* @source panel/src/components/Forms/Writer/Marks/Bold.js
|
|
739
|
+
* @source panel/src/components/Forms/Writer/Marks/Clear.js
|
|
740
|
+
* @source panel/src/components/Forms/Writer/Marks/Code.js
|
|
741
|
+
* @source panel/src/components/Forms/Writer/Marks/Email.js
|
|
742
|
+
* @source panel/src/components/Forms/Writer/Marks/Italic.js
|
|
743
|
+
* @source panel/src/components/Forms/Writer/Marks/Link.js
|
|
744
|
+
* @source panel/src/components/Forms/Writer/Marks/Strike.js
|
|
745
|
+
* @source panel/src/components/Forms/Writer/Marks/Sub.js
|
|
746
|
+
* @source panel/src/components/Forms/Writer/Marks/Sup.js
|
|
747
|
+
* @source panel/src/components/Forms/Writer/Marks/Underline.js
|
|
725
748
|
*/
|
|
726
749
|
export interface WriterMarkExtension {
|
|
727
750
|
// ---------------------------------------------------------------------------
|
|
@@ -736,7 +759,6 @@ export interface WriterMarkExtension {
|
|
|
736
759
|
*/
|
|
737
760
|
name?: string;
|
|
738
761
|
|
|
739
|
-
/** Extension type identifier */
|
|
740
762
|
type?: "mark";
|
|
741
763
|
|
|
742
764
|
/**
|
|
@@ -965,6 +987,20 @@ export interface WriterMarkExtension {
|
|
|
965
987
|
* ```
|
|
966
988
|
*
|
|
967
989
|
* @see https://getkirby.com/docs/reference/plugins/extensions/writer-marks-nodes
|
|
990
|
+
* @source panel/src/components/Forms/Writer/Node.js
|
|
991
|
+
* @source panel/src/components/Forms/Writer/Extension.js
|
|
992
|
+
* @source panel/src/components/Forms/Writer/Extensions.js
|
|
993
|
+
* @source panel/src/components/Forms/Writer/Nodes/BulletList.js
|
|
994
|
+
* @source panel/src/components/Forms/Writer/Nodes/Doc.js
|
|
995
|
+
* @source panel/src/components/Forms/Writer/Nodes/HardBreak.js
|
|
996
|
+
* @source panel/src/components/Forms/Writer/Nodes/Heading.js
|
|
997
|
+
* @source panel/src/components/Forms/Writer/Nodes/HorizontalRule.js
|
|
998
|
+
* @source panel/src/components/Forms/Writer/Nodes/ListDoc.js
|
|
999
|
+
* @source panel/src/components/Forms/Writer/Nodes/ListItem.js
|
|
1000
|
+
* @source panel/src/components/Forms/Writer/Nodes/OrderedList.js
|
|
1001
|
+
* @source panel/src/components/Forms/Writer/Nodes/Paragraph.js
|
|
1002
|
+
* @source panel/src/components/Forms/Writer/Nodes/Quote.js
|
|
1003
|
+
* @source panel/src/components/Forms/Writer/Nodes/Text.js
|
|
968
1004
|
*/
|
|
969
1005
|
export interface WriterNodeExtension {
|
|
970
1006
|
// ---------------------------------------------------------------------------
|
|
@@ -979,7 +1015,6 @@ export interface WriterNodeExtension {
|
|
|
979
1015
|
*/
|
|
980
1016
|
name?: string;
|
|
981
1017
|
|
|
982
|
-
/** Extension type identifier */
|
|
983
1018
|
type?: "node";
|
|
984
1019
|
|
|
985
1020
|
/**
|
|
@@ -1007,14 +1042,10 @@ export interface WriterNodeExtension {
|
|
|
1007
1042
|
*/
|
|
1008
1043
|
button?: WriterToolbarButton | WriterToolbarButton[];
|
|
1009
1044
|
|
|
1010
|
-
/**
|
|
1011
|
-
* Default options for the extension.
|
|
1012
|
-
*/
|
|
1045
|
+
/** Default options for the extension. */
|
|
1013
1046
|
defaults?: Record<string, any>;
|
|
1014
1047
|
|
|
1015
|
-
/**
|
|
1016
|
-
* ProseMirror node schema definition.
|
|
1017
|
-
*/
|
|
1048
|
+
/** ProseMirror node schema definition. */
|
|
1018
1049
|
schema?: NodeSpec;
|
|
1019
1050
|
|
|
1020
1051
|
/**
|