mirror of
https://github.com/penpot/penpot.git
synced 2025-07-18 22:57:19 +02:00
🐛 Fix copy/paste issues
This commit is contained in:
parent
4881bf3619
commit
4ef631fd6a
6 changed files with 82 additions and 5 deletions
|
@ -12,6 +12,7 @@ import ChangeController from "./controllers/ChangeController.js";
|
|||
import SelectionController from "./controllers/SelectionController.js";
|
||||
import { createSelectionImposterFromClientRects } from "./selection/Imposter.js";
|
||||
import { addEventListeners, removeEventListeners } from "./Event.js";
|
||||
import { mapContentFragmentFromHTML, mapContentFragmentFromString } from "./content/dom/Content.js";
|
||||
import { createRoot, createEmptyRoot } from "./content/dom/Root.js";
|
||||
import { createParagraph } from "./content/dom/Paragraph.js";
|
||||
import { createEmptyInline, createInline } from "./content/dom/Inline.js";
|
||||
|
@ -501,6 +502,20 @@ export class TextEditor extends EventTarget {
|
|||
}
|
||||
}
|
||||
|
||||
export function createRootFromHTML(html) {
|
||||
const fragment = mapContentFragmentFromHTML(html);
|
||||
const root = createRoot([]);
|
||||
root.replaceChildren(fragment);
|
||||
return root;
|
||||
}
|
||||
|
||||
export function createRootFromString(string) {
|
||||
const fragment = mapContentFragmentFromString(string);
|
||||
const root = createRoot([]);
|
||||
root.replaceChild(fragment);
|
||||
return root;
|
||||
}
|
||||
|
||||
export function isEditor(instance) {
|
||||
return (instance instanceof TextEditor);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue