@kubex/zinc 1.1.101 → 1.1.102
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 +260 -81
- package/dist/vscode.html-custom-data.json +13 -13
- package/dist/web-types.json +25 -25
- package/dist/zn.d.ts +124 -4
- package/dist/zn.min.js +359 -282
- package/docs/pages/components/remarkd-editor.md +59 -0
- package/package.json +1 -1
- package/src/components/menu/menu.component.ts +4 -1
- package/src/components/menu/menu.scss +3 -0
- package/src/components/remarkd-editor/actions.ts +159 -0
- package/src/components/remarkd-editor/feature-keys.ts +17 -0
- package/src/components/remarkd-editor/remarkd-editor.component.ts +509 -49
- package/src/components/remarkd-editor/remarkd-editor.scss +68 -1
- package/src/components/remarkd-editor/remarkd-editor.test.ts +675 -9
- package/src/components/slash-menu/slash-menu.scss +2 -0
- package/src/internal/toolbar-overflow.ts +100 -0
package/dist/zn.d.ts
CHANGED
|
@@ -989,6 +989,8 @@ declare module "components/menu/menu.component" {
|
|
|
989
989
|
* @csspart base - The component's base wrapper.
|
|
990
990
|
*
|
|
991
991
|
* @cssproperty --example - An example CSS custom property.
|
|
992
|
+
* @cssproperty --zn-menu-max-height - Caps the menu's height and makes it scroll internally.
|
|
993
|
+
* Unset (`none`) by default, so the menu grows to fit its items unless a consumer sets this.
|
|
992
994
|
*/
|
|
993
995
|
export default class ZnMenu extends ZincElement {
|
|
994
996
|
static styles: CSSResultGroup;
|
|
@@ -9453,9 +9455,73 @@ declare module "components/markdown-editor/index" {
|
|
|
9453
9455
|
}
|
|
9454
9456
|
}
|
|
9455
9457
|
}
|
|
9458
|
+
declare module "components/remarkd-editor/actions" {
|
|
9459
|
+
import type { SlashMenuItem } from "components/slash-menu/index";
|
|
9460
|
+
export type ActionGroup = 'text' | 'lists' | 'admonitions' | 'blocks' | 'structured' | 'media' | 'objects' | 'breaks' | 'logic' | 'inline';
|
|
9461
|
+
/** What an inline action wraps the selection in. `after` defaults to `before`. */
|
|
9462
|
+
export interface InlineMark {
|
|
9463
|
+
before: string;
|
|
9464
|
+
after?: string;
|
|
9465
|
+
placeholder?: string;
|
|
9466
|
+
}
|
|
9467
|
+
export interface EditorAction {
|
|
9468
|
+
/** Stable id, used for toolbar keys and tests. */
|
|
9469
|
+
key: string;
|
|
9470
|
+
label: string;
|
|
9471
|
+
icon: string;
|
|
9472
|
+
group: ActionGroup;
|
|
9473
|
+
/** Extra search terms for the slash menu, e.g. "bold" finds Strong. */
|
|
9474
|
+
keywords?: string[];
|
|
9475
|
+
/** Block actions: spliced in as a new block. */
|
|
9476
|
+
prefix?: string;
|
|
9477
|
+
/** Inline actions: applied to the selection in the open block. */
|
|
9478
|
+
inline?: InlineMark;
|
|
9479
|
+
/** Where the caret lands within `prefix`. Defaults to the end. */
|
|
9480
|
+
caretOffset?: number;
|
|
9481
|
+
/** Actions that open their own picker instead of inserting text. */
|
|
9482
|
+
opens?: 'image' | 'include';
|
|
9483
|
+
}
|
|
9484
|
+
/** Toolbar order, most-used first — the last groups are the first to collapse. */
|
|
9485
|
+
export const ACTION_GROUPS: {
|
|
9486
|
+
id: ActionGroup;
|
|
9487
|
+
label: string;
|
|
9488
|
+
}[];
|
|
9489
|
+
export const EDITOR_ACTIONS: EditorAction[];
|
|
9490
|
+
/** The registry as slash menu entries. Picker actions insert nothing; the menu emits their action id. */
|
|
9491
|
+
export function slashItems(actions: EditorAction[]): SlashMenuItem[];
|
|
9492
|
+
}
|
|
9493
|
+
declare module "internal/toolbar-overflow" {
|
|
9494
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
9495
|
+
interface ToolbarOverflowOptions {
|
|
9496
|
+
/** The measurable group elements, in toolbar order. */
|
|
9497
|
+
groups: () => HTMLElement[];
|
|
9498
|
+
/** The element whose width the groups have to fit inside. */
|
|
9499
|
+
container: () => HTMLElement | null | undefined;
|
|
9500
|
+
/** Space to keep for the overflow trigger. Defaults to 44px. */
|
|
9501
|
+
reserve?: number;
|
|
9502
|
+
}
|
|
9503
|
+
/**
|
|
9504
|
+
* Reports how many leading toolbar groups fit the container, so the host can render the
|
|
9505
|
+
* rest into an overflow menu. Two passes: the first ignores the trigger, because when
|
|
9506
|
+
* everything fits there is no trigger to make room for.
|
|
9507
|
+
*/
|
|
9508
|
+
export class ToolbarOverflowController implements ReactiveController {
|
|
9509
|
+
visibleCount: number;
|
|
9510
|
+
private readonly host;
|
|
9511
|
+
private readonly options;
|
|
9512
|
+
private resizeRafId;
|
|
9513
|
+
constructor(host: ReactiveControllerHost & Element, options: ToolbarOverflowOptions);
|
|
9514
|
+
hostUpdated(): void;
|
|
9515
|
+
private measure;
|
|
9516
|
+
private countThatFit;
|
|
9517
|
+
}
|
|
9518
|
+
}
|
|
9456
9519
|
declare module "components/remarkd-editor/remarkd-editor.component" {
|
|
9457
|
-
import { type CSSResultGroup, type PropertyValues } from 'lit';
|
|
9520
|
+
import { type CSSResultGroup, type PropertyValues, type TemplateResult } from 'lit';
|
|
9458
9521
|
import ZincElement from "internal/zinc-element";
|
|
9522
|
+
import ZnDropdown from "components/dropdown/index";
|
|
9523
|
+
import ZnMenu from "components/menu/index";
|
|
9524
|
+
import ZnMenuItem from "components/menu-item/index";
|
|
9459
9525
|
import ZnSlashMenu from "components/slash-menu/index";
|
|
9460
9526
|
import type { ZincFormControl } from "internal/zinc-element";
|
|
9461
9527
|
/**
|
|
@@ -9466,18 +9532,23 @@ declare module "components/remarkd-editor/remarkd-editor.component" {
|
|
|
9466
9532
|
*
|
|
9467
9533
|
* @dependency zn-button
|
|
9468
9534
|
* @dependency zn-button-group
|
|
9535
|
+
* @dependency zn-dropdown
|
|
9469
9536
|
* @dependency zn-icon
|
|
9470
9537
|
* @dependency zn-file
|
|
9538
|
+
* @dependency zn-menu
|
|
9539
|
+
* @dependency zn-menu-item
|
|
9471
9540
|
* @dependency zn-slash-menu
|
|
9472
9541
|
*
|
|
9473
9542
|
* @event zn-input - Emitted on each keystroke while editing a block.
|
|
9474
9543
|
* @event zn-change - Emitted when a block edit is committed and the value changes.
|
|
9475
9544
|
*
|
|
9476
9545
|
* @csspart base - The component's base wrapper.
|
|
9477
|
-
* @csspart toolbar - The always-visible block-insert toolbar.
|
|
9546
|
+
* @csspart toolbar - The always-visible block-insert and inline-formatting toolbar.
|
|
9478
9547
|
* @csspart raw-toggle - The button that switches between the block view and the raw source view.
|
|
9479
9548
|
* @csspart block - A rendered block wrapper.
|
|
9480
9549
|
* @csspart rendered - The rendered remarkd output of a block.
|
|
9550
|
+
* @csspart conditional - A labelled wrapper for an ifdef/ifndef/ifeval/iftrue/iffalse/ifempty/ifnempty range.
|
|
9551
|
+
* @csspart variable - A chip rendered for a document attribute, title, or bracket line.
|
|
9481
9552
|
* @csspart input - The textarea shown while editing a block.
|
|
9482
9553
|
* @csspart raw - The full-document textarea shown in raw source mode.
|
|
9483
9554
|
* @csspart slash-menu - The `zn-slash-menu` opened by typing "/" in an empty block.
|
|
@@ -9490,10 +9561,14 @@ declare module "components/remarkd-editor/remarkd-editor.component" {
|
|
|
9490
9561
|
export default class ZnRemarkdEditor extends ZincElement implements ZincFormControl {
|
|
9491
9562
|
static styles: CSSResultGroup;
|
|
9492
9563
|
static dependencies: {
|
|
9564
|
+
'zn-dropdown': typeof ZnDropdown;
|
|
9565
|
+
'zn-menu': typeof ZnMenu;
|
|
9566
|
+
'zn-menu-item': typeof ZnMenuItem;
|
|
9493
9567
|
'zn-slash-menu': typeof ZnSlashMenu;
|
|
9494
9568
|
};
|
|
9495
9569
|
private readonly formControlController;
|
|
9496
9570
|
private readonly slashController;
|
|
9571
|
+
private readonly toolbarOverflow;
|
|
9497
9572
|
private editingDraft;
|
|
9498
9573
|
private includeRequest;
|
|
9499
9574
|
private rawEntryValue;
|
|
@@ -9565,12 +9640,13 @@ declare module "components/remarkd-editor/remarkd-editor.component" {
|
|
|
9565
9640
|
/** Commits any in-progress block or raw edit. */
|
|
9566
9641
|
blur(): void;
|
|
9567
9642
|
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
9643
|
+
protected updated(changedProperties: PropertyValues<this>): void;
|
|
9568
9644
|
disconnectedCallback(): void;
|
|
9569
9645
|
handleValueChange(): void;
|
|
9570
9646
|
handleIncludeUrlChange(): void;
|
|
9571
9647
|
/**
|
|
9572
9648
|
* Splits remarkd source into blocks on blank lines, keeping fenced /
|
|
9573
|
-
* delimited containers (``` ==== !!!! .... ----) as single blocks.
|
|
9649
|
+
* delimited containers (``` ==== !!!! .... ---- ____ **** ////) as single blocks.
|
|
9574
9650
|
*/
|
|
9575
9651
|
private splitBlocks;
|
|
9576
9652
|
private fenceMarker;
|
|
@@ -9670,6 +9746,12 @@ declare module "components/remarkd-editor/remarkd-editor.component" {
|
|
|
9670
9746
|
/** Fetches the include list once; every later caller shares the same promise. */
|
|
9671
9747
|
private loadIncludeOptions;
|
|
9672
9748
|
private autosize;
|
|
9749
|
+
/**
|
|
9750
|
+
* Applies an inline mark to the open block's textarea: wraps the selection, toggles the
|
|
9751
|
+
* mark off when it is already wrapped, or inserts a selected placeholder when there is
|
|
9752
|
+
* no selection. Goes through `editingDraft` so `zn-input` still fires.
|
|
9753
|
+
*/
|
|
9754
|
+
private applyInline;
|
|
9673
9755
|
private toggleRawMode;
|
|
9674
9756
|
private focusRaw;
|
|
9675
9757
|
/**
|
|
@@ -9687,8 +9769,39 @@ declare module "components/remarkd-editor/remarkd-editor.component" {
|
|
|
9687
9769
|
private handleToolbarInsert;
|
|
9688
9770
|
private renderImageControls;
|
|
9689
9771
|
private renderIncludeChip;
|
|
9772
|
+
/** A metadata-only block parses to nothing, so show each of its lines as a chip instead. */
|
|
9773
|
+
private renderMetaChips;
|
|
9774
|
+
/**
|
|
9775
|
+
* One shared chip treatment for every metadata line kind — each kind just supplies an
|
|
9776
|
+
* icon, a name, and an optional value/state, display-only in all three cases.
|
|
9777
|
+
*/
|
|
9778
|
+
private renderMetaChip;
|
|
9779
|
+
/**
|
|
9780
|
+
* Wraps `{name}` references so they read as variables rather than literal text. Walks text
|
|
9781
|
+
* nodes and skips code, so a brace in a sample stays a brace, and no regex touches markup.
|
|
9782
|
+
*/
|
|
9783
|
+
private markVariables;
|
|
9784
|
+
/**
|
|
9785
|
+
* A conditional range as a labelled wrapper. The inner content is parsed without the
|
|
9786
|
+
* directive lines: evaluating instead would blank the block whenever the flag is not
|
|
9787
|
+
* defined in this same block, hiding the author's content while they edit it. It also
|
|
9788
|
+
* keeps both halves of an if/else idiom visible — with evaluation you could never see
|
|
9789
|
+
* the `ifndef` branch while the `ifdef` condition held. Nesting is handled by
|
|
9790
|
+
* `splitConditionalParts`/`renderConditionalWrapper` below, recursively.
|
|
9791
|
+
*/
|
|
9792
|
+
private renderConditional;
|
|
9690
9793
|
private renderBlock;
|
|
9691
|
-
|
|
9794
|
+
/** An inline action needs an open block to apply its mark to. */
|
|
9795
|
+
private isActionDisabled;
|
|
9796
|
+
/** Routes a toolbar/menu action to the inline or block insert path — the one place both
|
|
9797
|
+
* `renderAction` and `renderMenuAction` call, so the bar and the overflow menu cannot
|
|
9798
|
+
* drift out of sync on what a given action actually does. */
|
|
9799
|
+
private activateAction;
|
|
9800
|
+
/** A single toolbar action button, shared by the toolbar bar and the overflow menu. */
|
|
9801
|
+
private renderAction;
|
|
9802
|
+
/** The same action, rendered as a menu item for the overflow menu. */
|
|
9803
|
+
private renderMenuAction;
|
|
9804
|
+
render(): TemplateResult<1>;
|
|
9692
9805
|
private renderRaw;
|
|
9693
9806
|
/** The block views, with the inline image picker spliced in when active. */
|
|
9694
9807
|
private renderBody;
|
|
@@ -12744,6 +12857,13 @@ declare module "components/editor/modules/events/zn-editor-update" {
|
|
|
12744
12857
|
declare module "components/hover-container/hover-container" {
|
|
12745
12858
|
import '../../../dist/zn.min.js';
|
|
12746
12859
|
}
|
|
12860
|
+
declare module "components/remarkd-editor/feature-keys" {
|
|
12861
|
+
/**
|
|
12862
|
+
* The remarkd feature fixtures, from `node_modules/remarkd-js/requirements/features/`.
|
|
12863
|
+
* Regenerate with: ls node_modules/remarkd-js/requirements/features
|
|
12864
|
+
*/
|
|
12865
|
+
export const FEATURE_KEYS: string[];
|
|
12866
|
+
}
|
|
12747
12867
|
declare module "events/zn-after-collapse" {
|
|
12748
12868
|
export type ZnAfterExpandEvent = CustomEvent<Record<PropertyKey, never>>;
|
|
12749
12869
|
global {
|