@rcarls/rc-markdown-editor 0.6.0 → 0.7.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.
@@ -1,5 +1,5 @@
1
1
  import "@rcarls/rc-textarea/define";
2
- import { R as o, a as t } from "./rc-editor-toolbar-QnCEnJ2R.js";
2
+ import { R as o, a as t } from "./rc-editor-toolbar-DZHqoNun.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 +1 @@
1
- {"version":3,"file":"rc-markdown-editor-define.js","sources":["../src/define.ts"],"sourcesContent":["import '@rcarls/rc-textarea/define';\n\nimport { RcEditorToolbar } from './rc-editor-toolbar.js';\nimport { RcMarkdownEditor } from './rc-markdown-editor.js';\n\ncustomElements.get('rc-editor-toolbar') ??\n customElements.define('rc-editor-toolbar', RcEditorToolbar);\ncustomElements.get('rc-markdown-editor') ??\n customElements.define('rc-markdown-editor', RcMarkdownEditor);\n"],"names":["RcEditorToolbar","RcMarkdownEditor"],"mappings":";;AAKA,eAAe,IAAI,mBAAmB,KACpC,eAAe,OAAO,qBAAqBA,CAAe;AAC5D,eAAe,IAAI,oBAAoB,KACrC,eAAe,OAAO,sBAAsBC,CAAgB;"}
1
+ {"version":3,"file":"rc-markdown-editor-define.js","sources":["../src/define.ts"],"sourcesContent":["import '@rcarls/rc-textarea/define';\nimport { RcEditorToolbar } from './rc-editor-toolbar.js';\nimport { RcMarkdownEditor } from './rc-markdown-editor.js';\n\ncustomElements.get('rc-editor-toolbar') ??\n customElements.define('rc-editor-toolbar', RcEditorToolbar);\n\ncustomElements.get('rc-markdown-editor') ??\n customElements.define('rc-markdown-editor', RcMarkdownEditor);\n"],"names":["RcEditorToolbar","RcMarkdownEditor"],"mappings":";;AAIA,eAAe,IAAI,mBAAmB,KACpC,eAAe,OAAO,qBAAqBA,CAAe;AAE5D,eAAe,IAAI,oBAAoB,KACrC,eAAe,OAAO,sBAAsBC,CAAgB;"}
@@ -1,4 +1,4 @@
1
- import { R as a, a as d } from "./rc-editor-toolbar-QnCEnJ2R.js";
1
+ import { R as a, a as d } from "./rc-editor-toolbar-DZHqoNun.js";
2
2
  export {
3
3
  a as RcEditorToolbar,
4
4
  d as RcMarkdownEditor
@@ -5,9 +5,9 @@ import { ActiveFormats } from './types.js';
5
5
  * `selectionStart`. Returns the updated string, or `null` if the cursor is not
6
6
  * inside a fenced code block.
7
7
  *
8
- * @param value - Full source editor value.
9
- * @param selectionStart - Cursor offset used to locate the containing fence.
10
- * @param language - Language string to write (empty string removes the token).
8
+ * @param value - full source editor value
9
+ * @param selectionStart - cursor offset used to locate the containing fence
10
+ * @param language - language string to write (empty string removes the token)
11
11
  */
12
12
  export declare function setCodeBlockLanguage(value: string, selectionStart: number, language: string): string | null;
13
13
  /**
@@ -8,15 +8,15 @@
8
8
  * 1em so they scale with the button's font-size.
9
9
  */
10
10
  export declare const icons: {
11
- bold: import('lit').TemplateResult<2>;
12
- italic: import('lit').TemplateResult<2>;
13
- underline: import('lit').TemplateResult<2>;
14
- strikethrough: import('lit').TemplateResult<2>;
15
- code: import('lit').TemplateResult<2>;
16
- link: import('lit').TemplateResult<2>;
17
- blockquote: import('lit').TemplateResult<2>;
18
- bulletList: import('lit').TemplateResult<2>;
19
- orderedList: import('lit').TemplateResult<2>;
20
- codeBlock: import('lit').TemplateResult<2>;
21
- source: import('lit').TemplateResult<2>;
11
+ bold: import('lit-html').TemplateResult<2>;
12
+ italic: import('lit-html').TemplateResult<2>;
13
+ underline: import('lit-html').TemplateResult<2>;
14
+ strikethrough: import('lit-html').TemplateResult<2>;
15
+ code: import('lit-html').TemplateResult<2>;
16
+ link: import('lit-html').TemplateResult<2>;
17
+ blockquote: import('lit-html').TemplateResult<2>;
18
+ bulletList: import('lit-html').TemplateResult<2>;
19
+ orderedList: import('lit-html').TemplateResult<2>;
20
+ codeBlock: import('lit-html').TemplateResult<2>;
21
+ source: import('lit-html').TemplateResult<2>;
22
22
  };
@@ -1,20 +1,57 @@
1
1
  import { LitElement, SVGTemplateResult, TemplateResult } from 'lit';
2
2
  import { EditorToolbarAction, EditorToolbarActionDetail, HeadingLevel } from './types.js';
3
+ /** Built-in text of `rc-editor-toolbar`. */
4
+ export interface RCEditorToolbarMessages {
5
+ /** Accessible name of the toolbar. */
6
+ toolbar: string;
7
+ bold: string;
8
+ italic: string;
9
+ underline: string;
10
+ strikethrough: string;
11
+ inlineCode: string;
12
+ link: string;
13
+ headingLevel: string;
14
+ paragraph: string;
15
+ heading: (level: number, locale?: string) => string;
16
+ blockquote: string;
17
+ bulletList: string;
18
+ orderedList: string;
19
+ codeBlock: string;
20
+ codeBlockLanguage: string;
21
+ /** Placeholder of the code block language input. */
22
+ languagePlaceholder: string;
23
+ /** Tooltip of the code block language input. */
24
+ languageHint: string;
25
+ sourceMode: string;
26
+ /** Tooltip of the source mode button, before its shortcut. */
27
+ sourceModeHint: string;
28
+ /** A tooltip with its keyboard shortcut, such as `Bold (Ctrl+B)`. */
29
+ shortcut: (label: string, keys: string) => string;
30
+ }
31
+ export declare const DEFAULT_EDITOR_TOOLBAR_MESSAGES: Readonly<RCEditorToolbarMessages>;
32
+ declare module '@rcarls/rc-common' {
33
+ interface RcMessageCatalog {
34
+ 'rc-editor-toolbar': RCEditorToolbarMessages;
35
+ }
36
+ }
3
37
  /**
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.
38
+ * Formatting toolbar for `<rc-markdown-editor>`. Renders themed `rc-button` and
39
+ * `rc-toolbar` controls into its own light DOM so the parent editor can provide
40
+ * their shared appearance.
7
41
  *
8
42
  * Active-format properties are set by the parent editor and reflected as
9
- * `aria-pressed` on the corresponding buttons. Heading level is shown via an
10
- * `<rc-select>`. Code-block language is shown via a `<input>` when active.
43
+ * `aria-pressed` on the corresponding buttons. Heading level is shown via a
44
+ * native `<select>`. Code-block language is shown via a `<input>` when active.
11
45
  *
12
46
  * @see {@link https://richardcarls.github.io/rc-webcomponents/components/rc-markdown-editor rc-markdown-editor docs}
13
47
  * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/ WAI-ARIA Toolbar pattern}
14
48
  *
49
+ * Built-in text follows the element's own `lang`, else `<html lang>`: per
50
+ * element through `messages`, or for every toolbar through
51
+ * `registerMessages()` from `@rcarls/rc-common` under `rc-editor-toolbar`.
52
+ *
15
53
  * @fires rc-toolbar-action - When a formatting button or select is activated.
16
54
  *
17
- * @attr label - Accessible label applied to the `rc-toolbar` container.
18
55
  * @attr active-bold - Reflects Bold as active at the cursor.
19
56
  * @attr active-italic - Reflects Italic as active at the cursor.
20
57
  * @attr active-underline - Reflects Underline as active at the cursor.
@@ -30,8 +67,9 @@ import { EditorToolbarAction, EditorToolbarActionDetail, HeadingLevel } from './
30
67
  * @attr source-mode - Whether the parent editor is in source mode.
31
68
  */
32
69
  export declare class RcEditorToolbar extends LitElement {
33
- /** Accessible label applied to the `rc-toolbar` container. */
34
- label: string;
70
+ /** Built-in text overrides; unset keys fall back to registered text, then English. */
71
+ messages: Partial<RCEditorToolbarMessages> | undefined;
72
+ private readonly _messages;
35
73
  /** Whether Bold formatting is active at the cursor. */
36
74
  activeBold: boolean;
37
75
  /** Whether Italic formatting is active at the cursor. */
@@ -1,7 +1,29 @@
1
1
  import { LitElement } from 'lit';
2
- import { fromMarkdown } from 'mdast-util-from-markdown';
3
2
  import { RCTextarea, RCTextareaPluginAPI } from '@rcarls/rc-textarea';
4
3
  import { ActiveFormats, EditorMode, EditorToolbarAction, EditorToolbarActionDetail, HeadingLevel } from './types.js';
4
+ interface MarkdownTree {
5
+ type: string;
6
+ }
7
+ /** Built-in text of `rc-markdown-editor`, apart from its toolbar's. */
8
+ export interface RCMarkdownEditorMessages {
9
+ /** Accessible name of the source-mode textarea. */
10
+ source: string;
11
+ /** Accessible name of the link popover. */
12
+ linkPopover: string;
13
+ /** Accessible name of the link URL input. */
14
+ url: string;
15
+ applyLink: string;
16
+ openLink: string;
17
+ removeLink: string;
18
+ /** A tooltip with its keyboard shortcut, such as `Apply (Enter)`. */
19
+ shortcut: (label: string, keys: string) => string;
20
+ }
21
+ export declare const DEFAULT_MARKDOWN_EDITOR_MESSAGES: Readonly<RCMarkdownEditorMessages>;
22
+ declare module '@rcarls/rc-common' {
23
+ interface RcMessageCatalog {
24
+ 'rc-markdown-editor': RCMarkdownEditorMessages;
25
+ }
26
+ }
5
27
  /**
6
28
  * Rich/source Markdown editor with a formatting toolbar, backed by rc-textarea.
7
29
  *
@@ -21,6 +43,12 @@ import { ActiveFormats, EditorMode, EditorToolbarAction, EditorToolbarActionDeta
21
43
  * </rc-markdown-editor>
22
44
  * ```
23
45
  *
46
+ * Built-in text follows the element's own `lang`, else `<html lang>`: per
47
+ * element through `messages`, or for every editor through
48
+ * `registerMessages()` from `@rcarls/rc-common` under `rc-markdown-editor`
49
+ * and, for the toolbar, `rc-editor-toolbar`. The toolbar takes the editor's
50
+ * `lang`.
51
+ *
24
52
  * @see {@link https://richardcarls.github.io/rc-webcomponents/components/rc-markdown-editor rc-markdown-editor docs}
25
53
  *
26
54
  * @slot - Accepts a native `<textarea>` element (and optional `<label>`) for form wiring.
@@ -39,27 +67,58 @@ import { ActiveFormats, EditorMode, EditorToolbarAction, EditorToolbarActionDeta
39
67
  * @attr value - Current Markdown value.
40
68
  * @attr default-value - Initial uncontrolled Markdown value.
41
69
  *
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
70
+ * @cssprop [--rc-markdown-editor-font-family=inherit] - Font family of the rich-text view
71
+ * @cssprop [--rc-markdown-editor-font-size=inherit] - Font size of the rich-text view
72
+ * @cssprop [--rc-markdown-editor-line-height=1.6] - Line height of the rich-text view
73
+ * @cssprop [--rc-markdown-editor-padding=0.75em 1em] - Padding inside the rich-text view
74
+ * @cssprop [--rc-markdown-editor-background=Canvas] - Background color of the rich-text view
75
+ * @cssprop [--rc-markdown-editor-color=CanvasText] - Text color of the rich-text view
76
+ * @cssprop [--rc-markdown-editor-border=1px solid ButtonBorder] - Border around the rich-text view
77
+ * @cssprop [--rc-markdown-editor-border-radius=0 0 4px 4px] - Border radius of the rich-text view
78
+ * @cssprop [--rc-markdown-editor-focus-outline=2px solid Highlight] - Focus ring outline on the rich-text view
79
+ * @cssprop [--rc-markdown-editor-src-font-family='Cascadia Code', 'Fira Code', ui-monospace, monospace] - Font family of the source editor
80
+ * @cssprop [--rc-markdown-editor-toolbar-gap=1px] - Gap between toolbar buttons
81
+ * @cssprop [--rc-markdown-editor-toolbar-padding=4px] - Padding inside the toolbar
82
+ * @cssprop [--rc-markdown-editor-toolbar-radius=4px 4px 0 0] - Toolbar border radius
83
+ * @cssprop [--rc-markdown-editor-toolbar-border=1px solid ButtonBorder] - Toolbar border
84
+ * @cssprop [--rc-markdown-editor-toolbar-background=Canvas] - Toolbar background
85
+ * @cssprop [--rc-markdown-editor-toolbar-color=CanvasText] - Toolbar text color
86
+ * @cssprop [--rc-markdown-editor-toolbar-button-size=2rem] - Minimum inline and block size of toolbar buttons
87
+ * @cssprop [--rc-markdown-editor-toolbar-button-background=transparent] - Toolbar button background
88
+ * @cssprop [--rc-markdown-editor-toolbar-button-color=ButtonText] - Toolbar button text color
89
+ * @cssprop [--rc-markdown-editor-toolbar-button-border=1px solid transparent] - Toolbar button border
90
+ * @cssprop [--rc-markdown-editor-toolbar-button-radius=3px] - Toolbar button border radius
91
+ * @cssprop [--rc-markdown-editor-toolbar-button-hover-opacity=0.08] - Toolbar button hover state-layer opacity
92
+ * @cssprop [--rc-markdown-editor-toolbar-button-focus-opacity=0.12] - Toolbar button focus state-layer opacity
93
+ * @cssprop [--rc-markdown-editor-toolbar-button-pressed-opacity=0.12] - Toolbar button pressed state-layer opacity
94
+ * @cssprop [--rc-markdown-editor-toolbar-button-active-background=Highlight] - Active toolbar button background
95
+ * @cssprop [--rc-markdown-editor-toolbar-button-active-color=HighlightText] - Active toolbar button text color
96
+ * @cssprop [--rc-markdown-editor-toolbar-button-active-border=1px solid Highlight] - Active toolbar button border
97
+ * @cssprop [--rc-markdown-editor-toolbar-focus-outline=2px solid Highlight] - Toolbar control focus outline
98
+ * @cssprop [--rc-markdown-editor-toolbar-focus-outline-offset=1px] - Toolbar control focus outline offset
99
+ * @cssprop [--rc-markdown-editor-toolbar-select-border=1px solid ButtonBorder] - Toolbar select border
100
+ * @cssprop [--rc-markdown-editor-toolbar-select-radius=3px] - Toolbar select border radius
101
+ * @cssprop [--rc-markdown-editor-toolbar-select-background=ButtonFace] - Toolbar select background
102
+ * @cssprop [--rc-markdown-editor-toolbar-select-color=ButtonText] - Toolbar select text color
103
+ * @cssprop [--rc-markdown-editor-toolbar-select-active-background=Highlight] - Active toolbar select background
104
+ * @cssprop [--rc-markdown-editor-toolbar-select-active-color=HighlightText] - Active toolbar select text color
105
+ * @cssprop [--rc-markdown-editor-toolbar-select-active-border-color=Highlight] - Active toolbar select border color
106
+ * @cssprop [--rc-markdown-editor-toolbar-input-border=1px solid ButtonBorder] - Toolbar input border
107
+ * @cssprop [--rc-markdown-editor-toolbar-input-radius=3px] - Toolbar input border radius
108
+ * @cssprop [--rc-markdown-editor-toolbar-input-background=Field] - Toolbar input background
109
+ * @cssprop [--rc-markdown-editor-toolbar-input-color=FieldText] - Toolbar input text color
110
+ * @cssprop [--rc-markdown-editor-src-heading-color=light-dark(#1d6fc4, #82b4f5)] - Source-mode heading token color
111
+ * @cssprop [--rc-markdown-editor-src-code-color=light-dark(#c94a1a, #f09060)] - Source-mode inline/fenced code token color
112
+ * @cssprop [--rc-markdown-editor-src-link-color=light-dark(#0370b0, #60b8e8)] - Source-mode link token color
113
+ * @cssprop [--rc-markdown-editor-src-blockquote-color=light-dark(#2d7a42, #70b880)] - Source-mode blockquote token color
114
+ * @cssprop [--rc-markdown-editor-src-list-color=light-dark(#7a5c0a, #d4ac48)] - Source-mode list marker token color
115
+ * @cssprop [--rc-markdown-editor-src-dim-color=GrayText] - Source-mode strikethrough token color
60
116
  */
61
117
  export declare class RcMarkdownEditor extends LitElement {
62
118
  static styles: import('lit').CSSResult;
119
+ /** Built-in text overrides; unset keys fall back to registered text, then English. */
120
+ messages: Partial<RCMarkdownEditorMessages> | undefined;
121
+ private readonly _messages;
63
122
  private _value;
64
123
  private _defaultValue;
65
124
  private _valueInitialized;
@@ -95,7 +154,7 @@ export declare class RcMarkdownEditor extends LitElement {
95
154
  protected _pluginApi: RCTextareaPluginAPI | null;
96
155
  protected _ignoreRichMutations: boolean;
97
156
  protected _richViewRendered: boolean;
98
- protected _cachedTree: ReturnType<typeof fromMarkdown> | null;
157
+ protected _cachedTree: MarkdownTree | null;
99
158
  protected _renderedMode: EditorMode | null;
100
159
  protected _firstUpdatedDone: boolean;
101
160
  protected _$linkPopover?: HTMLDivElement;
@@ -106,7 +165,7 @@ export declare class RcMarkdownEditor extends LitElement {
106
165
  disconnectedCallback(): void;
107
166
  firstUpdated(): void;
108
167
  updated(changed: Map<string, unknown>): void;
109
- render(): import('lit').TemplateResult<1>;
168
+ render(): import('lit-html').TemplateResult<1>;
110
169
  protected _setRichViewContent(markdown: string): void;
111
170
  protected _renderMarkdown(markdown: string): string;
112
171
  protected _scheduleMarkdownSync(): void;
@@ -114,7 +173,7 @@ export declare class RcMarkdownEditor extends LitElement {
114
173
  protected _switchToSource(): void;
115
174
  protected _switchToRich(): void;
116
175
  protected _setupSourcePlugin(): void;
117
- protected _getCodeBlockLanguage(tree: ReturnType<typeof fromMarkdown>, offset: number): string | null;
176
+ protected _getCodeBlockLanguage(tree: MarkdownTree, offset: number): string | null;
118
177
  protected _onSourceChange: (_e: Event) => void;
119
178
  protected _onToolbarAction: (e: CustomEvent<EditorToolbarActionDetail>) => void;
120
179
  protected _applyRichFormat(action: EditorToolbarAction): void;
@@ -147,3 +206,4 @@ export declare class RcMarkdownEditor extends LitElement {
147
206
  protected _dispatchChange(value: string): void;
148
207
  protected _dispatchModeChange(mode: EditorMode): void;
149
208
  }
209
+ export {};
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.6.0",
6
+ "version": "0.7.0",
7
7
  "description": "Rich/source Markdown editor with a formatting toolbar, backed by rc-textarea.",
8
8
  "repository": {
9
9
  "type": "git",
@@ -45,10 +45,10 @@
45
45
  "test:browser:firefox": "vitest --run --project=firefox"
46
46
  },
47
47
  "dependencies": {
48
- "@rcarls/rc-button": "0.6.0",
49
- "@rcarls/rc-select": "0.6.0",
50
- "@rcarls/rc-textarea": "0.6.0",
51
- "@rcarls/rc-toolbar": "0.6.0"
48
+ "@rcarls/rc-button": "0.7.0",
49
+ "@rcarls/rc-common": "0.7.0",
50
+ "@rcarls/rc-textarea": "0.7.0",
51
+ "@rcarls/rc-toolbar": "0.7.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@custom-elements-manifest/analyzer": "0.11.0",