@srcker/editor-vue-next 1.0.3 → 1.0.4

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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@srcker/editor-vue-next",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": "^20.19.0 || >=22.12.0"
7
7
  },
8
8
  "scripts": {
9
9
  "dev": "vite",
10
- "build": "vue-tsc -b && vite build",
10
+ "build": "vue-tsc -b && vite build --emptyOutDir",
11
11
  "preview": "vite preview"
12
12
  },
13
13
  "dependencies": {
@@ -31,11 +31,14 @@ import EditorToolbar from './EditorToolbar.vue'
31
31
 
32
32
  import { UploadImageResult } from 'src/types';
33
33
 
34
+
34
35
  import "./styles/theme.css";
35
- import "./styles/variables.css";
36
+ import "./styles/style.scss";
37
+ import "./styles/variables.scss";
36
38
  import { ref } from 'vue'
37
39
 
38
40
 
41
+
39
42
  // props 类型
40
43
  interface EditorProps {
41
44
  theme?: 'light' | 'dark'
@@ -45,6 +48,10 @@ interface EditorProps {
45
48
 
46
49
  const props = defineProps<EditorProps>()
47
50
 
51
+ const emit = defineEmits<{
52
+ (e: 'update:modelValue', value: string): void
53
+ }>()
54
+
48
55
  // 默认主题
49
56
  const theme = ref<'light' | 'dark'>(props.theme ?? 'light')
50
57
 
@@ -80,16 +87,16 @@ const editor = useEditor({
80
87
  Heading.configure({
81
88
  levels: [1, 2, 3, 4, 5],
82
89
  }),
83
- // Indent,
84
- // ListStyle,
85
90
  CodeBlock.configure({
86
91
  HTMLAttributes: {
87
92
  class: 'code-block',
88
93
  },
89
94
  }),
90
95
  Code
91
-
92
96
  ],
97
+ onUpdate({ editor }) {
98
+ emit('update:modelValue', editor.getHTML())
99
+ }
93
100
  })
94
101
 
95
102
 
@@ -24,9 +24,11 @@ import { UploadImage } from './Extensions/UploadImage';
24
24
  import { BubbleMenu } from '@tiptap/vue-3/menus';
25
25
  import EditorToolbar from './EditorToolbar.vue';
26
26
  import "./styles/theme.css";
27
- import "./styles/variables.css";
27
+ import "./styles/style.scss";
28
+ import "./styles/variables.scss";
28
29
  import { ref } from 'vue';
29
30
  const props = defineProps();
31
+ const emit = defineEmits();
30
32
  // 默认主题
31
33
  const theme = ref(props.theme ?? 'light');
32
34
  // 切换主题
@@ -59,8 +61,6 @@ const editor = useEditor({
59
61
  Heading.configure({
60
62
  levels: [1, 2, 3, 4, 5],
61
63
  }),
62
- // Indent,
63
- // ListStyle,
64
64
  CodeBlock.configure({
65
65
  HTMLAttributes: {
66
66
  class: 'code-block',
@@ -68,6 +68,9 @@ const editor = useEditor({
68
68
  }),
69
69
  Code
70
70
  ],
71
+ onUpdate({ editor }) {
72
+ emit('update:modelValue', editor.getHTML());
73
+ }
71
74
  });
72
75
  const uploadImageBase64 = async (file) => {
73
76
  console.log(file);
@@ -87,6 +90,7 @@ const __VLS_ctx = {
87
90
  ...{},
88
91
  ...{},
89
92
  ...{},
93
+ ...{},
90
94
  };
91
95
  let __VLS_components;
92
96
  let __VLS_intrinsics;
@@ -194,6 +198,7 @@ const __VLS_15 = __VLS_14({
194
198
  // @ts-ignore
195
199
  [editor, theme,];
196
200
  const __VLS_export = (await import('vue')).defineComponent({
201
+ __typeEmits: {},
197
202
  __typeProps: {},
198
203
  });
199
204
  export default {};
package/src/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import './styles/style.scss';
2
1
  import RichEditor from './RichEditor.vue';
3
2
  RichEditor.install = (app) => {
4
3
  app.component('RichEditor', RichEditor);
package/src/index.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import type { App } from 'vue'
2
- import './styles/style.scss'
3
2
 
4
3
  import RichEditor from './RichEditor.vue';
5
4
 
@@ -0,0 +1,3 @@
1
+ import "./theme.css";
2
+ import "./style.scss";
3
+ import "./variables.scss";
@@ -0,0 +1,3 @@
1
+ import "./theme.css";
2
+ import "./style.scss";
3
+ import "./variables.scss";
@@ -1,4 +1,3 @@
1
- /* ================== Dark Theme ================== */
2
1
  .dark {
3
2
  --color: rgba(255, 255, 255, 0.9);
4
3
  --background: #0e0e11;
@@ -0,0 +1 @@
1
+ import "./variables.scss";
@@ -0,0 +1 @@
1
+ import "./variables.scss";
package/vite.config.ts CHANGED
@@ -7,17 +7,28 @@ import path from 'path'
7
7
  export default defineConfig({
8
8
  plugins: [vue()],
9
9
  build: {
10
+ cssCodeSplit: true,
10
11
  lib: {
11
- entry: path.resolve(__dirname, 'src/index.ts'),
12
+ entry: {
13
+ index: path.resolve(__dirname, 'src/index.ts'),
14
+ variables: path.resolve(__dirname, 'src/styles/variables.ts'),
15
+ style: path.resolve(__dirname, 'src/styles/index.ts'),
16
+ },
12
17
  name: 'RichEditor',
13
- fileName: (format) => `rich-editor.${format}.js`
18
+ fileName: (format, entryName) => {
19
+ if (entryName === 'index') {
20
+ return `rich-editor.${format}.js`
21
+ }
22
+ return `${entryName}.${format}.js`
23
+ }
14
24
  },
15
25
  rollupOptions: {
16
26
  external: ['vue'],
17
27
  output: {
28
+ assetFileNames: 'style/[name][extname]',
18
29
  globals: {
19
30
  vue: 'Vue'
20
- }
31
+ },
21
32
  }
22
33
  }
23
34
  }
Binary file
@@ -1,158 +0,0 @@
1
- .srcker-html-content {
2
- outline: none;
3
- min-height: 100%;
4
- font-size: 16px;
5
- line-height: 1.6;
6
- outline: none;
7
- color: var(--color);
8
- background: var(--background);
9
- }
10
-
11
- /* ===== focus ===== */
12
- .srcker-html-content .is-focused {
13
- background: var(--hover-background);
14
- }
15
-
16
- /* ===== placeholder ===== */
17
- .srcker-html-content p.is-editor-empty:first-child::before {
18
- color: #888;
19
- content: attr(data-placeholder);
20
- float: left;
21
- height: 0;
22
- pointer-events: none;
23
- }
24
-
25
- /* ===== list ===== */
26
- .srcker-html-content ul,
27
- .srcker-html-content ol {
28
- padding-left: 1.5rem;
29
- margin: 0.5rem 0;
30
- }
31
-
32
- .srcker-html-content ul[style*="list-style-type"],
33
- .srcker-html-content ol[style*="list-style-type"] {
34
- padding-left: 40px !important;
35
- }
36
-
37
- .srcker-html-content ul li,
38
- .srcker-html-content ol li {
39
- padding: 0;
40
- margin: 0;
41
- }
42
-
43
- /* ===== blockquote ===== */
44
- .srcker-html-content blockquote {
45
- border-left: 3px solid var(--border-color);
46
- margin: 1rem 0;
47
- padding-left: 1rem;
48
- font-style: italic;
49
- color: #555;
50
- background: rgba(0, 0, 0, 0.02);
51
- }
52
-
53
- /* ===== inline code ===== */
54
- .srcker-html-content code {
55
- background: #f0f0f0;
56
- color: #c7254e;
57
- border-radius: 4px;
58
- font-size: 12px;
59
- padding: 0.25em 0.3em;
60
- font-family: 'JetBrainsMono', monospace;
61
- }
62
-
63
- /* ===== code block ===== */
64
- .srcker-html-content pre {
65
- background: #000;
66
- border-radius: 5px;
67
- color: #fff;
68
- font-family: 'JetBrainsMono', monospace;
69
- margin: 15px 0;
70
- padding: 5px 10px;
71
- }
72
-
73
- .srcker-html-content pre code {
74
- background: none;
75
- color: inherit;
76
- font-size: 12px;
77
- padding: 0;
78
- }
79
-
80
- /* ===== hr ===== */
81
- .srcker-html-content hr {
82
- border: none;
83
- border-top: 1px solid #ccc;
84
- margin: 20px 0;
85
- }
86
-
87
- /* ===== link ===== */
88
- .srcker-html-content a {
89
- color: #1890ff;
90
- text-decoration: underline;
91
- cursor: pointer;
92
- }
93
-
94
- /* ===== heading ===== */
95
- .srcker-html-content h1,
96
- .srcker-html-content h2,
97
- .srcker-html-content h3,
98
- .srcker-html-content h4,
99
- .srcker-html-content h5,
100
- .srcker-html-content h6 {
101
- margin-top: 1em;
102
- margin-bottom: 0.5em;
103
- line-height: 1.3;
104
- padding-left: 0 !important;
105
- }
106
-
107
- /* ===== image ===== */
108
- .srcker-html-content img.resizable-image {
109
- cursor: pointer;
110
- transition: opacity 0.2s;
111
- }
112
-
113
- .srcker-html-content img.resizable-image:hover {
114
- opacity: 0.8;
115
- }
116
-
117
- .srcker-html-content img {
118
- max-width: 100%;
119
- }
120
-
121
-
122
- .srcker-html-content.light blockquote {
123
- color: #555;
124
- background: rgba(0, 0, 0, 0.02);
125
- }
126
-
127
- .srcker-html-content.light code {
128
- background: #f0f0f0;
129
- color: #c7254e;
130
- }
131
-
132
- .srcker-html-content.light pre {
133
- background: #f6f8fa;
134
- color: #24292e;
135
- }
136
-
137
- .srcker-html-content.light hr {
138
- border-top-color: rgba(0, 0, 0, 0.12);
139
- }
140
-
141
-
142
- .srcker-html-content.dark blockquote {
143
- color: #aaa;
144
- }
145
-
146
- .srcker-html-content.dark code {
147
- background: #333;
148
- color: #fff;
149
- }
150
-
151
- .srcker-html-content.dark pre {
152
- background: #000;
153
- color: #fff;
154
- }
155
-
156
- .srcker-html-content.dark hr {
157
- border-top-color: rgba(255, 255, 255, 0.15);
158
- }