@ckeditor/ckeditor5-table 47.5.0-alpha.8 → 47.6.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(e){const t=e.de=e.de||{};t.dictionary=Object.assign(t.dictionary||{},{"Align cell text to the bottom":"Zellentext unten ausrichten","Align cell text to the center":"Zellentext zentriert ausrichten","Align cell text to the left":"Zellentext linksbündig ausrichten","Align cell text to the middle":"Zellentext mittig ausrichten","Align cell text to the right":"Zellentext rechtsbündig ausrichten","Align cell text to the top":"Zellentext oben ausrichten","Align table to the left":"Tabelle links ausrichten","Align table to the left with no text wrapping":"Tabelle ohne Textumbruch linksbündig ausrichten","Align table to the left with text wrapping":"Tabelle mit Textumbruch linksbündig ausrichten","Align table to the right":"Tabelle rechts ausrichten","Align table to the right with no text wrapping":"Tabelle ohne Textumbruch rechtsbündig ausrichten","Align table to the right with text wrapping":"Tabelle mit Textumbruch rechtsbündig ausrichten",Alignment:"Ausrichtung",Background:"Hintergrund",Border:"Rahmen","Cell properties":"Zelleneigenschaften","Cell type":"Zelltyp","Center table":"Tabelle zentrieren","Center table with no text wrapping":"Tabelle ohne Textumbruch zentrieren","Choose table type":"Tabellentyp auswählen",Color:"Farbe",Column:"Spalte","Content table":"Inhaltstabelle",Dashed:"Gestrichelt","Data cell":"Datenzelle","Delete column":"Spalte löschen","Delete row":"Zeile löschen",Dimensions:"Größe",Dotted:"Gepunktet",Double:"Doppelt","Enter table caption":"Tabellenüberschrift eingeben",Groove:"Eingeritzt","Header cell":"Kopfzelle","Header column":"Kopfspalte","Header row":"Kopfzeile",Height:"Höhe","Horizontal text alignment toolbar":"Werkzeugleiste für die horizontale Zellentext-Ausrichtung","Insert a new table row (when in the last cell of a table)":"Eine neue Tabellenspalte einfügen (wenn in der letzten Tabellenzelle)","Insert column left":"Spalte links einfügen","Insert column right":"Spalte rechts einfügen","Insert row above":"Zeile oben einfügen","Insert row below":"Zeile unten einfügen","Insert table":"Tabelle einfügen","Insert table layout":"Tabellenlayout einfügen",Inset:"Eingelassen","Justify cell text":"Zellentext als Blocksatz ausrichten","Keystrokes that can be used in a table cell":"Tastatureingaben, die in einer Tabelle benutz werden können.","Layout table":"Layouttabelle","Merge cell down":"Zelle unten verbinden","Merge cell left":"Zelle links verbinden","Merge cell right":"Zelle rechts verbinden","Merge cell up":"Zelle verbinden","Merge cells":"Zellen verbinden","Move the selection to the next cell":"Auswahl in die nächste Zelle verschieben","Move the selection to the previous cell":"Auswahl in die vorherige Zelle verschieben","Navigate through the table":"Tabellennavigation",None:"Kein Rahmen",Outset:"Geprägt",Padding:"Innenabstand",Ridge:"Hervorgehoben",Row:"Zeile","Select column":"Spalte auswählen","Select row":"Zeile auswählen",Solid:"Durchgezogen","Split cell horizontally":"Zelle horizontal teilen","Split cell vertically":"Zelle vertikal teilen",Style:"Rahmenart",Table:"Tabelle","Table Alignment":"Tabellenausrichtung","Table alignment toolbar":"Werkzeugleiste für die Tabellen-Ausrichtung","Table cell text alignment":"Ausrichtung des Zellentextes","Table layout":"Tabellenlayout","Table properties":"Tabelleneigenschaften","Table toolbar":"Tabelle Werkzeugleiste","Table type":"Tabellentyp","Table type options":"Tabellentyp-Optionen",'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".':"Die Farbe ist ungültig. Probieren Sie „#FF0000“ oder „rgb(255,0,0)“ oder „red“.",'The value is invalid. Try "10px" or "2em" or simply "2".':"Der Wert ist ungültig. Probieren Sie „10px“ oder „2em“ oder „2“.","Vertical text alignment toolbar":"Werkzeugleiste für die vertikale Zellentext-Ausrichtung",Width:"Breite"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
1
+ !function(e){const t=e.de=e.de||{};t.dictionary=Object.assign(t.dictionary||{},{"Align cell text to the bottom":"Zellentext unten ausrichten","Align cell text to the center":"Zellentext zentriert ausrichten","Align cell text to the left":"Zellentext linksbündig ausrichten","Align cell text to the middle":"Zellentext mittig ausrichten","Align cell text to the right":"Zellentext rechtsbündig ausrichten","Align cell text to the top":"Zellentext oben ausrichten","Align table to the left":"Tabelle links ausrichten","Align table to the left with no text wrapping":"Tabelle ohne Textumbruch linksbündig ausrichten","Align table to the left with text wrapping":"Tabelle mit Textumbruch linksbündig ausrichten","Align table to the right":"Tabelle rechts ausrichten","Align table to the right with no text wrapping":"Tabelle ohne Textumbruch rechtsbündig ausrichten","Align table to the right with text wrapping":"Tabelle mit Textumbruch rechtsbündig ausrichten",Alignment:"Ausrichtung",Background:"Hintergrund",Border:"Rahmen","Cell properties":"Zelleneigenschaften","Cell type":"Zelltyp","Center table":"Tabelle zentrieren","Center table with no text wrapping":"Tabelle ohne Textumbruch zentrieren","Choose table type":"Tabellentyp auswählen",Color:"Farbe",Column:"Spalte","Content table":"Inhaltstabelle",Dashed:"Gestrichelt","Data cell":"Datenzelle","Delete column":"Spalte löschen","Delete row":"Zeile löschen",Dimensions:"Größe",Dotted:"Gepunktet",Double:"Doppelt","Enter table caption":"Tabellenüberschrift eingeben",Groove:"Eingeritzt","Header cell":"Kopfzelle","Header column":"Kopfspalte","Header row":"Kopfzeile",Height:"Höhe","Horizontal text alignment toolbar":"Werkzeugleiste für die horizontale Zellentext-Ausrichtung","Insert a new table row (when in the last cell of a table)":"Eine neue Tabellenspalte einfügen (wenn in der letzten Tabellenzelle)","Insert column left":"Spalte links einfügen","Insert column right":"Spalte rechts einfügen","Insert row above":"Zeile oben einfügen","Insert row below":"Zeile unten einfügen","Insert table":"Tabelle einfügen","Insert table layout":"Tabellenlayout einfügen",Inset:"Eingelassen","Justify cell text":"Zellentext als Blocksatz ausrichten","Keystrokes that can be used in a table cell":"Tastatureingaben, die in einer Tabelle benutz werden können.","Layout table":"Layouttabelle","Merge cell down":"Zelle unten verbinden","Merge cell left":"Zelle links verbinden","Merge cell right":"Zelle rechts verbinden","Merge cell up":"Zelle oben verbinden","Merge cells":"Zellen verbinden","Move the selection to the next cell":"Auswahl in die nächste Zelle verschieben","Move the selection to the previous cell":"Auswahl in die vorherige Zelle verschieben","Navigate through the table":"Tabellennavigation",None:"Kein Rahmen",Outset:"Geprägt",Padding:"Innenabstand",Ridge:"Hervorgehoben",Row:"Zeile","Select column":"Spalte auswählen","Select row":"Zeile auswählen",Solid:"Durchgezogen","Split cell horizontally":"Zelle horizontal teilen","Split cell vertically":"Zelle vertikal teilen",Style:"Rahmenart",Table:"Tabelle","Table Alignment":"Tabellenausrichtung","Table alignment toolbar":"Werkzeugleiste für die Tabellen-Ausrichtung","Table cell text alignment":"Ausrichtung des Zellentextes","Table layout":"Tabellenlayout","Table properties":"Tabelleneigenschaften","Table toolbar":"Tabelle Werkzeugleiste","Table type":"Tabellentyp","Table type options":"Tabellentyp-Optionen",'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".':"Die Farbe ist ungültig. Probieren Sie „#FF0000“ oder „rgb(255,0,0)“ oder „red“.",'The value is invalid. Try "10px" or "2em" or simply "2".':"Der Wert ist ungültig. Probieren Sie „10px“ oder „2em“ oder „2“.","Vertical text alignment toolbar":"Werkzeugleiste für die vertikale Zellentext-Ausrichtung",Width:"Breite"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { Command, Plugin } from '@ckeditor/ckeditor5-core/dist/index.js';
6
6
  import { toWidgetEditable, toWidget, Widget, isWidget, WidgetToolbarRepository } from '@ckeditor/ckeditor5-widget/dist/index.js';
7
- import { first, global, CKEditorError, KeystrokeHandler, FocusTracker, Collection, getLocalizedArrowKeyCodeDirection, Rect, priorities, DomEmitterMixin, toUnit } from '@ckeditor/ckeditor5-utils/dist/index.js';
7
+ import { first, global, CKEditorError, KeystrokeHandler, FocusTracker, Collection, getLocalizedArrowKeyCodeDirection, Rect, priorities, DomEmitterMixin, toUnit, uid } from '@ckeditor/ckeditor5-utils/dist/index.js';
8
8
  import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
9
9
  import { IconTable, IconTableColumn, IconTableRow, IconTableMergeCell, IconCheck, IconCancel, IconAlignBottom, IconAlignMiddle, IconAlignTop, IconAlignJustify, IconAlignRight, IconAlignCenter, IconAlignLeft, IconTableCellProperties, IconTableLayout, IconTableProperties, IconObjectInlineRight, IconObjectCenter, IconObjectInlineLeft, IconCaption, IconPreviousArrow, IconObjectRight, IconObjectLeft } from '@ckeditor/ckeditor5-icons/dist/index.js';
10
10
  import { View, addKeyboardHandlingForGrid, ButtonView, createDropdown, MenuBarMenuView, SwitchButtonView, SplitButtonView, addListToDropdown, UIModel, ViewCollection, FocusCycler, InputTextView, ColorSelectorView, FormHeaderView, FormRowView, submitHandler, LabelView, LabeledFieldView, createLabeledDropdown, createLabeledInputText, ToolbarView, BalloonPanelView, ContextualBalloon, normalizeColorOptions, getLocalizedColorOptions, clickOutsideHandler, DropdownButtonView } from '@ckeditor/ckeditor5-ui/dist/index.js';
@@ -2183,10 +2183,11 @@ const downcastTableAlignmentConfig = {
2183
2183
  const hasPlainTableOutput = editor.plugins.has('PlainTableOutput');
2184
2184
  const isClipboardPipeline = conversionApi.options.isClipboardPipeline;
2185
2185
  const useExtendedAlignment = editor.config.get('experimentalFlags.useExtendedTableBlockAlignment');
2186
- if (!hasPlainTableOutput && !(useExtendedAlignment && isClipboardPipeline)) {
2187
- return null;
2186
+ const stripFigureTagWithLayoutTable = shouldStripFigureTagWithLayoutTable(editor, table);
2187
+ if (hasPlainTableOutput || stripFigureTagWithLayoutTable || useExtendedAlignment && isClipboardPipeline) {
2188
+ return downcastPlainTable(table, conversionApi, editor);
2188
2189
  }
2189
- return downcastPlainTable(table, conversionApi, editor);
2190
+ return null;
2190
2191
  };
2191
2192
  }
2192
2193
  /**
@@ -2196,7 +2197,8 @@ const downcastTableAlignmentConfig = {
2196
2197
  const hasPlainTableOutput = editor.plugins.has('PlainTableOutput');
2197
2198
  const isClipboardPipeline = options.isClipboardPipeline;
2198
2199
  const useExtendedAlignment = editor.config.get('experimentalFlags.useExtendedTableBlockAlignment');
2199
- if (!hasPlainTableOutput && !(useExtendedAlignment && isClipboardPipeline)) {
2200
+ const stripFigureTagWithLayoutTable = shouldStripFigureTagWithLayoutTable(editor, modelElement);
2201
+ if (!(hasPlainTableOutput || stripFigureTagWithLayoutTable || useExtendedAlignment && isClipboardPipeline)) {
2200
2202
  return null;
2201
2203
  }
2202
2204
  if (modelElement.parent.name === 'table') {
@@ -2287,7 +2289,8 @@ const downcastTableAlignmentConfig = {
2287
2289
  const hasPlainTableOutput = editor.plugins.has('PlainTableOutput');
2288
2290
  const isClipboardPipeline = conversionApi.options.isClipboardPipeline;
2289
2291
  const useExtendedAlignment = editor.config.get('experimentalFlags.useExtendedTableBlockAlignment');
2290
- if (!hasPlainTableOutput && !(useExtendedAlignment && isClipboardPipeline)) {
2292
+ const stripFigureTagWithLayoutTable = shouldStripFigureTagWithLayoutTable(editor, item);
2293
+ if (!(hasPlainTableOutput || stripFigureTagWithLayoutTable || useExtendedAlignment && isClipboardPipeline)) {
2291
2294
  return;
2292
2295
  }
2293
2296
  if (!conversionApi.consumable.consume(item, evt.name)) {
@@ -2305,6 +2308,22 @@ const downcastTableAlignmentConfig = {
2305
2308
  });
2306
2309
  }
2307
2310
  }
2311
+ /**
2312
+ * Returns `true` if the figure tag should be stripped when using layout tables and when `tableType` is `layout`
2313
+ * or `stripFigureFromContentTable` option is set to `true`, `false` otherwise.
2314
+ *
2315
+ * @param editor The editor instance.
2316
+ * @param modelElement The model element to check.
2317
+ * @returns `true` if the figure tag should be stripped, `false` otherwise.
2318
+ */ function shouldStripFigureTagWithLayoutTable(editor, modelElement) {
2319
+ const hasTableLayout = editor.plugins.has('TableLayoutEditing');
2320
+ const stripFigureFromContentTable = editor.config.get('table.tableLayout.stripFigureFromContentTable') ?? true;
2321
+ const tableModelElement = modelElement.findAncestor('table', {
2322
+ includeSelf: true
2323
+ });
2324
+ const tableType = tableModelElement?.getAttribute('tableType');
2325
+ return hasTableLayout && (stripFigureFromContentTable || tableType === 'layout');
2326
+ }
2308
2327
 
2309
2328
  /**
2310
2329
  * The insert table command.
@@ -11859,7 +11878,6 @@ const TABLE_TYPES = [
11859
11878
  * @inheritDoc
11860
11879
  */ static get requires() {
11861
11880
  return [
11862
- PlainTableOutput,
11863
11881
  TableColumnResize,
11864
11882
  TableLayoutEditing,
11865
11883
  TableLayoutUI
@@ -13844,6 +13862,9 @@ const propertyToCommandMap$2 = {
13844
13862
  *
13845
13863
  * To learn more about this system, see {@link #_saveCaption}.
13846
13864
  */ _savedCaptionsMap = new WeakMap();
13865
+ /**
13866
+ * A map that keeps generated ids for table captions to reuse them if the same caption is rendered again.
13867
+ */ _captionIdsMapping = new WeakMap();
13847
13868
  /**
13848
13869
  * @inheritDoc
13849
13870
  */ static get pluginName() {
@@ -13914,6 +13935,42 @@ const propertyToCommandMap$2 = {
13914
13935
  return toWidgetEditable(captionElement, writer);
13915
13936
  }
13916
13937
  });
13938
+ editor.conversion.for('editingDowncast').add((dispatcher)=>{
13939
+ dispatcher.on('insert:table', (evt, data, { writer, mapper })=>{
13940
+ const modelTable = data.item;
13941
+ const viewFigure = mapper.toViewElement(modelTable);
13942
+ if (!viewFigure) {
13943
+ return;
13944
+ }
13945
+ const viewTable = Array.from(viewFigure.getChildren()).find((child)=>child.is('element', 'table'));
13946
+ if (!viewTable) {
13947
+ return;
13948
+ }
13949
+ const modelCaption = getCaptionFromTableModelElement(modelTable);
13950
+ // Remove `aria-labelledby` from the table if there is no caption.
13951
+ if (!modelCaption) {
13952
+ writer.removeAttribute('aria-labelledby', viewTable);
13953
+ return;
13954
+ }
13955
+ const viewCaption = mapper.toViewElement(modelCaption);
13956
+ if (!viewCaption) {
13957
+ return;
13958
+ }
13959
+ // Try reusing the same id for the caption if it was already created for the given model caption.
13960
+ // If it was not created before, generate a new one and save it in the mapping to reuse it in the future if needed.
13961
+ let captionId;
13962
+ if (viewCaption.hasAttribute('id')) {
13963
+ captionId = viewCaption.getAttribute('id');
13964
+ } else {
13965
+ captionId = this._captionIdsMapping.get(modelCaption) ?? `ck-editor__caption_${uid()}`;
13966
+ }
13967
+ this._captionIdsMapping.set(modelCaption, captionId);
13968
+ writer.setAttribute('id', captionId, viewCaption);
13969
+ writer.setAttribute('aria-labelledby', captionId, viewTable);
13970
+ }, {
13971
+ priority: 'low'
13972
+ });
13973
+ });
13917
13974
  injectTableCaptionPostFixer(editor.model);
13918
13975
  }
13919
13976
  /**