vue-editify 0.2.27 → 0.2.29

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,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-editify",
3
- "version": "0.2.27",
3
+ "version": "0.2.29",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "*.css"
@@ -17,7 +17,7 @@
17
17
  "lib": "vue-tsc && vite build"
18
18
  },
19
19
  "dependencies": {
20
- "alex-editor": "^1.5.0",
20
+ "alex-editor": "^1.5.1",
21
21
  "dap-util": "^1.5.8",
22
22
  "highlight.js": "^11.8.0",
23
23
  "katex": "^0.16.10",
@@ -84,8 +84,6 @@
84
84
  line-height: 1.5;
85
85
  color: var(--editify-font-color-dark);
86
86
  font-size: var(--editify-font-size);
87
- position: relative;
88
- line-height: 1.5;
89
87
  overflow-wrap: break-word;
90
88
 
91
89
  //显示占位符
@@ -1,18 +1,28 @@
1
1
  <template>
2
- <div class="editify" :class="{ 'editify-fullscreen': isFullScreen, 'editify-autoheight': !isFullScreen && isAutoHeight }" :style="{ zIndex: zIndex, paddingTop: isFullScreen ? '' : (offset || '') + 'px' }" ref="elRef">
2
+ <div class="editify"
3
+ :class="{ 'editify-fullscreen': isFullScreen, 'editify-autoheight': !isFullScreen && isAutoHeight }"
4
+ :style="{ zIndex: zIndex, paddingTop: isFullScreen ? '' : (offset || '') + 'px' }" ref="elRef">
3
5
  <!-- 菜单区域 -->
4
- <Menu ref="menuRef" v-if="menuConfig.use && editor" :config="menuConfig" :color="color" :z-index="zIndex + 1"></Menu>
6
+ <Menu ref="menuRef" v-if="menuConfig.use && editor" :config="menuConfig" :color="color" :z-index="zIndex + 1">
7
+ </Menu>
5
8
  <!-- 编辑层,与编辑区域宽高相同必须适配 -->
6
- <div ref="bodyRef" class="editify-body" :class="{ 'editify-border': showBorder, 'editify-menu_inner': menuConfig.use && menuConfig.mode == 'inner' }" :data-editify-uid="instance.uid">
9
+ <div ref="bodyRef" class="editify-body"
10
+ :class="{ 'editify-border': showBorder, 'editify-menu_inner': menuConfig.use && menuConfig.mode == 'inner' }"
11
+ :data-editify-uid="instance.uid">
7
12
  <!-- 编辑器 -->
8
- <div ref="contentRef" class="editify-content" :class="{ 'editify-placeholder': showPlaceholder, 'editify-disabled': isDisabled }" @click="handleEditorClick" @compositionstart="isInputChinese = true" @compositionend="isInputChinese = false" :data-editify-placeholder="placeholder" tabindex="-1"></div>
13
+ <div ref="contentRef" class="editify-content"
14
+ :class="{ 'editify-placeholder': showPlaceholder, 'editify-disabled': isDisabled }" @click="handleEditorClick"
15
+ @compositionstart="isInputChinese = true" @compositionend="isInputChinese = false"
16
+ :data-editify-placeholder="placeholder" tabindex="-1"></div>
9
17
  <!-- 代码视图 -->
10
18
  <textarea v-if="isSourceView" :value="value" readonly class="editify-sourceview" />
11
19
  <!-- 工具条 -->
12
- <Toolbar ref="toolbarRef" v-model="toolbarOptions.show" :node="toolbarOptions.node!" :type="toolbarOptions.type" :scroll-node="contentRef!" :config="toolbarConfig" :color="color" :z-index="zIndex + 10"></Toolbar>
20
+ <Toolbar ref="toolbarRef" v-model="toolbarOptions.show" :node="toolbarOptions.node!" :type="toolbarOptions.type"
21
+ :scroll-node="contentRef!" :config="toolbarConfig" :color="color" :z-index="zIndex + 10"></Toolbar>
13
22
  </div>
14
23
  <!-- 编辑器尾部 -->
15
- <div v-if="showWordLength" class="editify-footer" :class="{ 'editify-fullscreen': isFullScreen && !isSourceView }" :style="{ zIndex: zIndex + 1 }">
24
+ <div v-if="showWordLength" class="editify-footer" :class="{ 'editify-fullscreen': isFullScreen && !isSourceView }"
25
+ :style="{ zIndex: zIndex + 1 }">
16
26
  <!-- 字数统计 -->
17
27
  <div class="editify-footer-words">{{ $editTrans('totalWordCount') }}{{ textValue.length }}</div>
18
28
  </div>
@@ -343,9 +353,11 @@ const createEditor = () => {
343
353
  //dom渲染
344
354
  editor.value.domRender()
345
355
  //自动获取焦点
346
- if (props.autofocus && !isSourceView.value && !isDisabled.value) {
347
- collapseToEnd()
348
- }
356
+ nextTick(() => {
357
+ if (props.autofocus && !isSourceView.value && !isDisabled.value) {
358
+ collapseToEnd()
359
+ }
360
+ })
349
361
  }
350
362
  //设定编辑器内的视频高度
351
363
  const setVideoHeight = () => {
@@ -1,10 +1,15 @@
1
1
  <template>
2
- <div ref="menuRef" class="editify-menu" :class="{ 'editify-border': menuShowBorder, 'editify-source': isSourceView && menuMode == 'inner', 'editify-fullscreen': isFullScreen }" :data-editify-mode="menuMode" :style="{ zIndex: zIndex, ...(config.style || {}) }">
2
+ <div ref="menuRef" class="editify-menu"
3
+ :class="{ 'editify-border': menuShowBorder, 'editify-source': isSourceView && menuMode == 'inner', 'editify-fullscreen': isFullScreen }"
4
+ :data-editify-mode="menuMode" :style="{ zIndex: zIndex, ...(config.style || {}) }">
3
5
  <template v-for="item in menuNames">
4
6
  <!-- 内置菜单按钮 -->
5
- <component :ref="(el:MenuItemComponentPublicInstance) => (menuItemRefs[item] = el)" v-if="!!currentDefaultMenu(item)" :is="currentDefaultMenu(item)" :color="color" :z-index="zIndex + 1" :config="(config as any)[item]" :disabled="isDisabled || !rangeKey" :tooltip="config.tooltip!"></component>
7
+ <component :ref="(el) => (menuItemRefs[item] = el as MenuItemComponentPublicInstance)"
8
+ v-if="!!currentDefaultMenu(item)" :is="currentDefaultMenu(item)" :color="color" :z-index="zIndex + 1"
9
+ :config="(config as any)[item]" :disabled="isDisabled || !rangeKey" :tooltip="config.tooltip!"></component>
6
10
  <!-- 拓展菜单按钮 -->
7
- <ExtendMenuButton v-else :ref="el => (menuItemRefs[item] = (el as MenuItemComponentPublicInstance))" :name="item" />
11
+ <ExtendMenuButton v-else :ref="el => (menuItemRefs[item] = (el as MenuItemComponentPublicInstance))"
12
+ :name="item" />
8
13
  </template>
9
14
  </div>
10
15
  </template>
@@ -127,73 +132,73 @@ const ExtendMenuButton = defineComponent(
127
132
  return () => {
128
133
  return configuration
129
134
  ? h(
130
- Button,
131
- {
132
- ref: btnRef,
133
- name: extendProps.name,
134
- tooltip: props.config.tooltip,
135
- color: props.color,
136
- zIndex: props.zIndex + 1,
137
- type: configuration.type || 'default',
138
- title: `${configuration.title || ''}${configuration.shortcut?.title ? `【${configuration.shortcut?.title}】` : ''}`,
139
- leftBorder: configuration.leftBorder || false,
140
- rightBorder: configuration.rightBorder || false,
141
- hideScroll: configuration.hideScroll || false,
142
- disabled: isDisabled.value || !rangeKey.value || configuration.disabled,
143
- active: configuration.active || false,
144
- selectConfig: {
145
- width: configuration.width,
146
- maxHeight: configuration.maxHeight,
147
- options: configuration.options
148
- },
149
- displayConfig: {
150
- width: configuration.width,
151
- maxHeight: configuration.maxHeight,
152
- value: configuration.value,
153
- options: configuration.options
154
- },
155
- onLayerShow: () => {
156
- if (typeof configuration.onLayerShow == 'function') {
157
- configuration.onLayerShow(extendProps.name, btnRef.value!)
158
- }
159
- },
160
- onLayerShown: () => {
161
- if (typeof configuration.onLayerShown == 'function') {
162
- configuration.onLayerShown(extendProps.name, btnRef.value!)
163
- }
164
- },
165
- onLayerHidden: () => {
166
- if (typeof configuration.onLayerHidden == 'function') {
167
- configuration.onLayerHidden(extendProps.name, btnRef.value!)
168
- }
169
- },
170
- onOperate: (name, val) => {
171
- if (typeof configuration.onOperate == 'function') {
172
- configuration.onOperate(name, val, btnRef.value!)
173
- }
135
+ Button,
136
+ {
137
+ ref: btnRef,
138
+ name: extendProps.name,
139
+ tooltip: props.config.tooltip,
140
+ color: props.color,
141
+ zIndex: props.zIndex + 1,
142
+ type: configuration.type || 'default',
143
+ title: `${configuration.title || ''}${configuration.shortcut?.title ? `【${configuration.shortcut?.title}】` : ''}`,
144
+ leftBorder: configuration.leftBorder || false,
145
+ rightBorder: configuration.rightBorder || false,
146
+ hideScroll: configuration.hideScroll || false,
147
+ disabled: isDisabled.value || !rangeKey.value || configuration.disabled,
148
+ active: configuration.active || false,
149
+ selectConfig: {
150
+ width: configuration.width,
151
+ maxHeight: configuration.maxHeight,
152
+ options: configuration.options
153
+ },
154
+ displayConfig: {
155
+ width: configuration.width,
156
+ maxHeight: configuration.maxHeight,
157
+ value: configuration.value,
158
+ options: configuration.options
159
+ },
160
+ onLayerShow: () => {
161
+ if (typeof configuration.onLayerShow == 'function') {
162
+ configuration.onLayerShow(extendProps.name, btnRef.value!)
163
+ }
164
+ },
165
+ onLayerShown: () => {
166
+ if (typeof configuration.onLayerShown == 'function') {
167
+ configuration.onLayerShown(extendProps.name, btnRef.value!)
168
+ }
169
+ },
170
+ onLayerHidden: () => {
171
+ if (typeof configuration.onLayerHidden == 'function') {
172
+ configuration.onLayerHidden(extendProps.name, btnRef.value!)
173
+ }
174
+ },
175
+ onOperate: (name, val) => {
176
+ if (typeof configuration.onOperate == 'function') {
177
+ configuration.onOperate(name, val, btnRef.value!)
178
+ }
179
+ }
180
+ },
181
+ {
182
+ default: () => {
183
+ if (configuration.default) {
184
+ return configuration.default(extendProps.name, btnRef.value!)
185
+ }
186
+ return null
187
+ },
188
+ layer: () => {
189
+ if (configuration.layer) {
190
+ return configuration.layer(extendProps.name, btnRef.value!)
174
191
  }
192
+ return null
175
193
  },
176
- {
177
- default: () => {
178
- if (configuration.default) {
179
- return configuration.default(extendProps.name, btnRef.value!)
180
- }
181
- return null
182
- },
183
- layer: () => {
184
- if (configuration.layer) {
185
- return configuration.layer(extendProps.name, btnRef.value!)
186
- }
187
- return null
188
- },
189
- option: () => {
190
- if (configuration.option) {
191
- return configuration.option(extendProps.name, btnRef.value!)
192
- }
193
- return null
194
+ option: () => {
195
+ if (configuration.option) {
196
+ return configuration.option(extendProps.name, btnRef.value!)
194
197
  }
198
+ return null
195
199
  }
196
- )
200
+ }
201
+ )
197
202
  : null
198
203
  }
199
204
  },
@@ -205,9 +205,18 @@ export const TableToolbar = defineComponent(
205
205
  editor.value.range!.anchor.element = editor.value.range!.focus.element
206
206
  editor.value.range!.anchor.offset = editor.value.range!.focus.offset
207
207
  }
208
- const row = getMatchElementByRange(editor.value, dataRangeCaches.value, { parsedom: 'tr' })
209
- if (row) {
208
+ const cell = getMatchElementByRange(editor.value, dataRangeCaches.value, { parsedom: 'td' })
209
+ if (cell) {
210
+ const { rowspan } = getCellSpanNumber(cell)
211
+ let row = cell.parent!
210
212
  const tbody = row.parent!
213
+ if (type == 'down') {
214
+ let i = 1
215
+ while (i < rowspan) {
216
+ row = editor.value.getNextElement(row)!
217
+ i++
218
+ }
219
+ }
211
220
  const { columnNumber } = getTableSize(tbody.children!)
212
221
  const children: AlexElementCreateConfigType[] = []
213
222
  for (let i = 0; i < columnNumber; i++) {
package/src/index.ts CHANGED
@@ -5,11 +5,11 @@ import { withInstall } from '@/core/tool'
5
5
  //重写AlexElement.isPreStyle,将td加入到代码块样式中去
6
6
  const originFn = AlexElement.prototype.isPreStyle
7
7
  AlexElement.prototype.isPreStyle = function () {
8
- const block = this.getInblock() || this.getBlock()
9
- if (block.parsedom == 'td') {
10
- return true
11
- }
12
- return originFn.apply(this)
8
+ const block = this.getInblock() || this.getBlock()
9
+ if (block.parsedom == 'td') {
10
+ return true
11
+ }
12
+ return originFn.apply(this)
13
13
  }
14
14
 
15
15
  //引入根节点颜色变量样式
@@ -40,67 +40,14 @@ export type * from '@/editify/menu'
40
40
  export type * from '@/editify/toolbar'
41
41
 
42
42
  //导出编辑器操作方法
43
- export {
44
- elementIsMatch,
45
- getMatchElementByElement,
46
- getMatchElementByRange,
47
- elementIsList,
48
- getListByElement,
49
- hasListInRange,
50
- rangeIsInList,
51
- elementIsTask,
52
- getTaskByElement,
53
- hasTaskInRange,
54
- rangeIsInTask,
55
- elementIsAttachment,
56
- hasAttachmentInRange,
57
- elementIsMathformula,
58
- getMathformulaByElement,
59
- hasMathformulaInRange,
60
- elementIsInfoBlock,
61
- getInfoBlockByElement,
62
- hasInfoBlockInRange,
63
- rangeIsInInfoBlock,
64
- hasPreInRange,
65
- hasTableInRange,
66
- hasQuoteInRange,
67
- rangeIsInQuote,
68
- hasLinkInRange,
69
- hasImageInRange,
70
- hasVideoInRange,
71
- queryTextStyle,
72
- setTextStyle,
73
- removeTextStyle,
74
- queryTextMark,
75
- setTextMark,
76
- removeTextMark,
77
- getRangeText,
78
- addSpaceTextToBothSides,
79
- setHeading,
80
- setIndentIncrease,
81
- setIndentDecrease,
82
- setQuote,
83
- setAlign,
84
- setList,
85
- setTask,
86
- setLineHeight,
87
- insertLink,
88
- insertImage,
89
- insertVideo,
90
- insertTable,
91
- insertCodeBlock,
92
- insertSeparator,
93
- insertAttachment,
94
- insertMathformula,
95
- insertInfoBlock
96
- } from '@/core/function'
43
+ export { elementIsMatch, getMatchElementByElement, getMatchElementByRange, elementIsList, getListByElement, hasListInRange, rangeIsInList, elementIsTask, getTaskByElement, hasTaskInRange, rangeIsInTask, elementIsAttachment, hasAttachmentInRange, elementIsMathformula, getMathformulaByElement, hasMathformulaInRange, elementIsInfoBlock, getInfoBlockByElement, hasInfoBlockInRange, rangeIsInInfoBlock, hasPreInRange, hasTableInRange, hasQuoteInRange, rangeIsInQuote, hasLinkInRange, hasImageInRange, hasVideoInRange, queryTextStyle, setTextStyle, removeTextStyle, queryTextMark, setTextMark, removeTextMark, getRangeText, addSpaceTextToBothSides, setHeading, setIndentIncrease, setIndentDecrease, setQuote, setAlign, setList, setTask, setLineHeight, insertLink, insertImage, insertVideo, insertTable, insertCodeBlock, insertSeparator, insertAttachment, insertMathformula, insertInfoBlock } from '@/core/function'
97
44
 
98
45
  //安装函数
99
46
  const install = (app: App) => {
100
- app.component(Editify.name!, Editify)
47
+ app.component(Editify.name!, Editify)
101
48
  }
102
49
  //版本号
103
- const version = '0.2.27'
50
+ const version = '0.2.29'
104
51
 
105
52
  //导出组件和安装函数
106
53
  export { Editify as default, Editify, install, AlexElement, version }