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