@srcker/editor-vue-next 1.0.4 → 1.0.5

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 (104) hide show
  1. package/dist/rich-editor.es.js +21256 -0
  2. package/dist/style/index.css +1 -0
  3. package/dist/style/style.css +1 -0
  4. package/dist/style/variables.css +1 -0
  5. package/dist/style.es.js +1 -0
  6. package/dist/variables.es.js +1 -0
  7. package/package.json +7 -1
  8. package/.vscode/extensions.json +0 -3
  9. package/index.html +0 -13
  10. package/index.ts +0 -6
  11. package/jsconfig.json +0 -8
  12. package/src/App.vue +0 -9
  13. package/src/App.vue.js +0 -17
  14. package/src/Button/BackgroundButton.vue +0 -331
  15. package/src/Button/BackgroundButton.vue.js +0 -243
  16. package/src/Button/BlockQuoteButton.vue +0 -26
  17. package/src/Button/BlockQuoteButton.vue.js +0 -56
  18. package/src/Button/BoldButton.vue +0 -29
  19. package/src/Button/BoldButton.vue.js +0 -56
  20. package/src/Button/BulletListButton.vue +0 -114
  21. package/src/Button/BulletListButton.vue.js +0 -147
  22. package/src/Button/CodeBlockButton.vue +0 -28
  23. package/src/Button/CodeBlockButton.vue.js +0 -56
  24. package/src/Button/CodeButton.vue +0 -30
  25. package/src/Button/CodeButton.vue.js +0 -56
  26. package/src/Button/FontSizeButton.vue +0 -85
  27. package/src/Button/FontSizeButton.vue.js +0 -131
  28. package/src/Button/FormatButton.vue +0 -25
  29. package/src/Button/FormatButton.vue.js +0 -54
  30. package/src/Button/HeadingButton.vue +0 -103
  31. package/src/Button/HeadingButton.vue.js +0 -164
  32. package/src/Button/ImageUploadButton.vue +0 -93
  33. package/src/Button/ImageUploadButton.vue.js +0 -123
  34. package/src/Button/IndentLeftButton.vue +0 -25
  35. package/src/Button/IndentLeftButton.vue.js +0 -54
  36. package/src/Button/IndentRightButton.vue +0 -29
  37. package/src/Button/IndentRightButton.vue.js +0 -54
  38. package/src/Button/ItalicButton.vue +0 -29
  39. package/src/Button/ItalicButton.vue.js +0 -56
  40. package/src/Button/LineHeightButton.vue +0 -88
  41. package/src/Button/LineHeightButton.vue.js +0 -131
  42. package/src/Button/LinkButton.vue +0 -44
  43. package/src/Button/LinkButton.vue.js +0 -69
  44. package/src/Button/OrderedListButton.vue +0 -121
  45. package/src/Button/OrderedListButton.vue.js +0 -146
  46. package/src/Button/RedoButton.vue +0 -29
  47. package/src/Button/RedoButton.vue.js +0 -55
  48. package/src/Button/StrikeButton.vue +0 -30
  49. package/src/Button/StrikeButton.vue.js +0 -56
  50. package/src/Button/SubscriptButton.vue +0 -29
  51. package/src/Button/SubscriptButton.vue.js +0 -56
  52. package/src/Button/SuperscriptButton.vue +0 -29
  53. package/src/Button/SuperscriptButton.vue.js +0 -56
  54. package/src/Button/TextAlignCenterButton.vue +0 -26
  55. package/src/Button/TextAlignCenterButton.vue.js +0 -56
  56. package/src/Button/TextAlignLeftButton.vue +0 -26
  57. package/src/Button/TextAlignLeftButton.vue.js +0 -56
  58. package/src/Button/TextAlignRightButton.vue +0 -26
  59. package/src/Button/TextAlignRightButton.vue.js +0 -56
  60. package/src/Button/TextColorButton.vue +0 -329
  61. package/src/Button/TextColorButton.vue.js +0 -243
  62. package/src/Button/ThemeButton.vue +0 -34
  63. package/src/Button/ThemeButton.vue.js +0 -63
  64. package/src/Button/UnderLineButton.vue +0 -29
  65. package/src/Button/UnderLineButton.vue.js +0 -56
  66. package/src/Button/UndoButton.vue +0 -29
  67. package/src/Button/UndoButton.vue.js +0 -55
  68. package/src/Components/IconArrow.vue +0 -16
  69. package/src/Components/IconArrow.vue.js +0 -30
  70. package/src/Components/IconCheck.vue +0 -40
  71. package/src/Components/IconCheck.vue.js +0 -59
  72. package/src/EditorToolbar.vue +0 -150
  73. package/src/EditorToolbar.vue.js +0 -306
  74. package/src/Extensions/BulletListStyle.js +0 -19
  75. package/src/Extensions/BulletListStyle.ts +0 -24
  76. package/src/Extensions/FontSize.js +0 -27
  77. package/src/Extensions/FontSize.ts +0 -37
  78. package/src/Extensions/Indent.js +0 -58
  79. package/src/Extensions/Indent.ts +0 -73
  80. package/src/Extensions/OrderedListStyle.js +0 -19
  81. package/src/Extensions/OrderedListStyle.ts +0 -24
  82. package/src/Extensions/UploadImage.js +0 -18
  83. package/src/Extensions/UploadImage.ts +0 -22
  84. package/src/Extensions/index.js +0 -6
  85. package/src/Extensions/index.ts +0 -6
  86. package/src/Extensions/shims.d.ts +0 -26
  87. package/src/RichEditor.vue +0 -198
  88. package/src/RichEditor.vue.js +0 -204
  89. package/src/env.d.ts +0 -7
  90. package/src/index.js +0 -5
  91. package/src/index.ts +0 -10
  92. package/src/main.js +0 -4
  93. package/src/main.ts +0 -7
  94. package/src/styles/index.js +0 -3
  95. package/src/styles/index.ts +0 -3
  96. package/src/styles/style.scss +0 -196
  97. package/src/styles/theme.css +0 -27
  98. package/src/styles/variables.js +0 -1
  99. package/src/styles/variables.scss +0 -175
  100. package/src/styles/variables.ts +0 -1
  101. package/src/types.js +0 -1
  102. package/src/types.ts +0 -7
  103. package/tsconfig.json +0 -17
  104. package/vite.config.ts +0 -35
