@duskmoon-dev/el-markdown-input 0.8.1 → 0.8.3

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.
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @duskmoon-dev/el-markdown-input
3
+ *
4
+ * A form-associated custom element providing a markdown editor with:
5
+ * - Syntax-highlighted write mode (Prism.js, loaded from CDN)
6
+ * - Preview mode with rendered HTML
7
+ * - File upload via drag-and-drop, clipboard paste, or file picker
8
+ * - @mention / #reference autocomplete
9
+ * - Live word / character count status bar
10
+ * - Phoenix LiveView hook (MarkdownInputHook)
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { register } from '@duskmoon-dev/el-markdown-input';
15
+ * register();
16
+ * ```
17
+ *
18
+ * @example LiveView
19
+ * ```js
20
+ * import { MarkdownInputHook } from '@duskmoon-dev/el-markdown-input';
21
+ * let liveSocket = new LiveSocket('/live', Socket, {
22
+ * hooks: { MarkdownInput: MarkdownInputHook }
23
+ * });
24
+ * ```
25
+ */
26
+ export { ElDmMarkdownInput } from './element.js';
27
+ export type { Suggestion } from './types.js';
28
+ /**
29
+ * Register the <el-dm-markdown-input> custom element.
30
+ * Safe to call multiple times — guards against double registration.
31
+ */
32
+ export declare function register(): void;
33
+ type MarkdownInputEl = HTMLElement & {
34
+ getValue(): string;
35
+ setValue(s: string): void;
36
+ dataset: DOMStringMap;
37
+ };
38
+ interface LiveViewHook {
39
+ el: MarkdownInputEl;
40
+ pushEvent(event: string, payload: Record<string, unknown>): void;
41
+ mounted(): void;
42
+ updated(): void;
43
+ }
44
+ /**
45
+ * Phoenix LiveView hook that syncs the markdown editor value with the server.
46
+ *
47
+ * Usage:
48
+ * ```js
49
+ * import { MarkdownInputHook, register } from '@duskmoon-dev/el-markdown-input';
50
+ * register();
51
+ * let liveSocket = new LiveSocket('/live', Socket, {
52
+ * hooks: { MarkdownInput: MarkdownInputHook }
53
+ * });
54
+ * ```
55
+ *
56
+ * Template:
57
+ * ```heex
58
+ * <el-dm-markdown-input
59
+ * id="body-input"
60
+ * name="body"
61
+ * data-value={@content}
62
+ * phx-hook="MarkdownInput"
63
+ * />
64
+ * ```
65
+ */
66
+ export declare const MarkdownInputHook: Pick<LiveViewHook, 'mounted' | 'updated'>;
67
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;GAGG;AACH,wBAAgB,QAAQ,IAAI,IAAI,CAO/B;AAID,KAAK,eAAe,GAAG,WAAW,GAAG;IACnC,QAAQ,IAAI,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,UAAU,YAAY;IACpB,EAAE,EAAE,eAAe,CAAC;IACpB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACjE,OAAO,IAAI,IAAI,CAAC;IAChB,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,iBAAiB,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,SAAS,CAyBvE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/register.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Status bar utilities: word/character counting and colour thresholds.
3
+ */
4
+ /**
5
+ * Count words in a string using the algorithm specified in the PRD:
6
+ * trim, split on whitespace, filter empty strings.
7
+ */
8
+ export declare function countWords(text: string): number;
9
+ /**
10
+ * Determine the CSS colour class for the word count display.
11
+ *
12
+ * @param wordCount Current word count
13
+ * @param maxWords The configured maximum, or null if uncapped
14
+ * @returns 'normal' | 'warning' | 'error'
15
+ */
16
+ export declare function countColour(wordCount: number, maxWords: number | null): 'normal' | 'warning' | 'error';
17
+ /**
18
+ * Render the HTML content for the .status-bar-count span.
19
+ *
20
+ * @param wordCount Current word count
21
+ * @param charCount Current character count
22
+ * @param maxWords Configured cap, or null/undefined if uncapped
23
+ */
24
+ export declare function renderStatusCount(wordCount: number, charCount: number, maxWords: number | null | undefined): string;
25
+ //# sourceMappingURL=status-bar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-bar.d.ts","sourceRoot":"","sources":["../../src/status-bar.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG/C;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,GACtB,QAAQ,GAAG,SAAS,GAAG,OAAO,CAMhC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAClC,MAAM,CASR"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * An autocomplete suggestion provided by the host application.
3
+ */
4
+ export interface Suggestion {
5
+ /** Value inserted into the editor on confirmation */
6
+ id: string;
7
+ /** Display name shown in the dropdown */
8
+ label: string;
9
+ /** Optional secondary line (e.g. email, description) */
10
+ subtitle?: string;
11
+ }
12
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,qDAAqD;IACrD,EAAE,EAAE,MAAM,CAAC;IACX,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * File upload utilities for el-dm-markdown-input.
3
+ *
4
+ * Handles XHR-based multipart/form-data uploads, markdown snippet generation,
5
+ * and accepted file type validation.
6
+ */
7
+ /**
8
+ * Returns true if the file's MIME type or name extension is accepted.
9
+ */
10
+ export declare function isAcceptedType(file: File): boolean;
11
+ /**
12
+ * Generate the markdown insertion string for an uploaded file.
13
+ * Images use `![name](url)`, all other files use `[name](url)`.
14
+ */
15
+ export declare function fileToMarkdown(file: File, url: string): string;
16
+ /**
17
+ * Upload a single file to the given URL via XHR POST multipart/form-data.
18
+ *
19
+ * @param file The file to upload
20
+ * @param uploadUrl POST endpoint — must return `{ url: string }` on 2xx
21
+ * @param onProgress Callback fired with progress 0–100 during upload
22
+ * @returns Resolves with the URL from the server response
23
+ * @throws Rejects with an error message string on failure
24
+ */
25
+ export declare function uploadFile(file: File, uploadUrl: string, onProgress: (pct: number) => void): Promise<string>;
26
+ //# sourceMappingURL=upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/upload.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAOlD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAK9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAChC,OAAO,CAAC,MAAM,CAAC,CAmCjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duskmoon-dev/el-markdown-input",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "type": "module",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -39,7 +39,7 @@
39
39
  "release:dry-run": "bun publish --dry-run"
40
40
  },
41
41
  "dependencies": {
42
- "@duskmoon-dev/el-base": "0.8.0",
42
+ "@duskmoon-dev/el-base": "0.8.2",
43
43
  "@duskmoon-dev/core": "^1.10.1"
44
44
  },
45
45
  "devDependencies": {