UNPKG

@ckeditor/ckeditor5-paste-from-office

Version:

Paste from Office feature for CKEditor 5.

26 lines (25 loc) 950 B
/** * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options */ /** * Transforms `<a>` elements which are bookmarks by moving their children after the element. * * @internal */ export function transformBookmarks(documentFragment, writer) { const elementsToChange = []; for (const value of writer.createRangeIn(documentFragment)) { const element = value.item; if (element.is('element', 'a') && !element.hasAttribute('href') && (element.hasAttribute('id') || element.hasAttribute('name'))) { elementsToChange.push(element); } } for (const element of elementsToChange) { const index = element.parent.getChildIndex(element) + 1; const children = element.getChildren(); writer.insertChild(index, children, element.parent); } }