|
@@ -1049,17 +1049,36 @@ export default {
|
|
|
this.$refs.articel.addEventListener('copy', (e) => {
|
|
|
// 获取用户的选区
|
|
|
let content = window.getSelection().getRangeAt(0).cloneContents();
|
|
|
+ let paragraphs = content.querySelectorAll('.paragraph'); // 获取选中的段落
|
|
|
let div = document.createElement('div');
|
|
|
- div.classList = 'paragraph';
|
|
|
- div.style = 'display: flex; flex-wrap: wrap; margin-bottom: 22px;font-weight: 500;';
|
|
|
+ if (paragraphs.length <= 0) {
|
|
|
+ // 单行情况下
|
|
|
+ div.classList = 'paragraph';
|
|
|
+ div.style = 'display: flex; flex-wrap: wrap; margin-bottom: 22px;font-weight: 500;';
|
|
|
+ } else {
|
|
|
+ // 多行情况下
|
|
|
+ paragraphs.forEach((item) => {
|
|
|
+ item.style = 'display: flex; flex-wrap: wrap; margin-bottom: 22px;font-weight: 500;';
|
|
|
+ });
|
|
|
+ div.classList = 'articel';
|
|
|
+ div.style = 'font-weight: 500;';
|
|
|
+ }
|
|
|
// 将 content 设到 div 中
|
|
|
div.appendChild(content);
|
|
|
- console.log(div);
|
|
|
// words
|
|
|
- let words = div.querySelectorAll('.words');
|
|
|
- words.forEach((item) => {
|
|
|
- item.style.cssText += 'display: flex;';
|
|
|
- });
|
|
|
+ if (paragraphs.length <= 0) {
|
|
|
+ let words = div.querySelectorAll('.words');
|
|
|
+ words.forEach((item) => {
|
|
|
+ item.style.cssText += 'display: flex;';
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ paragraphs.forEach((item) => {
|
|
|
+ let words = item.querySelectorAll('.words');
|
|
|
+ words.forEach((items, i) => {
|
|
|
+ items.style.cssText += `display: flex;${i === 0 ? 'width: 22px;' : ''}`;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
// word
|
|
|
let word = div.querySelectorAll('.word');
|
|
|
word.forEach((item) => {
|