@rcarls/rc-markdown-editor 0.3.2 → 0.4.1
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/CHANGELOG.md +99 -0
- package/dist/custom-elements.json +214 -14
- package/dist/{rc-editor-toolbar-CcTLdYIt.js → rc-editor-toolbar-QnCEnJ2R.js} +1279 -1115
- package/dist/{rc-editor-toolbar-CcTLdYIt.js.map → rc-editor-toolbar-QnCEnJ2R.js.map} +1 -1
- package/dist/rc-markdown-editor-define.js +1 -1
- package/dist/rc-markdown-editor.js +1 -1
- package/dist/types/packages/rc-markdown-editor/src/rc-editor-toolbar.d.ts +37 -6
- package/dist/types/packages/rc-markdown-editor/src/rc-markdown-editor.d.ts +40 -6
- package/dist/types/packages/rc-markdown-editor/src/rc-markdown-editor.test.d.ts +0 -0
- package/package.json +6 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "@rcarls/rc-textarea/define";
|
|
2
|
-
import { R as o, a as t } from "./rc-editor-toolbar-
|
|
2
|
+
import { R as o, a as t } from "./rc-editor-toolbar-QnCEnJ2R.js";
|
|
3
3
|
customElements.get("rc-editor-toolbar") ?? customElements.define("rc-editor-toolbar", o);
|
|
4
4
|
customElements.get("rc-markdown-editor") ?? customElements.define("rc-markdown-editor", t);
|
|
5
5
|
//# sourceMappingURL=rc-markdown-editor-define.js.map
|
|
@@ -1,28 +1,58 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
1
|
+
import { LitElement, SVGTemplateResult, TemplateResult } from 'lit';
|
|
2
2
|
import { EditorToolbarAction, EditorToolbarActionDetail, HeadingLevel } from './types.ts';
|
|
3
3
|
/**
|
|
4
|
-
* Formatting toolbar for `<rc-markdown-editor>`. Renders
|
|
5
|
-
*
|
|
4
|
+
* Formatting toolbar for `<rc-markdown-editor>`. Renders themed `rc-button`,
|
|
5
|
+
* `rc-select`, and `rc-toolbar` controls into its own light DOM so the parent
|
|
6
|
+
* editor can provide their shared appearance.
|
|
6
7
|
*
|
|
7
8
|
* Active-format properties are set by the parent editor and reflected as
|
|
8
9
|
* `aria-pressed` on the corresponding buttons. Heading level is shown via an
|
|
9
10
|
* `<rc-select>`. Code-block language is shown via a `<input>` when active.
|
|
10
11
|
*
|
|
12
|
+
* @see {@link https://richardcarls.github.io/rc-webcomponents/components/rc-markdown-editor rc-markdown-editor docs}
|
|
13
|
+
* @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/ WAI-ARIA Toolbar pattern}
|
|
14
|
+
*
|
|
11
15
|
* @fires rc-toolbar-action - When a formatting button or select is activated.
|
|
16
|
+
*
|
|
17
|
+
* @attr label - Accessible label applied to the `rc-toolbar` container.
|
|
18
|
+
* @attr active-bold - Reflects Bold as active at the cursor.
|
|
19
|
+
* @attr active-italic - Reflects Italic as active at the cursor.
|
|
20
|
+
* @attr active-underline - Reflects Underline as active at the cursor.
|
|
21
|
+
* @attr active-strikethrough - Reflects Strikethrough as active at the cursor.
|
|
22
|
+
* @attr active-code - Reflects inline Code as active at the cursor.
|
|
23
|
+
* @attr active-link - Reflects Link as active at the cursor.
|
|
24
|
+
* @attr active-heading - Heading level active at the cursor, or absent for paragraph text.
|
|
25
|
+
* @attr active-blockquote - Reflects Blockquote as active at the cursor.
|
|
26
|
+
* @attr active-bullet-list - Reflects Bullet List as active at the cursor.
|
|
27
|
+
* @attr active-ordered-list - Reflects Ordered List as active at the cursor.
|
|
28
|
+
* @attr active-code-block - Reflects Code Block as active at the cursor.
|
|
29
|
+
* @attr code-language - Language of the code block at the cursor; absent when not in a code block.
|
|
30
|
+
* @attr source-mode - Whether the parent editor is in source mode.
|
|
12
31
|
*/
|
|
13
32
|
export declare class RcEditorToolbar extends LitElement {
|
|
14
|
-
/**
|
|
33
|
+
/** Accessible label applied to the `rc-toolbar` container. */
|
|
15
34
|
label: string;
|
|
35
|
+
/** Whether Bold formatting is active at the cursor. */
|
|
16
36
|
activeBold: boolean;
|
|
37
|
+
/** Whether Italic formatting is active at the cursor. */
|
|
17
38
|
activeItalic: boolean;
|
|
39
|
+
/** Whether Underline formatting is active at the cursor. */
|
|
18
40
|
activeUnderline: boolean;
|
|
41
|
+
/** Whether Strikethrough formatting is active at the cursor. */
|
|
19
42
|
activeStrikethrough: boolean;
|
|
43
|
+
/** Whether inline Code formatting is active at the cursor. */
|
|
20
44
|
activeCode: boolean;
|
|
45
|
+
/** Whether the cursor is inside a Link. */
|
|
21
46
|
activeLink: boolean;
|
|
47
|
+
/** Heading level active at the cursor, or `null` for paragraph text. */
|
|
22
48
|
activeHeading: HeadingLevel | null;
|
|
49
|
+
/** Whether the cursor is inside a Blockquote. */
|
|
23
50
|
activeBlockquote: boolean;
|
|
51
|
+
/** Whether the cursor is inside a Bullet List. */
|
|
24
52
|
activeBulletList: boolean;
|
|
53
|
+
/** Whether the cursor is inside an Ordered List. */
|
|
25
54
|
activeOrderedList: boolean;
|
|
55
|
+
/** Whether the cursor is inside a Code Block. */
|
|
26
56
|
activeCodeBlock: boolean;
|
|
27
57
|
/**
|
|
28
58
|
* Language of the code block at the cursor. `null` means not in a code block
|
|
@@ -32,7 +62,7 @@ export declare class RcEditorToolbar extends LitElement {
|
|
|
32
62
|
/** Whether the editor is in source mode. */
|
|
33
63
|
sourceMode: boolean;
|
|
34
64
|
protected _langInputValue: string;
|
|
35
|
-
createRenderRoot():
|
|
65
|
+
createRenderRoot(): HTMLElement;
|
|
36
66
|
updated(changed: Map<string, unknown>): void;
|
|
37
67
|
protected _dispatch(action: EditorToolbarAction, extra?: Partial<EditorToolbarActionDetail>): void;
|
|
38
68
|
protected _onClick: (e: MouseEvent) => void;
|
|
@@ -40,5 +70,6 @@ export declare class RcEditorToolbar extends LitElement {
|
|
|
40
70
|
protected _onLangInput: (e: Event) => void;
|
|
41
71
|
protected _onLangCommit: () => void;
|
|
42
72
|
protected _onLangKeyDown: (e: KeyboardEvent) => void;
|
|
43
|
-
|
|
73
|
+
protected _renderActionButton(action: EditorToolbarAction, label: string, title: string, active: boolean, icon: SVGTemplateResult): TemplateResult;
|
|
74
|
+
render(): TemplateResult<1>;
|
|
44
75
|
}
|
|
@@ -23,29 +23,62 @@ import { ActiveFormats, EditorMode, EditorToolbarAction, EditorToolbarActionDeta
|
|
|
23
23
|
*
|
|
24
24
|
* @see {@link https://richardcarls.github.io/rc-webcomponents/components/rc-markdown-editor rc-markdown-editor docs}
|
|
25
25
|
*
|
|
26
|
-
* @
|
|
27
|
-
*
|
|
26
|
+
* @slot - Accepts a native `<textarea>` element (and optional `<label>`) for form wiring.
|
|
27
|
+
*
|
|
28
|
+
* @fires rc-change - Value changed. Detail: `{ value: string }`.
|
|
29
|
+
* @fires rc-mode-change - Mode toggled. Detail: `{ mode: EditorMode }`.
|
|
28
30
|
* @fires rc-formatting-change - Active formats at cursor changed. Detail: `ActiveFormats`.
|
|
29
31
|
*
|
|
30
|
-
* @
|
|
31
|
-
* @
|
|
32
|
-
*
|
|
33
|
-
* @attr
|
|
32
|
+
* @csspart toolbar - The `<rc-editor-toolbar>` element.
|
|
33
|
+
* @csspart rich-view - The contenteditable rich-text view.
|
|
34
|
+
*
|
|
35
|
+
* @attr toolbar - Show the formatting toolbar.
|
|
36
|
+
* @attr source-mode - Controlled: show the markdown source editor.
|
|
37
|
+
* @attr default-source-mode - Uncontrolled initial source-mode state.
|
|
38
|
+
* @attr read-only - Make the editor read-only.
|
|
39
|
+
* @attr value - Current Markdown value.
|
|
40
|
+
* @attr default-value - Initial uncontrolled Markdown value.
|
|
41
|
+
*
|
|
42
|
+
* @cssprop [--rme-font-family=inherit] - Font family of the rich-text view
|
|
43
|
+
* @cssprop [--rme-font-size=inherit] - Font size of the rich-text view
|
|
44
|
+
* @cssprop [--rme-line-height=1.6] - Line height of the rich-text view
|
|
45
|
+
* @cssprop [--rme-padding=0.75em 1em] - Padding inside the rich-text view
|
|
46
|
+
* @cssprop [--rme-background=Canvas] - Background color of the rich-text view
|
|
47
|
+
* @cssprop [--rme-color=CanvasText] - Text color of the rich-text view
|
|
48
|
+
* @cssprop [--rme-border=1px solid ButtonBorder] - Border around the rich-text view
|
|
49
|
+
* @cssprop [--rme-border-radius=0 0 4px 4px] - Border radius of the rich-text view
|
|
50
|
+
* @cssprop [--rme-focus-outline=2px solid Highlight] - Focus ring outline on the rich-text view
|
|
51
|
+
* @cssprop [--rme-src-font-family='Cascadia Code', 'Fira Code', ui-monospace, monospace] - Font family of the source editor
|
|
52
|
+
* @cssprop [--rme-toolbar-gap=1px] - Gap between toolbar buttons
|
|
53
|
+
* @cssprop [--rme-toolbar-button-size=2rem] - Minimum inline and block size of toolbar buttons
|
|
54
|
+
* @cssprop [--rme-src-heading-color=light-dark(#1d6fc4, #82b4f5)] - Source-mode heading token color
|
|
55
|
+
* @cssprop [--rme-src-code-color=light-dark(#c94a1a, #f09060)] - Source-mode inline/fenced code token color
|
|
56
|
+
* @cssprop [--rme-src-link-color=light-dark(#0370b0, #60b8e8)] - Source-mode link token color
|
|
57
|
+
* @cssprop [--rme-src-blockquote-color=light-dark(#2d7a42, #70b880)] - Source-mode blockquote token color
|
|
58
|
+
* @cssprop [--rme-src-list-color=light-dark(#7a5c0a, #d4ac48)] - Source-mode list marker token color
|
|
59
|
+
* @cssprop [--rme-src-dim-color=GrayText] - Source-mode strikethrough token color
|
|
34
60
|
*/
|
|
35
61
|
export declare class RcMarkdownEditor extends LitElement {
|
|
36
62
|
static styles: import('lit').CSSResult;
|
|
37
63
|
private _value;
|
|
38
64
|
private _defaultValue;
|
|
39
65
|
private _valueInitialized;
|
|
66
|
+
/** Initial uncontrolled Markdown value. */
|
|
40
67
|
get defaultValue(): string;
|
|
41
68
|
set defaultValue(v: string);
|
|
69
|
+
/** Current Markdown value. Host writes are silent. */
|
|
42
70
|
get value(): string;
|
|
43
71
|
set value(v: string);
|
|
44
72
|
private _sourceMode;
|
|
45
73
|
private _defaultSourceMode;
|
|
46
74
|
private _sourceModeInitialized;
|
|
75
|
+
/** Initial uncontrolled source-mode state. */
|
|
47
76
|
get defaultSourceMode(): boolean;
|
|
48
77
|
set defaultSourceMode(v: boolean);
|
|
78
|
+
/**
|
|
79
|
+
* Controlled: show the markdown source editor instead of the rich view.
|
|
80
|
+
* Host writes are silent; toolbar/keyboard toggles dispatch `rc-mode-change`.
|
|
81
|
+
*/
|
|
49
82
|
get sourceMode(): boolean;
|
|
50
83
|
set sourceMode(v: boolean);
|
|
51
84
|
/** Show the formatting toolbar. */
|
|
@@ -63,6 +96,7 @@ export declare class RcMarkdownEditor extends LitElement {
|
|
|
63
96
|
protected _ignoreRichMutations: boolean;
|
|
64
97
|
protected _richViewRendered: boolean;
|
|
65
98
|
protected _cachedTree: ReturnType<typeof fromMarkdown> | null;
|
|
99
|
+
protected _renderedMode: EditorMode | null;
|
|
66
100
|
protected _firstUpdatedDone: boolean;
|
|
67
101
|
protected _$linkPopover?: HTMLDivElement;
|
|
68
102
|
protected _$linkPopoverInput?: HTMLInputElement;
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.4.1",
|
|
7
7
|
"description": "Rich/source Markdown editor with a formatting toolbar, backed by rc-textarea.",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -45,8 +45,10 @@
|
|
|
45
45
|
"test:browser:firefox": "vitest --run --project=firefox"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@rcarls/rc-
|
|
49
|
-
"@rcarls/rc-
|
|
48
|
+
"@rcarls/rc-button": "0.4.1",
|
|
49
|
+
"@rcarls/rc-select": "0.4.1",
|
|
50
|
+
"@rcarls/rc-textarea": "0.4.1",
|
|
51
|
+
"@rcarls/rc-toolbar": "0.4.1"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
52
54
|
"@custom-elements-manifest/analyzer": "0.11.0",
|
|
@@ -70,4 +72,4 @@
|
|
|
70
72
|
"peerDependencies": {
|
|
71
73
|
"lit": "^3.0.0"
|
|
72
74
|
}
|
|
73
|
-
}
|
|
75
|
+
}
|