fix: paste
This commit is contained in:
parent
b467b65edb
commit
5673538b8e
|
@ -79,5 +79,9 @@ export default defineConfig({
|
|||
pathRewrite: { '^/api': '' },
|
||||
},
|
||||
},
|
||||
// scripts: [
|
||||
// 'https://unpkg.com/vconsole/dist/vconsole.min.js',
|
||||
// 'var vConsole = new window.VConsole();',
|
||||
// ],
|
||||
// more config: https://d.umijs.org/config
|
||||
});
|
||||
|
|
|
@ -378,10 +378,15 @@ abstract class CardEntry<T extends CardValue = CardValue>
|
|||
this.resizeModel?.render(container);
|
||||
}
|
||||
}
|
||||
this.toolbarModel?.hide();
|
||||
this.toolbarModel?.destroy();
|
||||
if (this.toolbar) {
|
||||
this.toolbarModel = new Toolbar(this.editor, this);
|
||||
if (!this.toolbarModel)
|
||||
this.toolbarModel = new Toolbar(this.editor, this);
|
||||
if (this.activated) {
|
||||
this.toolbarModel.show();
|
||||
}
|
||||
} else {
|
||||
this.toolbarModel?.hide();
|
||||
this.toolbarModel?.destroy();
|
||||
}
|
||||
if (this.isEditable) {
|
||||
this.editor.nodeId.generateAll(this.getCenter().get<Element>()!);
|
||||
|
|
|
@ -480,10 +480,13 @@ class ChangeModel implements ChangeInterface {
|
|||
}
|
||||
// 被删除了重新设置开始节点位置
|
||||
if (startRange && !startRange.node[0].parentNode) {
|
||||
startRange = {
|
||||
node: appendNodes[0],
|
||||
offset: 0,
|
||||
};
|
||||
const parent = node.parent();
|
||||
if (parent) {
|
||||
startRange = {
|
||||
node: parent,
|
||||
offset: node.index(),
|
||||
};
|
||||
}
|
||||
}
|
||||
node = next;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import {
|
|||
CARD_RIGHT_SELECTOR,
|
||||
CARD_SELECTOR,
|
||||
DATA_ELEMENT,
|
||||
DATA_ID,
|
||||
EDITABLE,
|
||||
ROOT,
|
||||
ROOT_SELECTOR,
|
||||
|
@ -550,11 +551,27 @@ class NativeEvent {
|
|||
range,
|
||||
(range) => {
|
||||
this.engine.trigger('paste:insert', range);
|
||||
this.#lastePasteRange = range.cloneRange();
|
||||
const cloneRange = range.cloneRange();
|
||||
const { endNode } = cloneRange;
|
||||
let cardId = '';
|
||||
if (endNode.isCard() && endNode.children().length === 0) {
|
||||
cloneRange.setEndAfter(endNode);
|
||||
cardId = endNode.attributes(DATA_ID);
|
||||
}
|
||||
this.#lastePasteRange = cloneRange;
|
||||
range.collapse(false);
|
||||
const selection = range.createSelection();
|
||||
this.engine.card.render(undefined, (count) => {
|
||||
selection.move();
|
||||
if (cardId) {
|
||||
const newCard = this.engine.container.find(
|
||||
`[data-id="${cardId}"]`,
|
||||
);
|
||||
if (newCard.length > 0) {
|
||||
cloneRange.setEndAfter(newCard);
|
||||
this.#lastePasteRange = cloneRange;
|
||||
}
|
||||
}
|
||||
range.scrollRangeIntoView();
|
||||
change.range.select(range);
|
||||
if (callback) {
|
||||
|
|
|
@ -1057,7 +1057,10 @@ class Inline implements InlineModelInterface {
|
|||
|
||||
flat(node: NodeInterface | RangeInterface, schema?: SchemaInterface) {
|
||||
if (isRangeInterface(node)) {
|
||||
const selection = node.shrinkToElementNode().createSelection();
|
||||
const selection = node
|
||||
.cloneRange()
|
||||
.shrinkToElementNode()
|
||||
.createSelection();
|
||||
const inlines = this.findInlines(node);
|
||||
inlines.forEach((inline) => {
|
||||
if (inline.isCard()) return;
|
||||
|
|
|
@ -455,7 +455,7 @@ class List implements ListModelInterface {
|
|||
const safeRange = range || change.range.toTrusty();
|
||||
const selection = blocks
|
||||
? undefined
|
||||
: safeRange.shrinkToElementNode().createSelection();
|
||||
: safeRange.cloneRange().shrinkToElementNode().createSelection();
|
||||
blocks = blocks || block.getBlocks(safeRange);
|
||||
blocks.forEach((block) => {
|
||||
block = block.closest('ul,ol');
|
||||
|
|
|
@ -57,8 +57,7 @@ class Request implements RequestInterface {
|
|||
} else if (!!input['fireEvent']) {
|
||||
input['fireEvent'](event);
|
||||
} else throw '';
|
||||
|
||||
//document.addEventListener('mousedown', remove);
|
||||
document.addEventListener('mousedown', remove);
|
||||
} catch (error) {
|
||||
input.removeEventListener('change', change);
|
||||
remove();
|
||||
|
|
Loading…
Reference in New Issue