Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/queuepro/node_modules/@ckeditor/ckeditor5-table/src/converters/ drwxrwxr-x | |
| Viewing file: Select action/file-type: /**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
/**
* @module table/converters/table-caption-post-fixer
*/
/**
* Injects a table caption post-fixer into the model.
*
* The role of the table caption post-fixer is to ensure that the table with caption have the correct structure
* after a {@link module:engine/model/model~Model#change `change()`} block was executed.
*
* The correct structure means that:
*
* * If there are many caption model element, they are merged into one model.
* * A final, merged caption model is placed at the end of the table.
*
* @param {module:engine/model/model~Model} model
*/
export default function injectTableCaptionPostFixer( model ) {
model.document.registerPostFixer( writer => tableCaptionPostFixer( writer, model ) );
}
// The table caption post-fixer.
//
// @param {module:engine/model/writer~Writer} writer
// @param {module:engine/model/model~Model} model
function tableCaptionPostFixer( writer, model ) {
const changes = model.document.differ.getChanges();
let wasFixed = false;
for ( const entry of changes ) {
if ( entry.type != 'insert' ) {
continue;
}
const positionParent = entry.position.parent;
if ( positionParent.is( 'element', 'table' ) || entry.name == 'table' ) {
const table = entry.name == 'table' ? entry.position.nodeAfter : entry.position.parent;
const captionsToMerge = Array.from( table.getChildren() ).filter( child => child.is( 'element', 'caption' ) );
const firstCaption = captionsToMerge.shift();
if ( !firstCaption ) {
continue;
}
// Move all the contents of the captions to the first one.
for ( const caption of captionsToMerge ) {
writer.move( writer.createRangeIn( caption ), firstCaption, 'end' );
writer.remove( caption );
}
// Make sure the final caption is at the end of the table.
if ( firstCaption.nextSibling ) {
writer.move( writer.createRangeOn( firstCaption ), table, 'end' );
wasFixed = true;
}
// Do we merged captions and/or moved the single caption to the end of the table?
wasFixed = !!captionsToMerge.length || wasFixed;
}
}
return wasFixed;
}
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.02 ]-- |