chaeditor 0.1.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.
Files changed (40) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.ko.md +250 -0
  3. package/README.md +242 -0
  4. package/dist/core.cjs +1034 -0
  5. package/dist/core.d.mts +347 -0
  6. package/dist/core.d.ts +347 -0
  7. package/dist/core.mjs +988 -0
  8. package/dist/default-host.cjs +243 -0
  9. package/dist/default-host.d.mts +52 -0
  10. package/dist/default-host.d.ts +52 -0
  11. package/dist/default-host.mjs +239 -0
  12. package/dist/default-markdown-primitive-registry-B3PGEkqs.d.mts +12 -0
  13. package/dist/default-markdown-primitive-registry-CqzwhHj2.d.ts +12 -0
  14. package/dist/image-upload-kind-BJqItE_C.d.mts +18 -0
  15. package/dist/image-upload-kind-BJqItE_C.d.ts +18 -0
  16. package/dist/index.cjs +8736 -0
  17. package/dist/index.d.mts +7 -0
  18. package/dist/index.d.ts +7 -0
  19. package/dist/index.mjs +8668 -0
  20. package/dist/markdown-editor-B1qvE40Z.d.mts +460 -0
  21. package/dist/markdown-editor-Ce6DpnQk.d.ts +460 -0
  22. package/dist/markdown-primitive-contract-BXsqbKwY.d.mts +124 -0
  23. package/dist/markdown-primitive-contract-BXsqbKwY.d.ts +124 -0
  24. package/dist/panda-primitives.cjs +1299 -0
  25. package/dist/panda-primitives.d.mts +21127 -0
  26. package/dist/panda-primitives.d.ts +21127 -0
  27. package/dist/panda-primitives.mjs +1285 -0
  28. package/dist/react.cjs +8558 -0
  29. package/dist/react.d.mts +35 -0
  30. package/dist/react.d.ts +35 -0
  31. package/dist/react.mjs +8531 -0
  32. package/dist/toolbar-preset-B9ttTEol.d.ts +236 -0
  33. package/dist/toolbar-preset-DIsQN390.d.mts +236 -0
  34. package/package.json +151 -0
  35. package/recipes/host-presets/README.md +16 -0
  36. package/recipes/host-presets/emotion-host-preset.tsx.template +109 -0
  37. package/recipes/host-presets/styled-components-host-preset.tsx.template +102 -0
  38. package/recipes/host-presets/tailwind-host-preset.tsx.template +116 -0
  39. package/recipes/host-presets/vanilla-extract-host-preset.tsx.template +116 -0
  40. package/styled-system/styles.css +3370 -0