@@ -1,88 +0,0 @@
1
- <template>
2
-
3
- <div class="dropdown-button line-height-button" ref="wrapperRef" :class="{ 'is-open': isOpen }">
4
- <div class="trigger" @click="isOpen = !isOpen">
5
- <div class="icon">
6
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512">
7
- <path fill="currentColor" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" d="M40 32C17.9 32 0 49.9 0 72l0 56c0 17.7 14.3 32 32 32s32-14.3 32-32l0-32 64 0 0 320-32 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l128 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-32 0 0-320 64 0 0 32c0 17.7 14.3 32 32 32s32-14.3 32-32l0-56c0-22.1-17.9-40-40-40L40 32zM438.6 361.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l64 64c12.5 12.5 32.8 12.5 45.3 0l64-64c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-9.4 9.4 0-229.5 9.4 9.4c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-64-64c-6-6-14.1-9.4-22.6-9.4s-16.6 3.4-22.6 9.4l-64 64c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l9.4-9.4 0 229.5-9.4-9.4z"/>
8
- </svg>
9
- </div>
10
-
11
- <span class="label">{{ sizeLabel }}</span>
12
- </div>
13
-
14
- <transition name="dropdown">
15
- <div class="dropdown" v-show="isOpen">
16
- <div
17
- class="item"
18
- v-for="size in sizes"
19
- :key="size"
20
- :class="{ 'is-selected': editor.isActive('textStyle', { lineHeight: size }) }"
21
- @click="setLineHeight(size)">
22
- <span class="text">{{ size }}</span>
23
- </div>
24
- </div>
25
- </transition>
26
-
27
-
28
- </div>
29
-
30
- </template>
31
-
32
-
33
- <script setup>
34
- import { ref, computed, onMounted, onBeforeUnmount } from 'vue'
35
-
36
-
37
- const isOpen = ref(false)
38
- const wrapperRef = ref(null)
39
-
40
- const sizes = ['1.0', '1.2', '1.5', '2.0', '2.5', '3.0']
41
-
42
- const setLineHeight = (size) => {
43
- props.editor.chain().focus().toggleTextStyle({ lineHeight: size }).run()
44
- isOpen.value = false
45
- }
46
-
47
-
48
-
49
- const sizeLabel = computed(() => {
50
- if (!props.editor) return '16px'
51
- const size = props.editor.getAttributes('textStyle').lineHeight
52
- return size || '1.5'
53
- })
54
-
55
-
56
-
57
- const props = defineProps({
58
- editor: {
59
- type: Object,
60
- required: true
61
- }
62
- })
63
-
64
- const handleClickOutside = (e) => {
65
- if (!wrapperRef.value) return
66
-
67
- if (!wrapperRef.value.contains(e.target)) {
68
- isOpen.value = false
69
- }
70
- }
71
-
72
- onMounted(() => {
73
- document.addEventListener('mousedown', handleClickOutside)
74
- })
75
-
76
- onBeforeUnmount(() => {
77
- document.removeEventListener('mousedown', handleClickOutside)
78
- })
79
-
80
- </script>
81
-
82
-
83
-
84
- <style lang="css" scoped>
85
- .trigger{
86
- width: 45px;
87
- }
88
- </style>
@@ -1,131 +0,0 @@
1
- import { ref, computed, onMounted, onBeforeUnmount } from 'vue';
2
- const isOpen = ref(false);
3
- const wrapperRef = ref(null);
4
- const sizes = ['1.0', '1.2', '1.5', '2.0', '2.5', '3.0'];
5
- const setLineHeight = (size) => {
6
- props.editor.chain().focus().toggleTextStyle({ lineHeight: size }).run();
7
- isOpen.value = false;
8
- };
9
- const sizeLabel = computed(() => {
10
- if (!props.editor)
11
- return '16px';
12
- const size = props.editor.getAttributes('textStyle').lineHeight;
13
- return size || '1.5';
14
- });
15
- const props = defineProps({
16
- editor: {
17
- type: Object,
18
- required: true
19
- }
20
- });
21
- const handleClickOutside = (e) => {
22
- if (!wrapperRef.value)
23
- return;
24
- if (!wrapperRef.value.contains(e.target)) {
25
- isOpen.value = false;
26
- }
27
- };
28
- onMounted(() => {
29
- document.addEventListener('mousedown', handleClickOutside);
30
- });
31
- onBeforeUnmount(() => {
32
- document.removeEventListener('mousedown', handleClickOutside);
33
- });
34
- const __VLS_ctx = {
35
- ...{},
36
- ...{},
37
- ...{},
38
- ...{},
39
- };
40
- let __VLS_components;
41
- let __VLS_intrinsics;
42
- let __VLS_directives;
43
- __VLS_asFunctionalElement1(__VLS_intrinsics.div, __VLS_intrinsics.div)({
44
- ...{ class: "dropdown-button line-height-button" },
45
- ref: "wrapperRef",
46
- ...{ class: ({ 'is-open': __VLS_ctx.isOpen }) },
47
- });
48
- /** @type {__VLS_StyleScopedClasses['dropdown-button']} */ ;
49
- /** @type {__VLS_StyleScopedClasses['line-height-button']} */ ;
50
- /** @type {__VLS_StyleScopedClasses['is-open']} */ ;
51
- __VLS_asFunctionalElement1(__VLS_intrinsics.div, __VLS_intrinsics.div)({
52
- ...{ onClick: (...[$event]) => {
53
- __VLS_ctx.isOpen = !__VLS_ctx.isOpen;
54
- // @ts-ignore
55
- [isOpen, isOpen, isOpen,];
56
- } },
57
- ...{ class: "trigger" },
58
- });
59
- /** @type {__VLS_StyleScopedClasses['trigger']} */ ;
60
- __VLS_asFunctionalElement1(__VLS_intrinsics.div, __VLS_intrinsics.div)({
61
- ...{ class: "icon" },
62
- });
63
- /** @type {__VLS_StyleScopedClasses['icon']} */ ;
64
- __VLS_asFunctionalElement1(__VLS_intrinsics.svg, __VLS_intrinsics.svg)({
65
- xmlns: "http://www.w3.org/2000/svg",
66
- viewBox: "0 0 576 512",
67
- });
68
- __VLS_asFunctionalElement1(__VLS_intrinsics.path)({
69
- fill: "currentColor",
70
- stroke: "currentColor",
71
- 'stroke-width': "4",
72
- 'stroke-linecap': "round",
73
- 'stroke-linejoin': "round",
74
- d: "M40 32C17.9 32 0 49.9 0 72l0 56c0 17.7 14.3 32 32 32s32-14.3 32-32l0-32 64 0 0 320-32 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l128 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-32 0 0-320 64 0 0 32c0 17.7 14.3 32 32 32s32-14.3 32-32l0-56c0-22.1-17.9-40-40-40L40 32zM438.6 361.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l64 64c12.5 12.5 32.8 12.5 45.3 0l64-64c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-9.4 9.4 0-229.5 9.4 9.4c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-64-64c-6-6-14.1-9.4-22.6-9.4s-16.6 3.4-22.6 9.4l-64 64c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l9.4-9.4 0 229.5-9.4-9.4z",
75
- });
76
- __VLS_asFunctionalElement1(__VLS_intrinsics.span, __VLS_intrinsics.span)({
77
- ...{ class: "label" },
78
- });
79
- /** @type {__VLS_StyleScopedClasses['label']} */ ;
80
- (__VLS_ctx.sizeLabel);
81
- let __VLS_0;
82
- /** @ts-ignore @type {typeof __VLS_components.transition | typeof __VLS_components.Transition | typeof __VLS_components.transition | typeof __VLS_components.Transition} */
83
- transition;
84
- // @ts-ignore
85
- const __VLS_1 = __VLS_asFunctionalComponent1(__VLS_0, new __VLS_0({
86
- name: "dropdown",
87
- }));
88
- const __VLS_2 = __VLS_1({
89
- name: "dropdown",
90
- }, ...__VLS_functionalComponentArgsRest(__VLS_1));
91
- const { default: __VLS_5 } = __VLS_3.slots;
92
- __VLS_asFunctionalElement1(__VLS_intrinsics.div, __VLS_intrinsics.div)({
93
- ...{ class: "dropdown" },
94
- });
95
- __VLS_asFunctionalDirective(__VLS_directives.vShow, {})(null, { ...__VLS_directiveBindingRestFields, value: (__VLS_ctx.isOpen) }, null, null);
96
- /** @type {__VLS_StyleScopedClasses['dropdown']} */ ;
97
- for (const [size] of __VLS_vFor((__VLS_ctx.sizes))) {
98
- __VLS_asFunctionalElement1(__VLS_intrinsics.div, __VLS_intrinsics.div)({
99
- ...{ onClick: (...[$event]) => {
100
- __VLS_ctx.setLineHeight(size);
101
- // @ts-ignore
102
- [isOpen, sizeLabel, sizes, setLineHeight,];
103
- } },
104
- ...{ class: "item" },
105
- key: (size),
106
- ...{ class: ({ 'is-selected': __VLS_ctx.editor.isActive('textStyle', { lineHeight: size }) }) },
107
- });
108
- /** @type {__VLS_StyleScopedClasses['item']} */ ;
109
- /** @type {__VLS_StyleScopedClasses['is-selected']} */ ;
110
- __VLS_asFunctionalElement1(__VLS_intrinsics.span, __VLS_intrinsics.span)({
111
- ...{ class: "text" },
112
- });
113
- /** @type {__VLS_StyleScopedClasses['text']} */ ;
114
- (size);
115
- // @ts-ignore
116
- [editor,];
117
- }
118
- // @ts-ignore
119
- [];
120
- var __VLS_3;
121
- // @ts-ignore
122
- [];
123
- const __VLS_export = (await import('vue')).defineComponent({
124
- props: {
125
- editor: {
126
- type: Object,
127
- required: true
128
- }
129
- },
130
- });
131
- export default {};
@@ -1,44 +0,0 @@
1
- <template>
2
- <button
3
- class="icon-button"
4
- :class="{ 'active': editor.isActive('link') }"
5
- @click="setLink" >
6
-
7
- <div class="icon">
8
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512">
9
- <path fill="currentColor" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" d="M419.5 96c-16.6 0-32.7 4.5-46.8 12.7-15.8-16-34.2-29.4-54.5-39.5 28.2-24 64.1-37.2 101.3-37.2 86.4 0 156.5 70 156.5 156.5 0 41.5-16.5 81.3-45.8 110.6l-71.1 71.1c-29.3 29.3-69.1 45.8-110.6 45.8-86.4 0-156.5-70-156.5-156.5 0-1.5 0-3 .1-4.5 .5-17.7 15.2-31.6 32.9-31.1s31.6 15.2 31.1 32.9c0 .9 0 1.8 0 2.6 0 51.1 41.4 92.5 92.5 92.5 24.5 0 48-9.7 65.4-27.1l71.1-71.1c17.3-17.3 27.1-40.9 27.1-65.4 0-51.1-41.4-92.5-92.5-92.5zM275.2 173.3c-1.9-.8-3.8-1.9-5.5-3.1-12.6-6.5-27-10.2-42.1-10.2-24.5 0-48 9.7-65.4 27.1L91.1 258.2c-17.3 17.3-27.1 40.9-27.1 65.4 0 51.1 41.4 92.5 92.5 92.5 16.5 0 32.6-4.4 46.7-12.6 15.8 16 34.2 29.4 54.6 39.5-28.2 23.9-64 37.2-101.3 37.2-86.4 0-156.5-70-156.5-156.5 0-41.5 16.5-81.3 45.8-110.6l71.1-71.1c29.3-29.3 69.1-45.8 110.6-45.8 86.6 0 156.5 70.6 156.5 156.9 0 1.3 0 2.6 0 3.9-.4 17.7-15.1 31.6-32.8 31.2s-31.6-15.1-31.2-32.8c0-.8 0-1.5 0-2.3 0-33.7-18-63.3-44.8-79.6z"/>
10
- </svg>
11
- </div>
12
-
13
- <div class="tips">设置超链接</div>
14
- </button>
15
- </template>
16
-
17
-
18
- <script setup>
19
- const props = defineProps({
20
- editor: {
21
- type: Object,
22
- required: true
23
- }
24
- })
25
-
26
-
27
- const setLink = () => {
28
-
29
- if(props.editor.isActive('link')){
30
- props.editor.chain().focus().extendMarkRange('link').unsetLink().run()
31
- }else{
32
- const previousUrl = props.editor.getAttributes('link').href
33
- const url = window.prompt('请输入链接 URL', previousUrl)
34
- if (url === null) return
35
- if (url === '') {
36
- props.editor.chain().focus().extendMarkRange('link').unsetLink().run()
37
- return
38
- }
39
- props.editor.chain().focus().extendMarkRange('link').setLink({ href: url }).run()
40
- }
41
-
42
- }
43
-
44
- </script>
@@ -1,69 +0,0 @@
1
- const props = defineProps({
2
- editor: {
3
- type: Object,
4
- required: true
5
- }
6
- });
7
- const setLink = () => {
8
- if (props.editor.isActive('link')) {
9
- props.editor.chain().focus().extendMarkRange('link').unsetLink().run();
10
- }
11
- else {
12
- const previousUrl = props.editor.getAttributes('link').href;
13
- const url = window.prompt('请输入链接 URL', previousUrl);
14
- if (url === null)
15
- return;
16
- if (url === '') {
17
- props.editor.chain().focus().extendMarkRange('link').unsetLink().run();
18
- return;
19
- }
20
- props.editor.chain().focus().extendMarkRange('link').setLink({ href: url }).run();
21
- }
22
- };
23
- const __VLS_ctx = {
24
- ...{},
25
- ...{},
26
- ...{},
27
- ...{},
28
- };
29
- let __VLS_components;
30
- let __VLS_intrinsics;
31
- let __VLS_directives;
32
- __VLS_asFunctionalElement1(__VLS_intrinsics.button, __VLS_intrinsics.button)({
33
- ...{ onClick: (__VLS_ctx.setLink) },
34
- ...{ class: "icon-button" },
35
- ...{ class: ({ 'active': __VLS_ctx.editor.isActive('link') }) },
36
- });
37
- /** @type {__VLS_StyleScopedClasses['icon-button']} */ ;
38
- /** @type {__VLS_StyleScopedClasses['active']} */ ;
39
- __VLS_asFunctionalElement1(__VLS_intrinsics.div, __VLS_intrinsics.div)({
40
- ...{ class: "icon" },
41
- });
42
- /** @type {__VLS_StyleScopedClasses['icon']} */ ;
43
- __VLS_asFunctionalElement1(__VLS_intrinsics.svg, __VLS_intrinsics.svg)({
44
- xmlns: "http://www.w3.org/2000/svg",
45
- viewBox: "0 0 576 512",
46
- });
47
- __VLS_asFunctionalElement1(__VLS_intrinsics.path)({
48
- fill: "currentColor",
49
- stroke: "currentColor",
50
- 'stroke-width': "4",
51
- 'stroke-linecap': "round",
52
- 'stroke-linejoin': "round",
53
- d: "M419.5 96c-16.6 0-32.7 4.5-46.8 12.7-15.8-16-34.2-29.4-54.5-39.5 28.2-24 64.1-37.2 101.3-37.2 86.4 0 156.5 70 156.5 156.5 0 41.5-16.5 81.3-45.8 110.6l-71.1 71.1c-29.3 29.3-69.1 45.8-110.6 45.8-86.4 0-156.5-70-156.5-156.5 0-1.5 0-3 .1-4.5 .5-17.7 15.2-31.6 32.9-31.1s31.6 15.2 31.1 32.9c0 .9 0 1.8 0 2.6 0 51.1 41.4 92.5 92.5 92.5 24.5 0 48-9.7 65.4-27.1l71.1-71.1c17.3-17.3 27.1-40.9 27.1-65.4 0-51.1-41.4-92.5-92.5-92.5zM275.2 173.3c-1.9-.8-3.8-1.9-5.5-3.1-12.6-6.5-27-10.2-42.1-10.2-24.5 0-48 9.7-65.4 27.1L91.1 258.2c-17.3 17.3-27.1 40.9-27.1 65.4 0 51.1 41.4 92.5 92.5 92.5 16.5 0 32.6-4.4 46.7-12.6 15.8 16 34.2 29.4 54.6 39.5-28.2 23.9-64 37.2-101.3 37.2-86.4 0-156.5-70-156.5-156.5 0-41.5 16.5-81.3 45.8-110.6l71.1-71.1c29.3-29.3 69.1-45.8 110.6-45.8 86.6 0 156.5 70.6 156.5 156.9 0 1.3 0 2.6 0 3.9-.4 17.7-15.1 31.6-32.8 31.2s-31.6-15.1-31.2-32.8c0-.8 0-1.5 0-2.3 0-33.7-18-63.3-44.8-79.6z",
54
- });
55
- __VLS_asFunctionalElement1(__VLS_intrinsics.div, __VLS_intrinsics.div)({
56
- ...{ class: "tips" },
57
- });
58
- /** @type {__VLS_StyleScopedClasses['tips']} */ ;
59
- // @ts-ignore
60
- [setLink, editor,];
61
- const __VLS_export = (await import('vue')).defineComponent({
62
- props: {
63
- editor: {
64
- type: Object,
65
- required: true
66
- }
67
- },
68
- });
69
- export default {};
@@ -1,121 +0,0 @@
1
- <template>
2
-
3
- <div class="dropdown-button list-button" ref="wrapperRef">
4
- <div class="trigger" @click="isOpen = !isOpen" :class="{ 'open': isOpen, 'active': editor.isActive('orderedList') }">
5
- <div class="icon">
6
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
7
- <path fill="currentColor" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" d="M0 72C0 58.8 10.7 48 24 48l48 0c13.3 0 24 10.7 24 24l0 104 24 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l24 0 0-80-24 0C10.7 96 0 85.3 0 72zM30.4 301.2C41.8 292.6 55.7 288 70 288l4.9 0c33.7 0 61.1 27.4 61.1 61.1 0 19.6-9.4 37.9-25.2 49.4l-24 17.5 33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-90.7 0C13.1 464 0 450.9 0 434.7 0 425.3 4.5 416.5 12.1 411l70.5-51.3c3.4-2.5 5.4-6.4 5.4-10.6 0-7.2-5.9-13.1-13.1-13.1L70 336c-3.9 0-7.7 1.3-10.8 3.6L38.4 355.2c-10.6 8-25.6 5.8-33.6-4.8S-1 324.8 9.6 316.8l20.8-15.6zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"/></svg>
8
- </div>
9
- </div>
10
-
11
- <transition name="dropdown">
12
- <div class="dropdown" v-show="isOpen">
13
- <div
14
- class="item"
15
- v-for="item in list"
16
- :key="item.value"
17
- :class="{ 'is-selected': editor.isActive('orderedList') && editor.getAttributes('orderedList').listStyleType === item.value }"
18
- @click="setOrderedListStyle(item.value)">
19
- <div class="icon">{{item.icon}}</div>
20
- <span class="text">{{ item.label }}</span>
21
- </div>
22
- </div>
23
- </transition>
24
- </div>
25
-
26
- </template>
27
-
28
-
29
- <script setup>
30
- import { ref, computed, onMounted, onBeforeUnmount } from 'vue'
31
-
32
-
33
- const isOpen = ref(false)
34
- const wrapperRef = ref(null)
35
-
36
- const list = [
37
- { icon: '1', label: '1. 2. 3.', value: 'decimal' },
38
- { icon: '01', label: '01. 02. 03.', value: 'decimal-leading-zero' },
39
- { icon: 'a', label: 'a. b. c.', value: 'lower-alpha' },
40
- { icon: 'A', label: 'A. B. C.', value: 'upper-alpha' },
41
- { icon: 'i', label: 'i. ii. iii.', value: 'lower-roman' },
42
- { icon: 'I', label: 'I. II. III.', value: 'upper-roman' },
43
- { icon: '一', label: '一 二 三', value: 'cjk-ideographic' },
44
- { icon: '壹', label: '壹 贰 叁', value: 'simp-chinese-formal' },
45
- { icon: '', label: '取消列表', value: 'none' }
46
- ]
47
-
48
-
49
-
50
-
51
- const setOrderedListStyle = (value) => {
52
- if(props.editor.isActive('orderedList') && value != 'none'){
53
- props.editor.chain().focus()
54
- .updateAttributes('orderedList', { listStyleType: value })
55
- .run()
56
- }else{
57
- props.editor.chain().focus()
58
- .toggleOrderedList()
59
- .updateAttributes('orderedList', { listStyleType: value })
60
- .run()
61
- }
62
- isOpen.value = false
63
- }
64
-
65
-
66
-
67
-
68
- const props = defineProps({
69
- editor: {
70
- type: Object,
71
- required: true
72
- }
73
- })
74
-
75
- const handleClickOutside = (e) => {
76
- if (!wrapperRef.value) return
77
-
78
- if (!wrapperRef.value.contains(e.target)) {
79
- isOpen.value = false
80
- }
81
- }
82
-
83
- onMounted(() => {
84
- document.addEventListener('mousedown', handleClickOutside)
85
- })
86
-
87
- onBeforeUnmount(() => {
88
- document.removeEventListener('mousedown', handleClickOutside)
89
- })
90
-
91
- </script>
92
-
93
-
94
- <style lang="scss" scoped>
95
-
96
- .list-button {
97
- width: auto;
98
- .dropdown {
99
- .item {
100
- .icon {
101
- display: inline-flex;
102
- align-items: center;
103
- justify-content: center;
104
- margin-right: 5px;
105
- width: 15px;
106
- height: 15px;
107
- border-radius: 3px;
108
- font-size: 12px;
109
- font-weight: bold;
110
- transform: scale(0.8);
111
- padding: 0;
112
- background: rgba($color: #000000, $alpha: 0.2);
113
- }
114
- }
115
- }
116
- }
117
-
118
- </style>
119
-
120
-
121
-
@@ -1,146 +0,0 @@
1
- import { ref, computed, onMounted, onBeforeUnmount } from 'vue';
2
- const isOpen = ref(false);
3
- const wrapperRef = ref(null);
4
- const list = [
5
- { icon: '1', label: '1. 2. 3.', value: 'decimal' },
6
- { icon: '01', label: '01. 02. 03.', value: 'decimal-leading-zero' },
7
- { icon: 'a', label: 'a. b. c.', value: 'lower-alpha' },
8
- { icon: 'A', label: 'A. B. C.', value: 'upper-alpha' },
9
- { icon: 'i', label: 'i. ii. iii.', value: 'lower-roman' },
10
- { icon: 'I', label: 'I. II. III.', value: 'upper-roman' },
11
- { icon: '一', label: '一 二 三', value: 'cjk-ideographic' },
12
- { icon: '壹', label: '壹 贰 叁', value: 'simp-chinese-formal' },
13
- { icon: '', label: '取消列表', value: 'none' }
14
- ];
15
- const setOrderedListStyle = (value) => {
16
- if (props.editor.isActive('orderedList') && value != 'none') {
17
- props.editor.chain().focus()
18
- .updateAttributes('orderedList', { listStyleType: value })
19
- .run();
20
- }
21
- else {
22
- props.editor.chain().focus()
23
- .toggleOrderedList()
24
- .updateAttributes('orderedList', { listStyleType: value })
25
- .run();
26
- }
27
- isOpen.value = false;
28
- };
29
- const props = defineProps({
30
- editor: {
31
- type: Object,
32
- required: true
33
- }
34
- });
35
- const handleClickOutside = (e) => {
36
- if (!wrapperRef.value)
37
- return;
38
- if (!wrapperRef.value.contains(e.target)) {
39
- isOpen.value = false;
40
- }
41
- };
42
- onMounted(() => {
43
- document.addEventListener('mousedown', handleClickOutside);
44
- });
45
- onBeforeUnmount(() => {
46
- document.removeEventListener('mousedown', handleClickOutside);
47
- });
48
- const __VLS_ctx = {
49
- ...{},
50
- ...{},
51
- ...{},
52
- ...{},
53
- };
54
- let __VLS_components;
55
- let __VLS_intrinsics;
56
- let __VLS_directives;
57
- __VLS_asFunctionalElement1(__VLS_intrinsics.div, __VLS_intrinsics.div)({
58
- ...{ class: "dropdown-button list-button" },
59
- ref: "wrapperRef",
60
- });
61
- /** @type {__VLS_StyleScopedClasses['dropdown-button']} */ ;
62
- /** @type {__VLS_StyleScopedClasses['list-button']} */ ;
63
- __VLS_asFunctionalElement1(__VLS_intrinsics.div, __VLS_intrinsics.div)({
64
- ...{ onClick: (...[$event]) => {
65
- __VLS_ctx.isOpen = !__VLS_ctx.isOpen;
66
- // @ts-ignore
67
- [isOpen, isOpen,];
68
- } },
69
- ...{ class: "trigger" },
70
- ...{ class: ({ 'open': __VLS_ctx.isOpen, 'active': __VLS_ctx.editor.isActive('orderedList') }) },
71
- });
72
- /** @type {__VLS_StyleScopedClasses['trigger']} */ ;
73
- /** @type {__VLS_StyleScopedClasses['open']} */ ;
74
- /** @type {__VLS_StyleScopedClasses['active']} */ ;
75
- __VLS_asFunctionalElement1(__VLS_intrinsics.div, __VLS_intrinsics.div)({
76
- ...{ class: "icon" },
77
- });
78
- /** @type {__VLS_StyleScopedClasses['icon']} */ ;
79
- __VLS_asFunctionalElement1(__VLS_intrinsics.svg, __VLS_intrinsics.svg)({
80
- xmlns: "http://www.w3.org/2000/svg",
81
- viewBox: "0 0 512 512",
82
- });
83
- __VLS_asFunctionalElement1(__VLS_intrinsics.path)({
84
- fill: "currentColor",
85
- stroke: "currentColor",
86
- 'stroke-width': "4",
87
- 'stroke-linecap': "round",
88
- 'stroke-linejoin': "round",
89
- d: "M0 72C0 58.8 10.7 48 24 48l48 0c13.3 0 24 10.7 24 24l0 104 24 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l24 0 0-80-24 0C10.7 96 0 85.3 0 72zM30.4 301.2C41.8 292.6 55.7 288 70 288l4.9 0c33.7 0 61.1 27.4 61.1 61.1 0 19.6-9.4 37.9-25.2 49.4l-24 17.5 33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-90.7 0C13.1 464 0 450.9 0 434.7 0 425.3 4.5 416.5 12.1 411l70.5-51.3c3.4-2.5 5.4-6.4 5.4-10.6 0-7.2-5.9-13.1-13.1-13.1L70 336c-3.9 0-7.7 1.3-10.8 3.6L38.4 355.2c-10.6 8-25.6 5.8-33.6-4.8S-1 324.8 9.6 316.8l20.8-15.6zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z",
90
- });
91
- let __VLS_0;
92
- /** @ts-ignore @type {typeof __VLS_components.transition | typeof __VLS_components.Transition | typeof __VLS_components.transition | typeof __VLS_components.Transition} */
93
- transition;
94
- // @ts-ignore
95
- const __VLS_1 = __VLS_asFunctionalComponent1(__VLS_0, new __VLS_0({
96
- name: "dropdown",
97
- }));
98
- const __VLS_2 = __VLS_1({
99
- name: "dropdown",
100
- }, ...__VLS_functionalComponentArgsRest(__VLS_1));
101
- const { default: __VLS_5 } = __VLS_3.slots;
102
- __VLS_asFunctionalElement1(__VLS_intrinsics.div, __VLS_intrinsics.div)({
103
- ...{ class: "dropdown" },
104
- });
105
- __VLS_asFunctionalDirective(__VLS_directives.vShow, {})(null, { ...__VLS_directiveBindingRestFields, value: (__VLS_ctx.isOpen) }, null, null);
106
- /** @type {__VLS_StyleScopedClasses['dropdown']} */ ;
107
- for (const [item] of __VLS_vFor((__VLS_ctx.list))) {
108
- __VLS_asFunctionalElement1(__VLS_intrinsics.div, __VLS_intrinsics.div)({
109
- ...{ onClick: (...[$event]) => {
110
- __VLS_ctx.setOrderedListStyle(item.value);
111
- // @ts-ignore
112
- [isOpen, isOpen, editor, list, setOrderedListStyle,];
113
- } },
114
- ...{ class: "item" },
115
- key: (item.value),
116
- ...{ class: ({ 'is-selected': __VLS_ctx.editor.isActive('orderedList') && __VLS_ctx.editor.getAttributes('orderedList').listStyleType === item.value }) },
117
- });
118
- /** @type {__VLS_StyleScopedClasses['item']} */ ;
119
- /** @type {__VLS_StyleScopedClasses['is-selected']} */ ;
120
- __VLS_asFunctionalElement1(__VLS_intrinsics.div, __VLS_intrinsics.div)({
121
- ...{ class: "icon" },
122
- });
123
- /** @type {__VLS_StyleScopedClasses['icon']} */ ;
124
- (item.icon);
125
- __VLS_asFunctionalElement1(__VLS_intrinsics.span, __VLS_intrinsics.span)({
126
- ...{ class: "text" },
127
- });
128
- /** @type {__VLS_StyleScopedClasses['text']} */ ;
129
- (item.label);
130
- // @ts-ignore
131
- [editor, editor,];
132
- }
133
- // @ts-ignore
134
- [];
135
- var __VLS_3;
136
- // @ts-ignore
137
- [];
138
- const __VLS_export = (await import('vue')).defineComponent({
139
- props: {
140
- editor: {
141
- type: Object,
142
- required: true
143
- }
144
- },
145
- });
146
- export default {};
@@ -1,29 +0,0 @@
1
- <template>
2
- <button
3
- class="icon-button"
4
- :disabled="!editor.can().redo()"
5
- @click="editor.chain().focus().redo().run()" >
6
-
7
- <div class="icon">
8
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
9
- <path fill="currentColor" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" d="M488 192l-144 0c-9.7 0-18.5-5.8-22.2-14.8s-1.7-19.3 5.2-26.2l46.7-46.7c-75.3-58.6-184.3-53.3-253.5 15.9-75 75-75 196.5 0 271.5s196.5 75 271.5 0c8.2-8.2 15.5-16.9 21.9-26.1 10.1-14.5 30.1-18 44.6-7.9s18 30.1 7.9 44.6c-8.5 12.2-18.2 23.8-29.1 34.7-100 100-262.1 100-362 0S-25 175 75 75c94.3-94.3 243.7-99.6 344.3-16.2L471 7c6.9-6.9 17.2-8.9 26.2-5.2S512 14.3 512 24l0 144c0 13.3-10.7 24-24 24z"/>
10
- </svg>
11
- </div>
12
-
13
- <div class="tips">撤销</div>
14
- </button>
15
- </template>
16
-
17
-
18
- <script setup>
19
- const props = defineProps({
20
- editor: {
21
- type: Object,
22
- required: true
23
- }
24
- })
25
-
26
-
27
-
28
- </script>
29
-
@@ -1,55 +0,0 @@
1
- const props = defineProps({
2
- editor: {
3
- type: Object,
4
- required: true
5
- }
6
- });
7
- const __VLS_ctx = {
8
- ...{},
9
- ...{},
10
- ...{},
11
- };
12
- let __VLS_components;
13
- let __VLS_intrinsics;
14
- let __VLS_directives;
15
- __VLS_asFunctionalElement1(__VLS_intrinsics.button, __VLS_intrinsics.button)({
16
- ...{ onClick: (...[$event]) => {
17
- __VLS_ctx.editor.chain().focus().redo().run();
18
- // @ts-ignore
19
- [editor,];
20
- } },
21
- ...{ class: "icon-button" },
22
- disabled: (!__VLS_ctx.editor.can().redo()),
23
- });
24
- /** @type {__VLS_StyleScopedClasses['icon-button']} */ ;
25
- __VLS_asFunctionalElement1(__VLS_intrinsics.div, __VLS_intrinsics.div)({
26
- ...{ class: "icon" },
27
- });
28
- /** @type {__VLS_StyleScopedClasses['icon']} */ ;
29
- __VLS_asFunctionalElement1(__VLS_intrinsics.svg, __VLS_intrinsics.svg)({
30
- xmlns: "http://www.w3.org/2000/svg",
31
- viewBox: "0 0 512 512",
32
- });
33
- __VLS_asFunctionalElement1(__VLS_intrinsics.path)({
34
- fill: "currentColor",
35
- stroke: "currentColor",
36
- 'stroke-width': "4",
37
- 'stroke-linecap': "round",
38
- 'stroke-linejoin': "round",
39
- d: "M488 192l-144 0c-9.7 0-18.5-5.8-22.2-14.8s-1.7-19.3 5.2-26.2l46.7-46.7c-75.3-58.6-184.3-53.3-253.5 15.9-75 75-75 196.5 0 271.5s196.5 75 271.5 0c8.2-8.2 15.5-16.9 21.9-26.1 10.1-14.5 30.1-18 44.6-7.9s18 30.1 7.9 44.6c-8.5 12.2-18.2 23.8-29.1 34.7-100 100-262.1 100-362 0S-25 175 75 75c94.3-94.3 243.7-99.6 344.3-16.2L471 7c6.9-6.9 17.2-8.9 26.2-5.2S512 14.3 512 24l0 144c0 13.3-10.7 24-24 24z",
40
- });
41
- __VLS_asFunctionalElement1(__VLS_intrinsics.div, __VLS_intrinsics.div)({
42
- ...{ class: "tips" },
43
- });
44
- /** @type {__VLS_StyleScopedClasses['tips']} */ ;
45
- // @ts-ignore
46
- [editor,];
47
- const __VLS_export = (await import('vue')).defineComponent({
48
- props: {
49
- editor: {
50
- type: Object,
51
- required: true
52
- }
53
- },
54
- });
55
- export default {};