@kubex/zinc 1.1.141 → 1.1.142
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/dist/custom-elements.json +313 -80
- package/dist/vscode.html-custom-data.json +44 -14
- package/dist/web-types.json +101 -28
- package/dist/zn.d.ts +555 -530
- package/dist/zn.min.js +894 -866
- package/package.json +1 -1
- package/src/components/form-group/form-group.scss +11 -1
- package/src/components/form-group/form-group.test.ts +16 -0
- package/src/components/linked-select/linked-select.component.ts +37 -5
- package/src/components/linked-select/linked-select.test.ts +95 -9
- package/src/components/page-builder/page-builder.component.ts +56 -2
- package/src/components/page-builder/page-builder.scss +41 -0
- package/src/components/page-builder/page-builder.test.ts +210 -0
- package/src/components/remarkd-editor/remarkd-editor.component.ts +2 -0
- package/src/components/remarkd-editor/remarkd-editor.test.ts +35 -7
- package/src/components/sp/sp.scss +6 -0
- package/src/components/sp/sp.test.ts +31 -0
- package/src/components/translations/translations.component.ts +33 -2
- package/src/components/translations/translations.test.ts +41 -0
package/dist/zn.d.ts
CHANGED
|
@@ -7639,9 +7639,9 @@ declare module "components/linked-select/linked-select.component" {
|
|
|
7639
7639
|
export default class ZnLinkedSelect extends ZincElement implements ZincFormControl {
|
|
7640
7640
|
static styles: CSSResultGroup;
|
|
7641
7641
|
name: string;
|
|
7642
|
-
value: string;
|
|
7642
|
+
value: string | string[];
|
|
7643
7643
|
/** The default value of the form control. Primarily used for resetting the form control. */
|
|
7644
|
-
defaultValue: string;
|
|
7644
|
+
defaultValue: string | string[];
|
|
7645
7645
|
checked: boolean;
|
|
7646
7646
|
options: linkedSelectOptions;
|
|
7647
7647
|
linkedSelect: string;
|
|
@@ -7649,6 +7649,12 @@ declare module "components/linked-select/linked-select.component" {
|
|
|
7649
7649
|
label: string;
|
|
7650
7650
|
/** Automatically select the first option of the linked group when no value is set. */
|
|
7651
7651
|
selectFirst: boolean;
|
|
7652
|
+
/** Allows more than one option of the linked group to be selected. */
|
|
7653
|
+
multiple: boolean;
|
|
7654
|
+
placeholder: string;
|
|
7655
|
+
clearable: boolean;
|
|
7656
|
+
search: boolean;
|
|
7657
|
+
helpText: string;
|
|
7652
7658
|
input: ZnSelect;
|
|
7653
7659
|
private linkedSelectElement;
|
|
7654
7660
|
private readonly formControlController;
|
|
@@ -7656,6 +7662,7 @@ declare module "components/linked-select/linked-select.component" {
|
|
|
7656
7662
|
get validity(): ValidityState;
|
|
7657
7663
|
get validationMessage(): string;
|
|
7658
7664
|
connectedCallback(): void;
|
|
7665
|
+
protected willUpdate(_changedProperties: PropertyValues): void;
|
|
7659
7666
|
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
7660
7667
|
disconnectedCallback(): void;
|
|
7661
7668
|
checkValidity(): boolean;
|
|
@@ -7663,6 +7670,7 @@ declare module "components/linked-select/linked-select.component" {
|
|
|
7663
7670
|
reportValidity(): boolean;
|
|
7664
7671
|
setCustomValidity(message: string): void;
|
|
7665
7672
|
handleLinkedSelectChange: () => void;
|
|
7673
|
+
private serialisedValue;
|
|
7666
7674
|
handleChange(e: Event): void;
|
|
7667
7675
|
handleSelectChange: (e: ZnSelectEvent) => void;
|
|
7668
7676
|
/** The options of the group the linked select currently points at. */
|
|
@@ -9196,114 +9204,527 @@ declare module "components/audio-select/index" {
|
|
|
9196
9204
|
}
|
|
9197
9205
|
}
|
|
9198
9206
|
}
|
|
9199
|
-
declare module "components/
|
|
9200
|
-
import {
|
|
9207
|
+
declare module "components/remarkd-editor/actions" {
|
|
9208
|
+
import type { SlashMenuItem } from "components/slash-menu/index";
|
|
9209
|
+
export type ActionGroup = 'text' | 'lists' | 'admonitions' | 'blocks' | 'structured' | 'media' | 'objects' | 'breaks' | 'logic' | 'inline';
|
|
9210
|
+
/** What an inline action wraps the selection in. `after` defaults to `before`. */
|
|
9211
|
+
export interface InlineMark {
|
|
9212
|
+
before: string;
|
|
9213
|
+
after?: string;
|
|
9214
|
+
placeholder?: string;
|
|
9215
|
+
}
|
|
9216
|
+
export interface EditorAction {
|
|
9217
|
+
/** Stable id, used for toolbar keys and tests. */
|
|
9218
|
+
key: string;
|
|
9219
|
+
label: string;
|
|
9220
|
+
icon: string;
|
|
9221
|
+
group: ActionGroup;
|
|
9222
|
+
/** Extra search terms for the slash menu, e.g. "bold" finds Strong. */
|
|
9223
|
+
keywords?: string[];
|
|
9224
|
+
/** Block actions: spliced in as a new block. */
|
|
9225
|
+
prefix?: string;
|
|
9226
|
+
/** Inline actions: applied to the selection in the open block. */
|
|
9227
|
+
inline?: InlineMark;
|
|
9228
|
+
/** Where the caret lands within `prefix`. Defaults to the end. */
|
|
9229
|
+
caretOffset?: number;
|
|
9230
|
+
/** Actions that open their own picker instead of inserting text. */
|
|
9231
|
+
opens?: 'image' | 'include' | 'link';
|
|
9232
|
+
}
|
|
9233
|
+
/** Toolbar order, most-used first — the last groups are the first to collapse. */
|
|
9234
|
+
export const ACTION_GROUPS: {
|
|
9235
|
+
id: ActionGroup;
|
|
9236
|
+
label: string;
|
|
9237
|
+
}[];
|
|
9238
|
+
export const EDITOR_ACTIONS: EditorAction[];
|
|
9239
|
+
/** The registry as slash menu entries. Picker actions insert nothing; the menu emits their action id. */
|
|
9240
|
+
export function slashItems(actions: EditorAction[]): SlashMenuItem[];
|
|
9241
|
+
}
|
|
9242
|
+
declare module "internal/toolbar-overflow" {
|
|
9243
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
9244
|
+
interface ToolbarOverflowOptions {
|
|
9245
|
+
/** The measurable group elements, in toolbar order. */
|
|
9246
|
+
groups: () => HTMLElement[];
|
|
9247
|
+
/** The element whose width the groups have to fit inside. */
|
|
9248
|
+
container: () => HTMLElement | null | undefined;
|
|
9249
|
+
/** Space to keep for the overflow trigger. Defaults to 44px. */
|
|
9250
|
+
reserve?: number;
|
|
9251
|
+
}
|
|
9252
|
+
/**
|
|
9253
|
+
* Reports how many leading toolbar groups fit the container, so the host can render the
|
|
9254
|
+
* rest into an overflow menu. Two passes: the first ignores the trigger, because when
|
|
9255
|
+
* everything fits there is no trigger to make room for.
|
|
9256
|
+
*/
|
|
9257
|
+
export class ToolbarOverflowController implements ReactiveController {
|
|
9258
|
+
visibleCount: number;
|
|
9259
|
+
private readonly host;
|
|
9260
|
+
private readonly options;
|
|
9261
|
+
private resizeRafId;
|
|
9262
|
+
constructor(host: ReactiveControllerHost & Element, options: ToolbarOverflowOptions);
|
|
9263
|
+
hostUpdated(): void;
|
|
9264
|
+
private measure;
|
|
9265
|
+
private countThatFit;
|
|
9266
|
+
}
|
|
9267
|
+
}
|
|
9268
|
+
declare module "components/remarkd-editor/remarkd-editor.component" {
|
|
9269
|
+
import { type CSSResultGroup, type PropertyValues, type TemplateResult } from 'lit';
|
|
9201
9270
|
import ZincElement from "internal/zinc-element";
|
|
9202
|
-
import
|
|
9203
|
-
import
|
|
9204
|
-
import
|
|
9205
|
-
import
|
|
9206
|
-
import ZnSelect from "components/select/index";
|
|
9207
|
-
import ZnTextarea from "components/textarea/index";
|
|
9208
|
-
import type { PropertyValues } from 'lit';
|
|
9271
|
+
import ZnDropdown from "components/dropdown/index";
|
|
9272
|
+
import ZnMenu from "components/menu/index";
|
|
9273
|
+
import ZnMenuItem from "components/menu-item/index";
|
|
9274
|
+
import ZnSlashMenu from "components/slash-menu/index";
|
|
9209
9275
|
import type { ZincFormControl } from "internal/zinc-element";
|
|
9210
9276
|
/**
|
|
9211
|
-
* @summary
|
|
9212
|
-
* @documentation https://zinc.style/components/
|
|
9277
|
+
* @summary A Notion-style block editor for remarkd content. Blocks render inline; click one to edit its source.
|
|
9278
|
+
* @documentation https://zinc.style/components/remarkd-editor
|
|
9213
9279
|
* @status experimental
|
|
9214
9280
|
* @since 1.0
|
|
9215
9281
|
*
|
|
9216
|
-
*
|
|
9217
|
-
*
|
|
9218
|
-
*
|
|
9219
|
-
*
|
|
9220
|
-
*
|
|
9221
|
-
*
|
|
9222
|
-
*
|
|
9223
|
-
*
|
|
9224
|
-
* Put several of these in a `zn-translation-group` to have one select drive all of them.
|
|
9225
|
-
*
|
|
9226
|
-
* @dependency zn-chip
|
|
9227
|
-
* @dependency zn-inline-edit
|
|
9228
|
-
* @dependency zn-input
|
|
9229
|
-
* @dependency zn-option
|
|
9230
|
-
* @dependency zn-select
|
|
9231
|
-
* @dependency zn-textarea
|
|
9282
|
+
* @dependency zn-button
|
|
9283
|
+
* @dependency zn-button-group
|
|
9284
|
+
* @dependency zn-dropdown
|
|
9285
|
+
* @dependency zn-icon
|
|
9286
|
+
* @dependency zn-file
|
|
9287
|
+
* @dependency zn-menu
|
|
9288
|
+
* @dependency zn-menu-item
|
|
9289
|
+
* @dependency zn-slash-menu
|
|
9232
9290
|
*
|
|
9233
|
-
* @
|
|
9234
|
-
* @
|
|
9235
|
-
* Alternatively, use the `help-text` attribute.
|
|
9291
|
+
* @event zn-input - Emitted on each keystroke while editing a block.
|
|
9292
|
+
* @event zn-change - Emitted when a block edit is committed and the value changes.
|
|
9236
9293
|
*
|
|
9237
|
-
* @
|
|
9238
|
-
* @
|
|
9294
|
+
* @csspart base - The component's base wrapper.
|
|
9295
|
+
* @csspart toolbar - The always-visible block-insert and inline-formatting toolbar.
|
|
9296
|
+
* @csspart raw-toggle - The button that switches between the block view and the raw source view.
|
|
9297
|
+
* @csspart block - A rendered block wrapper.
|
|
9298
|
+
* @csspart rendered - The rendered remarkd output of a block.
|
|
9299
|
+
* @csspart conditional - A labelled wrapper for an ifdef/ifndef/ifeval/iftrue/iffalse/ifempty/ifnempty range.
|
|
9300
|
+
* @csspart variable - A chip rendered for a document attribute, title, or bracket line.
|
|
9301
|
+
* @csspart input - The textarea shown while editing a block.
|
|
9302
|
+
* @csspart raw - The full-document textarea shown in raw source mode.
|
|
9303
|
+
* @csspart slash-menu - The `zn-slash-menu` opened by typing "/" in an empty block.
|
|
9304
|
+
* @csspart image-controls - The caption / alignment / size panel shown when an image block is clicked.
|
|
9305
|
+
* @csspart include - The chip rendered in place of an `include::` directive.
|
|
9306
|
+
* @csspart include-picker - The inline Include picker opened from the toolbar or "/include".
|
|
9239
9307
|
*
|
|
9240
|
-
* @
|
|
9241
|
-
* @csspart form-control-label - The label's wrapper.
|
|
9242
|
-
* @csspart form-control-input - The wrapper around the field being edited.
|
|
9243
|
-
* @csspart form-control-help-text - The help text's wrapper.
|
|
9244
|
-
* @csspart language-select - The select that chooses the language being edited.
|
|
9308
|
+
* @cssproperty --remarkd-editor-max-height - The tallest the editor grows before its body scrolls. Defaults to `100dvh`.
|
|
9245
9309
|
*/
|
|
9246
|
-
export default class
|
|
9247
|
-
static styles:
|
|
9310
|
+
export default class ZnRemarkdEditor extends ZincElement implements ZincFormControl {
|
|
9311
|
+
static styles: CSSResultGroup;
|
|
9248
9312
|
static dependencies: {
|
|
9249
|
-
'zn-
|
|
9250
|
-
'zn-
|
|
9251
|
-
'zn-
|
|
9252
|
-
'zn-
|
|
9253
|
-
'zn-select': typeof ZnSelect;
|
|
9254
|
-
'zn-textarea': typeof ZnTextarea;
|
|
9313
|
+
'zn-dropdown': typeof ZnDropdown;
|
|
9314
|
+
'zn-menu': typeof ZnMenu;
|
|
9315
|
+
'zn-menu-item': typeof ZnMenuItem;
|
|
9316
|
+
'zn-slash-menu': typeof ZnSlashMenu;
|
|
9255
9317
|
};
|
|
9256
9318
|
private readonly formControlController;
|
|
9257
|
-
private readonly
|
|
9258
|
-
|
|
9259
|
-
|
|
9260
|
-
|
|
9261
|
-
|
|
9262
|
-
|
|
9263
|
-
|
|
9319
|
+
private readonly slashController;
|
|
9320
|
+
private readonly toolbarOverflow;
|
|
9321
|
+
private editingDraft;
|
|
9322
|
+
private includeRequest;
|
|
9323
|
+
private rawEntryValue;
|
|
9324
|
+
private suppressValueSync;
|
|
9325
|
+
private suppressBlurCommit;
|
|
9326
|
+
private validationInput;
|
|
9327
|
+
private slashMenuElement;
|
|
9328
|
+
private blocks;
|
|
9329
|
+
private editingIndex;
|
|
9264
9330
|
/**
|
|
9265
|
-
*
|
|
9266
|
-
* `
|
|
9331
|
+
* Lists the blocks most recently inserted here above the rest of the slash menu, remembered in
|
|
9332
|
+
* `localStorage` under this key. Leave unset to offer no recently used section.
|
|
9267
9333
|
*/
|
|
9268
|
-
|
|
9269
|
-
/**
|
|
9270
|
-
|
|
9271
|
-
|
|
9272
|
-
|
|
9273
|
-
|
|
9274
|
-
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
|
|
9278
|
-
|
|
9334
|
+
slashRecentKey: string;
|
|
9335
|
+
/** Renders the slash menu only once it has been needed. */
|
|
9336
|
+
private hasSlashMenu;
|
|
9337
|
+
private imagePickerIndex;
|
|
9338
|
+
private imageEdit;
|
|
9339
|
+
private dropIndicator;
|
|
9340
|
+
private dragIndex;
|
|
9341
|
+
private editShell;
|
|
9342
|
+
private rawMode;
|
|
9343
|
+
private includeOptions;
|
|
9344
|
+
private includeLoadFailed;
|
|
9345
|
+
private includePickerIndex;
|
|
9346
|
+
private includeQuery;
|
|
9347
|
+
private linkPickerOpen;
|
|
9348
|
+
private linkQuery;
|
|
9349
|
+
private linkResults;
|
|
9350
|
+
private linkSearchFailed;
|
|
9351
|
+
private linkSelection;
|
|
9352
|
+
private linkSearchTimer?;
|
|
9353
|
+
private linkSearchToken;
|
|
9354
|
+
/** Resolved link targets by reference; a null value is one the app does not know. */
|
|
9355
|
+
private linkRefs;
|
|
9356
|
+
private linkRefsPending;
|
|
9357
|
+
private pendingDragHandle;
|
|
9358
|
+
private dragStartX;
|
|
9359
|
+
private dragStartY;
|
|
9360
|
+
private dragGhost;
|
|
9361
|
+
private dragPointerY;
|
|
9362
|
+
private autoScrollFrame;
|
|
9363
|
+
/** The name of the control, submitted as part of form data. */
|
|
9364
|
+
name: string;
|
|
9365
|
+
/** The current remarkd source. */
|
|
9366
|
+
value: string;
|
|
9367
|
+
/** The default value — used when resetting the form. */
|
|
9368
|
+
defaultValue: string;
|
|
9369
|
+
/** Placeholder shown when the document is empty. */
|
|
9370
|
+
placeholder: string;
|
|
9279
9371
|
/**
|
|
9280
|
-
*
|
|
9281
|
-
*
|
|
9372
|
+
* Endpoint for image uploads — required for image support. Posting the file
|
|
9373
|
+
* metadata here must return `{uploadPath, uploadUrl}`; the file is then PUT
|
|
9374
|
+
* to `uploadUrl` and the returned `uploadPath` is embedded as the image URL.
|
|
9282
9375
|
*/
|
|
9283
|
-
|
|
9376
|
+
attachmentUrl: string;
|
|
9284
9377
|
/**
|
|
9285
|
-
*
|
|
9286
|
-
*
|
|
9378
|
+
* Endpoint listing the Includes this document may embed, as
|
|
9379
|
+
* `{"items":[{id,title,description,scope,keywords,languages,url}]}`. Labels the
|
|
9380
|
+
* chips rendered for `include::` directives and feeds the include picker.
|
|
9287
9381
|
*/
|
|
9288
|
-
|
|
9289
|
-
/** Names of item sets registered with `registerSlashMenuPreset`, comma separated. */
|
|
9290
|
-
slashPreset: string;
|
|
9291
|
-
/** The characters that open the slash menu. */
|
|
9292
|
-
slashTrigger: string;
|
|
9293
|
-
/** The name the slash menu's list is announced by. */
|
|
9294
|
-
slashHeading: string;
|
|
9295
|
-
/** Hides the insertion keys normally shown against the slash menu's items. */
|
|
9296
|
-
slashHideKeys: boolean;
|
|
9297
|
-
/** Lists the slash menu items most recently chosen here above the rest, remembered under this key. */
|
|
9298
|
-
slashRecentKey: string;
|
|
9299
|
-
/** Resolves additional slash menu items each time the menu opens. JavaScript only. */
|
|
9300
|
-
slashItemsProvider?: (query: string) => SlashMenuItem[] | Promise<SlashMenuItem[]>;
|
|
9382
|
+
includeUrl: string;
|
|
9301
9383
|
/**
|
|
9302
|
-
*
|
|
9303
|
-
*
|
|
9384
|
+
* Endpoint the article link picker searches, as
|
|
9385
|
+
* `{"items":[{ref,kind,title,context,status}]}`. Queried with `?q=<term>` as
|
|
9386
|
+
* the author types and with `?refs=a,b` to resolve the references a body
|
|
9387
|
+
* already carries.
|
|
9304
9388
|
*/
|
|
9305
|
-
|
|
9306
|
-
/**
|
|
9389
|
+
linkUrl: string;
|
|
9390
|
+
/** Adds a toolbar toggle that swaps the block view for the full remarkd source. */
|
|
9391
|
+
allowRaw: boolean;
|
|
9392
|
+
/** Makes the editor required for form submission. */
|
|
9393
|
+
required: boolean;
|
|
9394
|
+
/** Makes the editor read-only. */
|
|
9395
|
+
readonly: boolean;
|
|
9396
|
+
/** Disables the editor. */
|
|
9397
|
+
disabled: boolean;
|
|
9398
|
+
get validity(): ValidityState;
|
|
9399
|
+
get validationMessage(): string;
|
|
9400
|
+
checkValidity(): boolean;
|
|
9401
|
+
getForm(): HTMLFormElement | null;
|
|
9402
|
+
reportValidity(): boolean;
|
|
9403
|
+
setCustomValidity(message: string): void;
|
|
9404
|
+
/** Starts editing the first block, or a new block if the document is empty. */
|
|
9405
|
+
focus(): void;
|
|
9406
|
+
/** Commits any in-progress block or raw edit. */
|
|
9407
|
+
blur(): void;
|
|
9408
|
+
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
9409
|
+
protected updated(changedProperties: PropertyValues<this>): void;
|
|
9410
|
+
disconnectedCallback(): void;
|
|
9411
|
+
handleValueChange(): void;
|
|
9412
|
+
handleIncludeUrlChange(): void;
|
|
9413
|
+
handleLinkUrlChange(): void;
|
|
9414
|
+
/**
|
|
9415
|
+
* Splits remarkd source into blocks on blank lines, keeping fenced /
|
|
9416
|
+
* delimited containers (``` ==== !!!! .... ---- ____ **** ////) as single blocks.
|
|
9417
|
+
*/
|
|
9418
|
+
private splitBlocks;
|
|
9419
|
+
private fenceMarker;
|
|
9420
|
+
private closesFence;
|
|
9421
|
+
private updateBlocks;
|
|
9422
|
+
private handleRenderedClick;
|
|
9423
|
+
/** Parses a block that is purely an image (with optional caption/align lines). */
|
|
9424
|
+
private parseImageBlock;
|
|
9425
|
+
/** Parses a block that is nothing but an include directive. */
|
|
9426
|
+
private parseIncludeBlock;
|
|
9427
|
+
private serializeImageBlock;
|
|
9428
|
+
private toggleCheckbox;
|
|
9429
|
+
private startEdit;
|
|
9430
|
+
private updateImageEdit;
|
|
9431
|
+
private saveImageEdit;
|
|
9432
|
+
private closeImageEdit;
|
|
9433
|
+
private deleteImageBlock;
|
|
9434
|
+
private editImageSource;
|
|
9435
|
+
private handleImageControlsKeydown;
|
|
9436
|
+
/**
|
|
9437
|
+
* The remarkd chrome the editing block should keep, derived from its first
|
|
9438
|
+
* line — so a NOTE still looks like a note while its source is edited.
|
|
9439
|
+
*/
|
|
9440
|
+
private computeEditShell;
|
|
9441
|
+
private focusInput;
|
|
9442
|
+
/**
|
|
9443
|
+
* Scrolls the editor's own body to bring `el` into view. Never `scrollIntoView()` and
|
|
9444
|
+
* never `focus()` without preventScroll: both walk every scrollable ancestor, and an
|
|
9445
|
+
* `overflow: hidden`/`auto` panel around the editor is scrollable too — that shifts a
|
|
9446
|
+
* container the user never asked to move.
|
|
9447
|
+
*/
|
|
9448
|
+
private reveal;
|
|
9449
|
+
private revealAfterUpdate;
|
|
9450
|
+
/**
|
|
9451
|
+
* Centres a block added without opening an editor. An image has no height until it
|
|
9452
|
+
* loads, so the first pass scrolls against a layout that is still short — the second
|
|
9453
|
+
* pass corrects it once the real dimensions are in.
|
|
9454
|
+
*/
|
|
9455
|
+
private revealBlock;
|
|
9456
|
+
private addBlockAt;
|
|
9457
|
+
private deleteBlock;
|
|
9458
|
+
/** Inserts a draft block — committed (or dropped, if left empty) on blur. */
|
|
9459
|
+
private insertDraftBlock;
|
|
9460
|
+
/**
|
|
9461
|
+
* Blur handler for the editing textarea. Re-renders that replace the
|
|
9462
|
+
* focused textarea (e.g. Shift+Enter committing and opening the next
|
|
9463
|
+
* block) fire blur mid-transition — `suppressBlurCommit` masks those.
|
|
9464
|
+
*/
|
|
9465
|
+
private handleEditBlur;
|
|
9466
|
+
/** Commits the in-progress edit; returns the index after the committed parts. */
|
|
9467
|
+
private commitEdit;
|
|
9468
|
+
private handleDraftInput;
|
|
9469
|
+
private handleEditKeydown;
|
|
9470
|
+
/** Whether the block being edited is nothing but the slash command. */
|
|
9471
|
+
private isSlashBlock;
|
|
9472
|
+
private mountSlashMenu;
|
|
9473
|
+
/** Returns false for items the controller should not insert text for. */
|
|
9474
|
+
private handleSlashSelect;
|
|
9475
|
+
private handleEditPaste;
|
|
9476
|
+
private handleDragOver;
|
|
9477
|
+
private handleDrop;
|
|
9478
|
+
/** The insertion index a drop at `y` maps to, from the rendered block positions. */
|
|
9479
|
+
private insertionIndexFromY;
|
|
9480
|
+
private handleHandlePointerDown;
|
|
9481
|
+
private handleDragPointerMove;
|
|
9482
|
+
/**
|
|
9483
|
+
* Holding the pointer near a scroll edge keeps the content moving, so a block can
|
|
9484
|
+
* be dragged past the visible slice of a long document. Runs per frame rather than
|
|
9485
|
+
* per pointermove — a pointer parked at the edge stops emitting moves.
|
|
9486
|
+
*/
|
|
9487
|
+
private stepAutoScroll;
|
|
9488
|
+
/** Scrolls the editor body, falling through to the page once the body is at its limit. */
|
|
9489
|
+
private autoScroll;
|
|
9490
|
+
/** Scroll step for this frame: nothing until the pointer is within `edge` of a boundary. */
|
|
9491
|
+
private edgeScrollDelta;
|
|
9492
|
+
private handleDragPointerUp;
|
|
9493
|
+
private cancelDrag;
|
|
9494
|
+
private createDragGhost;
|
|
9495
|
+
private moveDragGhost;
|
|
9496
|
+
private pickImage;
|
|
9497
|
+
private pickInclude;
|
|
9498
|
+
/**
|
|
9499
|
+
* Opens the picker over the block being edited. The caret range is captured
|
|
9500
|
+
* now: the picker's own filter takes focus, so the textarea's selection is
|
|
9501
|
+
* gone by the time an option is chosen.
|
|
9502
|
+
*/
|
|
9503
|
+
private pickLink;
|
|
9504
|
+
private closeLinkPicker;
|
|
9505
|
+
/** Debounced; only the newest response is kept. */
|
|
9506
|
+
private searchLinks;
|
|
9507
|
+
private closeIncludePicker;
|
|
9508
|
+
private insertInclude;
|
|
9509
|
+
private closeImagePicker;
|
|
9510
|
+
private handleImagePicked;
|
|
9511
|
+
private insertImage;
|
|
9512
|
+
private uploadImage;
|
|
9513
|
+
/**
|
|
9514
|
+
* Resolves an app-relative path the way the console's pagelet handler does:
|
|
9515
|
+
* an app fragment's URLs sit under the app base, and the console puts the app's
|
|
9516
|
+
* `gaid` on the host element. Links rendered here live in the shadow root,
|
|
9517
|
+
* where a click retargets to the host, so that handler never sees them — the
|
|
9518
|
+
* href has to carry the base itself.
|
|
9519
|
+
*/
|
|
9520
|
+
private appPath;
|
|
9521
|
+
private hasIncludeBlock;
|
|
9522
|
+
/** Fetches the include list once; every later caller shares the same promise. */
|
|
9523
|
+
private loadIncludeOptions;
|
|
9524
|
+
/**
|
|
9525
|
+
* Resolves the references in the body that have not been resolved yet, so a
|
|
9526
|
+
* link whose target is gone can be marked. A failed request records nothing:
|
|
9527
|
+
* an unanswered reference is not a broken one.
|
|
9528
|
+
*/
|
|
9529
|
+
private resolveContentLinks;
|
|
9530
|
+
private markContentLinks;
|
|
9531
|
+
private autosize;
|
|
9532
|
+
/**
|
|
9533
|
+
* Applies an inline mark to the open block's textarea: wraps the selection, toggles the
|
|
9534
|
+
* mark off when it is already wrapped, or inserts a selected placeholder when there is
|
|
9535
|
+
* no selection. Goes through `editingDraft` so `zn-input` still fires.
|
|
9536
|
+
*/
|
|
9537
|
+
private applyInline;
|
|
9538
|
+
private toggleRawMode;
|
|
9539
|
+
private focusRaw;
|
|
9540
|
+
/**
|
|
9541
|
+
* Raw mode keeps the whole document in one textarea, so the textarea — not
|
|
9542
|
+
* the block list — is authoritative while it is open: re-splitting on every
|
|
9543
|
+
* keystroke would normalise blank lines out from under the cursor.
|
|
9544
|
+
*/
|
|
9545
|
+
private handleRawInput;
|
|
9546
|
+
/**
|
|
9547
|
+
* Re-splits the raw source into blocks. Not `updateBlocks` — that only
|
|
9548
|
+
* reports a change when the re-join differs from the value, and raw edits
|
|
9549
|
+
* have already written straight to the value.
|
|
9550
|
+
*/
|
|
9551
|
+
private commitRaw;
|
|
9552
|
+
private handleToolbarInsert;
|
|
9553
|
+
private renderImageControls;
|
|
9554
|
+
private renderIncludeChip;
|
|
9555
|
+
/** A metadata-only block parses to nothing, so show each of its lines as a chip instead. */
|
|
9556
|
+
private renderMetaChips;
|
|
9557
|
+
/**
|
|
9558
|
+
* One shared chip treatment for every metadata line kind — each kind just supplies an
|
|
9559
|
+
* icon, a name, and an optional value/state, display-only in all three cases.
|
|
9560
|
+
*/
|
|
9561
|
+
private renderMetaChip;
|
|
9562
|
+
/**
|
|
9563
|
+
* Wraps `{name}` references so they read as variables rather than literal text. Walks text
|
|
9564
|
+
* nodes and skips code, so a brace in a sample stays a brace, and no regex touches markup.
|
|
9565
|
+
*/
|
|
9566
|
+
private markVariables;
|
|
9567
|
+
/**
|
|
9568
|
+
* A conditional range as a labelled wrapper. The inner content is parsed without the
|
|
9569
|
+
* directive lines: evaluating instead would blank the block whenever the flag is not
|
|
9570
|
+
* defined in this same block, hiding the author's content while they edit it. It also
|
|
9571
|
+
* keeps both halves of an if/else idiom visible — with evaluation you could never see
|
|
9572
|
+
* the `ifndef` branch while the `ifdef` condition held. Nesting is handled by
|
|
9573
|
+
* `splitConditionalParts`/`renderConditionalWrapper` below, recursively.
|
|
9574
|
+
*/
|
|
9575
|
+
private renderConditional;
|
|
9576
|
+
private renderBlock;
|
|
9577
|
+
/** Inline marks and the article link both apply into an open block, not a new one. */
|
|
9578
|
+
private isActionDisabled;
|
|
9579
|
+
/** A picker action with no endpoint configured is not offered at all. */
|
|
9580
|
+
private actionAvailable;
|
|
9581
|
+
private slashItemAvailable;
|
|
9582
|
+
/** Routes a toolbar/menu action to the inline or block insert path — the one place both
|
|
9583
|
+
* `renderAction` and `renderMenuAction` call, so the bar and the overflow menu cannot
|
|
9584
|
+
* drift out of sync on what a given action actually does. */
|
|
9585
|
+
private activateAction;
|
|
9586
|
+
/** A single toolbar action button, shared by the toolbar bar and the overflow menu. */
|
|
9587
|
+
private renderAction;
|
|
9588
|
+
/** The same action, rendered as a menu item for the overflow menu. */
|
|
9589
|
+
private renderMenuAction;
|
|
9590
|
+
render(): TemplateResult<1>;
|
|
9591
|
+
private renderRaw;
|
|
9592
|
+
/** The block views, with the inline image picker spliced in when active. */
|
|
9593
|
+
private renderBody;
|
|
9594
|
+
private renderIncludePicker;
|
|
9595
|
+
private renderLinkPicker;
|
|
9596
|
+
private insertLink;
|
|
9597
|
+
private renderImagePicker;
|
|
9598
|
+
}
|
|
9599
|
+
}
|
|
9600
|
+
declare module "components/remarkd-editor/index" {
|
|
9601
|
+
import ZnRemarkdEditor from "components/remarkd-editor/remarkd-editor.component";
|
|
9602
|
+
export * from "components/remarkd-editor/remarkd-editor.component";
|
|
9603
|
+
export default ZnRemarkdEditor;
|
|
9604
|
+
global {
|
|
9605
|
+
interface HTMLElementTagNameMap {
|
|
9606
|
+
'zn-remarkd-editor': ZnRemarkdEditor;
|
|
9607
|
+
}
|
|
9608
|
+
}
|
|
9609
|
+
}
|
|
9610
|
+
declare module "components/translations/translations.component" {
|
|
9611
|
+
import { type SlashMenuItem } from "components/slash-menu/index";
|
|
9612
|
+
import ZincElement from "internal/zinc-element";
|
|
9613
|
+
import ZnChip from "components/chip/index";
|
|
9614
|
+
import ZnInlineEdit from "components/inline-edit/index";
|
|
9615
|
+
import ZnInput from "components/input/index";
|
|
9616
|
+
import ZnOption from "components/option/index";
|
|
9617
|
+
import ZnRemarkdEditor from "components/remarkd-editor/index";
|
|
9618
|
+
import ZnSelect from "components/select/index";
|
|
9619
|
+
import ZnTextarea from "components/textarea/index";
|
|
9620
|
+
import type { PropertyValues } from 'lit';
|
|
9621
|
+
import type { ZincFormControl } from "internal/zinc-element";
|
|
9622
|
+
/**
|
|
9623
|
+
* @summary Collects one piece of text in several languages, one language at a time.
|
|
9624
|
+
* @documentation https://zinc.style/components/translations
|
|
9625
|
+
* @status experimental
|
|
9626
|
+
* @since 1.0
|
|
9627
|
+
*
|
|
9628
|
+
* A select above the field chooses the language being edited. Closed, it carries how many languages are translated —
|
|
9629
|
+
* `1/5`; open, every language it offers carries a chip saying whether it has a translation of its own or falls back
|
|
9630
|
+
* to English. Blank languages fall back to English at render
|
|
9631
|
+
* time, so a blank field shows the English text as its placeholder rather than looking empty.
|
|
9632
|
+
*
|
|
9633
|
+
* The value submitted is a JSON object keyed by language code. A language stays out of it until it is typed into, so
|
|
9634
|
+
* browsing the languages does not pad the payload with empty translations.
|
|
9635
|
+
*
|
|
9636
|
+
* Put several of these in a `zn-translation-group` to have one select drive all of them.
|
|
9637
|
+
*
|
|
9638
|
+
* @dependency zn-chip
|
|
9639
|
+
* @dependency zn-inline-edit
|
|
9640
|
+
* @dependency zn-input
|
|
9641
|
+
* @dependency zn-option
|
|
9642
|
+
* @dependency zn-select
|
|
9643
|
+
* @dependency zn-textarea
|
|
9644
|
+
*
|
|
9645
|
+
* @slot label - The field's label. Alternatively, use the `label` attribute.
|
|
9646
|
+
* @slot help-text - Text describing how to fill the field in, shown below it and shared by every language.
|
|
9647
|
+
* Alternatively, use the `help-text` attribute.
|
|
9648
|
+
*
|
|
9649
|
+
* @event zn-change - Emitted when a translation's value changes.
|
|
9650
|
+
* @event zn-input - Emitted when a translation receives input.
|
|
9651
|
+
*
|
|
9652
|
+
* @csspart form-control - The form control that wraps the label, the language select, the field and the help text.
|
|
9653
|
+
* @csspart form-control-label - The label's wrapper.
|
|
9654
|
+
* @csspart form-control-input - The wrapper around the field being edited.
|
|
9655
|
+
* @csspart form-control-help-text - The help text's wrapper.
|
|
9656
|
+
* @csspart language-select - The select that chooses the language being edited.
|
|
9657
|
+
*/
|
|
9658
|
+
export default class ZnTranslations extends ZincElement implements ZincFormControl {
|
|
9659
|
+
static styles: import("lit").CSSResult[];
|
|
9660
|
+
static dependencies: {
|
|
9661
|
+
'zn-chip': typeof ZnChip;
|
|
9662
|
+
'zn-inline-edit': typeof ZnInlineEdit;
|
|
9663
|
+
'zn-input': typeof ZnInput;
|
|
9664
|
+
'zn-option': typeof ZnOption;
|
|
9665
|
+
'zn-remarkd-editor': typeof ZnRemarkdEditor;
|
|
9666
|
+
'zn-select': typeof ZnSelect;
|
|
9667
|
+
'zn-textarea': typeof ZnTextarea;
|
|
9668
|
+
};
|
|
9669
|
+
private readonly formControlController;
|
|
9670
|
+
private readonly hasSlotController;
|
|
9671
|
+
/** The name submitted with the form. */
|
|
9672
|
+
name: string;
|
|
9673
|
+
/** The translations as a JSON object keyed by language code. The mirror of `values` in attribute form. */
|
|
9674
|
+
value: string;
|
|
9675
|
+
/** The label shown above the field. If you need HTML, use the `label` slot instead. */
|
|
9676
|
+
label: string;
|
|
9677
|
+
/**
|
|
9678
|
+
* Text shown below the field, describing how to fill it in. Applies to every language. If you need HTML, use the
|
|
9679
|
+
* `help-text` slot instead.
|
|
9680
|
+
*/
|
|
9681
|
+
helpText: string;
|
|
9682
|
+
/** Disables editing in every language. */
|
|
9683
|
+
disabled: boolean;
|
|
9684
|
+
/** Marks the label required. Validity is not enforced per language. */
|
|
9685
|
+
required: boolean;
|
|
9686
|
+
/** Removes the component's own padding. */
|
|
9687
|
+
flush: boolean;
|
|
9688
|
+
/** The control each translation is edited through. */
|
|
9689
|
+
inputType: 'text' | 'number' | 'textarea' | 'remarkd';
|
|
9690
|
+
/** Rows of the textarea, when `input-type` is `textarea`. */
|
|
9691
|
+
textareaRows: number | undefined;
|
|
9692
|
+
/** Allows raw HTML blocks, when `input-type` is `remarkd`. */
|
|
9693
|
+
allowRaw: boolean;
|
|
9694
|
+
/** Where the remarkd editor uploads images, when `input-type` is `remarkd`. */
|
|
9695
|
+
attachmentUrl: string;
|
|
9696
|
+
/** Where the remarkd editor lists embeddable includes, when `input-type` is `remarkd`. */
|
|
9697
|
+
includeUrl: string;
|
|
9698
|
+
/** Where the remarkd editor searches link targets, when `input-type` is `remarkd`. */
|
|
9699
|
+
linkUrl: string;
|
|
9700
|
+
/**
|
|
9701
|
+
* Edits the translation through a `zn-inline-edit` — the value reads as text until it is clicked — rather than a
|
|
9702
|
+
* plain input or textarea.
|
|
9703
|
+
*/
|
|
9704
|
+
inlineEdit: boolean;
|
|
9705
|
+
/**
|
|
9706
|
+
* Quick insertions offered by the slash menu on `text` and `textarea` inputs. Accepts a JSON array of items, or
|
|
9707
|
+
* the shorthand `Brand name={{BRAND_NAME}}, Support email={{SUPPORT_EMAIL}}`. Every language shares the list.
|
|
9708
|
+
*/
|
|
9709
|
+
slashItems: SlashMenuItem[];
|
|
9710
|
+
/** Names of item sets registered with `registerSlashMenuPreset`, comma separated. */
|
|
9711
|
+
slashPreset: string;
|
|
9712
|
+
/** The characters that open the slash menu. */
|
|
9713
|
+
slashTrigger: string;
|
|
9714
|
+
/** The name the slash menu's list is announced by. */
|
|
9715
|
+
slashHeading: string;
|
|
9716
|
+
/** Hides the insertion keys normally shown against the slash menu's items. */
|
|
9717
|
+
slashHideKeys: boolean;
|
|
9718
|
+
/** Lists the slash menu items most recently chosen here above the rest, remembered under this key. */
|
|
9719
|
+
slashRecentKey: string;
|
|
9720
|
+
/** Resolves additional slash menu items each time the menu opens. JavaScript only. */
|
|
9721
|
+
slashItemsProvider?: (query: string) => SlashMenuItem[] | Promise<SlashMenuItem[]>;
|
|
9722
|
+
/**
|
|
9723
|
+
* Hides this component's own language select and defers the choice to a parent zn-translation-group. The group sets
|
|
9724
|
+
* this on its children itself.
|
|
9725
|
+
*/
|
|
9726
|
+
grouped: boolean;
|
|
9727
|
+
/**
|
|
9307
9728
|
* The languages on offer, as language code to display name — `{"en": "English", "fr": "French"}`. Writing the code
|
|
9308
9729
|
* as the name (`{"en": "EN"}`) is also accepted. `en` is the language every other one falls back to.
|
|
9309
9730
|
*/
|
|
@@ -9840,473 +10261,70 @@ declare module "components/markdown-editor/markdown-editor.component" {
|
|
|
9840
10261
|
private readonly markdownSlotController;
|
|
9841
10262
|
private debounceTimer;
|
|
9842
10263
|
textarea: ZnTextarea;
|
|
9843
|
-
previewEl: HTMLDivElement;
|
|
9844
|
-
/** The name of the control, submitted as part of form data. */
|
|
9845
|
-
name: string;
|
|
9846
|
-
/** The current markdown content. */
|
|
9847
|
-
value: string;
|
|
9848
|
-
/** The default value — used when resetting the form. */
|
|
9849
|
-
defaultValue: string;
|
|
9850
|
-
/** The control's label. If you need HTML, use the `label` slot. */
|
|
9851
|
-
label: string;
|
|
9852
|
-
/** Help text displayed below the editor. If you need HTML, use the `help-text` slot. */
|
|
9853
|
-
helpText: string;
|
|
9854
|
-
/** Placeholder text shown when the editor is empty. */
|
|
9855
|
-
placeholder: string;
|
|
9856
|
-
/** Number of rows for the textarea. */
|
|
9857
|
-
rows: number;
|
|
9858
|
-
/** Which view to show. */
|
|
9859
|
-
viewMode: ViewMode;
|
|
9860
|
-
/**
|
|
9861
|
-
* Key used to persist the selected view mode to `localStorage`. Set to an empty string to disable persistence.
|
|
9862
|
-
*/
|
|
9863
|
-
storageKey: string;
|
|
9864
|
-
/** Makes the editor required for form submission. */
|
|
9865
|
-
required: boolean;
|
|
9866
|
-
/** Makes the editor read-only. */
|
|
9867
|
-
readonly: boolean;
|
|
9868
|
-
/** Disables the editor. */
|
|
9869
|
-
disabled: boolean;
|
|
9870
|
-
/** Whether the editor is currently expanded to cover its containing positioned ancestor. */
|
|
9871
|
-
expanded: boolean;
|
|
9872
|
-
get validity(): ValidityState;
|
|
9873
|
-
get validationMessage(): string;
|
|
9874
|
-
checkValidity(): boolean;
|
|
9875
|
-
getForm(): HTMLFormElement | null;
|
|
9876
|
-
reportValidity(): boolean;
|
|
9877
|
-
setCustomValidity(message: string): void;
|
|
9878
|
-
/** Sets focus on the editor. */
|
|
9879
|
-
focus(options?: FocusOptions): void;
|
|
9880
|
-
/** Removes focus from the editor. */
|
|
9881
|
-
blur(): void;
|
|
9882
|
-
connectedCallback(): void;
|
|
9883
|
-
disconnectedCallback(): void;
|
|
9884
|
-
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
9885
|
-
private readStoredViewMode;
|
|
9886
|
-
private writeStoredViewMode;
|
|
9887
|
-
private renderPreview;
|
|
9888
|
-
private handleInput;
|
|
9889
|
-
private handleChange;
|
|
9890
|
-
private handleViewToggle;
|
|
9891
|
-
private handleExpandToggle;
|
|
9892
|
-
handleViewModeChange(): Promise<void>;
|
|
9893
|
-
handleValueChange(): Promise<void>;
|
|
9894
|
-
handleMarkedReady(): void;
|
|
9895
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
9896
|
-
markdownHelperBtn(): import("lit-html").TemplateResult<1>;
|
|
9897
|
-
private renderViewButton;
|
|
9898
|
-
}
|
|
9899
|
-
}
|
|
9900
|
-
declare module "components/markdown-editor/index" {
|
|
9901
|
-
import ZnMarkdownEditor from "components/markdown-editor/markdown-editor.component";
|
|
9902
|
-
export * from "components/markdown-editor/markdown-editor.component";
|
|
9903
|
-
export default ZnMarkdownEditor;
|
|
9904
|
-
global {
|
|
9905
|
-
interface HTMLElementTagNameMap {
|
|
9906
|
-
'zn-markdown-editor': ZnMarkdownEditor;
|
|
9907
|
-
}
|
|
9908
|
-
}
|
|
9909
|
-
}
|
|
9910
|
-
declare module "components/remarkd-editor/actions" {
|
|
9911
|
-
import type { SlashMenuItem } from "components/slash-menu/index";
|
|
9912
|
-
export type ActionGroup = 'text' | 'lists' | 'admonitions' | 'blocks' | 'structured' | 'media' | 'objects' | 'breaks' | 'logic' | 'inline';
|
|
9913
|
-
/** What an inline action wraps the selection in. `after` defaults to `before`. */
|
|
9914
|
-
export interface InlineMark {
|
|
9915
|
-
before: string;
|
|
9916
|
-
after?: string;
|
|
9917
|
-
placeholder?: string;
|
|
9918
|
-
}
|
|
9919
|
-
export interface EditorAction {
|
|
9920
|
-
/** Stable id, used for toolbar keys and tests. */
|
|
9921
|
-
key: string;
|
|
9922
|
-
label: string;
|
|
9923
|
-
icon: string;
|
|
9924
|
-
group: ActionGroup;
|
|
9925
|
-
/** Extra search terms for the slash menu, e.g. "bold" finds Strong. */
|
|
9926
|
-
keywords?: string[];
|
|
9927
|
-
/** Block actions: spliced in as a new block. */
|
|
9928
|
-
prefix?: string;
|
|
9929
|
-
/** Inline actions: applied to the selection in the open block. */
|
|
9930
|
-
inline?: InlineMark;
|
|
9931
|
-
/** Where the caret lands within `prefix`. Defaults to the end. */
|
|
9932
|
-
caretOffset?: number;
|
|
9933
|
-
/** Actions that open their own picker instead of inserting text. */
|
|
9934
|
-
opens?: 'image' | 'include' | 'link';
|
|
9935
|
-
}
|
|
9936
|
-
/** Toolbar order, most-used first — the last groups are the first to collapse. */
|
|
9937
|
-
export const ACTION_GROUPS: {
|
|
9938
|
-
id: ActionGroup;
|
|
9939
|
-
label: string;
|
|
9940
|
-
}[];
|
|
9941
|
-
export const EDITOR_ACTIONS: EditorAction[];
|
|
9942
|
-
/** The registry as slash menu entries. Picker actions insert nothing; the menu emits their action id. */
|
|
9943
|
-
export function slashItems(actions: EditorAction[]): SlashMenuItem[];
|
|
9944
|
-
}
|
|
9945
|
-
declare module "internal/toolbar-overflow" {
|
|
9946
|
-
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
9947
|
-
interface ToolbarOverflowOptions {
|
|
9948
|
-
/** The measurable group elements, in toolbar order. */
|
|
9949
|
-
groups: () => HTMLElement[];
|
|
9950
|
-
/** The element whose width the groups have to fit inside. */
|
|
9951
|
-
container: () => HTMLElement | null | undefined;
|
|
9952
|
-
/** Space to keep for the overflow trigger. Defaults to 44px. */
|
|
9953
|
-
reserve?: number;
|
|
9954
|
-
}
|
|
9955
|
-
/**
|
|
9956
|
-
* Reports how many leading toolbar groups fit the container, so the host can render the
|
|
9957
|
-
* rest into an overflow menu. Two passes: the first ignores the trigger, because when
|
|
9958
|
-
* everything fits there is no trigger to make room for.
|
|
9959
|
-
*/
|
|
9960
|
-
export class ToolbarOverflowController implements ReactiveController {
|
|
9961
|
-
visibleCount: number;
|
|
9962
|
-
private readonly host;
|
|
9963
|
-
private readonly options;
|
|
9964
|
-
private resizeRafId;
|
|
9965
|
-
constructor(host: ReactiveControllerHost & Element, options: ToolbarOverflowOptions);
|
|
9966
|
-
hostUpdated(): void;
|
|
9967
|
-
private measure;
|
|
9968
|
-
private countThatFit;
|
|
9969
|
-
}
|
|
9970
|
-
}
|
|
9971
|
-
declare module "components/remarkd-editor/remarkd-editor.component" {
|
|
9972
|
-
import { type CSSResultGroup, type PropertyValues, type TemplateResult } from 'lit';
|
|
9973
|
-
import ZincElement from "internal/zinc-element";
|
|
9974
|
-
import ZnDropdown from "components/dropdown/index";
|
|
9975
|
-
import ZnMenu from "components/menu/index";
|
|
9976
|
-
import ZnMenuItem from "components/menu-item/index";
|
|
9977
|
-
import ZnSlashMenu from "components/slash-menu/index";
|
|
9978
|
-
import type { ZincFormControl } from "internal/zinc-element";
|
|
9979
|
-
/**
|
|
9980
|
-
* @summary A Notion-style block editor for remarkd content. Blocks render inline; click one to edit its source.
|
|
9981
|
-
* @documentation https://zinc.style/components/remarkd-editor
|
|
9982
|
-
* @status experimental
|
|
9983
|
-
* @since 1.0
|
|
9984
|
-
*
|
|
9985
|
-
* @dependency zn-button
|
|
9986
|
-
* @dependency zn-button-group
|
|
9987
|
-
* @dependency zn-dropdown
|
|
9988
|
-
* @dependency zn-icon
|
|
9989
|
-
* @dependency zn-file
|
|
9990
|
-
* @dependency zn-menu
|
|
9991
|
-
* @dependency zn-menu-item
|
|
9992
|
-
* @dependency zn-slash-menu
|
|
9993
|
-
*
|
|
9994
|
-
* @event zn-input - Emitted on each keystroke while editing a block.
|
|
9995
|
-
* @event zn-change - Emitted when a block edit is committed and the value changes.
|
|
9996
|
-
*
|
|
9997
|
-
* @csspart base - The component's base wrapper.
|
|
9998
|
-
* @csspart toolbar - The always-visible block-insert and inline-formatting toolbar.
|
|
9999
|
-
* @csspart raw-toggle - The button that switches between the block view and the raw source view.
|
|
10000
|
-
* @csspart block - A rendered block wrapper.
|
|
10001
|
-
* @csspart rendered - The rendered remarkd output of a block.
|
|
10002
|
-
* @csspart conditional - A labelled wrapper for an ifdef/ifndef/ifeval/iftrue/iffalse/ifempty/ifnempty range.
|
|
10003
|
-
* @csspart variable - A chip rendered for a document attribute, title, or bracket line.
|
|
10004
|
-
* @csspart input - The textarea shown while editing a block.
|
|
10005
|
-
* @csspart raw - The full-document textarea shown in raw source mode.
|
|
10006
|
-
* @csspart slash-menu - The `zn-slash-menu` opened by typing "/" in an empty block.
|
|
10007
|
-
* @csspart image-controls - The caption / alignment / size panel shown when an image block is clicked.
|
|
10008
|
-
* @csspart include - The chip rendered in place of an `include::` directive.
|
|
10009
|
-
* @csspart include-picker - The inline Include picker opened from the toolbar or "/include".
|
|
10010
|
-
*
|
|
10011
|
-
* @cssproperty --remarkd-editor-max-height - The tallest the editor grows before its body scrolls. Defaults to `100dvh`.
|
|
10012
|
-
*/
|
|
10013
|
-
export default class ZnRemarkdEditor extends ZincElement implements ZincFormControl {
|
|
10014
|
-
static styles: CSSResultGroup;
|
|
10015
|
-
static dependencies: {
|
|
10016
|
-
'zn-dropdown': typeof ZnDropdown;
|
|
10017
|
-
'zn-menu': typeof ZnMenu;
|
|
10018
|
-
'zn-menu-item': typeof ZnMenuItem;
|
|
10019
|
-
'zn-slash-menu': typeof ZnSlashMenu;
|
|
10020
|
-
};
|
|
10021
|
-
private readonly formControlController;
|
|
10022
|
-
private readonly slashController;
|
|
10023
|
-
private readonly toolbarOverflow;
|
|
10024
|
-
private editingDraft;
|
|
10025
|
-
private includeRequest;
|
|
10026
|
-
private rawEntryValue;
|
|
10027
|
-
private suppressValueSync;
|
|
10028
|
-
private suppressBlurCommit;
|
|
10029
|
-
private validationInput;
|
|
10030
|
-
private slashMenuElement;
|
|
10031
|
-
private blocks;
|
|
10032
|
-
private editingIndex;
|
|
10033
|
-
/**
|
|
10034
|
-
* Lists the blocks most recently inserted here above the rest of the slash menu, remembered in
|
|
10035
|
-
* `localStorage` under this key. Leave unset to offer no recently used section.
|
|
10036
|
-
*/
|
|
10037
|
-
slashRecentKey: string;
|
|
10038
|
-
/** Renders the slash menu only once it has been needed. */
|
|
10039
|
-
private hasSlashMenu;
|
|
10040
|
-
private imagePickerIndex;
|
|
10041
|
-
private imageEdit;
|
|
10042
|
-
private dropIndicator;
|
|
10043
|
-
private dragIndex;
|
|
10044
|
-
private editShell;
|
|
10045
|
-
private rawMode;
|
|
10046
|
-
private includeOptions;
|
|
10047
|
-
private includeLoadFailed;
|
|
10048
|
-
private includePickerIndex;
|
|
10049
|
-
private includeQuery;
|
|
10050
|
-
private linkPickerOpen;
|
|
10051
|
-
private linkQuery;
|
|
10052
|
-
private linkResults;
|
|
10053
|
-
private linkSearchFailed;
|
|
10054
|
-
private linkSelection;
|
|
10055
|
-
private linkSearchTimer?;
|
|
10056
|
-
private linkSearchToken;
|
|
10057
|
-
/** Resolved link targets by reference; a null value is one the app does not know. */
|
|
10058
|
-
private linkRefs;
|
|
10059
|
-
private linkRefsPending;
|
|
10060
|
-
private pendingDragHandle;
|
|
10061
|
-
private dragStartX;
|
|
10062
|
-
private dragStartY;
|
|
10063
|
-
private dragGhost;
|
|
10064
|
-
private dragPointerY;
|
|
10065
|
-
private autoScrollFrame;
|
|
10264
|
+
previewEl: HTMLDivElement;
|
|
10066
10265
|
/** The name of the control, submitted as part of form data. */
|
|
10067
10266
|
name: string;
|
|
10068
|
-
/** The current
|
|
10267
|
+
/** The current markdown content. */
|
|
10069
10268
|
value: string;
|
|
10070
10269
|
/** The default value — used when resetting the form. */
|
|
10071
10270
|
defaultValue: string;
|
|
10072
|
-
/**
|
|
10271
|
+
/** The control's label. If you need HTML, use the `label` slot. */
|
|
10272
|
+
label: string;
|
|
10273
|
+
/** Help text displayed below the editor. If you need HTML, use the `help-text` slot. */
|
|
10274
|
+
helpText: string;
|
|
10275
|
+
/** Placeholder text shown when the editor is empty. */
|
|
10073
10276
|
placeholder: string;
|
|
10277
|
+
/** Number of rows for the textarea. */
|
|
10278
|
+
rows: number;
|
|
10279
|
+
/** Which view to show. */
|
|
10280
|
+
viewMode: ViewMode;
|
|
10074
10281
|
/**
|
|
10075
|
-
*
|
|
10076
|
-
* metadata here must return `{uploadPath, uploadUrl}`; the file is then PUT
|
|
10077
|
-
* to `uploadUrl` and the returned `uploadPath` is embedded as the image URL.
|
|
10078
|
-
*/
|
|
10079
|
-
attachmentUrl: string;
|
|
10080
|
-
/**
|
|
10081
|
-
* Endpoint listing the Includes this document may embed, as
|
|
10082
|
-
* `{"items":[{id,title,description,scope,keywords,languages,url}]}`. Labels the
|
|
10083
|
-
* chips rendered for `include::` directives and feeds the include picker.
|
|
10084
|
-
*/
|
|
10085
|
-
includeUrl: string;
|
|
10086
|
-
/**
|
|
10087
|
-
* Endpoint the article link picker searches, as
|
|
10088
|
-
* `{"items":[{ref,kind,title,context,status}]}`. Queried with `?q=<term>` as
|
|
10089
|
-
* the author types and with `?refs=a,b` to resolve the references a body
|
|
10090
|
-
* already carries.
|
|
10282
|
+
* Key used to persist the selected view mode to `localStorage`. Set to an empty string to disable persistence.
|
|
10091
10283
|
*/
|
|
10092
|
-
|
|
10093
|
-
/** Adds a toolbar toggle that swaps the block view for the full remarkd source. */
|
|
10094
|
-
allowRaw: boolean;
|
|
10284
|
+
storageKey: string;
|
|
10095
10285
|
/** Makes the editor required for form submission. */
|
|
10096
10286
|
required: boolean;
|
|
10097
10287
|
/** Makes the editor read-only. */
|
|
10098
10288
|
readonly: boolean;
|
|
10099
10289
|
/** Disables the editor. */
|
|
10100
10290
|
disabled: boolean;
|
|
10291
|
+
/** Whether the editor is currently expanded to cover its containing positioned ancestor. */
|
|
10292
|
+
expanded: boolean;
|
|
10101
10293
|
get validity(): ValidityState;
|
|
10102
10294
|
get validationMessage(): string;
|
|
10103
10295
|
checkValidity(): boolean;
|
|
10104
10296
|
getForm(): HTMLFormElement | null;
|
|
10105
10297
|
reportValidity(): boolean;
|
|
10106
10298
|
setCustomValidity(message: string): void;
|
|
10107
|
-
/**
|
|
10108
|
-
focus(): void;
|
|
10109
|
-
/**
|
|
10299
|
+
/** Sets focus on the editor. */
|
|
10300
|
+
focus(options?: FocusOptions): void;
|
|
10301
|
+
/** Removes focus from the editor. */
|
|
10110
10302
|
blur(): void;
|
|
10111
|
-
|
|
10112
|
-
protected updated(changedProperties: PropertyValues<this>): void;
|
|
10303
|
+
connectedCallback(): void;
|
|
10113
10304
|
disconnectedCallback(): void;
|
|
10114
|
-
|
|
10115
|
-
|
|
10116
|
-
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
private
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
private
|
|
10128
|
-
/** Parses a block that is nothing but an include directive. */
|
|
10129
|
-
private parseIncludeBlock;
|
|
10130
|
-
private serializeImageBlock;
|
|
10131
|
-
private toggleCheckbox;
|
|
10132
|
-
private startEdit;
|
|
10133
|
-
private updateImageEdit;
|
|
10134
|
-
private saveImageEdit;
|
|
10135
|
-
private closeImageEdit;
|
|
10136
|
-
private deleteImageBlock;
|
|
10137
|
-
private editImageSource;
|
|
10138
|
-
private handleImageControlsKeydown;
|
|
10139
|
-
/**
|
|
10140
|
-
* The remarkd chrome the editing block should keep, derived from its first
|
|
10141
|
-
* line — so a NOTE still looks like a note while its source is edited.
|
|
10142
|
-
*/
|
|
10143
|
-
private computeEditShell;
|
|
10144
|
-
private focusInput;
|
|
10145
|
-
/**
|
|
10146
|
-
* Scrolls the editor's own body to bring `el` into view. Never `scrollIntoView()` and
|
|
10147
|
-
* never `focus()` without preventScroll: both walk every scrollable ancestor, and an
|
|
10148
|
-
* `overflow: hidden`/`auto` panel around the editor is scrollable too — that shifts a
|
|
10149
|
-
* container the user never asked to move.
|
|
10150
|
-
*/
|
|
10151
|
-
private reveal;
|
|
10152
|
-
private revealAfterUpdate;
|
|
10153
|
-
/**
|
|
10154
|
-
* Centres a block added without opening an editor. An image has no height until it
|
|
10155
|
-
* loads, so the first pass scrolls against a layout that is still short — the second
|
|
10156
|
-
* pass corrects it once the real dimensions are in.
|
|
10157
|
-
*/
|
|
10158
|
-
private revealBlock;
|
|
10159
|
-
private addBlockAt;
|
|
10160
|
-
private deleteBlock;
|
|
10161
|
-
/** Inserts a draft block — committed (or dropped, if left empty) on blur. */
|
|
10162
|
-
private insertDraftBlock;
|
|
10163
|
-
/**
|
|
10164
|
-
* Blur handler for the editing textarea. Re-renders that replace the
|
|
10165
|
-
* focused textarea (e.g. Shift+Enter committing and opening the next
|
|
10166
|
-
* block) fire blur mid-transition — `suppressBlurCommit` masks those.
|
|
10167
|
-
*/
|
|
10168
|
-
private handleEditBlur;
|
|
10169
|
-
/** Commits the in-progress edit; returns the index after the committed parts. */
|
|
10170
|
-
private commitEdit;
|
|
10171
|
-
private handleDraftInput;
|
|
10172
|
-
private handleEditKeydown;
|
|
10173
|
-
/** Whether the block being edited is nothing but the slash command. */
|
|
10174
|
-
private isSlashBlock;
|
|
10175
|
-
private mountSlashMenu;
|
|
10176
|
-
/** Returns false for items the controller should not insert text for. */
|
|
10177
|
-
private handleSlashSelect;
|
|
10178
|
-
private handleEditPaste;
|
|
10179
|
-
private handleDragOver;
|
|
10180
|
-
private handleDrop;
|
|
10181
|
-
/** The insertion index a drop at `y` maps to, from the rendered block positions. */
|
|
10182
|
-
private insertionIndexFromY;
|
|
10183
|
-
private handleHandlePointerDown;
|
|
10184
|
-
private handleDragPointerMove;
|
|
10185
|
-
/**
|
|
10186
|
-
* Holding the pointer near a scroll edge keeps the content moving, so a block can
|
|
10187
|
-
* be dragged past the visible slice of a long document. Runs per frame rather than
|
|
10188
|
-
* per pointermove — a pointer parked at the edge stops emitting moves.
|
|
10189
|
-
*/
|
|
10190
|
-
private stepAutoScroll;
|
|
10191
|
-
/** Scrolls the editor body, falling through to the page once the body is at its limit. */
|
|
10192
|
-
private autoScroll;
|
|
10193
|
-
/** Scroll step for this frame: nothing until the pointer is within `edge` of a boundary. */
|
|
10194
|
-
private edgeScrollDelta;
|
|
10195
|
-
private handleDragPointerUp;
|
|
10196
|
-
private cancelDrag;
|
|
10197
|
-
private createDragGhost;
|
|
10198
|
-
private moveDragGhost;
|
|
10199
|
-
private pickImage;
|
|
10200
|
-
private pickInclude;
|
|
10201
|
-
/**
|
|
10202
|
-
* Opens the picker over the block being edited. The caret range is captured
|
|
10203
|
-
* now: the picker's own filter takes focus, so the textarea's selection is
|
|
10204
|
-
* gone by the time an option is chosen.
|
|
10205
|
-
*/
|
|
10206
|
-
private pickLink;
|
|
10207
|
-
private closeLinkPicker;
|
|
10208
|
-
/** Debounced; only the newest response is kept. */
|
|
10209
|
-
private searchLinks;
|
|
10210
|
-
private closeIncludePicker;
|
|
10211
|
-
private insertInclude;
|
|
10212
|
-
private closeImagePicker;
|
|
10213
|
-
private handleImagePicked;
|
|
10214
|
-
private insertImage;
|
|
10215
|
-
private uploadImage;
|
|
10216
|
-
/**
|
|
10217
|
-
* Resolves an app-relative path the way the console's pagelet handler does:
|
|
10218
|
-
* an app fragment's URLs sit under the app base, and the console puts the app's
|
|
10219
|
-
* `gaid` on the host element. Links rendered here live in the shadow root,
|
|
10220
|
-
* where a click retargets to the host, so that handler never sees them — the
|
|
10221
|
-
* href has to carry the base itself.
|
|
10222
|
-
*/
|
|
10223
|
-
private appPath;
|
|
10224
|
-
private hasIncludeBlock;
|
|
10225
|
-
/** Fetches the include list once; every later caller shares the same promise. */
|
|
10226
|
-
private loadIncludeOptions;
|
|
10227
|
-
/**
|
|
10228
|
-
* Resolves the references in the body that have not been resolved yet, so a
|
|
10229
|
-
* link whose target is gone can be marked. A failed request records nothing:
|
|
10230
|
-
* an unanswered reference is not a broken one.
|
|
10231
|
-
*/
|
|
10232
|
-
private resolveContentLinks;
|
|
10233
|
-
private markContentLinks;
|
|
10234
|
-
private autosize;
|
|
10235
|
-
/**
|
|
10236
|
-
* Applies an inline mark to the open block's textarea: wraps the selection, toggles the
|
|
10237
|
-
* mark off when it is already wrapped, or inserts a selected placeholder when there is
|
|
10238
|
-
* no selection. Goes through `editingDraft` so `zn-input` still fires.
|
|
10239
|
-
*/
|
|
10240
|
-
private applyInline;
|
|
10241
|
-
private toggleRawMode;
|
|
10242
|
-
private focusRaw;
|
|
10243
|
-
/**
|
|
10244
|
-
* Raw mode keeps the whole document in one textarea, so the textarea — not
|
|
10245
|
-
* the block list — is authoritative while it is open: re-splitting on every
|
|
10246
|
-
* keystroke would normalise blank lines out from under the cursor.
|
|
10247
|
-
*/
|
|
10248
|
-
private handleRawInput;
|
|
10249
|
-
/**
|
|
10250
|
-
* Re-splits the raw source into blocks. Not `updateBlocks` — that only
|
|
10251
|
-
* reports a change when the re-join differs from the value, and raw edits
|
|
10252
|
-
* have already written straight to the value.
|
|
10253
|
-
*/
|
|
10254
|
-
private commitRaw;
|
|
10255
|
-
private handleToolbarInsert;
|
|
10256
|
-
private renderImageControls;
|
|
10257
|
-
private renderIncludeChip;
|
|
10258
|
-
/** A metadata-only block parses to nothing, so show each of its lines as a chip instead. */
|
|
10259
|
-
private renderMetaChips;
|
|
10260
|
-
/**
|
|
10261
|
-
* One shared chip treatment for every metadata line kind — each kind just supplies an
|
|
10262
|
-
* icon, a name, and an optional value/state, display-only in all three cases.
|
|
10263
|
-
*/
|
|
10264
|
-
private renderMetaChip;
|
|
10265
|
-
/**
|
|
10266
|
-
* Wraps `{name}` references so they read as variables rather than literal text. Walks text
|
|
10267
|
-
* nodes and skips code, so a brace in a sample stays a brace, and no regex touches markup.
|
|
10268
|
-
*/
|
|
10269
|
-
private markVariables;
|
|
10270
|
-
/**
|
|
10271
|
-
* A conditional range as a labelled wrapper. The inner content is parsed without the
|
|
10272
|
-
* directive lines: evaluating instead would blank the block whenever the flag is not
|
|
10273
|
-
* defined in this same block, hiding the author's content while they edit it. It also
|
|
10274
|
-
* keeps both halves of an if/else idiom visible — with evaluation you could never see
|
|
10275
|
-
* the `ifndef` branch while the `ifdef` condition held. Nesting is handled by
|
|
10276
|
-
* `splitConditionalParts`/`renderConditionalWrapper` below, recursively.
|
|
10277
|
-
*/
|
|
10278
|
-
private renderConditional;
|
|
10279
|
-
private renderBlock;
|
|
10280
|
-
/** Inline marks and the article link both apply into an open block, not a new one. */
|
|
10281
|
-
private isActionDisabled;
|
|
10282
|
-
/** A picker action with no endpoint configured is not offered at all. */
|
|
10283
|
-
private actionAvailable;
|
|
10284
|
-
private slashItemAvailable;
|
|
10285
|
-
/** Routes a toolbar/menu action to the inline or block insert path — the one place both
|
|
10286
|
-
* `renderAction` and `renderMenuAction` call, so the bar and the overflow menu cannot
|
|
10287
|
-
* drift out of sync on what a given action actually does. */
|
|
10288
|
-
private activateAction;
|
|
10289
|
-
/** A single toolbar action button, shared by the toolbar bar and the overflow menu. */
|
|
10290
|
-
private renderAction;
|
|
10291
|
-
/** The same action, rendered as a menu item for the overflow menu. */
|
|
10292
|
-
private renderMenuAction;
|
|
10293
|
-
render(): TemplateResult<1>;
|
|
10294
|
-
private renderRaw;
|
|
10295
|
-
/** The block views, with the inline image picker spliced in when active. */
|
|
10296
|
-
private renderBody;
|
|
10297
|
-
private renderIncludePicker;
|
|
10298
|
-
private renderLinkPicker;
|
|
10299
|
-
private insertLink;
|
|
10300
|
-
private renderImagePicker;
|
|
10305
|
+
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
10306
|
+
private readStoredViewMode;
|
|
10307
|
+
private writeStoredViewMode;
|
|
10308
|
+
private renderPreview;
|
|
10309
|
+
private handleInput;
|
|
10310
|
+
private handleChange;
|
|
10311
|
+
private handleViewToggle;
|
|
10312
|
+
private handleExpandToggle;
|
|
10313
|
+
handleViewModeChange(): Promise<void>;
|
|
10314
|
+
handleValueChange(): Promise<void>;
|
|
10315
|
+
handleMarkedReady(): void;
|
|
10316
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
10317
|
+
markdownHelperBtn(): import("lit-html").TemplateResult<1>;
|
|
10318
|
+
private renderViewButton;
|
|
10301
10319
|
}
|
|
10302
10320
|
}
|
|
10303
|
-
declare module "components/
|
|
10304
|
-
import
|
|
10305
|
-
export * from "components/
|
|
10306
|
-
export default
|
|
10321
|
+
declare module "components/markdown-editor/index" {
|
|
10322
|
+
import ZnMarkdownEditor from "components/markdown-editor/markdown-editor.component";
|
|
10323
|
+
export * from "components/markdown-editor/markdown-editor.component";
|
|
10324
|
+
export default ZnMarkdownEditor;
|
|
10307
10325
|
global {
|
|
10308
10326
|
interface HTMLElementTagNameMap {
|
|
10309
|
-
'zn-
|
|
10327
|
+
'zn-markdown-editor': ZnMarkdownEditor;
|
|
10310
10328
|
}
|
|
10311
10329
|
}
|
|
10312
10330
|
}
|
|
@@ -11742,6 +11760,8 @@ declare module "components/page-builder/page-builder.component" {
|
|
|
11742
11760
|
private _slotPicker;
|
|
11743
11761
|
/** The stamped config form for the selected section; rebuilt on selection change. */
|
|
11744
11762
|
private _form;
|
|
11763
|
+
private _inspectorWidth;
|
|
11764
|
+
private _inspectorWide;
|
|
11745
11765
|
private readonly _hasSlot;
|
|
11746
11766
|
private _history;
|
|
11747
11767
|
private _redoStack;
|
|
@@ -11929,6 +11949,11 @@ declare module "components/page-builder/page-builder.component" {
|
|
|
11929
11949
|
private _onInspectorInput;
|
|
11930
11950
|
private _updateSectionData;
|
|
11931
11951
|
private _renameSection;
|
|
11952
|
+
/** Width the inspector may be dragged to, against the builder's own width. */
|
|
11953
|
+
private _clampInspector;
|
|
11954
|
+
private _inspectorRect;
|
|
11955
|
+
private _onResizeStart;
|
|
11956
|
+
private _onResizeKey;
|
|
11932
11957
|
private _renderInspector;
|
|
11933
11958
|
render(): import("lit-html").TemplateResult<1>;
|
|
11934
11959
|
}
|