alien-editor 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 (37) hide show
  1. package/README.md +249 -0
  2. package/dist/alien-editor.js +2103 -0
  3. package/dist/alien-editor.umd.cjs +2 -0
  4. package/dist/index.d.ts +8 -0
  5. package/dist/nuxt.cjs +1 -0
  6. package/dist/nuxt.js +17 -0
  7. package/dist/src/components/AlienEditor.vue.d.ts +20 -0
  8. package/dist/src/components/blocks/BlockList.vue.d.ts +2 -0
  9. package/dist/src/components/blocks/BlockWrapper.vue.d.ts +21 -0
  10. package/dist/src/components/blocks/ButtonBlock.vue.d.ts +6 -0
  11. package/dist/src/components/blocks/CodeBlock.vue.d.ts +6 -0
  12. package/dist/src/components/blocks/DividerBlock.vue.d.ts +6 -0
  13. package/dist/src/components/blocks/HeadingBlock.vue.d.ts +8 -0
  14. package/dist/src/components/blocks/ImageBlock.vue.d.ts +8 -0
  15. package/dist/src/components/blocks/ListBlock.vue.d.ts +6 -0
  16. package/dist/src/components/blocks/ModuleBlock.vue.d.ts +8 -0
  17. package/dist/src/components/blocks/TextBlock.vue.d.ts +8 -0
  18. package/dist/src/components/blocks/VideoBlock.vue.d.ts +6 -0
  19. package/dist/src/components/modals/ImageUrlModal.vue.d.ts +2 -0
  20. package/dist/src/components/modals/LinkModal.vue.d.ts +2 -0
  21. package/dist/src/components/toolbar/AlienToolbar.vue.d.ts +2 -0
  22. package/dist/src/components/toolbar/ColorPicker.vue.d.ts +2 -0
  23. package/dist/src/components/toolbar/ModeToggle.vue.d.ts +2 -0
  24. package/dist/src/components/toolbar/ModuleDropdown.vue.d.ts +2 -0
  25. package/dist/src/components/toolbar/ToolbarButton.vue.d.ts +26 -0
  26. package/dist/src/composables/useBlocks.d.ts +13 -0
  27. package/dist/src/composables/useDragDrop.d.ts +16 -0
  28. package/dist/src/composables/useEditorState.d.ts +191 -0
  29. package/dist/src/composables/useFormatting.d.ts +14 -0
  30. package/dist/src/composables/useHistory.d.ts +9 -0
  31. package/dist/src/composables/useParser.d.ts +4 -0
  32. package/dist/src/composables/useSelection.d.ts +8 -0
  33. package/dist/src/composables/useSerializer.d.ts +7 -0
  34. package/dist/src/types/index.d.ts +116 -0
  35. package/dist/src/utils/tailwindMap.d.ts +12 -0
  36. package/dist/style.css +1 -0
  37. package/package.json +53 -0
