@liquid-js/lyr-extras 0.0.0-stage → 22.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +23 -0
- package/README.md +61 -2
- package/fesm2022/liquid-js-lyr-extras-chart.mjs +871 -0
- package/fesm2022/liquid-js-lyr-extras-chart.mjs.map +1 -0
- package/fesm2022/liquid-js-lyr-extras-color-picker.mjs +819 -0
- package/fesm2022/liquid-js-lyr-extras-color-picker.mjs.map +1 -0
- package/fesm2022/liquid-js-lyr-extras-markdown-editor.mjs +921 -0
- package/fesm2022/liquid-js-lyr-extras-markdown-editor.mjs.map +1 -0
- package/fesm2022/liquid-js-lyr-extras-markdown-viewer.mjs +369 -0
- package/fesm2022/liquid-js-lyr-extras-markdown-viewer.mjs.map +1 -0
- package/fesm2022/liquid-js-lyr-extras-mask.mjs +238 -0
- package/fesm2022/liquid-js-lyr-extras-mask.mjs.map +1 -0
- package/fesm2022/liquid-js-lyr-extras-media.mjs +1142 -0
- package/fesm2022/liquid-js-lyr-extras-media.mjs.map +1 -0
- package/fesm2022/liquid-js-lyr-extras-phone-input.mjs +862 -0
- package/fesm2022/liquid-js-lyr-extras-phone-input.mjs.map +1 -0
- package/fesm2022/liquid-js-lyr-extras-qr-code.mjs +236 -0
- package/fesm2022/liquid-js-lyr-extras-qr-code.mjs.map +1 -0
- package/fesm2022/liquid-js-lyr-extras.mjs +0 -0
- package/package.json +159 -3
- package/types/liquid-js-lyr-extras-chart.d.ts +294 -0
- package/types/liquid-js-lyr-extras-color-picker.d.ts +311 -0
- package/types/liquid-js-lyr-extras-markdown-editor.d.ts +367 -0
- package/types/liquid-js-lyr-extras-markdown-viewer.d.ts +174 -0
- package/types/liquid-js-lyr-extras-mask.d.ts +130 -0
- package/types/liquid-js-lyr-extras-media.d.ts +517 -0
- package/types/liquid-js-lyr-extras-phone-input.d.ts +428 -0
- package/types/liquid-js-lyr-extras-qr-code.d.ts +113 -0
- package/types/liquid-js-lyr-extras.d.ts +1 -0
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
import { ElementRef } from "@angular/core";
|
|
6
|
+
import { ControlValueAccessor } from "@angular/forms";
|
|
7
|
+
import { NbComponentShape, NbIconLibraries, NbValidationDirective } from "@liquid-js/lyr-core";
|
|
8
|
+
import { Editor, EditorOptions, EditorType, IconName, PreviewStyle, ToolbarItemOptions } from "@liquid-js/underflow";
|
|
9
|
+
import { HLJSApi } from "highlight.js";
|
|
10
|
+
import { HighlightLoader } from "nxt-highlightjs";
|
|
11
|
+
/**
|
|
12
|
+
* The texts of the markdown editor's toolbar, tabs and popups. `provideNbTexts({ markdownEditor: { ... } })` changes
|
|
13
|
+
* them, and they're translated with Angular's i18n, as `$localize` messages with ids like
|
|
14
|
+
* `@@nb.markdownEditor.bold`.
|
|
15
|
+
*/
|
|
16
|
+
interface NbMarkdownEditorTexts {
|
|
17
|
+
/** The markdown mode's tab. */
|
|
18
|
+
markdown: string;
|
|
19
|
+
/** The WYSIWYG mode's tab. */
|
|
20
|
+
wysiwyg: string;
|
|
21
|
+
/** The tab with the markdown, when the preview is a tab. */
|
|
22
|
+
write: string;
|
|
23
|
+
preview: string;
|
|
24
|
+
/** The toolbar button that opens the headings. */
|
|
25
|
+
headings: string;
|
|
26
|
+
/** A level in the list of headings, given the level, e.g. "Heading 2". */
|
|
27
|
+
headingLevel: (level: string) => string;
|
|
28
|
+
paragraph: string;
|
|
29
|
+
bold: string;
|
|
30
|
+
italic: string;
|
|
31
|
+
strike: string;
|
|
32
|
+
code: string;
|
|
33
|
+
line: string;
|
|
34
|
+
blockquote: string;
|
|
35
|
+
unorderedList: string;
|
|
36
|
+
orderedList: string;
|
|
37
|
+
task: string;
|
|
38
|
+
indent: string;
|
|
39
|
+
outdent: string;
|
|
40
|
+
insertLink: string;
|
|
41
|
+
insertCodeBlock: string;
|
|
42
|
+
insertTable: string;
|
|
43
|
+
insertImage: string;
|
|
44
|
+
/** The toolbar button that writes the markdown in one style, with its shortcut. */
|
|
45
|
+
format: string;
|
|
46
|
+
/** The toolbar button that shows the items that don't fit. */
|
|
47
|
+
more: string;
|
|
48
|
+
/** Names the toolbar. */
|
|
49
|
+
textFormatting: string;
|
|
50
|
+
/** Describes the toolbar button whose format the text at the cursor has. */
|
|
51
|
+
activeButton: string;
|
|
52
|
+
autoScrollEnabled: string;
|
|
53
|
+
autoScrollDisabled: string;
|
|
54
|
+
imageUrl: string;
|
|
55
|
+
selectImageFile: string;
|
|
56
|
+
chooseFile: string;
|
|
57
|
+
noFile: string;
|
|
58
|
+
description: string;
|
|
59
|
+
file: string;
|
|
60
|
+
url: string;
|
|
61
|
+
linkText: string;
|
|
62
|
+
linkTextRequired: string;
|
|
63
|
+
urlRequired: string;
|
|
64
|
+
ok: string;
|
|
65
|
+
cancel: string;
|
|
66
|
+
edit: string;
|
|
67
|
+
editLink: string;
|
|
68
|
+
removeLink: string;
|
|
69
|
+
editImage: string;
|
|
70
|
+
removeImage: string;
|
|
71
|
+
/** Asked when tabular text is pasted. */
|
|
72
|
+
pasteAsTable: string;
|
|
73
|
+
textColor: string;
|
|
74
|
+
/** Edits the language of a code block. */
|
|
75
|
+
chooseLanguage: string;
|
|
76
|
+
addRowAbove: string;
|
|
77
|
+
addRowBelow: string;
|
|
78
|
+
addColumnLeft: string;
|
|
79
|
+
addColumnRight: string;
|
|
80
|
+
removeRow: string;
|
|
81
|
+
removeColumn: string;
|
|
82
|
+
alignColumnLeft: string;
|
|
83
|
+
alignColumnCenter: string;
|
|
84
|
+
alignColumnRight: string;
|
|
85
|
+
removeTable: string;
|
|
86
|
+
}
|
|
87
|
+
declare module '@liquid-js/lyr-core' {
|
|
88
|
+
interface NbTexts {
|
|
89
|
+
markdownEditor: NbMarkdownEditorTexts;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** Options of `@liquid-js/underflow`'s editor that the component's inputs don't set. */
|
|
93
|
+
export type NbMarkdownEditorOptions = Omit<EditorOptions, 'el' | 'initialValue' | 'initialEditType' | 'height' | 'minHeight' | 'previewStyle' | 'placeholder' | 'toolbarItems' | 'hideModeSwitch' | 'toolbarStyle' | 'language' | 'theme' | 'autofocus' | 'viewer' | 'readonly' | 'disabled' | 'autoDirection'>;
|
|
94
|
+
/** Groups of toolbar items: the names of the editor's items, e.g. `bold`, `format`, or items of your own. */
|
|
95
|
+
export type NbMarkdownEditorToolbar = Array<Array<string | ToolbarItemOptions>>;
|
|
96
|
+
/** What the editor is made with. */
|
|
97
|
+
interface Setup {
|
|
98
|
+
texts: NbMarkdownEditorTexts;
|
|
99
|
+
toolbarItems?: NbMarkdownEditorToolbar;
|
|
100
|
+
hideModeSwitch: boolean;
|
|
101
|
+
autoDirection: boolean;
|
|
102
|
+
options: NbMarkdownEditorOptions;
|
|
103
|
+
/** Highlights code, once it's loaded. */
|
|
104
|
+
highlighter?: HLJSApi;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A markdown editor, with a toolbar, a preview and a WYSIWYG mode:
|
|
108
|
+
*
|
|
109
|
+
* ```html
|
|
110
|
+
* <nb-markdown-editor [formControl]="text" aria-label="Description" />
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @stacked-example(Showcase, markdown/markdown-editor-showcase.component)
|
|
114
|
+
*
|
|
115
|
+
* ### Installation
|
|
116
|
+
*
|
|
117
|
+
* Install [`@liquid-js/underflow`](https://www.npmjs.com/package/@liquid-js/underflow), which is the editor, with the
|
|
118
|
+
* ProseMirror and DOMPurify packages it uses, and import `NbMarkdownEditorComponent` from
|
|
119
|
+
* `@liquid-js/lyr-extras/markdown-editor`:
|
|
120
|
+
*
|
|
121
|
+
* ```bash
|
|
122
|
+
* npm install @liquid-js/underflow prosemirror-commands prosemirror-history prosemirror-inputrules \
|
|
123
|
+
* prosemirror-keymap prosemirror-model prosemirror-state prosemirror-transform prosemirror-view dompurify
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* The Format button formats with [`remark`](https://remark.js.org), which it loads when it's first used, with
|
|
127
|
+
* `remark-gfm` and `remark-frontmatter`:
|
|
128
|
+
*
|
|
129
|
+
* ```bash
|
|
130
|
+
* npm install remark remark-gfm remark-frontmatter
|
|
131
|
+
* ```
|
|
132
|
+
*
|
|
133
|
+
* The editor loads when the first one shows; its styles come with the component. It highlights code with the
|
|
134
|
+
* highlight.js that [`nxt-highlightjs`](https://www.npmjs.com/package/nxt-highlightjs) loads, when the app sets it up
|
|
135
|
+
* as in `nb-markdown-viewer`, so install them too:
|
|
136
|
+
*
|
|
137
|
+
* ```bash
|
|
138
|
+
* npm install nxt-highlightjs highlight.js
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* ### Usage
|
|
142
|
+
*
|
|
143
|
+
* It's a form control whose value is the markdown, CommonMark with GitHub's extensions, e.g. tables and task lists.
|
|
144
|
+
* Its frame has the colours of a field and its `status`, and the text the theme's styles:
|
|
145
|
+
* @stacked-example(States, markdown/markdown-editor-status.component)
|
|
146
|
+
*
|
|
147
|
+
* The preview shows the text's straight quotes, `--`, `---` and `...` as typographic quotes, en and em dashes and
|
|
148
|
+
* ellipses, as `nb-markdown-viewer` does, while the markdown and the WYSIWYG mode keep them as written.
|
|
149
|
+
*
|
|
150
|
+
* In the markdown mode the preview is a tab, or next to the markdown with `previewStyle="vertical"`; the WYSIWYG mode
|
|
151
|
+
* edits the formatted text, and `mode` is the one that shows. The toolbar wraps onto more lines when it doesn't fit,
|
|
152
|
+
* so all of its buttons can be reached with Tab; `toolbarItems` picks them.
|
|
153
|
+
*
|
|
154
|
+
* The Format button, and Shift+Alt+F in the text, writes the markdown in one style with `nbFormatMarkdown`, which
|
|
155
|
+
* also writes typographic quotes, dashes and ellipses as plain characters; Undo brings the text back. It's `format` in
|
|
156
|
+
* `toolbarItems`.
|
|
157
|
+
*
|
|
158
|
+
* In the text, Tab indents list items and moves between table cells, so Escape and then Tab or Shift+Tab moves focus
|
|
159
|
+
* out of it, as in code editors. Name the text with `aria-label`, `aria-labelledby` for a `label`, or an `nbLabel` with
|
|
160
|
+
* `nbValidation`, which also gives it the field's status and errors, as it does an input.
|
|
161
|
+
*
|
|
162
|
+
* With `readonly` the text can be read, selected and copied, but not changed, as in a read-only field: the toolbar
|
|
163
|
+
* and the mode switch are disabled, while the Write and Preview tabs still switch. Disabled, the editor is read-only
|
|
164
|
+
* too, in the colours of a disabled field, and Tab skips it.
|
|
165
|
+
*
|
|
166
|
+
* Text that mixes right-to-left and left-to-right languages, e.g. Arabic or Hebrew quoted in English, reads right
|
|
167
|
+
* with `autoDirection`: each paragraph, heading, list, quote and table takes the direction of its own text, as
|
|
168
|
+
* `dir="auto"` does, in the preview and the WYSIWYG mode, and so does each line of the markdown. Code blocks read left
|
|
169
|
+
* to right. The markdown itself doesn't change.
|
|
170
|
+
*
|
|
171
|
+
* `options` takes the [editor's other options](https://liquid-js.github.io/underflow/docs/), e.g. plugins, widgets
|
|
172
|
+
* or `hooks.addImageBlobHook` to upload pasted images, and `editor()` is the editor, for its methods. It's made again
|
|
173
|
+
* when the options, the toolbar, the texts or `autoDirection` change, keeping the markdown.
|
|
174
|
+
*/
|
|
175
|
+
export declare class NbMarkdownEditorComponent implements ControlValueAccessor {
|
|
176
|
+
protected readonly texts: import("@angular/core").Signal<NbMarkdownEditorTexts>;
|
|
177
|
+
protected readonly iconLibraries: NbIconLibraries;
|
|
178
|
+
/** The editor's height with the toolbar, e.g. `300px` (default) or `auto`, which grows with the text. */
|
|
179
|
+
readonly height: import("@angular/core").InputSignal<string>;
|
|
180
|
+
/** `200px` by default. */
|
|
181
|
+
readonly minHeight: import("@angular/core").InputSignal<string>;
|
|
182
|
+
/** The preview in a `tab` (default), or `vertical`, next to the markdown. */
|
|
183
|
+
readonly previewStyle: import("@angular/core").InputSignal<PreviewStyle>;
|
|
184
|
+
/** `markdown` (default) or `wysiwyg`, and the mode the user picks. */
|
|
185
|
+
readonly mode: import("@angular/core").ModelSignal<EditorType>;
|
|
186
|
+
readonly placeholder: import("@angular/core").InputSignal<string>;
|
|
187
|
+
/** Field status: `basic` (default), `primary`, `info`, `success`, `warning`, `danger` or `control`. */
|
|
188
|
+
readonly status: import("@angular/core").InputSignal<string>;
|
|
189
|
+
protected readonly nbDefaults: import("@angular/core").Signal<import("@liquid-js/lyr-core").NbControlDefaults>;
|
|
190
|
+
/** Field shape: `rectangle` (default), `semi-round` or `round`, only as round as a textarea gets. */
|
|
191
|
+
readonly shapeInput: import("@angular/core").InputSignal<NbComponentShape | undefined>;
|
|
192
|
+
/** The shape in use: the input's, the app's default, or 'rectangle'. */
|
|
193
|
+
readonly shape: import("@angular/core").WritableSignal<NbComponentShape>;
|
|
194
|
+
/** Groups of toolbar items, e.g. `[['heading', 'bold', 'italic'], ['link']]`. */
|
|
195
|
+
readonly toolbarItems: import("@angular/core").InputSignal<NbMarkdownEditorToolbar | undefined>;
|
|
196
|
+
/** Hides the Markdown and WYSIWYG tabs. */
|
|
197
|
+
readonly hideModeSwitch: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
198
|
+
/**
|
|
199
|
+
* Gives each paragraph, heading, list, quote and table the direction of its own text (`dir="auto"`), for text in
|
|
200
|
+
* more than one direction; `false` by default.
|
|
201
|
+
*/
|
|
202
|
+
readonly autoDirection: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
203
|
+
/** Options of `@liquid-js/underflow`'s editor, e.g. plugins. */
|
|
204
|
+
readonly options: import("@angular/core").InputSignal<NbMarkdownEditorOptions>;
|
|
205
|
+
/** Names the text area when there's no `aria-labelledby`. */
|
|
206
|
+
readonly ariaLabel: import("@angular/core").InputSignal<string | undefined>;
|
|
207
|
+
/** The id of the element that names the text area, e.g. a `label`. */
|
|
208
|
+
readonly ariaLabelledBy: import("@angular/core").InputSignal<string | undefined>;
|
|
209
|
+
readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
210
|
+
/** Lets the user read the text, but not change it. */
|
|
211
|
+
readonly readonly: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
212
|
+
/** The editor, once it's loaded. */
|
|
213
|
+
readonly editor: import("@angular/core").WritableSignal<Editor | undefined>;
|
|
214
|
+
protected readonly validation: NbValidationDirective | null;
|
|
215
|
+
protected readonly resolvedStatus: import("@angular/core").Signal<string>;
|
|
216
|
+
protected readonly value: import("@angular/core").WritableSignal<string>;
|
|
217
|
+
protected readonly isDisabled: import("@angular/core").WritableSignal<boolean>;
|
|
218
|
+
protected readonly container: import("@angular/core").Signal<ElementRef<HTMLElement>>;
|
|
219
|
+
/** Loads highlight.js, when the app highlights code. */
|
|
220
|
+
protected readonly highlightLoader: HighlightLoader | undefined;
|
|
221
|
+
protected readonly statusStyles: import("@angular/core").Signal<{
|
|
222
|
+
'--nb-markdown-border-radius': string;
|
|
223
|
+
'--nb-markdown-field-border-radius': string;
|
|
224
|
+
'--nb-markdown-rest-background': string;
|
|
225
|
+
'--nb-markdown-border-color': string;
|
|
226
|
+
'--nb-markdown-hover-background': string;
|
|
227
|
+
'--nb-markdown-hover-border-color': string;
|
|
228
|
+
'--nb-markdown-focus-background': string;
|
|
229
|
+
'--nb-markdown-focus-border-color': string;
|
|
230
|
+
'--nb-markdown-focus-and-hover-background': string;
|
|
231
|
+
'--nb-markdown-focus-and-hover-border-color': string;
|
|
232
|
+
'--nb-markdown-disabled-background': string;
|
|
233
|
+
'--nb-markdown-disabled-border-color': string;
|
|
234
|
+
}>;
|
|
235
|
+
/** What the editor is made with; it's made again when this changes. */
|
|
236
|
+
protected readonly setup: import("@angular/core").Signal<Setup | undefined>;
|
|
237
|
+
protected creating: number;
|
|
238
|
+
protected destroyed: boolean;
|
|
239
|
+
/** Set while the form's value is written, which isn't a change to report. */
|
|
240
|
+
protected writing: boolean;
|
|
241
|
+
protected onChange: (value: string) => void;
|
|
242
|
+
/** @internal */
|
|
243
|
+
onTouched: () => void;
|
|
244
|
+
constructor();
|
|
245
|
+
writeValue(value?: string | null): void;
|
|
246
|
+
registerOnChange(fn: (value: string) => void): void;
|
|
247
|
+
registerOnTouched(fn: () => void): void;
|
|
248
|
+
setDisabledState(disabled: boolean): void;
|
|
249
|
+
/** Moves focus to the text. */
|
|
250
|
+
focus(): void;
|
|
251
|
+
protected create(setup: Setup): Promise<void>;
|
|
252
|
+
/** The toolbar's groups, with the Format button for `format`. */
|
|
253
|
+
protected toolbar(setup: Setup): NbMarkdownEditorToolbar;
|
|
254
|
+
/** Formats the markdown, with Shift+Alt+F too, unless the user can't change it. */
|
|
255
|
+
protected onKeydown(event: KeyboardEvent): void;
|
|
256
|
+
/**
|
|
257
|
+
* Writes the markdown in one style, as an edit Undo takes back, keeping the cursor's line; the text stays if the
|
|
258
|
+
* user changes it while the formatter loads.
|
|
259
|
+
*/
|
|
260
|
+
protected format(editor: Editor): Promise<void>;
|
|
261
|
+
protected changed(editor: Editor): void;
|
|
262
|
+
/**
|
|
263
|
+
* The editor's icons as the `essentials` pack has them, so an app that replaces one there replaces it here too; one
|
|
264
|
+
* the pack doesn't have keeps UnderFlow's own.
|
|
265
|
+
*/
|
|
266
|
+
protected icons(): Partial<Record<IconName, string>>;
|
|
267
|
+
/** Gives the scroll sync switch the checkmark of Lyra's toggle, which shows when it's on. */
|
|
268
|
+
protected markSwitch(): void;
|
|
269
|
+
/** Names the texts, the markdown and the WYSIWYG one, leaving out the attributes without a value. */
|
|
270
|
+
protected label(editor: Editor, attributes: Record<string, string | undefined>): void;
|
|
271
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbMarkdownEditorComponent, never>;
|
|
272
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NbMarkdownEditorComponent, "nb-markdown-editor", never, {
|
|
273
|
+
"height": {
|
|
274
|
+
"alias": "height";
|
|
275
|
+
"required": false;
|
|
276
|
+
"isSignal": true;
|
|
277
|
+
};
|
|
278
|
+
"minHeight": {
|
|
279
|
+
"alias": "minHeight";
|
|
280
|
+
"required": false;
|
|
281
|
+
"isSignal": true;
|
|
282
|
+
};
|
|
283
|
+
"previewStyle": {
|
|
284
|
+
"alias": "previewStyle";
|
|
285
|
+
"required": false;
|
|
286
|
+
"isSignal": true;
|
|
287
|
+
};
|
|
288
|
+
"mode": {
|
|
289
|
+
"alias": "mode";
|
|
290
|
+
"required": false;
|
|
291
|
+
"isSignal": true;
|
|
292
|
+
};
|
|
293
|
+
"placeholder": {
|
|
294
|
+
"alias": "placeholder";
|
|
295
|
+
"required": false;
|
|
296
|
+
"isSignal": true;
|
|
297
|
+
};
|
|
298
|
+
"status": {
|
|
299
|
+
"alias": "status";
|
|
300
|
+
"required": false;
|
|
301
|
+
"isSignal": true;
|
|
302
|
+
};
|
|
303
|
+
"shapeInput": {
|
|
304
|
+
"alias": "shape";
|
|
305
|
+
"required": false;
|
|
306
|
+
"isSignal": true;
|
|
307
|
+
};
|
|
308
|
+
"toolbarItems": {
|
|
309
|
+
"alias": "toolbarItems";
|
|
310
|
+
"required": false;
|
|
311
|
+
"isSignal": true;
|
|
312
|
+
};
|
|
313
|
+
"hideModeSwitch": {
|
|
314
|
+
"alias": "hideModeSwitch";
|
|
315
|
+
"required": false;
|
|
316
|
+
"isSignal": true;
|
|
317
|
+
};
|
|
318
|
+
"autoDirection": {
|
|
319
|
+
"alias": "autoDirection";
|
|
320
|
+
"required": false;
|
|
321
|
+
"isSignal": true;
|
|
322
|
+
};
|
|
323
|
+
"options": {
|
|
324
|
+
"alias": "options";
|
|
325
|
+
"required": false;
|
|
326
|
+
"isSignal": true;
|
|
327
|
+
};
|
|
328
|
+
"ariaLabel": {
|
|
329
|
+
"alias": "aria-label";
|
|
330
|
+
"required": false;
|
|
331
|
+
"isSignal": true;
|
|
332
|
+
};
|
|
333
|
+
"ariaLabelledBy": {
|
|
334
|
+
"alias": "aria-labelledby";
|
|
335
|
+
"required": false;
|
|
336
|
+
"isSignal": true;
|
|
337
|
+
};
|
|
338
|
+
"disabled": {
|
|
339
|
+
"alias": "disabled";
|
|
340
|
+
"required": false;
|
|
341
|
+
"isSignal": true;
|
|
342
|
+
};
|
|
343
|
+
"readonly": {
|
|
344
|
+
"alias": "readonly";
|
|
345
|
+
"required": false;
|
|
346
|
+
"isSignal": true;
|
|
347
|
+
};
|
|
348
|
+
}, {
|
|
349
|
+
"mode": "modeChange";
|
|
350
|
+
}, never, never, true, never>;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Formats markdown, CommonMark with GitHub's extensions, in one style, as `nb-markdown-editor`'s Format button does:
|
|
354
|
+
* the same document, written the same way wherever it came from. Prose is written in plain characters, quotes,
|
|
355
|
+
* dashes and ellipses as `'`, `"`, `--`, `---` and `...`, leaving how they look to the renderer, and a rule written
|
|
356
|
+
* as `<hr>` as `---`. Code stays as it is, and so does front matter, YAML between `---` lines or TOML between `+++`
|
|
357
|
+
* lines. It loads `remark`, `remark-gfm` and `remark-frontmatter` when first called.
|
|
358
|
+
*
|
|
359
|
+
* ```ts
|
|
360
|
+
* import { nbFormatMarkdown } from '@liquid-js/lyr-extras/markdown-editor';
|
|
361
|
+
*
|
|
362
|
+
* const formatted = await nbFormatMarkdown('* one\n* two\n\n__it’s bold__');
|
|
363
|
+
* // "- one\n- two\n\n**it's bold**\n"
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
export declare function nbFormatMarkdown(markdown: string): Promise<string>;
|
|
367
|
+
export type { NbMarkdownEditorTexts };
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
import { ElementRef, TemplateRef } from "@angular/core";
|
|
6
|
+
import { FootnoteDefinition, Node, Parent, Root } from "mdast";
|
|
7
|
+
import { RemarkTemplateDirective } from "ngx-remark";
|
|
8
|
+
/** A unified processor that parses markdown, with its plugins, e.g. `remark().use(remarkGfm)`. */
|
|
9
|
+
export interface NbMarkdownProcessor {
|
|
10
|
+
parse(markdown: string): Node;
|
|
11
|
+
runSync(tree: Node): Node;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Shows markdown, in the theme's text styles:
|
|
15
|
+
*
|
|
16
|
+
* ```html
|
|
17
|
+
* <nb-markdown-viewer [markdown]="text" />
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @stacked-example(Showcase, markdown/markdown-viewer-showcase.component)
|
|
21
|
+
*
|
|
22
|
+
* ### Installation
|
|
23
|
+
*
|
|
24
|
+
* It renders the markdown with Angular's templates through [`ngx-remark`](https://www.npmjs.com/package/ngx-remark),
|
|
25
|
+
* which parses it with [`remark`](https://remark.js.org), [`remark-gfm`](https://www.npmjs.com/package/remark-gfm) and
|
|
26
|
+
* [`remark-smartypants`](https://www.npmjs.com/package/remark-smartypants), and highlights code with
|
|
27
|
+
* [`nxt-highlightjs`](https://www.npmjs.com/package/nxt-highlightjs); install them and import
|
|
28
|
+
* `NbMarkdownViewerComponent` from `@liquid-js/lyr-extras/markdown-viewer`.
|
|
29
|
+
*
|
|
30
|
+
* ```sh
|
|
31
|
+
* npm install ngx-remark remark remark-gfm remark-smartypants nxt-highlightjs highlight.js
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* `remark` uses a CommonJS module, `extend`, which Angular's build warns about unless it's in
|
|
35
|
+
* `allowedCommonJsDependencies` in `angular.json`.
|
|
36
|
+
*
|
|
37
|
+
* ### Usage
|
|
38
|
+
*
|
|
39
|
+
* The markdown is CommonMark with GitHub's extensions: tables, task lists, strikethrough, autolinks and footnotes. It
|
|
40
|
+
* renders as the editor's preview shows it, on the server too, so a prerendered page has the text before scripts run.
|
|
41
|
+
* The text's straight quotes, `--`, `---` and `...` show as typographic quotes, en and em dashes and ellipses, so the
|
|
42
|
+
* markdown can keep the plain characters that the editor's Format button writes; code shows them as they are.
|
|
43
|
+
*
|
|
44
|
+
* HTML blocks in the markdown are sanitized by Angular. In a line of text, only formatting elements such as `<kbd>`,
|
|
45
|
+
* `<sup>` or `<mark>` apply, without their attributes.
|
|
46
|
+
*
|
|
47
|
+
* Each element is rendered by an Angular template, which a template of your own can replace, e.g. to render links
|
|
48
|
+
* with the router or code with a highlighter. Import `RemarkModule` from `ngx-remark`, and put the templates in the
|
|
49
|
+
* viewer, named by the [type of node](https://github.com/syntax-tree/mdast#nodes) they render; `[remarkNode]` renders
|
|
50
|
+
* the node's content in an element, or `<remark-node [remarkNode]="node" />` in a component:
|
|
51
|
+
*
|
|
52
|
+
* ```html
|
|
53
|
+
* <nb-markdown-viewer [markdown]="text">
|
|
54
|
+
* <a *remarkTemplate="'link'; let node" [routerLink]="node.url" [remarkNode]="node"></a>
|
|
55
|
+
* </nb-markdown-viewer>
|
|
56
|
+
* ```
|
|
57
|
+
* @stacked-example(Templates, markdown/markdown-viewer-templates.component)
|
|
58
|
+
*
|
|
59
|
+
* Text that mixes right-to-left and left-to-right languages, e.g. Arabic or Hebrew quoted in English, reads right
|
|
60
|
+
* with `autoDirection`, as in the editor: each block of the document, i.e. a paragraph, heading, list, quote, table,
|
|
61
|
+
* HTML block or the footnotes, takes the direction of its own text, as `dir="auto"` does. Blocks in a quote or a list
|
|
62
|
+
* share its direction, and code blocks read left to right. Templates of your own render their elements as they are, so
|
|
63
|
+
* they need `dir="auto"` themselves.
|
|
64
|
+
*
|
|
65
|
+
* `processor` replaces the parser, e.g. to add remark plugins, whose new types of nodes need templates of their own.
|
|
66
|
+
*
|
|
67
|
+
* ### Code highlighting
|
|
68
|
+
*
|
|
69
|
+
* Code blocks are highlighted in the theme's colours once the app loads highlight.js, with the languages it uses:
|
|
70
|
+
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { provideHighlightOptions } from 'nxt-highlightjs';
|
|
73
|
+
*
|
|
74
|
+
* provideHighlightOptions({
|
|
75
|
+
* coreLibraryLoader: () => import('highlight.js/lib/core').then((m) => m.default),
|
|
76
|
+
* languages: {
|
|
77
|
+
* typescript: () => import('highlight.js/lib/languages/typescript').then((m) => m.default),
|
|
78
|
+
* xml: () => import('highlight.js/lib/languages/xml').then((m) => m.default),
|
|
79
|
+
* },
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* Code in other languages, or without one, shows as plain text. The server waits for highlight.js, so a prerendered
|
|
84
|
+
* page has highlighted code. `nb-markdown-editor` highlights its preview and WYSIWYG code the same way.
|
|
85
|
+
*/
|
|
86
|
+
export declare class NbMarkdownViewerComponent {
|
|
87
|
+
/** The markdown to show. */
|
|
88
|
+
readonly markdown: import("@angular/core").InputSignal<string>;
|
|
89
|
+
/** Parses the markdown, `remark().use(remarkGfm).use(remarkSmartypants, { dashes: 'oldschool' })` by default. */
|
|
90
|
+
readonly processor: import("@angular/core").InputSignal<NbMarkdownProcessor | undefined>;
|
|
91
|
+
/**
|
|
92
|
+
* Gives each block of the document, e.g. a paragraph or a list, the direction of its own text (`dir="auto"`), for
|
|
93
|
+
* text in more than one direction; `false` by default.
|
|
94
|
+
*/
|
|
95
|
+
readonly autoDirection: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
96
|
+
/** The markdown's syntax tree, as its templates render it. */
|
|
97
|
+
readonly tree: import("@angular/core").Signal<Root>;
|
|
98
|
+
protected readonly id: string;
|
|
99
|
+
protected readonly texts: import("@angular/core").Signal<import("@liquid-js/lyr-extras/markdown-viewer").NbMarkdownViewerTexts>;
|
|
100
|
+
protected readonly htmlElements: Set<string>;
|
|
101
|
+
protected readonly blockParents: Set<string>;
|
|
102
|
+
protected readonly element: ElementRef<HTMLElement>;
|
|
103
|
+
/** Whether the app loads highlight.js for code, the same on the server and in the browser. */
|
|
104
|
+
protected readonly highlighting: boolean;
|
|
105
|
+
protected readonly defaultTemplates: import("@angular/core").Signal<readonly RemarkTemplateDirective[]>;
|
|
106
|
+
protected readonly customTemplates: import("@angular/core").Signal<readonly RemarkTemplateDirective[]>;
|
|
107
|
+
protected readonly fallback: import("@angular/core").Signal<TemplateRef<unknown>>;
|
|
108
|
+
constructor();
|
|
109
|
+
/** `auto` for a block of the document, with `autoDirection`, which a block in a quote or a list shares. */
|
|
110
|
+
protected direction(parent: Node): "auto" | null;
|
|
111
|
+
protected footnoteId(identifier: string, reference?: boolean): string;
|
|
112
|
+
/** Moves to a footnote in the page, whose address the document's base would otherwise change. */
|
|
113
|
+
protected showFootnote(event: Event, id: string): void;
|
|
114
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbMarkdownViewerComponent, never>;
|
|
115
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NbMarkdownViewerComponent, "nb-markdown-viewer", never, {
|
|
116
|
+
"markdown": {
|
|
117
|
+
"alias": "markdown";
|
|
118
|
+
"required": false;
|
|
119
|
+
"isSignal": true;
|
|
120
|
+
};
|
|
121
|
+
"processor": {
|
|
122
|
+
"alias": "processor";
|
|
123
|
+
"required": false;
|
|
124
|
+
"isSignal": true;
|
|
125
|
+
};
|
|
126
|
+
"autoDirection": {
|
|
127
|
+
"alias": "autoDirection";
|
|
128
|
+
"required": false;
|
|
129
|
+
"isSignal": true;
|
|
130
|
+
};
|
|
131
|
+
}, {}, ["customTemplates"], never, true, never>;
|
|
132
|
+
}
|
|
133
|
+
/** An inline HTML element of the markdown, e.g. `<kbd>Ctrl</kbd>`, with the markdown between its tags. */
|
|
134
|
+
interface NbMarkdownHtmlElement extends Parent {
|
|
135
|
+
type: 'nbHtmlElement';
|
|
136
|
+
tagName: string;
|
|
137
|
+
}
|
|
138
|
+
/** A link from a footnote back to where the text refers to it, at the end of the footnote. */
|
|
139
|
+
interface NbMarkdownFootnoteBack extends Node {
|
|
140
|
+
type: 'nbFootnoteBack';
|
|
141
|
+
identifier: string;
|
|
142
|
+
}
|
|
143
|
+
/** The footnotes, at the end of the document. */
|
|
144
|
+
interface NbMarkdownFootnotes extends Parent {
|
|
145
|
+
type: 'nbFootnotes';
|
|
146
|
+
children: FootnoteDefinition[];
|
|
147
|
+
}
|
|
148
|
+
declare module 'mdast' {
|
|
149
|
+
interface PhrasingContentMap {
|
|
150
|
+
nbHtmlElement: NbMarkdownHtmlElement;
|
|
151
|
+
nbFootnoteBack: NbMarkdownFootnoteBack;
|
|
152
|
+
}
|
|
153
|
+
interface RootContentMap {
|
|
154
|
+
nbHtmlElement: NbMarkdownHtmlElement;
|
|
155
|
+
nbFootnoteBack: NbMarkdownFootnoteBack;
|
|
156
|
+
nbFootnotes: NbMarkdownFootnotes;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The texts of the markdown viewer. `provideNbTexts({ markdownViewer: { ... } })` changes them, and they're translated
|
|
161
|
+
* with Angular's i18n, as `$localize` messages with ids like `@@nb.markdownViewer.footnotes`.
|
|
162
|
+
*/
|
|
163
|
+
interface NbMarkdownViewerTexts {
|
|
164
|
+
/** Names the footnotes at the end of the text. */
|
|
165
|
+
footnotes: string;
|
|
166
|
+
/** Names the link at the end of a footnote back to where the text refers to it. */
|
|
167
|
+
backToText: string;
|
|
168
|
+
}
|
|
169
|
+
declare module '@liquid-js/lyr-core' {
|
|
170
|
+
interface NbTexts {
|
|
171
|
+
markdownViewer: NbMarkdownViewerTexts;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
export type { NbMarkdownFootnoteBack, NbMarkdownFootnotes, NbMarkdownHtmlElement, NbMarkdownViewerTexts };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
import { ControlValueAccessor, ValidationErrors, Validator } from "@angular/forms";
|
|
5
|
+
import { Mask, MaskInput, MaskInputOptions, MaskType, MaskaDetail } from "maska";
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
/** The form value of a masked field: the characters typed (`unmasked`, default), or the text as shown (`masked`). */
|
|
8
|
+
export type NbMaskValue = 'unmasked' | 'masked';
|
|
9
|
+
/** The error kind of a value that doesn't fill the mask. */
|
|
10
|
+
export declare const NB_MASK_ERROR: "nbMask";
|
|
11
|
+
/** The `nbMask` error, as Angular gives parse errors: its kind and its message. */
|
|
12
|
+
export interface NbMaskError {
|
|
13
|
+
kind: typeof NB_MASK_ERROR;
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
16
|
+
/** maska's options besides the mask: `tokens`, `eager`, `reversed`, `number`, `preProcess` and `postProcess`. */
|
|
17
|
+
export type NbMaskOptions = Omit<MaskInputOptions, 'mask' | 'onMaska'>;
|
|
18
|
+
/**
|
|
19
|
+
* Formats what the user types in a field with a mask, e.g. a phone number or a card number:
|
|
20
|
+
*
|
|
21
|
+
* ```html
|
|
22
|
+
* <input nbInput type="tel" [nbMask]="'(###) ###-####'" formControlName="phone" />
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @stacked-example(Showcase, mask/mask-showcase.component)
|
|
26
|
+
*
|
|
27
|
+
* ### Installation
|
|
28
|
+
*
|
|
29
|
+
* It formats with [`maska`](https://www.npmjs.com/package/maska); install it and import `NbMaskDirective` from
|
|
30
|
+
* `@liquid-js/lyr-extras/mask`.
|
|
31
|
+
*
|
|
32
|
+
* ```sh
|
|
33
|
+
* npm install maska
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* ### Usage
|
|
37
|
+
*
|
|
38
|
+
* In the mask, `#` is a digit, `@` a letter and `*` either; other characters are shown as they are. A list of masks
|
|
39
|
+
* picks the one that fits the length of what's typed, e.g. `['#### ####', '#### #### ####']`, and a function gives
|
|
40
|
+
* the mask for what's typed. `nbMaskOptions` takes maska's other options, e.g. `eager` to show the mask's next
|
|
41
|
+
* characters before they're typed, `tokens` of your own, or `number` for numbers in the app's format.
|
|
42
|
+
*
|
|
43
|
+
* The form value is what the user typed, without the mask's characters, e.g. `2015550123`, or with
|
|
44
|
+
* `nbMaskValue="masked"`, the text as shown, `(201) 555-0123`. While the text doesn't fill the mask, the value stays
|
|
45
|
+
* the last complete one, or empty, and the field has the `nbMask` parse error, `{ kind, message }`, as Angular's
|
|
46
|
+
* controls report text they can't parse; an empty field passes. It works with `formControl`, `formControlName`,
|
|
47
|
+
* `ngModel` and signal forms' `[formField]`.
|
|
48
|
+
* @stacked-example(Validation, mask/mask-validation.component)
|
|
49
|
+
*
|
|
50
|
+
* It works on text, search, URL, phone and password inputs.
|
|
51
|
+
*/
|
|
52
|
+
export declare class NbMaskDirective implements ControlValueAccessor, Validator {
|
|
53
|
+
protected readonly texts: import("@angular/core").Signal<import("@liquid-js/lyr-extras/mask").NbMaskTexts>;
|
|
54
|
+
/** The message of an error, as `nb-validation-errors` shows it. */
|
|
55
|
+
protected readonly message: (error: import("@liquid-js/lyr-core").NbValidationError) => string;
|
|
56
|
+
protected readonly element: HTMLInputElement;
|
|
57
|
+
/** The mask, e.g. `(###) ###-####`, a list of masks, or a function that gives the mask for what's typed. */
|
|
58
|
+
readonly mask: import("@angular/core").InputSignal<MaskType>;
|
|
59
|
+
/** maska's other options, e.g. `{ eager: true }`. */
|
|
60
|
+
readonly options: import("@angular/core").InputSignal<NbMaskOptions>;
|
|
61
|
+
/** The form value: `unmasked` (default), what was typed, or `masked`, the text as shown. */
|
|
62
|
+
readonly valueType: import("@angular/core").InputSignal<NbMaskValue>;
|
|
63
|
+
/** Whether the text fills the mask. */
|
|
64
|
+
readonly completed: import("@angular/core").WritableSignal<boolean>;
|
|
65
|
+
/** Whether the text doesn't fill the mask, which the form gets as a parse error. */
|
|
66
|
+
protected readonly parseError: import("@angular/core").WritableSignal<boolean>;
|
|
67
|
+
/** Formats values the way the field does. */
|
|
68
|
+
protected readonly formatter: import("@angular/core").Signal<{
|
|
69
|
+
mask: Mask;
|
|
70
|
+
masked: (value: string) => string;
|
|
71
|
+
unmasked: (value: string) => string;
|
|
72
|
+
completed: (value: string) => boolean;
|
|
73
|
+
}>;
|
|
74
|
+
protected maskInput?: MaskInput;
|
|
75
|
+
/** The value last given to the form. */
|
|
76
|
+
protected value: string;
|
|
77
|
+
protected onChange: (value: string) => void;
|
|
78
|
+
/** @internal */
|
|
79
|
+
onTouched: () => void;
|
|
80
|
+
protected onValidatorChange: () => void;
|
|
81
|
+
constructor();
|
|
82
|
+
writeValue(value?: string | number | null): void;
|
|
83
|
+
registerOnChange(fn: (value: string) => void): void;
|
|
84
|
+
registerOnTouched(fn: () => void): void;
|
|
85
|
+
registerOnValidatorChange(fn: () => void): void;
|
|
86
|
+
setDisabledState(disabled: boolean): void;
|
|
87
|
+
/** The parse error of text that doesn't fill the mask. */
|
|
88
|
+
validate(): ValidationErrors | null;
|
|
89
|
+
/** Shows a form value in the field, formatted. */
|
|
90
|
+
protected show(value: string): void;
|
|
91
|
+
protected changed(detail: MaskaDetail): void;
|
|
92
|
+
/**
|
|
93
|
+
* Gives the form the value of the text in the field, when it's another; while the text doesn't fill the mask, the
|
|
94
|
+
* value stays and the field has the parse error.
|
|
95
|
+
*/
|
|
96
|
+
protected take(masked: string): void;
|
|
97
|
+
protected setParseError(parseError: boolean): void;
|
|
98
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NbMaskDirective, never>;
|
|
99
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<NbMaskDirective, "input[nbMask]", ["nbMask"], {
|
|
100
|
+
"mask": {
|
|
101
|
+
"alias": "nbMask";
|
|
102
|
+
"required": true;
|
|
103
|
+
"isSignal": true;
|
|
104
|
+
};
|
|
105
|
+
"options": {
|
|
106
|
+
"alias": "nbMaskOptions";
|
|
107
|
+
"required": false;
|
|
108
|
+
"isSignal": true;
|
|
109
|
+
};
|
|
110
|
+
"valueType": {
|
|
111
|
+
"alias": "nbMaskValue";
|
|
112
|
+
"required": false;
|
|
113
|
+
"isSignal": true;
|
|
114
|
+
};
|
|
115
|
+
}, {}, never, never, true, never>;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The texts of masked fields. `provideNbTexts({ mask: { ... } })` changes them, and they're translated with Angular's
|
|
119
|
+
* i18n, as `$localize` messages with ids like `@@nb.mask.incomplete`.
|
|
120
|
+
*/
|
|
121
|
+
interface NbMaskTexts {
|
|
122
|
+
/** The message of the `nbMask` error for a value that doesn't fill the mask. */
|
|
123
|
+
incomplete: string;
|
|
124
|
+
}
|
|
125
|
+
declare module '@liquid-js/lyr-core' {
|
|
126
|
+
interface NbTexts {
|
|
127
|
+
mask: NbMaskTexts;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export type { NbMaskTexts };
|