@anweb/nuxt-aneditor 0.1.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.
Files changed (59) hide show
  1. package/README.md +81 -0
  2. package/dist/module.d.mts +14 -0
  3. package/dist/module.d.ts +14 -0
  4. package/dist/module.json +9 -0
  5. package/dist/module.mjs +29 -0
  6. package/dist/runtime/assets/icons/blockquote.svg +1 -0
  7. package/dist/runtime/assets/icons/bold.svg +1 -0
  8. package/dist/runtime/assets/icons/code-block.svg +1 -0
  9. package/dist/runtime/assets/icons/code.svg +1 -0
  10. package/dist/runtime/assets/icons/edit.svg +1 -0
  11. package/dist/runtime/assets/icons/expand.svg +1 -0
  12. package/dist/runtime/assets/icons/heading.svg +1 -0
  13. package/dist/runtime/assets/icons/horizontal-rule.svg +1 -0
  14. package/dist/runtime/assets/icons/image.svg +1 -0
  15. package/dist/runtime/assets/icons/italic.svg +1 -0
  16. package/dist/runtime/assets/icons/link.svg +1 -0
  17. package/dist/runtime/assets/icons/ordered-list.svg +1 -0
  18. package/dist/runtime/assets/icons/redo.svg +1 -0
  19. package/dist/runtime/assets/icons/remove.svg +1 -0
  20. package/dist/runtime/assets/icons/strikethrough.svg +1 -0
  21. package/dist/runtime/assets/icons/table.svg +1 -0
  22. package/dist/runtime/assets/icons/task-list.svg +1 -0
  23. package/dist/runtime/assets/icons/undo.svg +1 -0
  24. package/dist/runtime/assets/icons/unordered-list.svg +1 -0
  25. package/dist/runtime/assets/icons/upload.svg +1 -0
  26. package/dist/runtime/assets/icons/youtube.svg +1 -0
  27. package/dist/runtime/components/AnEditor/Editor.vue +630 -0
  28. package/dist/runtime/components/AnEditor/Editor.vue.d.ts +2 -0
  29. package/dist/runtime/components/AnEditor/Prompt.vue +50 -0
  30. package/dist/runtime/components/AnEditor/Prompt.vue.d.ts +2 -0
  31. package/dist/runtime/components/AnEditor/Toolbar.vue +191 -0
  32. package/dist/runtime/components/AnEditor/Toolbar.vue.d.ts +2 -0
  33. package/dist/runtime/components/AnEditor/Viewer.vue +16 -0
  34. package/dist/runtime/components/AnEditor/Viewer.vue.d.ts +2 -0
  35. package/dist/runtime/composables/useBlocks.d.ts +15 -0
  36. package/dist/runtime/composables/useBlocks.js +258 -0
  37. package/dist/runtime/composables/useHistory.d.ts +12 -0
  38. package/dist/runtime/composables/useHistory.js +56 -0
  39. package/dist/runtime/composables/useImage.d.ts +27 -0
  40. package/dist/runtime/composables/useImage.js +81 -0
  41. package/dist/runtime/composables/useList.d.ts +10 -0
  42. package/dist/runtime/composables/useList.js +116 -0
  43. package/dist/runtime/composables/useSelection.d.ts +20 -0
  44. package/dist/runtime/composables/useSelection.js +92 -0
  45. package/dist/runtime/composables/useTable.d.ts +29 -0
  46. package/dist/runtime/composables/useTable.js +175 -0
  47. package/dist/runtime/types/global.d.ts +8 -0
  48. package/dist/runtime/types/index.d.ts +1 -0
  49. package/dist/runtime/types/index.js +1 -0
  50. package/dist/runtime/utils/index.d.ts +3 -0
  51. package/dist/runtime/utils/index.js +3 -0
  52. package/dist/runtime/utils/parseMarkdown.d.ts +1 -0
  53. package/dist/runtime/utils/parseMarkdown.js +184 -0
  54. package/dist/runtime/utils/toMarkdown.d.ts +1 -0
  55. package/dist/runtime/utils/toMarkdown.js +233 -0
  56. package/dist/runtime/utils/youtube.d.ts +1 -0
  57. package/dist/runtime/utils/youtube.js +6 -0
  58. package/dist/types.d.mts +3 -0
  59. package/package.json +50 -0