@@ -0,0 +1,4 @@
1
+ import { Block } from '../types';
2
+ export declare function useParser(): {
3
+ parse: (html: string) => Block[];
4
+ };
@@ -0,0 +1,8 @@
1
+ import { Ref } from 'vue';
2
+ export declare function useSelection(savedRange: Ref<Range | null>): {
3
+ saveSelection: () => void;
4
+ restoreSelection: () => void;
5
+ getRange: () => Range | null;
6
+ isCollapsed: () => boolean;
7
+ getSelectedText: () => string | null;
8
+ };
@@ -0,0 +1,7 @@
1
+ import { Block } from '../types';
2
+ declare function serializeBlock(block: Block): string;
3
+ export declare function useSerializer(): {
4
+ serialize: (blocks: Block[]) => string;
5
+ serializeBlock: typeof serializeBlock;
6
+ };
7
+ export {};
@@ -0,0 +1,116 @@
1
+ export interface ColorOption {
2
+ title: string;
3
+ key: string;
4
+ class: string;
5
+ }
6
+ export interface ModuleOption {
7
+ title: string;
8
+ key: string;
9
+ module: string;
10
+ }
11
+ export type BlockType = 'paragraph' | 'heading' | 'image' | 'video' | 'code' | 'divider' | 'button' | 'module' | 'blockquote' | 'ordered-list' | 'unordered-list';
12
+ export type TextAlign = 'left' | 'center' | 'right' | 'justify';
13
+ export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
14
+ export interface BaseBlock {
15
+ id: string;
16
+ type: BlockType;
17
+ }
18
+ export interface ParagraphBlock extends BaseBlock {
19
+ type: 'paragraph';
20
+ html: string;
21
+ align: TextAlign;
22
+ classes: string[];
23
+ }
24
+ export interface BlockquoteBlock extends BaseBlock {
25
+ type: 'blockquote';
26
+ html: string;
27
+ align: TextAlign;
28
+ classes: string[];
29
+ }
30
+ export interface HeadingBlock extends BaseBlock {
31
+ type: 'heading';
32
+ level: HeadingLevel;
33
+ html: string;
34
+ align: TextAlign;
35
+ classes: string[];
36
+ }
37
+ export interface OrderedListBlock extends BaseBlock {
38
+ type: 'ordered-list';
39
+ items: string[];
40
+ }
41
+ export interface UnorderedListBlock extends BaseBlock {
42
+ type: 'unordered-list';
43
+ items: string[];
44
+ }
45
+ export interface ImageBlock extends BaseBlock {
46
+ type: 'image';
47
+ src: string;
48
+ alt: string;
49
+ classes: string[];
50
+ }
51
+ export interface VideoBlock extends BaseBlock {
52
+ type: 'video';
53
+ src: string;
54
+ classes: string[];
55
+ }
56
+ export interface CodeBlock extends BaseBlock {
57
+ type: 'code';
58
+ code: string;
59
+ language: string;
60
+ }
61
+ export interface DividerBlock extends BaseBlock {
62
+ type: 'divider';
63
+ classes: string[];
64
+ }
65
+ export interface ButtonBlock extends BaseBlock {
66
+ type: 'button';
67
+ label: string;
68
+ href: string;
69
+ classes: string[];
70
+ }
71
+ export interface ModuleBlock extends BaseBlock {
72
+ type: 'module';
73
+ html: string;
74
+ }
75
+ export type Block = ParagraphBlock | BlockquoteBlock | HeadingBlock | OrderedListBlock | UnorderedListBlock | ImageBlock | VideoBlock | CodeBlock | DividerBlock | ButtonBlock | ModuleBlock;
76
+ export type EditorMode = 'edit' | 'code' | 'preview';
77
+ export interface HistorySnapshot {
78
+ blocks: Block[];
79
+ timestamp: number;
80
+ }
81
+ export interface DragState {
82
+ draggedId: string | null;
83
+ overId: string | null;
84
+ }
85
+ export interface EditorContext {
86
+ blocks: import('vue').Ref<Block[]>;
87
+ mode: import('vue').Ref<EditorMode>;
88
+ activeBlockId: import('vue').Ref<string | null>;
89
+ savedRange: import('vue').Ref<Range | null>;
90
+ colors: ColorOption[];
91
+ modules: ModuleOption[];
92
+ placeholder: string;
93
+ pushSnapshot: () => void;
94
+ undo: () => void;
95
+ redo: () => void;
96
+ canUndo: () => boolean;
97
+ canRedo: () => boolean;
98
+ updateBlock: (id: string, patch: Partial<Block>) => void;
99
+ addBlockAfter: (afterId: string, type: BlockType, overrides?: Partial<Block>) => string;
100
+ addBlockAt: (index: number, type: BlockType, overrides?: Partial<Block>) => string;
101
+ removeBlock: (id: string) => void;
102
+ moveBlock: (fromId: string, toId: string) => void;
103
+ saveSelection: () => void;
104
+ restoreSelection: () => void;
105
+ onUpload: (file: File) => void;
106
+ showLinkModal: import('vue').Ref<boolean>;
107
+ showImageUrlModal: import('vue').Ref<boolean>;
108
+ linkModalCallback: import('vue').Ref<((href: string, text: string) => void) | null>;
109
+ imageUrlCallback: import('vue').Ref<((url: string) => void) | null>;
110
+ dragState: import('vue').Ref<DragState>;
111
+ onDragStart: (blockId: string, event: DragEvent) => void;
112
+ onDragOver: (blockId: string, event: DragEvent) => void;
113
+ onDragLeave: () => void;
114
+ onDrop: (targetId: string) => void;
115
+ onDragEnd: () => void;
116
+ }
@@ -0,0 +1,12 @@
1
+ export declare const tailwindMap: {
2
+ readonly bold: "font-bold";
3
+ readonly italic: "italic";
4
+ readonly underline: "underline";
5
+ readonly strikethrough: "line-through";
6
+ readonly fontSizes: Record<string, string>;
7
+ readonly fontWeights: Record<string, string>;
8
+ readonly headingDefaults: Record<number, string>;
9
+ readonly align: Record<string, string>;
10
+ };
11
+ export type FontSizeKey = keyof typeof tailwindMap.fontSizes;
12
+ export type FontWeightKey = keyof typeof tailwindMap.fontWeights;
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ .ae-text-block:empty:before,.ae-heading-content:empty:before{content:attr(data-placeholder);color:#9ca3af;pointer-events:none}.ae-list-block li:empty:before{content:attr(data-placeholder);color:#9ca3af;pointer-events:none}.ae-block-wrapper{position:relative;padding:2px 0;margin:0 0 2px}.ae-block--dragging{opacity:.4}.ae-block--drag-over{outline:2px solid #3b82f6;outline-offset:2px;border-radius:4px}.ae-preview-mode h1{font-size:3rem;font-weight:700;margin-bottom:.5em}.ae-preview-mode h2{font-size:2.25rem;font-weight:700;margin-bottom:.5em}.ae-preview-mode h3{font-size:1.875rem;font-weight:600;margin-bottom:.5em}.ae-preview-mode h4{font-size:1.5rem;font-weight:600;margin-bottom:.5em}.ae-preview-mode h5{font-size:1.25rem;font-weight:500;margin-bottom:.5em}.ae-preview-mode h6{font-size:1.125rem;font-weight:500;margin-bottom:.5em}.ae-preview-mode p{margin-bottom:.75em}.ae-preview-mode ul{list-style:disc;padding-left:1.5em;margin-bottom:.75em}.ae-preview-mode ol{list-style:decimal;padding-left:1.5em;margin-bottom:.75em}.ae-preview-mode blockquote{border-left:4px solid #d1d5db;padding-left:1em;color:#6b7280;font-style:italic}.ae-preview-mode pre{background:#111827;color:#f3f4f6;padding:1em;border-radius:.5em;overflow-x:auto}.ae-preview-mode a{color:#2563eb;text-decoration:underline}.ae-preview-mode img{max-width:100%;border-radius:.375rem}.ae-preview-mode hr{border-top:1px solid #d1d5db;margin:1em 0}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "alien-editor",
3
+ "version": "0.1.0",
4
+ "description": "A Vue 3 block-based rich text editor with Tailwind CSS integration",
5
+ "type": "module",
6
+ "main": "./dist/alien-editor.umd.cjs",
7
+ "module": "./dist/alien-editor.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/alien-editor.js",
11
+ "require": "./dist/alien-editor.umd.cjs"
12
+ },
13
+ "./nuxt": {
14
+ "import": "./dist/nuxt.js",
15
+ "require": "./dist/nuxt.cjs"
16
+ },
17
+ "./dist/style.css": "./dist/style.css"
18
+ },
19
+ "types": "./dist/index.d.ts",
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "scripts": {
24
+ "dev": "vite",
25
+ "build": "vue-tsc --noEmit && vite build && vite build --config vite.nuxt.config.ts",
26
+ "build:nuxt": "vite build --config vite.nuxt.config.ts",
27
+ "type-check": "vue-tsc --noEmit"
28
+ },
29
+ "peerDependencies": {
30
+ "vue": "^3.3.0"
31
+ },
32
+ "devDependencies": {
33
+ "@vitejs/plugin-vue": "^5.0.0",
34
+ "autoprefixer": "^10.4.0",
35
+ "postcss": "^8.4.0",
36
+ "tailwindcss": "^3.4.0",
37
+ "typescript": "^5.3.0",
38
+ "vite": "^5.0.0",
39
+ "vite-plugin-dts": "^4.5.4",
40
+ "vue": "^3.4.0",
41
+ "vue-tsc": "^2.0.0"
42
+ },
43
+ "keywords": [
44
+ "vue",
45
+ "vue3",
46
+ "editor",
47
+ "rich-text",
48
+ "block-editor",
49
+ "tailwind",
50
+ "nuxt"
51
+ ],
52
+ "license": "MIT"
53
+ }