Update paste.ts
This commit is contained in:
parent
15d8e848c7
commit
200cd5d3b7
|
@ -47,7 +47,7 @@ export default class Paste {
|
||||||
let parent = node.parent();
|
let parent = node.parent();
|
||||||
// 跳过已被删除的节点
|
// 跳过已被删除的节点
|
||||||
if (!parent || node.isCard() || node.fragment === fragment) {
|
if (!parent || node.isCard() || node.fragment === fragment) {
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (node.isText()) {
|
if (node.isText()) {
|
||||||
let text = node.text();
|
let text = node.text();
|
||||||
|
@ -73,7 +73,7 @@ export default class Paste {
|
||||||
node.text(text);
|
node.text(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
const styles = node.css();
|
const styles = node.css();
|
||||||
defautlStyleKeys.forEach((key) => {
|
defautlStyleKeys.forEach((key) => {
|
||||||
|
@ -87,7 +87,7 @@ export default class Paste {
|
||||||
let type = this.schema.getType(node);
|
let type = this.schema.getType(node);
|
||||||
if (!type) {
|
if (!type) {
|
||||||
nodeApi.unwrap(node);
|
nodeApi.unwrap(node);
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
nodeApi.removeMinusStyle(node, 'text-indent');
|
nodeApi.removeMinusStyle(node, 'text-indent');
|
||||||
if (nodeApi.isList(node)) {
|
if (nodeApi.isList(node)) {
|
||||||
|
@ -113,17 +113,17 @@ export default class Paste {
|
||||||
}
|
}
|
||||||
parent = node.parent();
|
parent = node.parent();
|
||||||
node.remove();
|
node.remove();
|
||||||
if (!parent) return;
|
if (!parent) return undefined;
|
||||||
node = parent;
|
node = parent;
|
||||||
parent = node.parent();
|
parent = node.parent();
|
||||||
if (!parent) return;
|
if (!parent) return undefined;
|
||||||
type = undefined;
|
type = undefined;
|
||||||
attributes = undefined;
|
attributes = undefined;
|
||||||
}
|
}
|
||||||
if (!attributes) attributes = node.attributes();
|
if (!attributes) attributes = node.attributes();
|
||||||
// 跳过Card
|
// 跳过Card
|
||||||
if (attributes[READY_CARD_KEY]) {
|
if (attributes[READY_CARD_KEY]) {
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
const nodeIsBlock = type
|
const nodeIsBlock = type
|
||||||
? type === 'block'
|
? type === 'block'
|
||||||
|
@ -140,7 +140,7 @@ export default class Paste {
|
||||||
nodeApi.html(node) === ''
|
nodeApi.html(node) === ''
|
||||||
) {
|
) {
|
||||||
node.remove();
|
node.remove();
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
// 段落
|
// 段落
|
||||||
if (attributes['data-type'] === 'p') {
|
if (attributes['data-type'] === 'p') {
|
||||||
|
@ -160,7 +160,7 @@ export default class Paste {
|
||||||
const ul = $('<ul />');
|
const ul = $('<ul />');
|
||||||
node.before(ul);
|
node.before(ul);
|
||||||
ul.append(node);
|
ul.append(node);
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (nodeApi.isList(node) && parent && nodeApi.isList(parent)) {
|
if (nodeApi.isList(node) && parent && nodeApi.isList(parent)) {
|
||||||
// 分割付节点list
|
// 分割付节点list
|
||||||
|
@ -218,7 +218,7 @@ export default class Paste {
|
||||||
const li = $('<li />');
|
const li = $('<li />');
|
||||||
node.before(li);
|
node.before(li);
|
||||||
li.append(node);
|
li.append(node);
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
// <li>two<ol><li>three</li></ol>four</li>
|
// <li>two<ol><li>three</li></ol>four</li>
|
||||||
/**
|
/**
|
||||||
|
@ -238,7 +238,7 @@ export default class Paste {
|
||||||
const rootListElement = parent?.parent();
|
const rootListElement = parent?.parent();
|
||||||
if (!rootListElement) {
|
if (!rootListElement) {
|
||||||
nodeApi.unwrap(parent);
|
nodeApi.unwrap(parent);
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
// 分割付节点list
|
// 分割付节点list
|
||||||
const leftList = rootListElement.clone();
|
const leftList = rootListElement.clone();
|
||||||
|
@ -305,13 +305,13 @@ export default class Paste {
|
||||||
return (
|
return (
|
||||||
(next as NodeInterface | null)?.next() ||
|
(next as NodeInterface | null)?.next() ||
|
||||||
leftList.next() ||
|
leftList.next() ||
|
||||||
void 0
|
undefined
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// p 改成 li
|
// p 改成 li
|
||||||
if (node.name === 'p' && parentIsList) {
|
if (node.name === 'p' && parentIsList) {
|
||||||
nodeApi.replace(node, $('<li />'));
|
nodeApi.replace(node, $('<li />'));
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
// 处理空 Block
|
// 处理空 Block
|
||||||
if (
|
if (
|
||||||
|
@ -339,7 +339,7 @@ export default class Paste {
|
||||||
node.after('<br />');
|
node.after('<br />');
|
||||||
}
|
}
|
||||||
nodeApi.unwrap(node);
|
nodeApi.unwrap(node);
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!nodeIsBlock &&
|
!nodeIsBlock &&
|
||||||
|
@ -404,6 +404,7 @@ export default class Paste {
|
||||||
nodeParent = nodeParent.parent();
|
nodeParent = nodeParent.parent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return undefined;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue