Skip to content

Commit d02e2b9

Browse files
authored
feat: solve the problem of losing content style when copying from Excel (#466)
* feat: solve the problem of losing content style when copying from Excel * fix: review and modify issues
1 parent 89c3006 commit d02e2b9

5 files changed

Lines changed: 77 additions & 29 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
3+
import { onMounted, ref } from 'vue'
4+
import 'quill-table-up/index.css'
5+
import 'quill-table-up/table-creator.css'
6+
7+
let editorContextmenu: FluentEditor
8+
let editorSelect: FluentEditor
9+
const editorContextmenuRef = ref<HTMLElement>()
10+
11+
onMounted(async () => {
12+
// ssr compat, reference: https://vitepress.dev/guide/ssr-compat#importing-in-mounted-hook
13+
const [
14+
{ default: FluentEditor, DEFAULT_TOOLBAR, generateTableUp },
15+
{ defaultCustomSelect, TableMenuContextmenu, TableSelection, TableUp },
16+
] = await Promise.all([
17+
import('@opentiny/fluent-editor'),
18+
import('quill-table-up'),
19+
])
20+
21+
FluentEditor.register({ 'modules/table-up': generateTableUp(TableUp) }, true)
22+
if (editorContextmenuRef.value) {
23+
editorContextmenu = new FluentEditor(editorContextmenuRef.value, {
24+
theme: 'snow',
25+
modules: {
26+
'toolbar': [
27+
...DEFAULT_TOOLBAR,
28+
[{ 'table-up': [] }],
29+
],
30+
'table-up': {
31+
customSelect: defaultCustomSelect,
32+
pasteStyleSheet: true,
33+
pasteDefaultTagStyle: false,
34+
modules: [
35+
{ module: TableSelection },
36+
{ module: TableMenuContextmenu },
37+
],
38+
},
39+
},
40+
})
41+
}
42+
})
43+
</script>
44+
45+
<template>
46+
<div>
47+
<p>
48+
主要针对从 Excel 粘贴内容时,quill-table-up从3.5.0版本新增的选项 pasteStyleSheet,配置为 true 会将粘贴的 html 中 style 标签的样式也进行解析。
49+
如果你希望保留粘贴 html 中通过标签选择器设置的样式,可以将 pasteDefaultTagStyle 也设置为 true。
50+
</p>
51+
<p> 请注意:如果开启了配置 pasteStyleSheet,可能会对粘贴时的解析性能造成一定影响,因为会对整个粘贴的文档进行额外的解析。</p>
52+
<div ref="editorContextmenuRef" />
53+
</div>
54+
</template>

packages/docs/fluent-editor/docs/demo/table-up.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ npm install quill-table-up
1919
## 快捷菜单配置
2020

2121
<demo vue="../../demos/table-up-shortcut.vue" />
22+
23+
## 表格剪粘板
24+
25+
<demo vue="../../demos/table-up-clipboard.vue" />

packages/docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"quill-cursors": "^4.0.3",
2828
"quill-header-list": "0.0.2",
2929
"quill-markdown-shortcuts": "^0.0.10",
30-
"quill-table-up": "^3.4.0",
30+
"quill-table-up": "^3.5.0",
3131
"quill-toolbar-tip": "1.1.0",
3232
"simple-mind-map": "0.14.0-fix.1",
3333
"simple-mind-map-plugin-themes": "^1.0.1",

packages/projects/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@tailwindcss/vite": "^4.0.0",
1616
"quill-cursors": "^4.0.4",
1717
"quill-header-list": "0.0.2",
18-
"quill-table-up": "^3.0.1",
18+
"quill-table-up": "^3.5.0",
1919
"sass": "^1.90.0",
2020
"simple-mind-map": "0.14.0-fix.1",
2121
"simple-mind-map-plugin-themes": "^1.0.1",

pnpm-lock.yaml

Lines changed: 17 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)