@@ -0,0 +1,347 @@
1
+ export { E as EditorAttachment, a as EditorContentType } from './image-upload-kind-BJqItE_C.mjs';
2
+ export { D as DEFAULT_MARKDOWN_TOOLBAR_PRESET, F as FetchLinkPreviewMeta, H as HostImageRenderProps, a as HostImageRenderer, M as MarkdownEditorHostAdapters, b as MarkdownImageViewerLabels, c as MarkdownRendererHostAdapters, d as MarkdownSegment, e as MarkdownToolbarPresetItemKey, f as MarkdownToolbarPresetSection, g as MarkdownToolbarResolvedSection, h as MarkdownToolbarSectionKey, P as PreviewImageSource, R as ResolveAttachmentHref, i as RichMarkdownRenderArgs, U as UploadEditorFile, j as UploadEditorImage, k as UploadEditorVideo, l as decodeHtmlAttributeEntities, p as parseRichMarkdownSegments, m as parseToggleTitle, r as resolveMarkdownToolbarPresetSections } from './toolbar-preset-DIsQN390.mjs';
3
+ import 'react';
4
+
5
+ declare const EDITOR_ATTACHMENT_MAX_FILE_SIZE: number;
6
+ declare const EDITOR_ATTACHMENT_FILE_INPUT_ACCEPT: string;
7
+ /**
8
+ * Checks whether the file name uses an allowed attachment extension.
9
+ */
10
+ declare const isAllowedEditorAttachmentExtension: (fileName: string) => boolean;
11
+ /**
12
+ * Checks whether the file matches the attachment upload policy.
13
+ */
14
+ declare const isAllowedEditorAttachmentFile: (file: File) => boolean;
15
+
16
+ declare const EDITOR_VIDEO_MAX_FILE_SIZE: number;
17
+ declare const EDITOR_VIDEO_FILE_INPUT_ACCEPT: string;
18
+ /**
19
+ * Checks whether the file name uses an allowed video extension.
20
+ */
21
+ declare const isAllowedEditorVideoExtension: (fileName: string) => boolean;
22
+ /**
23
+ * Checks whether the file matches the video upload policy.
24
+ */
25
+ declare const isAllowedEditorVideoFile: (file: File) => boolean;
26
+
27
+ /**
28
+ * Applies a transform only to prose outside fenced blocks and inline code.
29
+ *
30
+ * @param markdown Raw markdown string.
31
+ * @param transform Transform applied to prose segments.
32
+ * @returns Markdown with code segments preserved.
33
+ */
34
+ declare const transformMarkdownOutsideCode: (markdown: string, transform: (value: string) => string) => string;
35
+ /**
36
+ * Converts custom inline syntax into link-like tokens consumable by react-markdown.
37
+ *
38
+ * @param markdown Raw markdown string.
39
+ * @returns Markdown with normalized inline directives.
40
+ */
41
+ declare const preprocessMarkdownInlineSyntax: (markdown: string) => string;
42
+ /**
43
+ * Normalizes raw HTML aliases such as line breaks and horizontal rules into markdown equivalents.
44
+ *
45
+ * @param markdown Raw markdown string.
46
+ * @returns Markdown with HTML aliases normalized.
47
+ */
48
+ declare const normalizeMarkdownHtmlAliases: (markdown: string) => string;
49
+
50
+ type EditorLinkMode = 'card' | 'embed' | 'link' | 'preview';
51
+ type BuildEditorLinkInsertionInput = {
52
+ clipboardText: string;
53
+ selectedText: string;
54
+ };
55
+ type EditorLinkInsertion = {
56
+ text: string;
57
+ type: 'link';
58
+ };
59
+ type CreateMarkdownLinkByModeInput = {
60
+ label: string;
61
+ mode: EditorLinkMode;
62
+ url: string;
63
+ };
64
+ /**
65
+ * Combines selected text and a URL into markdown link syntax.
66
+ */
67
+ declare const createMarkdownLink: (label: string, url: string, title?: string) => string;
68
+ /**
69
+ * Creates markdown link syntax for the selected editor link mode.
70
+ */
71
+ declare const createMarkdownLinkByMode: ({ label, mode, url }: CreateMarkdownLinkByModeInput) => string;
72
+ /**
73
+ * Resolves markdown insertion text from clipboard input and the current selection.
74
+ */
75
+ declare const buildEditorLinkInsertion: ({ clipboardText, selectedText, }: BuildEditorLinkInsertionInput) => EditorLinkInsertion | null;
76
+
77
+ type VideoProvider = 'upload' | 'youtube';
78
+ type YoutubeVideoEmbedReference = {
79
+ provider: 'youtube';
80
+ videoId: string;
81
+ };
82
+ type UploadVideoEmbedReference = {
83
+ provider: 'upload';
84
+ src: string;
85
+ };
86
+ type VideoEmbedReference = UploadVideoEmbedReference | YoutubeVideoEmbedReference;
87
+ /**
88
+ * Extracts a supported video reference from a user-provided URL.
89
+ *
90
+ * @param value Raw video URL string.
91
+ * @returns A normalized video reference or null.
92
+ */
93
+ declare const extractVideoEmbedReference: (value: string) => VideoEmbedReference | null;
94
+ /**
95
+ * Extracts only the YouTube video id from a supported URL.
96
+ *
97
+ * @param value Raw YouTube URL string.
98
+ * @returns A YouTube video id or null.
99
+ */
100
+ declare const extractYoutubeId: (value: string) => string | null;
101
+ /**
102
+ * Builds the custom Video markdown tag from a normalized reference.
103
+ *
104
+ * @param reference Video provider reference.
105
+ * @returns A custom Video markdown string.
106
+ */
107
+ declare const createVideoEmbedMarkdown: (reference: VideoEmbedReference) => string;
108
+ /**
109
+ * Builds a Video markdown tag for a YouTube video id.
110
+ *
111
+ * @param videoId YouTube video id.
112
+ * @returns A YouTube Video markdown string.
113
+ */
114
+ declare const createYoutubeEmbedMarkdown: (videoId: string) => string;
115
+ /**
116
+ * Builds a Video markdown tag for an uploaded video URL.
117
+ *
118
+ * @param src Public URL of the uploaded video.
119
+ * @returns An upload Video markdown string.
120
+ */
121
+ declare const createUploadedVideoEmbedMarkdown: (src: string) => string;
122
+
123
+ /**
124
+ * Builds markdown image syntax for a single image.
125
+ *
126
+ * @param altText Image alt text.
127
+ * @param url Image URL.
128
+ * @returns A markdown image string.
129
+ */
130
+ declare const createImageEmbedMarkdown: (altText: string, url: string) => string;
131
+ /**
132
+ * Builds multiple standalone markdown image blocks.
133
+ *
134
+ * @param items Image entries.
135
+ * @returns Markdown image blocks joined by blank lines.
136
+ */
137
+ declare const createImageEmbedMarkdownGroup: (items: Array<{
138
+ altText: string;
139
+ url: string;
140
+ }>) => string;
141
+ /**
142
+ * Builds a gallery block from multiple image entries.
143
+ *
144
+ * @param items Image entries for the gallery.
145
+ * @returns A gallery block string.
146
+ */
147
+ declare const createImageGalleryMarkdown: (items: Array<{
148
+ altText: string;
149
+ url: string;
150
+ }>) => string;
151
+ /**
152
+ * Builds the custom Attachment markdown tag.
153
+ *
154
+ * @param contentType Attachment MIME type.
155
+ * @param fileName Attachment file name.
156
+ * @param fileSize Attachment size in bytes.
157
+ * @param url Attachment URL.
158
+ * @returns A custom Attachment markdown string.
159
+ */
160
+ declare const createAttachmentEmbedMarkdown: ({ contentType, fileName, fileSize, url, }: {
161
+ contentType: string;
162
+ fileName: string;
163
+ fileSize: number;
164
+ url: string;
165
+ }) => string;
166
+ /**
167
+ * Builds the custom Math markdown tag.
168
+ *
169
+ * @param formula LaTeX formula string.
170
+ * @param isBlock Whether the formula should be rendered as a block.
171
+ * @returns A custom Math markdown string.
172
+ */
173
+ declare const createMathEmbedMarkdown: ({ formula, isBlock, }: {
174
+ formula: string;
175
+ isBlock: boolean;
176
+ }) => string;
177
+ /**
178
+ * Builds an align block template and its default cursor position.
179
+ *
180
+ * @param align Alignment direction.
181
+ * @returns The align block text and cursor offset.
182
+ */
183
+ declare const createAlignBlockMarkdown: (align: "center" | "left" | "right") => {
184
+ cursorOffset: number;
185
+ text: string;
186
+ };
187
+ /**
188
+ * Builds a toggle block template and its default cursor position.
189
+ *
190
+ * @param level Heading level used in the toggle title.
191
+ * @param selectedText Selected title text.
192
+ * @returns The toggle block text and cursor offset.
193
+ */
194
+ declare const createToggleBlockMarkdown: (level: 1 | 2 | 3 | 4, selectedText: string) => {
195
+ cursorOffset: number;
196
+ text: string;
197
+ };
198
+
199
+ type TextareaValueChangeHandler = (value: string) => void;
200
+ type TextareaValueTransform = (textarea: HTMLTextAreaElement) => string;
201
+ /**
202
+ * Wraps the current selection with prefix and suffix strings.
203
+ * Inserts the placeholder and selects it when there is no selection.
204
+ */
205
+ declare const wrapSelection: (textarea: HTMLTextAreaElement, before: string, after: string, placeholder?: string) => string;
206
+ /**
207
+ * Toggles a line prefix for each selected line.
208
+ * Empty lines are left unchanged.
209
+ */
210
+ declare const prefixLine: (textarea: HTMLTextAreaElement, prefix: string) => string;
211
+ /**
212
+ * Replaces the current selection with a template and restores the caret.
213
+ */
214
+ declare const insertTemplate: (textarea: HTMLTextAreaElement, template: string, cursorOffset?: number) => string;
215
+ /**
216
+ * Restores the selection range on the rendered textarea after state updates.
217
+ */
218
+ declare const restoreCursor: (textarea: HTMLTextAreaElement, start: number, end: number) => void;
219
+ /**
220
+ * Returns focus to the textarea after a toolbar interaction.
221
+ */
222
+ declare const focusTextarea: (textarea: HTMLTextAreaElement) => void;
223
+ /**
224
+ * Reads the pending selection range stored for the next render cycle.
225
+ */
226
+ declare const getPendingSelection: (textarea: HTMLTextAreaElement) => {
227
+ end: number;
228
+ start: number;
229
+ };
230
+ /**
231
+ * Runs a textarea transform and restores focus and selection after `onChange`.
232
+ */
233
+ declare const applyTextareaTransform: (textarea: HTMLTextAreaElement, onChange: TextareaValueChangeHandler, transform: TextareaValueTransform) => string;
234
+ /**
235
+ * Toggles the selected lines to the requested heading level.
236
+ */
237
+ declare const toggleHeadingLine: (textarea: HTMLTextAreaElement, level: 1 | 2 | 3 | 4) => string;
238
+ /**
239
+ * Continues or exits the current markdown list item on Enter.
240
+ */
241
+ declare const continueMarkdownList: (textarea: HTMLTextAreaElement) => string | null;
242
+ /**
243
+ * Increases list indentation for the selected markdown list items.
244
+ */
245
+ declare const indentMarkdownList: (textarea: HTMLTextAreaElement) => string | null;
246
+ /**
247
+ * Decreases list indentation for the selected markdown list items.
248
+ */
249
+ declare const outdentMarkdownList: (textarea: HTMLTextAreaElement) => string | null;
250
+
251
+ declare const CHAEDITOR_THEME_VARIABLES: {
252
+ readonly border: "--chaeditor-color-border";
253
+ readonly borderStrong: "--chaeditor-color-border-strong";
254
+ readonly focusRing: "--chaeditor-color-focus-ring";
255
+ readonly monoFont: "--chaeditor-font-mono";
256
+ readonly muted: "--chaeditor-color-muted";
257
+ readonly overlayBackdrop: "--chaeditor-color-overlay-backdrop";
258
+ readonly primary: "--chaeditor-color-primary";
259
+ readonly primaryContrast: "--chaeditor-color-primary-contrast";
260
+ readonly primaryHover: "--chaeditor-color-primary-hover";
261
+ readonly primaryMuted: "--chaeditor-color-primary-muted";
262
+ readonly primarySubtle: "--chaeditor-color-primary-subtle";
263
+ readonly sansFont: "--chaeditor-font-sans";
264
+ readonly sansJaFont: "--chaeditor-font-sans-ja";
265
+ readonly success: "--chaeditor-color-success";
266
+ readonly surface: "--chaeditor-color-surface";
267
+ readonly surfaceMuted: "--chaeditor-color-surface-muted";
268
+ readonly surfaceStrong: "--chaeditor-color-surface-strong";
269
+ readonly text: "--chaeditor-color-text";
270
+ readonly textSubtle: "--chaeditor-color-text-subtle";
271
+ readonly error: "--chaeditor-color-error";
272
+ };
273
+ type ChaeditorThemeVariableName = (typeof CHAEDITOR_THEME_VARIABLES)[keyof typeof CHAEDITOR_THEME_VARIABLES];
274
+ type ChaeditorThemeDefinition = Partial<{
275
+ border: string;
276
+ borderStrong: string;
277
+ error: string;
278
+ focusRing: string;
279
+ monoFont: string;
280
+ muted: string;
281
+ overlayBackdrop: string;
282
+ primary: string;
283
+ primaryContrast: string;
284
+ primaryHover: string;
285
+ primaryMuted: string;
286
+ primarySubtle: string;
287
+ sansFont: string;
288
+ sansJaFont: string;
289
+ success: string;
290
+ surface: string;
291
+ surfaceMuted: string;
292
+ surfaceStrong: string;
293
+ text: string;
294
+ textSubtle: string;
295
+ }>;
296
+ declare const CHAEDITOR_THEME_DEFAULTS: {
297
+ readonly dark: {
298
+ readonly border: "#52525b";
299
+ readonly borderStrong: "#71717a";
300
+ readonly error: "#f87171";
301
+ readonly focusRing: "#1e3a8a";
302
+ readonly muted: "#a1a1aa";
303
+ readonly overlayBackdrop: "rgb(9 9 11 / 0.82)";
304
+ readonly primary: "#93c5fd";
305
+ readonly primaryContrast: "#18181b";
306
+ readonly primaryHover: "#bfdbfe";
307
+ readonly primaryMuted: "#1e40af";
308
+ readonly primarySubtle: "#1e3a8a";
309
+ readonly success: "#4ade80";
310
+ readonly surface: "#18181b";
311
+ readonly surfaceMuted: "#27272a";
312
+ readonly surfaceStrong: "#3f3f46";
313
+ readonly text: "#fafafa";
314
+ readonly textSubtle: "#d4d4d8";
315
+ };
316
+ readonly fonts: {
317
+ readonly mono: "var(--font-d2coding), 'D2Coding', 'SFMono-Regular', 'JetBrains Mono', Consolas, 'Liberation Mono', monospace";
318
+ readonly sans: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif";
319
+ readonly sansJa: "system-ui, -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Yu Gothic', 'Meiryo', sans-serif";
320
+ };
321
+ readonly light: {
322
+ readonly border: "#d4d4d8";
323
+ readonly borderStrong: "#a1a1aa";
324
+ readonly error: "#ef4444";
325
+ readonly focusRing: "#dbeafe";
326
+ readonly muted: "#71717a";
327
+ readonly overlayBackdrop: "rgb(15 23 42 / 0.86)";
328
+ readonly primary: "#3b82f6";
329
+ readonly primaryContrast: "#ffffff";
330
+ readonly primaryHover: "#2563eb";
331
+ readonly primaryMuted: "#dbeafe";
332
+ readonly primarySubtle: "#eff6ff";
333
+ readonly success: "#22c55e";
334
+ readonly surface: "#ffffff";
335
+ readonly surfaceMuted: "#f4f4f5";
336
+ readonly surfaceStrong: "#e4e4e7";
337
+ readonly text: "#18181b";
338
+ readonly textSubtle: "#52525b";
339
+ };
340
+ };
341
+ /**
342
+ * Converts semantic theme values into CSS custom properties that a host app can attach
343
+ * to any wrapper element, :root, or theme scope.
344
+ */
345
+ declare const createChaeditorThemeVars: (theme: ChaeditorThemeDefinition) => Partial<Record<ChaeditorThemeVariableName, string>>;
346
+
347
+ export { CHAEDITOR_THEME_DEFAULTS, CHAEDITOR_THEME_VARIABLES, type ChaeditorThemeDefinition, type ChaeditorThemeVariableName, EDITOR_ATTACHMENT_FILE_INPUT_ACCEPT, EDITOR_ATTACHMENT_MAX_FILE_SIZE, EDITOR_VIDEO_FILE_INPUT_ACCEPT, EDITOR_VIDEO_MAX_FILE_SIZE, type EditorLinkMode, type UploadVideoEmbedReference, type VideoEmbedReference, type VideoProvider, type YoutubeVideoEmbedReference, applyTextareaTransform, buildEditorLinkInsertion, continueMarkdownList, createAlignBlockMarkdown, createAttachmentEmbedMarkdown, createChaeditorThemeVars, createImageEmbedMarkdown, createImageEmbedMarkdownGroup, createImageGalleryMarkdown, createMarkdownLink, createMarkdownLinkByMode, createMathEmbedMarkdown, createToggleBlockMarkdown, createUploadedVideoEmbedMarkdown, createVideoEmbedMarkdown, createYoutubeEmbedMarkdown, extractVideoEmbedReference, extractYoutubeId, focusTextarea, getPendingSelection, indentMarkdownList, insertTemplate, isAllowedEditorAttachmentExtension, isAllowedEditorAttachmentFile, isAllowedEditorVideoExtension, isAllowedEditorVideoFile, normalizeMarkdownHtmlAliases, outdentMarkdownList, prefixLine, preprocessMarkdownInlineSyntax, restoreCursor, toggleHeadingLine, transformMarkdownOutsideCode, wrapSelection };
package/dist/core.d.ts ADDED
@@ -0,0 +1,347 @@
1
+ export { E as EditorAttachment, a as EditorContentType } from './image-upload-kind-BJqItE_C.js';
2
+ export { D as DEFAULT_MARKDOWN_TOOLBAR_PRESET, F as FetchLinkPreviewMeta, H as HostImageRenderProps, a as HostImageRenderer, M as MarkdownEditorHostAdapters, b as MarkdownImageViewerLabels, c as MarkdownRendererHostAdapters, d as MarkdownSegment, e as MarkdownToolbarPresetItemKey, f as MarkdownToolbarPresetSection, g as MarkdownToolbarResolvedSection, h as MarkdownToolbarSectionKey, P as PreviewImageSource, R as ResolveAttachmentHref, i as RichMarkdownRenderArgs, U as UploadEditorFile, j as UploadEditorImage, k as UploadEditorVideo, l as decodeHtmlAttributeEntities, p as parseRichMarkdownSegments, m as parseToggleTitle, r as resolveMarkdownToolbarPresetSections } from './toolbar-preset-B9ttTEol.js';
3
+ import 'react';
4
+
5
+ declare const EDITOR_ATTACHMENT_MAX_FILE_SIZE: number;
6
+ declare const EDITOR_ATTACHMENT_FILE_INPUT_ACCEPT: string;
7
+ /**
8
+ * Checks whether the file name uses an allowed attachment extension.
9
+ */
10
+ declare const isAllowedEditorAttachmentExtension: (fileName: string) => boolean;
11
+ /**
12
+ * Checks whether the file matches the attachment upload policy.
13
+ */
14
+ declare const isAllowedEditorAttachmentFile: (file: File) => boolean;
15
+
16
+ declare const EDITOR_VIDEO_MAX_FILE_SIZE: number;
17
+ declare const EDITOR_VIDEO_FILE_INPUT_ACCEPT: string;
18
+ /**
19
+ * Checks whether the file name uses an allowed video extension.
20
+ */
21
+ declare const isAllowedEditorVideoExtension: (fileName: string) => boolean;
22
+ /**
23
+ * Checks whether the file matches the video upload policy.
24
+ */
25
+ declare const isAllowedEditorVideoFile: (file: File) => boolean;
26
+
27
+ /**
28
+ * Applies a transform only to prose outside fenced blocks and inline code.
29
+ *
30
+ * @param markdown Raw markdown string.
31
+ * @param transform Transform applied to prose segments.
32
+ * @returns Markdown with code segments preserved.
33
+ */
34
+ declare const transformMarkdownOutsideCode: (markdown: string, transform: (value: string) => string) => string;
35
+ /**
36
+ * Converts custom inline syntax into link-like tokens consumable by react-markdown.
37
+ *
38
+ * @param markdown Raw markdown string.
39
+ * @returns Markdown with normalized inline directives.
40
+ */
41
+ declare const preprocessMarkdownInlineSyntax: (markdown: string) => string;
42
+ /**
43
+ * Normalizes raw HTML aliases such as line breaks and horizontal rules into markdown equivalents.
44
+ *
45
+ * @param markdown Raw markdown string.
46
+ * @returns Markdown with HTML aliases normalized.
47
+ */
48
+ declare const normalizeMarkdownHtmlAliases: (markdown: string) => string;
49
+
50
+ type EditorLinkMode = 'card' | 'embed' | 'link' | 'preview';
51
+ type BuildEditorLinkInsertionInput = {
52
+ clipboardText: string;
53
+ selectedText: string;
54
+ };
55
+ type EditorLinkInsertion = {
56
+ text: string;
57
+ type: 'link';
58
+ };
59
+ type CreateMarkdownLinkByModeInput = {
60
+ label: string;
61
+ mode: EditorLinkMode;
62
+ url: string;
63
+ };
64
+ /**
65
+ * Combines selected text and a URL into markdown link syntax.
66
+ */
67
+ declare const createMarkdownLink: (label: string, url: string, title?: string) => string;
68
+ /**
69
+ * Creates markdown link syntax for the selected editor link mode.
70
+ */
71
+ declare const createMarkdownLinkByMode: ({ label, mode, url }: CreateMarkdownLinkByModeInput) => string;
72
+ /**
73
+ * Resolves markdown insertion text from clipboard input and the current selection.
74
+ */
75
+ declare const buildEditorLinkInsertion: ({ clipboardText, selectedText, }: BuildEditorLinkInsertionInput) => EditorLinkInsertion | null;
76
+
77
+ type VideoProvider = 'upload' | 'youtube';
78
+ type YoutubeVideoEmbedReference = {
79
+ provider: 'youtube';
80
+ videoId: string;
81
+ };
82
+ type UploadVideoEmbedReference = {
83
+ provider: 'upload';
84
+ src: string;
85
+ };
86
+ type VideoEmbedReference = UploadVideoEmbedReference | YoutubeVideoEmbedReference;
87
+ /**
88
+ * Extracts a supported video reference from a user-provided URL.
89
+ *
90
+ * @param value Raw video URL string.
91
+ * @returns A normalized video reference or null.
92
+ */
93
+ declare const extractVideoEmbedReference: (value: string) => VideoEmbedReference | null;
94
+ /**
95
+ * Extracts only the YouTube video id from a supported URL.
96
+ *
97
+ * @param value Raw YouTube URL string.
98
+ * @returns A YouTube video id or null.
99
+ */
100
+ declare const extractYoutubeId: (value: string) => string | null;
101
+ /**
102
+ * Builds the custom Video markdown tag from a normalized reference.
103
+ *
104
+ * @param reference Video provider reference.
105
+ * @returns A custom Video markdown string.
106
+ */
107
+ declare const createVideoEmbedMarkdown: (reference: VideoEmbedReference) => string;
108
+ /**
109
+ * Builds a Video markdown tag for a YouTube video id.
110
+ *
111
+ * @param videoId YouTube video id.
112
+ * @returns A YouTube Video markdown string.
113
+ */
114
+ declare const createYoutubeEmbedMarkdown: (videoId: string) => string;
115
+ /**
116
+ * Builds a Video markdown tag for an uploaded video URL.
117
+ *
118
+ * @param src Public URL of the uploaded video.
119
+ * @returns An upload Video markdown string.
120
+ */
121
+ declare const createUploadedVideoEmbedMarkdown: (src: string) => string;
122
+
123
+ /**
124
+ * Builds markdown image syntax for a single image.
125
+ *
126
+ * @param altText Image alt text.
127
+ * @param url Image URL.
128
+ * @returns A markdown image string.
129
+ */
130
+ declare const createImageEmbedMarkdown: (altText: string, url: string) => string;
131
+ /**
132
+ * Builds multiple standalone markdown image blocks.
133
+ *
134
+ * @param items Image entries.
135
+ * @returns Markdown image blocks joined by blank lines.
136
+ */
137
+ declare const createImageEmbedMarkdownGroup: (items: Array<{
138
+ altText: string;
139
+ url: string;
140
+ }>) => string;
141
+ /**
142
+ * Builds a gallery block from multiple image entries.
143
+ *
144
+ * @param items Image entries for the gallery.
145
+ * @returns A gallery block string.
146
+ */
147
+ declare const createImageGalleryMarkdown: (items: Array<{
148
+ altText: string;
149
+ url: string;
150
+ }>) => string;
151
+ /**
152
+ * Builds the custom Attachment markdown tag.
153
+ *
154
+ * @param contentType Attachment MIME type.
155
+ * @param fileName Attachment file name.
156
+ * @param fileSize Attachment size in bytes.
157
+ * @param url Attachment URL.
158
+ * @returns A custom Attachment markdown string.
159
+ */
160
+ declare const createAttachmentEmbedMarkdown: ({ contentType, fileName, fileSize, url, }: {
161
+ contentType: string;
162
+ fileName: string;
163
+ fileSize: number;
164
+ url: string;
165
+ }) => string;
166
+ /**
167
+ * Builds the custom Math markdown tag.
168
+ *
169
+ * @param formula LaTeX formula string.
170
+ * @param isBlock Whether the formula should be rendered as a block.
171
+ * @returns A custom Math markdown string.
172
+ */
173
+ declare const createMathEmbedMarkdown: ({ formula, isBlock, }: {
174
+ formula: string;
175
+ isBlock: boolean;
176
+ }) => string;
177
+ /**
178
+ * Builds an align block template and its default cursor position.
179
+ *
180
+ * @param align Alignment direction.
181
+ * @returns The align block text and cursor offset.
182
+ */
183
+ declare const createAlignBlockMarkdown: (align: "center" | "left" | "right") => {
184
+ cursorOffset: number;
185
+ text: string;
186
+ };
187
+ /**
188
+ * Builds a toggle block template and its default cursor position.
189
+ *
190
+ * @param level Heading level used in the toggle title.
191
+ * @param selectedText Selected title text.
192
+ * @returns The toggle block text and cursor offset.
193
+ */
194
+ declare const createToggleBlockMarkdown: (level: 1 | 2 | 3 | 4, selectedText: string) => {
195
+ cursorOffset: number;
196
+ text: string;
197
+ };
198
+
199
+ type TextareaValueChangeHandler = (value: string) => void;
200
+ type TextareaValueTransform = (textarea: HTMLTextAreaElement) => string;
201
+ /**
202
+ * Wraps the current selection with prefix and suffix strings.
203
+ * Inserts the placeholder and selects it when there is no selection.
204
+ */
205
+ declare const wrapSelection: (textarea: HTMLTextAreaElement, before: string, after: string, placeholder?: string) => string;
206
+ /**
207
+ * Toggles a line prefix for each selected line.
208
+ * Empty lines are left unchanged.
209
+ */
210
+ declare const prefixLine: (textarea: HTMLTextAreaElement, prefix: string) => string;
211
+ /**
212
+ * Replaces the current selection with a template and restores the caret.
213
+ */
214
+ declare const insertTemplate: (textarea: HTMLTextAreaElement, template: string, cursorOffset?: number) => string;
215
+ /**
216
+ * Restores the selection range on the rendered textarea after state updates.
217
+ */
218
+ declare const restoreCursor: (textarea: HTMLTextAreaElement, start: number, end: number) => void;
219
+ /**
220
+ * Returns focus to the textarea after a toolbar interaction.
221
+ */
222
+ declare const focusTextarea: (textarea: HTMLTextAreaElement) => void;
223
+ /**
224
+ * Reads the pending selection range stored for the next render cycle.
225
+ */
226
+ declare const getPendingSelection: (textarea: HTMLTextAreaElement) => {
227
+ end: number;
228
+ start: number;
229
+ };
230
+ /**
231
+ * Runs a textarea transform and restores focus and selection after `onChange`.
232
+ */
233
+ declare const applyTextareaTransform: (textarea: HTMLTextAreaElement, onChange: TextareaValueChangeHandler, transform: TextareaValueTransform) => string;
234
+ /**
235
+ * Toggles the selected lines to the requested heading level.
236
+ */
237
+ declare const toggleHeadingLine: (textarea: HTMLTextAreaElement, level: 1 | 2 | 3 | 4) => string;
238
+ /**
239
+ * Continues or exits the current markdown list item on Enter.
240
+ */
241
+ declare const continueMarkdownList: (textarea: HTMLTextAreaElement) => string | null;
242
+ /**
243
+ * Increases list indentation for the selected markdown list items.
244
+ */
245
+ declare const indentMarkdownList: (textarea: HTMLTextAreaElement) => string | null;
246
+ /**
247
+ * Decreases list indentation for the selected markdown list items.
248
+ */
249
+ declare const outdentMarkdownList: (textarea: HTMLTextAreaElement) => string | null;
250
+
251
+ declare const CHAEDITOR_THEME_VARIABLES: {
252
+ readonly border: "--chaeditor-color-border";
253
+ readonly borderStrong: "--chaeditor-color-border-strong";
254
+ readonly focusRing: "--chaeditor-color-focus-ring";
255
+ readonly monoFont: "--chaeditor-font-mono";
256
+ readonly muted: "--chaeditor-color-muted";
257
+ readonly overlayBackdrop: "--chaeditor-color-overlay-backdrop";
258
+ readonly primary: "--chaeditor-color-primary";
259
+ readonly primaryContrast: "--chaeditor-color-primary-contrast";
260
+ readonly primaryHover: "--chaeditor-color-primary-hover";
261
+ readonly primaryMuted: "--chaeditor-color-primary-muted";
262
+ readonly primarySubtle: "--chaeditor-color-primary-subtle";
263
+ readonly sansFont: "--chaeditor-font-sans";
264
+ readonly sansJaFont: "--chaeditor-font-sans-ja";
265
+ readonly success: "--chaeditor-color-success";
266
+ readonly surface: "--chaeditor-color-surface";
267
+ readonly surfaceMuted: "--chaeditor-color-surface-muted";
268
+ readonly surfaceStrong: "--chaeditor-color-surface-strong";
269
+ readonly text: "--chaeditor-color-text";
270
+ readonly textSubtle: "--chaeditor-color-text-subtle";
271
+ readonly error: "--chaeditor-color-error";
272
+ };
273
+ type ChaeditorThemeVariableName = (typeof CHAEDITOR_THEME_VARIABLES)[keyof typeof CHAEDITOR_THEME_VARIABLES];
274
+ type ChaeditorThemeDefinition = Partial<{
275
+ border: string;
276
+ borderStrong: string;
277
+ error: string;
278
+ focusRing: string;
279
+ monoFont: string;
280
+ muted: string;
281
+ overlayBackdrop: string;
282
+ primary: string;
283
+ primaryContrast: string;
284
+ primaryHover: string;
285
+ primaryMuted: string;
286
+ primarySubtle: string;
287
+ sansFont: string;
288
+ sansJaFont: string;
289
+ success: string;
290
+ surface: string;
291
+ surfaceMuted: string;
292
+ surfaceStrong: string;
293
+ text: string;
294
+ textSubtle: string;
295
+ }>;
296
+ declare const CHAEDITOR_THEME_DEFAULTS: {
297
+ readonly dark: {
298
+ readonly border: "#52525b";
299
+ readonly borderStrong: "#71717a";
300
+ readonly error: "#f87171";
301
+ readonly focusRing: "#1e3a8a";
302
+ readonly muted: "#a1a1aa";
303
+ readonly overlayBackdrop: "rgb(9 9 11 / 0.82)";
304
+ readonly primary: "#93c5fd";
305
+ readonly primaryContrast: "#18181b";
306
+ readonly primaryHover: "#bfdbfe";
307
+ readonly primaryMuted: "#1e40af";
308
+ readonly primarySubtle: "#1e3a8a";
309
+ readonly success: "#4ade80";
310
+ readonly surface: "#18181b";
311
+ readonly surfaceMuted: "#27272a";
312
+ readonly surfaceStrong: "#3f3f46";
313
+ readonly text: "#fafafa";
314
+ readonly textSubtle: "#d4d4d8";
315
+ };
316
+ readonly fonts: {
317
+ readonly mono: "var(--font-d2coding), 'D2Coding', 'SFMono-Regular', 'JetBrains Mono', Consolas, 'Liberation Mono', monospace";
318
+ readonly sans: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif";
319
+ readonly sansJa: "system-ui, -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Yu Gothic', 'Meiryo', sans-serif";
320
+ };
321
+ readonly light: {
322
+ readonly border: "#d4d4d8";
323
+ readonly borderStrong: "#a1a1aa";
324
+ readonly error: "#ef4444";
325
+ readonly focusRing: "#dbeafe";
326
+ readonly muted: "#71717a";
327
+ readonly overlayBackdrop: "rgb(15 23 42 / 0.86)";
328
+ readonly primary: "#3b82f6";
329
+ readonly primaryContrast: "#ffffff";
330
+ readonly primaryHover: "#2563eb";
331
+ readonly primaryMuted: "#dbeafe";
332
+ readonly primarySubtle: "#eff6ff";
333
+ readonly success: "#22c55e";
334
+ readonly surface: "#ffffff";
335
+ readonly surfaceMuted: "#f4f4f5";
336
+ readonly surfaceStrong: "#e4e4e7";
337
+ readonly text: "#18181b";
338
+ readonly textSubtle: "#52525b";
339
+ };
340
+ };
341
+ /**
342
+ * Converts semantic theme values into CSS custom properties that a host app can attach
343
+ * to any wrapper element, :root, or theme scope.
344
+ */
345
+ declare const createChaeditorThemeVars: (theme: ChaeditorThemeDefinition) => Partial<Record<ChaeditorThemeVariableName, string>>;
346
+
347
+ export { CHAEDITOR_THEME_DEFAULTS, CHAEDITOR_THEME_VARIABLES, type ChaeditorThemeDefinition, type ChaeditorThemeVariableName, EDITOR_ATTACHMENT_FILE_INPUT_ACCEPT, EDITOR_ATTACHMENT_MAX_FILE_SIZE, EDITOR_VIDEO_FILE_INPUT_ACCEPT, EDITOR_VIDEO_MAX_FILE_SIZE, type EditorLinkMode, type UploadVideoEmbedReference, type VideoEmbedReference, type VideoProvider, type YoutubeVideoEmbedReference, applyTextareaTransform, buildEditorLinkInsertion, continueMarkdownList, createAlignBlockMarkdown, createAttachmentEmbedMarkdown, createChaeditorThemeVars, createImageEmbedMarkdown, createImageEmbedMarkdownGroup, createImageGalleryMarkdown, createMarkdownLink, createMarkdownLinkByMode, createMathEmbedMarkdown, createToggleBlockMarkdown, createUploadedVideoEmbedMarkdown, createVideoEmbedMarkdown, createYoutubeEmbedMarkdown, extractVideoEmbedReference, extractYoutubeId, focusTextarea, getPendingSelection, indentMarkdownList, insertTemplate, isAllowedEditorAttachmentExtension, isAllowedEditorAttachmentFile, isAllowedEditorVideoExtension, isAllowedEditorVideoFile, normalizeMarkdownHtmlAliases, outdentMarkdownList, prefixLine, preprocessMarkdownInlineSyntax, restoreCursor, toggleHeadingLine, transformMarkdownOutsideCode, wrapSelection };