/**
 * Copyright (c) Tiny Technologies, Inc. All rights reserved.
 * Licensed under the LGPL or a commercial license.
 * For LGPL see License.txt in the project root for license information.
 * For commercial licenses see https://www.tiny.cloud/
 */ import DOMUtils from 'tinymce/core/api/dom/DOMUtils' ; import Tools from 'tinymce/core/api/util/Tools' ; import * as NodeType from './NodeType' ; const DOM = DOMUtils . DOM ; const normalizeList = function ( dom , ul ) { let sibling ; const parentNode = ul . parentNode ; if ( parentNode . nodeName === 'LI' && parentNode . firstChild === ul ) { sibling = parentNode . previousSibling ; if ( sibling && sibling . nodeName === 'LI' ) { sibling . appendChild ( ul ) ; if ( NodeType . isEmpty ( dom , parentNode ) ) { DOM . remove ( parentNode ) ; } } else { DOM . setStyle ( parentNode , 'listStyleType' , 'none' ) ; } } if ( NodeType . isListNode ( parentNode ) ) { sibling = parentNode . previousSibling ; if ( sibling && sibling . nodeName === 'LI' ) { sibling . appendChild ( ul ) ; } } } ; const normalizeLists = function ( dom , element ) { Tools . each ( Tools . grep ( dom . select ( 'ol,ul' , element ) ) , function ( ul ) { normalizeList ( dom , ul ) ; } ) ; } ; export { normalizeList , normalizeLists } ;