@rcarls/rc-textarea-plugin-markdown 0.0.0-next-20260921045401

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 ADDED
@@ -0,0 +1,39 @@
1
+ # @rcarls/rc-textarea-plugin-markdown
2
+
3
+ ## 0.0.0-next-20260921045401
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [079e025]
8
+ - Updated dependencies [4617b45]
9
+ - @rcarls/rc-textarea@0.0.0-next-20260921045401
10
+
11
+ ## 0.6.0
12
+
13
+ ## 0.5.0
14
+
15
+ ## 0.4.2
16
+
17
+ ## 0.4.1
18
+
19
+ ## 0.4.0
20
+
21
+ ## 0.3.2
22
+
23
+ ## 0.3.1
24
+
25
+ ## 0.3.0
26
+
27
+ ### Changed
28
+
29
+ - Update package metadata, README intro, and docs links.
30
+
31
+ ### Fixed
32
+
33
+ - Fix Markdown code-block language updates.
34
+
35
+ ## 0.2.0
36
+
37
+ ### Patch Changes
38
+
39
+ - @rcarls/rc-textarea@0.2.0
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # @rcarls/rc-textarea-plugin-markdown
2
+
3
+ Markdown decoration plugin for `rc-textarea`.
4
+
5
+ Docs: [https://richardcarls.github.io/rc-webcomponents/components/rc-textarea](https://richardcarls.github.io/rc-webcomponents/components/rc-textarea).
6
+
7
+ Part of the [rc-webcomponents](https://github.com/richardcarls/rc-webcomponents) library.
8
+
9
+ ## Documentation
10
+
11
+ Full API, usage examples, and keyboard/accessibility notes are on the
12
+ [rc-webcomponents docs site](https://richardcarls.github.io/rc-webcomponents/).
13
+
14
+ ## License
15
+
16
+ MIT
@@ -0,0 +1,36 @@
1
+ import { fromMarkdown as l } from "mdast-util-from-markdown";
2
+ import { visit as m } from "unist-util-visit";
3
+ import { micromark as d } from "micromark";
4
+ const u = {
5
+ heading: { bold: !0, className: "rte-heading" },
6
+ emphasis: { italic: !0 },
7
+ strong: { bold: !0 },
8
+ inlineCode: { className: "rte-code" },
9
+ link: { underline: "solid", className: "rte-link" },
10
+ blockquote: { className: "rte-blockquote" }
11
+ };
12
+ function f(t) {
13
+ return d(t);
14
+ }
15
+ function s() {
16
+ return {
17
+ getPreviewHtml: f,
18
+ update(t, a) {
19
+ const c = l(t), e = [];
20
+ m(c, (o) => {
21
+ const r = u[o.type], i = o.position?.start.offset, n = o.position?.end.offset;
22
+ r !== void 0 && i !== void 0 && n !== void 0 && e.push({ type: "mark", from: i, to: n, ...r });
23
+ }), a.setDecorations(e);
24
+ }
25
+ };
26
+ }
27
+ const v = s();
28
+ function w() {
29
+ return s();
30
+ }
31
+ export {
32
+ w as createMarkdownPlugin,
33
+ f as getMarkdownPreviewHtml,
34
+ v as markdownPlugin
35
+ };
36
+ //# sourceMappingURL=rc-textarea-plugin-markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rc-textarea-plugin-markdown.js","sources":["../src/markdown-plugin.ts"],"sourcesContent":["import { fromMarkdown } from 'mdast-util-from-markdown';\nimport { visit } from 'unist-util-visit';\nimport { micromark } from 'micromark';\n\nimport type { RCTextareaPlugin, RCTextareaPluginAPI, DecorationInput } from '@rcarls/rc-textarea';\n\n/** Minimal shape of a unist node as used by visit(). */\ninterface VisitNode {\n type: string;\n position?: {\n start: { offset?: number };\n end: { offset?: number };\n };\n}\n\n/** Decoration styles applied per MDAST node type. */\nconst DECORATION_MAP: Record<string, Partial<Omit<DecorationInput, 'type' | 'from' | 'to'>>> = {\n heading: { bold: true, className: 'rte-heading' },\n emphasis: { italic: true },\n strong: { bold: true },\n inlineCode: { className: 'rte-code' },\n link: { underline: 'solid', className: 'rte-link' },\n blockquote: { className: 'rte-blockquote' },\n};\n\n/** Render a markdown string to safe HTML using micromark (no raw HTML passthrough). */\nexport function getMarkdownPreviewHtml(value: string): string {\n return micromark(value);\n}\n\nfunction buildPlugin(): RCTextareaPlugin & { getPreviewHtml(value: string): string } {\n return {\n getPreviewHtml: getMarkdownPreviewHtml,\n\n update(value: string, api: RCTextareaPluginAPI): void {\n const tree = fromMarkdown(value);\n const decorations: DecorationInput[] = [];\n\n visit(tree, (node: VisitNode) => {\n const style = DECORATION_MAP[node.type];\n const start = node.position?.start.offset;\n const end = node.position?.end.offset;\n\n if (style !== undefined && start !== undefined && end !== undefined) {\n decorations.push({ type: 'mark', from: start, to: end, ...style } as DecorationInput);\n }\n });\n\n api.setDecorations(decorations);\n },\n };\n}\n\n/** Singleton markdown plugin. Use when a single instance is sufficient. */\nexport const markdownPlugin = buildPlugin();\n\n/** Factory for cases where multiple independent instances are needed. */\nexport function createMarkdownPlugin(): RCTextareaPlugin & {\n getPreviewHtml(value: string): string;\n} {\n return buildPlugin();\n}\n"],"names":["DECORATION_MAP","getMarkdownPreviewHtml","value","micromark","buildPlugin","api","tree","fromMarkdown","decorations","visit","node","style","start","end","markdownPlugin","createMarkdownPlugin"],"mappings":";;;AAgBA,MAAMA,IAAyF;AAAA,EAC7F,SAAS,EAAE,MAAM,IAAM,WAAW,cAAA;AAAA,EAClC,UAAU,EAAE,QAAQ,GAAA;AAAA,EACpB,QAAQ,EAAE,MAAM,GAAA;AAAA,EAChB,YAAY,EAAE,WAAW,WAAA;AAAA,EACzB,MAAM,EAAE,WAAW,SAAS,WAAW,WAAA;AAAA,EACvC,YAAY,EAAE,WAAW,iBAAA;AAC3B;AAGO,SAASC,EAAuBC,GAAuB;AAC5D,SAAOC,EAAUD,CAAK;AACxB;AAEA,SAASE,IAA4E;AACnF,SAAO;AAAA,IACL,gBAAgBH;AAAA,IAEhB,OAAOC,GAAeG,GAAgC;AACpD,YAAMC,IAAOC,EAAaL,CAAK,GACzBM,IAAiC,CAAA;AAEvC,MAAAC,EAAMH,GAAM,CAACI,MAAoB;AAC/B,cAAMC,IAAQX,EAAeU,EAAK,IAAI,GAChCE,IAAQF,EAAK,UAAU,MAAM,QAC7BG,IAAMH,EAAK,UAAU,IAAI;AAE/B,QAAIC,MAAU,UAAaC,MAAU,UAAaC,MAAQ,UACxDL,EAAY,KAAK,EAAE,MAAM,QAAQ,MAAMI,GAAO,IAAIC,GAAK,GAAGF,GAA0B;AAAA,MAExF,CAAC,GAEDN,EAAI,eAAeG,CAAW;AAAA,IAChC;AAAA,EAAA;AAEJ;AAGO,MAAMM,IAAiBV,EAAA;AAGvB,SAASW,IAEd;AACA,SAAOX,EAAA;AACT;"}
@@ -0,0 +1 @@
1
+ export { markdownPlugin, createMarkdownPlugin, getMarkdownPreviewHtml } from './markdown-plugin.js';
@@ -0,0 +1,11 @@
1
+ import { RCTextareaPlugin } from '@rcarls/rc-textarea';
2
+ /** Render a markdown string to safe HTML using micromark (no raw HTML passthrough). */
3
+ export declare function getMarkdownPreviewHtml(value: string): string;
4
+ /** Singleton markdown plugin. Use when a single instance is sufficient. */
5
+ export declare const markdownPlugin: RCTextareaPlugin & {
6
+ getPreviewHtml(value: string): string;
7
+ };
8
+ /** Factory for cases where multiple independent instances are needed. */
9
+ export declare function createMarkdownPlugin(): RCTextareaPlugin & {
10
+ getPreviewHtml(value: string): string;
11
+ };
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@rcarls/rc-textarea-plugin-markdown",
3
+ "publishConfig": {
4
+ "access": "public"
5
+ },
6
+ "version": "0.0.0-next-20260921045401",
7
+ "description": "Markdown decoration plugin for rc-textarea.",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/richardcarls/rc-webcomponents.git",
11
+ "directory": "packages/rc-textarea-plugin-markdown"
12
+ },
13
+ "homepage": "https://richardcarls.github.io/rc-webcomponents/components/rc-textarea",
14
+ "license": "MIT",
15
+ "type": "module",
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "module": "./dist/rc-textarea-plugin-markdown.js",
20
+ "exports": {
21
+ ".": {
22
+ "import": {
23
+ "types": "./dist/types/index.d.ts",
24
+ "default": "./dist/rc-textarea-plugin-markdown.js"
25
+ }
26
+ }
27
+ },
28
+ "types": "./dist/types/index.d.ts",
29
+ "sideEffects": false,
30
+ "scripts": {
31
+ "build": "tsc && vite build"
32
+ },
33
+ "devDependencies": {
34
+ "@rcarls/rc-textarea": "0.0.0-next-20260921045401",
35
+ "mdast-util-from-markdown": "^2.0.2",
36
+ "micromark": "^4.0.2",
37
+ "typescript": "~5.9.3",
38
+ "unist-util-visit": "^5.0.0",
39
+ "vite": "^7.1.7",
40
+ "vite-plugin-dts": "^4.5.4"
41
+ },
42
+ "peerDependencies": {
43
+ "@rcarls/rc-textarea": "0.0.0-next-20260921045401",
44
+ "mdast-util-from-markdown": ">=2.0.0",
45
+ "micromark": ">=4.0.0",
46
+ "unist-util-visit": ">=5.0.0"
47
+ }
48
+ }