package/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # AnEditor — WYSIWYG markdown editor for Nuxt
2
+
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
+ [![Nuxt][nuxt-src]][nuxt-href]
6
+
7
+ Visual WYSIWYG editor with markdown output. Toolbar, keyboard shortcuts, tables, lists, images, YouTube embeds, undo/redo.
8
+
9
+ ## Setup
10
+
11
+ ```bash
12
+ npm i @anweb/nuxt-aneditor
13
+ ```
14
+
15
+ ```ts
16
+ export default defineNuxtConfig({
17
+ modules: ['@anweb/nuxt-aneditor']
18
+ })
19
+ ```
20
+
21
+ ## Components
22
+
23
+ | Name | Description |
24
+ |---|---|
25
+ | `AnEditor` | WYSIWYG editor with toolbar, markdown v-model |
26
+ | `AnEditorViewer` | Read-only markdown renderer |
27
+
28
+ ## AnEditor Props
29
+
30
+ | Prop | Type | Default | Description |
31
+ |---|---|---|---|
32
+ | `modelValue` | `string` | `''` | Markdown content (v-model) |
33
+ | `placeholder` | `string` | `''` | Placeholder text |
34
+ | `upload` | `(file: File) => Promise<string>` | — | Image upload function, returns URL |
35
+ | `disabled` | `boolean` | `false` | Disable editing |
36
+
37
+ ## AnEditor Exposed
38
+
39
+ | Method | Description |
40
+ |---|---|
41
+ | `focus()` | Focus the editor |
42
+ | `clear()` | Clear all content |
43
+
44
+ ## AnEditorViewer Props
45
+
46
+ | Prop | Type | Description |
47
+ |---|---|---|
48
+ | `content` | `string` | Markdown string to render |
49
+
50
+ ## Keyboard Shortcuts
51
+
52
+ | Shortcut | Action |
53
+ |---|---|
54
+ | `Ctrl+B` | Bold |
55
+ | `Ctrl+I` | Italic |
56
+ | `Ctrl+K` | Insert link |
57
+ | `Ctrl+Z` | Undo |
58
+ | `Ctrl+Shift+Z` | Redo |
59
+ | `Tab` | Indent list item |
60
+ | `Shift+Tab` | Outdent list item |
61
+
62
+ ## CSS Variables
63
+
64
+ | Variable | Default | Description |
65
+ |---|---|---|
66
+ | `--an-editor-border` | `#e0e0e0` | Border color |
67
+ | `--an-editor-border-focus` | `#7c83ff` | Focus border color |
68
+ | `--an-editor-background` | `#fff` | Editor background |
69
+ | `--an-editor-toolbar-background` | `#fafafa` | Toolbar background |
70
+ | `--an-editor-font-size` | `15px` | Content font size |
71
+ | `--an-editor-min-height` | `200px` | Minimum editor height |
72
+
73
+ <!-- Badges -->
74
+ [npm-version-src]: https://img.shields.io/npm/v/@anweb/nuxt-aneditor/latest.svg?style=flat&colorA=020420&colorB=00DC82
75
+ [npm-version-href]: https://npmjs.com/package/@anweb/nuxt-aneditor
76
+
77
+ [npm-downloads-src]: https://img.shields.io/npm/dm/@anweb/nuxt-aneditor.svg?style=flat&colorA=020420&colorB=00DC82
78
+ [npm-downloads-href]: https://npm.chart.dev/@anweb/nuxt-aneditor
79
+
80
+ [nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js
81
+ [nuxt-href]: https://nuxt.com
@@ -0,0 +1,14 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+ import { ModuleOptions as ModuleOptions$1 } from '@nuxt/icon';
3
+
4
+ interface ModuleOptions {
5
+ }
6
+ declare module '@nuxt/schema' {
7
+ interface NuxtOptions {
8
+ icon?: Partial<ModuleOptions$1>;
9
+ }
10
+ }
11
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
12
+
13
+ export { _default as default };
14
+ export type { ModuleOptions };
@@ -0,0 +1,14 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+ import { ModuleOptions as ModuleOptions$1 } from '@nuxt/icon';
3
+
4
+ interface ModuleOptions {
5
+ }
6
+ declare module '@nuxt/schema' {
7
+ interface NuxtOptions {
8
+ icon?: Partial<ModuleOptions$1>;
9
+ }
10
+ }
11
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
12
+
13
+ export { _default as default };
14
+ export type { ModuleOptions };
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "AnEditor",
3
+ "configKey": "aneditor",
4
+ "version": "0.1.1",
5
+ "builder": {
6
+ "@nuxt/module-builder": "1.0.2",
7
+ "unbuild": "3.6.1"
8
+ }
9
+ }
@@ -0,0 +1,29 @@
1
+ import { defineNuxtModule, createResolver, addComponentsDir, addImportsDir } from '@nuxt/kit';
2
+
3
+ const module$1 = defineNuxtModule({
4
+ meta: {
5
+ name: "AnEditor",
6
+ configKey: "aneditor"
7
+ },
8
+ defaults: {},
9
+ moduleDependencies: {
10
+ "@anweb/nuxt-ancore": {},
11
+ "@nuxt/icon": {}
12
+ },
13
+ async setup(_options, _nuxt) {
14
+ const { resolve } = createResolver(import.meta.url);
15
+ _nuxt.options.alias["#aneditor/types"] = resolve("./runtime/types");
16
+ _nuxt.options.icon = _nuxt.options.icon || {};
17
+ _nuxt.options.icon.customCollections = [
18
+ ..._nuxt.options.icon.customCollections || [],
19
+ { prefix: "aneditor", dir: resolve("./runtime/assets/icons") }
20
+ ];
21
+ addComponentsDir({
22
+ path: resolve("./runtime/components")
23
+ });
24
+ addImportsDir(resolve("./runtime/composables"));
25
+ addImportsDir(resolve("./runtime/utils"));
26
+ }
27
+ });
28
+
29
+ export { module$1 as default };
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path d="M4 4h4v4H6c0 1.1.9 2 2 2v2a4 4 0 0 1-4-4V4zm8 0h4v4h-2c0 1.1.9 2 2 2v2a4 4 0 0 1-4-4V4z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 4h5.5a3.5 3.5 0 0 1 0 7H6V4z"/><path d="M6 11h6.5a3.5 3.5 0 0 1 0 7H6v-7z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="2" width="16" height="16" rx="2"/><polyline points="7 12 5 10 7 8"/><polyline points="13 8 15 10 13 12"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 14 2 10 6 6"/><polyline points="14 6 18 10 14 14"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3l5 5-9 9H3v-5l9-9z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 8 4 4 8 4" /><polyline points="16 12 16 16 12 16" /><line x1="4" y1="4" x2="9" y2="9" /><line x1="16" y1="16" x2="11" y2="11" /></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="4" x2="4" y2="16"/><line x1="16" y1="4" x2="16" y2="16"/><line x1="4" y1="10" x2="16" y2="10"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="2" y1="10" x2="18" y2="10"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="16" height="14" rx="2"/><circle cx="7" cy="8" r="1.5"/><path d="M18 13l-4-4L4 17"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="3" x2="8" y2="17"/><line x1="7" y1="3" x2="15" y2="3"/><line x1="5" y1="17" x2="13" y2="17"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 12a4 4 0 0 0 5.66 0l2-2a4 4 0 0 0-5.66-5.66l-1 1"/><path d="M12 8a4 4 0 0 0-5.66 0l-2 2a4 4 0 0 0 5.66 5.66l1-1"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="9" y1="5" x2="17" y2="5"/><line x1="9" y1="10" x2="17" y2="10"/><line x1="9" y1="15" x2="17" y2="15"/><text x="3" y="7" font-size="6" fill="currentColor" stroke="none" font-family="sans-serif">1</text><text x="3" y="12" font-size="6" fill="currentColor" stroke="none" font-family="sans-serif">2</text><text x="3" y="17" font-size="6" fill="currentColor" stroke="none" font-family="sans-serif">3</text></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 8 18 10 16 12"/><path d="M18 10H6a4 4 0 0 0 0 8h4"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="5" x2="15" y2="15"/><line x1="15" y1="5" x2="5" y2="15"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 5a4 4 0 0 0-4-2H7a4 4 0 0 0 0 7"/><path d="M7 15a4 4 0 0 0 4 2h3a4 4 0 0 0 0-7"/><line x1="2" y1="10" x2="18" y2="10"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="16" height="14" rx="2"/><line x1="2" y1="8" x2="18" y2="8"/><line x1="2" y1="13" x2="18" y2="13"/><line x1="8" y1="3" x2="8" y2="17"/><line x1="13" y1="3" x2="13" y2="17"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="4" height="4" rx="1"/><line x1="9" y1="5" x2="18" y2="5"/><path d="M3 12l1.5 1.5L7 11"/><line x1="9" y1="12" x2="18" y2="12"/><rect x="2" y="15" width="4" height="4" rx="1"/><line x1="9" y1="17" x2="18" y2="17"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 8 2 10 4 12"/><path d="M2 10h12a4 4 0 0 1 0 8H10"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="9" y1="5" x2="17" y2="5"/><line x1="9" y1="10" x2="17" y2="10"/><line x1="9" y1="15" x2="17" y2="15"/><circle cx="4" cy="5" r="1.5" fill="currentColor"/><circle cx="4" cy="10" r="1.5" fill="currentColor"/><circle cx="4" cy="15" r="1.5" fill="currentColor"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 14V3"/><polyline points="6 7 10 3 14 7"/><path d="M17 14v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path d="M17.8 6.2s-.2-1.2-.7-1.7c-.7-.7-1.4-.7-1.8-.8C13 3.5 10 3.5 10 3.5s-3 0-5.3.2c-.4.1-1.1.1-1.8.8-.5.5-.7 1.7-.7 1.7S2 7.6 2 9v1.3c0 1.4.2 2.8.2 2.8s.2 1.2.7 1.7c.7.7 1.5.7 1.9.8 1.4.1 5.2.2 5.2.2s3 0 5.3-.2c.4-.1 1.1-.1 1.8-.8.5-.5.7-1.7.7-1.7s.2-1.4.2-2.8V9c0-1.4-.2-2.8-.2-2.8zM8.5 12.5v-5L13 10l-4.5 2.5z"/></svg>