Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 1... Línea 1...
1
/**
1
/**
2
 * TinyMCE version 6.8.3 (2024-02-08)
2
 * TinyMCE version 7.7.1 (2025-03-05)
3
 */
3
 */
Línea 4... Línea 4...
4
 
4
 
5
(function () {
5
(function () {
Línea 747... Línea 747...
747
      element,
747
      element,
748
      columns
748
      columns
749
    });
749
    });
Línea 750... Línea 750...
750
 
750
 
751
    const isShadowRoot = dos => isDocumentFragment(dos) && isNonNullable(dos.dom.host);
751
    const isShadowRoot = dos => isDocumentFragment(dos) && isNonNullable(dos.dom.host);
752
    const supported = isFunction(Element.prototype.attachShadow) && isFunction(Node.prototype.getRootNode);
-
 
753
    const isSupported$1 = constant(supported);
752
    const getRootNode = e => SugarElement.fromDom(e.dom.getRootNode());
754
    const getRootNode = supported ? e => SugarElement.fromDom(e.dom.getRootNode()) : documentOrOwner;
753
    const getContentContainer = dos => isShadowRoot(dos) ? dos : SugarElement.fromDom(documentOrOwner(dos).dom.body);
755
    const getShadowRoot = e => {
754
    const getShadowRoot = e => {
756
      const r = getRootNode(e);
755
      const r = getRootNode(e);
757
      return isShadowRoot(r) ? Optional.some(r) : Optional.none();
756
      return isShadowRoot(r) ? Optional.some(r) : Optional.none();
758
    };
757
    };
759
    const getShadowHost = e => SugarElement.fromDom(e.dom.host);
758
    const getShadowHost = e => SugarElement.fromDom(e.dom.host);
760
    const getOriginalEventTarget = event => {
759
    const getOriginalEventTarget = event => {
761
      if (isSupported$1() && isNonNullable(event.target)) {
760
      if (isNonNullable(event.target)) {
762
        const el = SugarElement.fromDom(event.target);
761
        const el = SugarElement.fromDom(event.target);
763
        if (isElement(el) && isOpenShadowHost(el)) {
762
        if (isElement(el) && isOpenShadowHost(el)) {
764
          if (event.composed && event.composedPath) {
763
          if (event.composed && event.composedPath) {
765
            const composedPath = event.composedPath();
764
            const composedPath = event.composedPath();
Línea 877... Línea 876...
877
      return r;
876
      return r;
878
    };
877
    };
879
    const bindFrom = (a, f) => a !== undefined && a !== null ? f(a) : Optional.none();
878
    const bindFrom = (a, f) => a !== undefined && a !== null ? f(a) : Optional.none();
880
    const someIf = (b, a) => b ? Optional.some(a) : Optional.none();
879
    const someIf = (b, a) => b ? Optional.some(a) : Optional.none();
Línea -... Línea 880...
-
 
880
 
-
 
881
    const removeFromStart = (str, numChars) => {
-
 
882
      return str.substring(numChars);
-
 
883
    };
881
 
884
 
-
 
885
    const checkRange = (str, substr, start) => substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
-
 
886
    const removeLeading = (str, prefix) => {
-
 
887
      return startsWith(str, prefix) ? removeFromStart(str, prefix.length) : str;
882
    const checkRange = (str, substr, start) => substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
888
    };
883
    const contains = (str, substr, start = 0, end) => {
889
    const contains = (str, substr, start = 0, end) => {
884
      const idx = str.indexOf(substr, start);
890
      const idx = str.indexOf(substr, start);
885
      if (idx !== -1) {
891
      if (idx !== -1) {
886
        return isUndefined(end) ? true : idx + substr.length <= end;
892
        return isUndefined(end) ? true : idx + substr.length <= end;
Línea 1362... Línea 1368...
1362
      };
1368
      };
1363
    };
1369
    };
1364
    const PlatformDetection = { detect: detect$3 };
1370
    const PlatformDetection = { detect: detect$3 };
Línea 1365... Línea 1371...
1365
 
1371
 
1366
    const mediaMatch = query => window.matchMedia(query).matches;
1372
    const mediaMatch = query => window.matchMedia(query).matches;
1367
    let platform = cached(() => PlatformDetection.detect(navigator.userAgent, Optional.from(navigator.userAgentData), mediaMatch));
1373
    let platform = cached(() => PlatformDetection.detect(window.navigator.userAgent, Optional.from(window.navigator.userAgentData), mediaMatch));
Línea 1368... Línea 1374...
1368
    const detect$2 = () => platform();
1374
    const detect$2 = () => platform();
1369
 
1375
 
1370
    const Dimension = (name, getOffset) => {
1376
    const Dimension = (name, getOffset) => {
Línea 1504... Línea 1510...
1504
        });
1510
        });
1505
        index += colspan;
1511
        index += colspan;
1506
      });
1512
      });
1507
      return columnsGroup;
1513
      return columnsGroup;
1508
    };
1514
    };
1509
    const generate$1 = list => {
1515
    const generate$2 = list => {
1510
      const access = {};
1516
      const access = {};
1511
      const cells = [];
1517
      const cells = [];
1512
      const tableOpt = head(list).map(rowData => rowData.element).bind(table);
1518
      const tableOpt = head(list).map(rowData => rowData.element).bind(table);
1513
      const lockedColumns = tableOpt.bind(getLockedColumnsFromTable).getOr({});
1519
      const lockedColumns = tableOpt.bind(getLockedColumnsFromTable).getOr({});
1514
      let maxRows = 0;
1520
      let maxRows = 0;
Línea 1562... Línea 1568...
1562
        colgroups
1568
        colgroups
1563
      };
1569
      };
1564
    };
1570
    };
1565
    const fromTable = table => {
1571
    const fromTable = table => {
1566
      const list = fromTable$1(table);
1572
      const list = fromTable$1(table);
1567
      return generate$1(list);
1573
      return generate$2(list);
1568
    };
1574
    };
1569
    const justCells = warehouse => bind$2(warehouse.all, w => w.cells);
1575
    const justCells = warehouse => bind$2(warehouse.all, w => w.cells);
1570
    const justColumns = warehouse => values(warehouse.columns);
1576
    const justColumns = warehouse => values(warehouse.columns);
1571
    const hasColumns = warehouse => keys(warehouse.columns).length > 0;
1577
    const hasColumns = warehouse => keys(warehouse.columns).length > 0;
1572
    const getColumnAt = (warehouse, columnIndex) => Optional.from(warehouse.columns[columnIndex]);
1578
    const getColumnAt = (warehouse, columnIndex) => Optional.from(warehouse.columns[columnIndex]);
1573
    const Warehouse = {
1579
    const Warehouse = {
1574
      fromTable,
1580
      fromTable,
1575
      generate: generate$1,
1581
      generate: generate$2,
1576
      getAt,
1582
      getAt,
1577
      findItem,
1583
      findItem,
1578
      filterItems,
1584
      filterItems,
1579
      justCells,
1585
      justCells,
1580
      justColumns,
1586
      justColumns,
Línea 1833... Línea 1839...
1833
    };
1839
    };
Línea 1834... Línea 1840...
1834
 
1840
 
1835
    const rPercentageBasedSizeRegex = /(\d+(\.\d+)?)%/;
1841
    const rPercentageBasedSizeRegex = /(\d+(\.\d+)?)%/;
1836
    const rPixelBasedSizeRegex = /(\d+(\.\d+)?)px|em/;
1842
    const rPixelBasedSizeRegex = /(\d+(\.\d+)?)px|em/;
-
 
1843
    const isCol$2 = isTag('col');
1837
    const isCol$2 = isTag('col');
1844
    const isRow$2 = isTag('tr');
1838
    const getPercentSize = (elm, outerGetter, innerGetter) => {
1845
    const getPercentSize = (elm, outerGetter, innerGetter) => {
1839
      const relativeParent = parentElement(elm).getOrThunk(() => getBody$1(owner(elm)));
1846
      const relativeParent = parentElement(elm).getOrThunk(() => getBody$1(owner(elm)));
1840
      return outerGetter(elm) / innerGetter(relativeParent) * 100;
1847
      return outerGetter(elm) / innerGetter(relativeParent) * 100;
1841
    };
1848
    };
Línea 1846... Línea 1853...
1846
      set$1(cell, 'width', amount + '%');
1853
      set$1(cell, 'width', amount + '%');
1847
    };
1854
    };
1848
    const setHeight = (cell, amount) => {
1855
    const setHeight = (cell, amount) => {
1849
      set$1(cell, 'height', amount + 'px');
1856
      set$1(cell, 'height', amount + 'px');
1850
    };
1857
    };
-
 
1858
    const removeHeight = cell => {
-
 
1859
      remove$5(cell, 'height');
-
 
1860
    };
1851
    const getHeightValue = cell => getRuntime(cell) + 'px';
1861
    const getHeightValue = cell => getRuntime(cell) + 'px';
1852
    const convert = (cell, number, getter, setter) => {
1862
    const convert = (cell, number, getter, setter) => {
1853
      const newSize = table(cell).map(table => {
1863
      const newSize = table(cell).map(table => {
1854
        const total = getter(table);
1864
        const total = getter(table);
1855
        return Math.floor(number / 100 * total);
1865
        return Math.floor(number / 100 * total);
Línea 1877... Línea 1887...
1877
      return getRaw$2(element, prop).orThunk(() => {
1887
      return getRaw$2(element, prop).orThunk(() => {
1878
        return getOpt(element, prop).map(val => val + 'px');
1888
        return getOpt(element, prop).map(val => val + 'px');
1879
      });
1889
      });
1880
    };
1890
    };
1881
    const getRawWidth$1 = element => getRaw$1(element, 'width');
1891
    const getRawWidth$1 = element => getRaw$1(element, 'width');
1882
    const getRawHeight = element => getRaw$1(element, 'height');
1892
    const getRawHeight$1 = element => getRaw$1(element, 'height');
1883
    const getPercentageWidth = cell => getPercentSize(cell, get$9, getInner);
1893
    const getPercentageWidth = cell => getPercentSize(cell, get$9, getInner);
1884
    const getPixelWidth$1 = cell => isCol$2(cell) ? get$9(cell) : getRuntime$1(cell);
1894
    const getPixelWidth$1 = cell => isCol$2(cell) ? get$9(cell) : getRuntime$1(cell);
1885
    const getHeight = cell => {
1895
    const getHeight = cell => {
1886
      return get$7(cell, 'rowspan', getTotalHeight);
1896
      return isRow$2(cell) ? get$8(cell) : get$7(cell, 'rowspan', getTotalHeight);
1887
    };
1897
    };
1888
    const getGenericWidth = cell => {
1898
    const getGenericWidth = cell => {
1889
      const width = getRawWidth$1(cell);
1899
      const width = getRawWidth$1(cell);
1890
      return width.bind(w => parse(w, [
1900
      return width.bind(w => parse(w, [
1891
        'fixed',
1901
        'fixed',
Línea 1895... Línea 1905...
1895
    };
1905
    };
1896
    const setGenericWidth = (cell, amount, unit) => {
1906
    const setGenericWidth = (cell, amount, unit) => {
1897
      set$1(cell, 'width', amount + unit);
1907
      set$1(cell, 'width', amount + unit);
1898
    };
1908
    };
1899
    const getPixelTableWidth = table => get$9(table) + 'px';
1909
    const getPixelTableWidth = table => get$9(table) + 'px';
-
 
1910
    const getPixelTableHeight = table => get$8(table) + 'px';
1900
    const getPercentTableWidth = table => getPercentSize(table, get$9, getInner) + '%';
1911
    const getPercentTableWidth = table => getPercentSize(table, get$9, getInner) + '%';
1901
    const isPercentSizing$1 = table => getRawWidth$1(table).exists(size => rPercentageBasedSizeRegex.test(size));
1912
    const isPercentSizing$1 = table => getRawWidth$1(table).exists(size => rPercentageBasedSizeRegex.test(size));
1902
    const isPixelSizing$1 = table => getRawWidth$1(table).exists(size => rPixelBasedSizeRegex.test(size));
1913
    const isPixelSizing$1 = table => getRawWidth$1(table).exists(size => rPixelBasedSizeRegex.test(size));
1903
    const isNoneSizing$1 = table => getRawWidth$1(table).isNone();
1914
    const isNoneSizing$1 = table => getRawWidth$1(table).isNone();
1904
    const percentageBasedSizeRegex = constant(rPercentageBasedSizeRegex);
1915
    const percentageBasedSizeRegex = constant(rPercentageBasedSizeRegex);
Línea 1906... Línea 1917...
1906
    const isCol$1 = isTag('col');
1917
    const isCol$1 = isTag('col');
1907
    const getRawW = cell => {
1918
    const getRawW = cell => {
1908
      return getRawWidth$1(cell).getOrThunk(() => getPixelWidth$1(cell) + 'px');
1919
      return getRawWidth$1(cell).getOrThunk(() => getPixelWidth$1(cell) + 'px');
1909
    };
1920
    };
1910
    const getRawH = cell => {
1921
    const getRawH = cell => {
1911
      return getRawHeight(cell).getOrThunk(() => getHeight(cell) + 'px');
1922
      return getRawHeight$1(cell).getOrThunk(() => getHeight(cell) + 'px');
1912
    };
1923
    };
1913
    const justCols = warehouse => map$1(Warehouse.justColumns(warehouse), column => Optional.from(column.element));
1924
    const justCols = warehouse => map$1(Warehouse.justColumns(warehouse), column => Optional.from(column.element));
1914
    const isValidColumn = cell => {
1925
    const isValidColumn = cell => {
1915
      const browser = detect$2().browser;
1926
      const browser = detect$2().browser;
1916
      const supportsColWidths = browser.isChromium() || browser.isFirefox();
1927
      const supportsColWidths = browser.isChromium() || browser.isFirefox();
Línea 1953... Línea 1964...
1953
    const getPixelWidths = (warehouse, table, tableSize) => {
1964
    const getPixelWidths = (warehouse, table, tableSize) => {
1954
      return getWidthFrom(warehouse, table, getPixelWidth$1, deduced => {
1965
      return getWidthFrom(warehouse, table, getPixelWidth$1, deduced => {
1955
        return deduced.getOrThunk(tableSize.minCellWidth);
1966
        return deduced.getOrThunk(tableSize.minCellWidth);
1956
      });
1967
      });
1957
    };
1968
    };
1958
    const getHeightFrom = (warehouse, table, direction, getHeight, fallback) => {
1969
    const getHeightFrom = (warehouse, table, getHeight, fallback) => {
1959
      const rows$1 = rows(warehouse);
1970
      const rowCells = rows(warehouse);
-
 
1971
      const rows$1 = map$1(warehouse.all, r => Optional.some(r.element));
1960
      const backups = [Optional.some(direction.edge(table))].concat(map$1(direction.positions(rows$1, table), pos => pos.map(p => p.y)));
1972
      const backups = [Optional.some(height.edge(table))].concat(map$1(height.positions(rowCells, table), pos => pos.map(p => p.y)));
1961
      return map$1(rows$1, (cellOption, c) => {
-
 
1962
        return getDimension(cellOption, c, backups, not(hasRowspan), getHeight, fallback);
1973
      return map$1(rows$1, (row, i) => getDimension(row, i, backups, always, getHeight, fallback));
1963
      });
-
 
1964
    };
1974
    };
1965
    const getPixelHeights = (warehouse, table, direction) => {
1975
    const getPixelHeights = (warehouse, table) => {
1966
      return getHeightFrom(warehouse, table, direction, getHeight, deduced => {
1976
      return getHeightFrom(warehouse, table, getHeight, deduced => {
1967
        return deduced.getOrThunk(minHeight);
1977
        return deduced.getOrThunk(minHeight);
1968
      });
1978
      });
1969
    };
1979
    };
1970
    const getRawHeights = (warehouse, table, direction) => {
1980
    const getRawHeights = (warehouse, table) => {
1971
      return getHeightFrom(warehouse, table, direction, getRawH, getDeduced);
1981
      return getHeightFrom(warehouse, table, getRawH, getDeduced);
1972
    };
1982
    };
Línea 1973... Línea 1983...
1973
 
1983
 
1974
    const widthLookup = (table, getter) => () => {
1984
    const widthLookup = (table, getter) => () => {
1975
      if (inBody(table)) {
1985
      if (inBody(table)) {
Línea 2487... Línea 2497...
2487
      const options = editor.options;
2497
      const options = editor.options;
2488
      const defaultStyles = options.get('table_default_styles');
2498
      const defaultStyles = options.get('table_default_styles');
2489
      return options.isSet('table_default_styles') ? defaultStyles : determineDefaultTableStyles(editor, defaultStyles);
2499
      return options.isSet('table_default_styles') ? defaultStyles : determineDefaultTableStyles(editor, defaultStyles);
2490
    };
2500
    };
2491
    const tableUseColumnGroup = option('table_use_colgroups');
2501
    const tableUseColumnGroup = option('table_use_colgroups');
-
 
2502
    const fixedContainerSelector = option('fixed_toolbar_container');
-
 
2503
    const fixedToolbarContainerTarget = option('fixed_toolbar_container_target');
-
 
2504
    const fixedContainerTarget = editor => {
-
 
2505
      var _a;
-
 
2506
      if (!editor.inline) {
-
 
2507
        return Optional.none();
-
 
2508
      }
-
 
2509
      const selector = (_a = fixedContainerSelector(editor)) !== null && _a !== void 0 ? _a : '';
-
 
2510
      if (selector.length > 0) {
-
 
2511
        return descendant(body$1(), selector);
-
 
2512
      }
-
 
2513
      const element = fixedToolbarContainerTarget(editor);
-
 
2514
      if (isNonNullable(element)) {
-
 
2515
        return Optional.some(SugarElement.fromDom(element));
-
 
2516
      }
-
 
2517
      return Optional.none();
-
 
2518
    };
-
 
2519
    const useFixedContainer = editor => editor.inline && fixedContainerTarget(editor).isSome();
-
 
2520
    const getUiMode = option('ui_mode');
-
 
2521
    const isSplitUiMode = editor => !useFixedContainer(editor) && getUiMode(editor) === 'split';
Línea 2492... Línea 2522...
2492
 
2522
 
2493
    const closest = target => closest$1(target, '[contenteditable]');
2523
    const closest = target => closest$1(target, '[contenteditable]');
2494
    const isEditable$1 = (element, assumeEditable = false) => {
2524
    const isEditable$1 = (element, assumeEditable = false) => {
2495
      if (inBody(element)) {
2525
      if (inBody(element)) {
Línea 2510... Línea 2540...
2510
      each$2(rows$1(table), removeStyleAttribute);
2540
      each$2(rows$1(table), removeStyleAttribute);
2511
    };
2541
    };
2512
    const getSelectionStart = editor => SugarElement.fromDom(editor.selection.getStart());
2542
    const getSelectionStart = editor => SugarElement.fromDom(editor.selection.getStart());
2513
    const getPixelWidth = elm => elm.getBoundingClientRect().width;
2543
    const getPixelWidth = elm => elm.getBoundingClientRect().width;
2514
    const getPixelHeight = elm => elm.getBoundingClientRect().height;
2544
    const getPixelHeight = elm => elm.getBoundingClientRect().height;
2515
    const getRawWidth = (editor, elm) => {
2545
    const getRawValue = prop => (editor, elm) => {
2516
      const raw = editor.dom.getStyle(elm, 'width') || editor.dom.getAttrib(elm, 'width');
2546
      const raw = editor.dom.getStyle(elm, prop) || editor.dom.getAttrib(elm, prop);
2517
      return Optional.from(raw).filter(isNotEmpty);
2547
      return Optional.from(raw).filter(isNotEmpty);
2518
    };
2548
    };
-
 
2549
    const getRawWidth = getRawValue('width');
-
 
2550
    const getRawHeight = getRawValue('height');
2519
    const isPercentage$1 = value => /^(\d+(\.\d+)?)%$/.test(value);
2551
    const isPercentage$1 = value => /^(\d+(\.\d+)?)%$/.test(value);
2520
    const isPixel = value => /^(\d+(\.\d+)?)px$/.test(value);
2552
    const isPixel = value => /^(\d+(\.\d+)?)px$/.test(value);
2521
    const isInEditableContext$1 = cell => closest$2(cell, isTag('table')).exists(isEditable$1);
2553
    const isInEditableContext$1 = cell => closest$2(cell, isTag('table')).exists(isEditable$1);
Línea 2522... Línea 2554...
2522
 
2554
 
Línea 3011... Línea 3043...
3011
        removeDataStyle(replica);
3043
        removeDataStyle(replica);
3012
        return [replica];
3044
        return [replica];
3013
      });
3045
      });
3014
    };
3046
    };
3015
    const serializeElements = (editor, elements) => map$1(elements, elm => editor.selection.serializer.serialize(elm.dom, {})).join('');
3047
    const serializeElements = (editor, elements) => map$1(elements, elm => editor.selection.serializer.serialize(elm.dom, {})).join('');
3016
    const getTextContent = elements => map$1(elements, element => element.dom.innerText).join('');
3048
    const getTextContent = (editor, replicaElements) => {
-
 
3049
      const doc = editor.getDoc();
-
 
3050
      const dos = getRootNode(SugarElement.fromDom(editor.getBody()));
-
 
3051
      const offscreenDiv = SugarElement.fromTag('div', doc);
-
 
3052
      set$2(offscreenDiv, 'data-mce-bogus', 'all');
-
 
3053
      setAll(offscreenDiv, {
-
 
3054
        position: 'fixed',
-
 
3055
        left: '-9999999px',
-
 
3056
        top: '0',
-
 
3057
        overflow: 'hidden',
-
 
3058
        opacity: '0'
-
 
3059
      });
-
 
3060
      const root = getContentContainer(dos);
-
 
3061
      append(offscreenDiv, replicaElements);
-
 
3062
      append$1(root, offscreenDiv);
-
 
3063
      const textContent = offscreenDiv.dom.innerText;
-
 
3064
      remove$6(offscreenDiv);
-
 
3065
      return textContent;
-
 
3066
    };
3017
    const registerEvents = (editor, actions) => {
3067
    const registerEvents = (editor, actions) => {
3018
      editor.on('BeforeGetContent', e => {
3068
      editor.on('BeforeGetContent', e => {
3019
        const multiCellContext = cells => {
3069
        const multiCellContext = cells => {
3020
          e.preventDefault();
3070
          e.preventDefault();
3021
          extractSelected(cells).each(elements => {
3071
          extractSelected(cells).each(replicaElements => {
3022
            e.content = e.format === 'text' ? getTextContent(elements) : serializeElements(editor, elements);
3072
            const content = e.format === 'text' ? getTextContent(editor, replicaElements) : serializeElements(editor, replicaElements);
-
 
3073
            e.content = content;
3023
          });
3074
          });
3024
        };
3075
        };
3025
        if (e.selection === true) {
3076
        if (e.selection === true) {
3026
          const cells = getCellsFromFakeSelection(editor);
3077
          const cells = getCellsFromFakeSelection(editor);
3027
          if (cells.length >= 1) {
3078
          if (cells.length >= 1) {
Línea 4010... Línea 4061...
4010
      const rows = extractGridDetails(grid).rows;
4061
      const rows = extractGridDetails(grid).rows;
4011
      const targetCells = map$1(details, detail => getCell(rows[detail.row], detail.column));
4062
      const targetCells = map$1(details, detail => getCell(rows[detail.row], detail.column));
4012
      return replaceIn(grid, targetCells, comparator, substitution, replace, Optional.none, always);
4063
      return replaceIn(grid, targetCells, comparator, substitution, replace, Optional.none, always);
4013
    };
4064
    };
Línea 4014... Línea 4065...
4014
 
4065
 
4015
    const generate = cases => {
4066
    const generate$1 = cases => {
4016
      if (!isArray(cases)) {
4067
      if (!isArray(cases)) {
4017
        throw new Error('cases must be an array');
4068
        throw new Error('cases must be an array');
4018
      }
4069
      }
4019
      if (cases.length === 0) {
4070
      if (cases.length === 0) {
Línea 4073... Línea 4124...
4073
          };
4124
          };
4074
        };
4125
        };
4075
      });
4126
      });
4076
      return adt;
4127
      return adt;
4077
    };
4128
    };
4078
    const Adt = { generate };
4129
    const Adt = { generate: generate$1 };
Línea 4079... Línea 4130...
4079
 
4130
 
4080
    const adt$6 = Adt.generate([
4131
    const adt$6 = Adt.generate([
4081
      { none: [] },
4132
      { none: [] },
4082
      { only: ['index'] },
4133
      { only: ['index'] },
Línea 4155... Línea 4206...
4155
        element: column.element,
4206
        element: column.element,
4156
        width: widths[index],
4207
        width: widths[index],
4157
        colspan: column.colspan
4208
        colspan: column.colspan
4158
      }));
4209
      }));
4159
    };
4210
    };
4160
    const recalculateHeightForCells = (warehouse, heights) => {
-
 
4161
      const all = Warehouse.justCells(warehouse);
-
 
4162
      return map$1(all, cell => {
-
 
4163
        const height = total(cell.row, cell.row + cell.rowspan, heights);
-
 
4164
        return {
-
 
4165
          element: cell.element,
-
 
4166
          height,
-
 
4167
          rowspan: cell.rowspan
-
 
4168
        };
-
 
4169
      });
-
 
4170
    };
-
 
4171
    const matchRowHeight = (warehouse, heights) => {
4211
    const matchRowHeight = (warehouse, heights) => {
4172
      return map$1(warehouse.all, (row, i) => {
4212
      return map$1(warehouse.all, (row, i) => {
4173
        return {
4213
        return {
4174
          element: row.element,
4214
          element: row.element,
4175
          height: heights[i]
4215
          height: heights[i]
Línea 4200... Línea 4240...
4200
      const deltas = determine(widths, index, clampedStep, tableSize, resizing);
4240
      const deltas = determine(widths, index, clampedStep, tableSize, resizing);
4201
      const newWidths = map$1(deltas, (dx, i) => dx + widths[i]);
4241
      const newWidths = map$1(deltas, (dx, i) => dx + widths[i]);
4202
      recalculateAndApply(warehouse, newWidths, tableSize);
4242
      recalculateAndApply(warehouse, newWidths, tableSize);
4203
      resizing.resizeTable(tableSize.adjustTableWidth, clampedStep, isLastColumn);
4243
      resizing.resizeTable(tableSize.adjustTableWidth, clampedStep, isLastColumn);
4204
    };
4244
    };
4205
    const adjustHeight = (table, delta, index, direction) => {
4245
    const adjustHeight = (table, delta, index) => {
4206
      const warehouse = Warehouse.fromTable(table);
4246
      const warehouse = Warehouse.fromTable(table);
4207
      const heights = getPixelHeights(warehouse, table, direction);
4247
      const heights = getPixelHeights(warehouse, table);
4208
      const newHeights = map$1(heights, (dy, i) => index === i ? Math.max(delta + dy, minHeight()) : dy);
4248
      const newHeights = map$1(heights, (dy, i) => index === i ? Math.max(delta + dy, minHeight()) : dy);
4209
      const newCellSizes = recalculateHeightForCells(warehouse, newHeights);
-
 
4210
      const newRowSizes = matchRowHeight(warehouse, newHeights);
4249
      const newRowSizes = matchRowHeight(warehouse, newHeights);
4211
      each$2(newRowSizes, row => {
4250
      each$2(newRowSizes, row => {
4212
        setHeight(row.element, row.height);
4251
        setHeight(row.element, row.height);
4213
      });
4252
      });
4214
      each$2(newCellSizes, cell => {
4253
      each$2(Warehouse.justCells(warehouse), cell => {
4215
        setHeight(cell.element, cell.height);
4254
        removeHeight(cell.element);
4216
      });
4255
      });
4217
      const total = sumUp(newHeights);
4256
      const total = sumUp(newHeights);
4218
      setHeight(table, total);
4257
      setHeight(table, total);
4219
    };
4258
    };
4220
    const adjustAndRedistributeWidths$1 = (_table, list, details, tableSize, resizeBehaviour) => {
4259
    const adjustAndRedistributeWidths$1 = (_table, list, details, tableSize, resizeBehaviour) => {
Línea 4579... Línea 4618...
4579
      return bundle(newGrid, columns[0].row, Math.min(columns[0].column, maxColIndex));
4618
      return bundle(newGrid, columns[0].row, Math.min(columns[0].column, maxColIndex));
4580
    };
4619
    };
4581
    const opEraseRows = (grid, details, _comparator, _genWrappers) => {
4620
    const opEraseRows = (grid, details, _comparator, _genWrappers) => {
4582
      const rows = uniqueRows(details);
4621
      const rows = uniqueRows(details);
4583
      const newGrid = deleteRowsAt(grid, rows[0].row, rows[rows.length - 1].row);
4622
      const newGrid = deleteRowsAt(grid, rows[0].row, rows[rows.length - 1].row);
4584
      const maxRowIndex = newGrid.length > 0 ? newGrid.length - 1 : 0;
4623
      const maxRowIndex = Math.max(extractGridDetails(newGrid).rows.length - 1, 0);
4585
      return bundle(newGrid, Math.min(details[0].row, maxRowIndex), details[0].column);
4624
      return bundle(newGrid, Math.min(details[0].row, maxRowIndex), details[0].column);
4586
    };
4625
    };
4587
    const opMergeCells = (grid, mergable, comparator, genWrappers) => {
4626
    const opMergeCells = (grid, mergable, comparator, genWrappers) => {
4588
      const cells = mergable.cells;
4627
      const cells = mergable.cells;
4589
      merge(cells);
4628
      merge(cells);
Línea 4624... Línea 4663...
4624
      const rows = extractGridDetails(grid).rows;
4663
      const rows = extractGridDetails(grid).rows;
4625
      const index = pasteDetails.cells[pasteDetails.cells.length - 1].column + pasteDetails.cells[pasteDetails.cells.length - 1].colspan;
4664
      const index = pasteDetails.cells[pasteDetails.cells.length - 1].column + pasteDetails.cells[pasteDetails.cells.length - 1].colspan;
4626
      const context = rows[pasteDetails.cells[0].row];
4665
      const context = rows[pasteDetails.cells[0].row];
4627
      const gridB = gridifyRows(pasteDetails.clipboard, pasteDetails.generators, context);
4666
      const gridB = gridifyRows(pasteDetails.clipboard, pasteDetails.generators, context);
4628
      const mergedGrid = insertCols(index, grid, gridB, pasteDetails.generators, comparator);
4667
      const mergedGrid = insertCols(index, grid, gridB, pasteDetails.generators, comparator);
4629
      return bundle(mergedGrid, pasteDetails.cells[0].row, pasteDetails.cells[0].column);
4668
      return bundle(mergedGrid, pasteDetails.cells[0].row, index);
4630
    };
4669
    };
4631
    const opPasteRowsBefore = (grid, pasteDetails, comparator, _genWrappers) => {
4670
    const opPasteRowsBefore = (grid, pasteDetails, comparator, _genWrappers) => {
4632
      const rows = extractGridDetails(grid).rows;
4671
      const rows = extractGridDetails(grid).rows;
4633
      const index = pasteDetails.cells[0].row;
4672
      const index = pasteDetails.cells[0].row;
4634
      const context = rows[index];
4673
      const context = rows[index];
Línea 4640... Línea 4679...
4640
      const rows = extractGridDetails(grid).rows;
4679
      const rows = extractGridDetails(grid).rows;
4641
      const index = pasteDetails.cells[pasteDetails.cells.length - 1].row + pasteDetails.cells[pasteDetails.cells.length - 1].rowspan;
4680
      const index = pasteDetails.cells[pasteDetails.cells.length - 1].row + pasteDetails.cells[pasteDetails.cells.length - 1].rowspan;
4642
      const context = rows[pasteDetails.cells[0].row];
4681
      const context = rows[pasteDetails.cells[0].row];
4643
      const gridB = gridifyRows(pasteDetails.clipboard, pasteDetails.generators, context);
4682
      const gridB = gridifyRows(pasteDetails.clipboard, pasteDetails.generators, context);
4644
      const mergedGrid = insertRows(index, grid, gridB, pasteDetails.generators, comparator);
4683
      const mergedGrid = insertRows(index, grid, gridB, pasteDetails.generators, comparator);
4645
      return bundle(mergedGrid, pasteDetails.cells[0].row, pasteDetails.cells[0].column);
4684
      return bundle(mergedGrid, index, pasteDetails.cells[0].column);
4646
    };
4685
    };
4647
    const opGetColumnsType = (table, target) => {
4686
    const opGetColumnsType = (table, target) => {
4648
      const house = Warehouse.fromTable(table);
4687
      const house = Warehouse.fromTable(table);
4649
      const details = onCells(house, target);
4688
      const details = onCells(house, target);
4650
      return details.bind(selectedCells => {
4689
      return details.bind(selectedCells => {
Línea 4707... Línea 4746...
4707
    const insertColumnsAfter = run(opInsertColumnsAfter, insertColumnsExtractor(false), adjustAndRedistributeWidths, noop, Generators.modification);
4746
    const insertColumnsAfter = run(opInsertColumnsAfter, insertColumnsExtractor(false), adjustAndRedistributeWidths, noop, Generators.modification);
4708
    const eraseColumns = run(opEraseColumns, eraseColumnsExtractor, adjustAndRedistributeWidths, prune, Generators.modification);
4747
    const eraseColumns = run(opEraseColumns, eraseColumnsExtractor, adjustAndRedistributeWidths, prune, Generators.modification);
4709
    const eraseRows = run(opEraseRows, onCells, noop, prune, Generators.modification);
4748
    const eraseRows = run(opEraseRows, onCells, noop, prune, Generators.modification);
4710
    const makeColumnsHeader = run(opMakeColumnsHeader, onUnlockedCells, noop, noop, headerCellGenerator);
4749
    const makeColumnsHeader = run(opMakeColumnsHeader, onUnlockedCells, noop, noop, headerCellGenerator);
4711
    const unmakeColumnsHeader = run(opUnmakeColumnsHeader, onUnlockedCells, noop, noop, bodyCellGenerator);
4750
    const unmakeColumnsHeader = run(opUnmakeColumnsHeader, onUnlockedCells, noop, noop, bodyCellGenerator);
4712
    const makeRowsHeader = run(opMakeRowsHeader, onUnlockedCells, noop, noop, headerCellGenerator);
4751
    const makeRowsHeader = run(opMakeRowsHeader, onCells, noop, noop, headerCellGenerator);
4713
    const makeRowsBody = run(opMakeRowsBody, onUnlockedCells, noop, noop, bodyCellGenerator);
4752
    const makeRowsBody = run(opMakeRowsBody, onCells, noop, noop, bodyCellGenerator);
4714
    const makeRowsFooter = run(opMakeRowsFooter, onUnlockedCells, noop, noop, bodyCellGenerator);
4753
    const makeRowsFooter = run(opMakeRowsFooter, onCells, noop, noop, bodyCellGenerator);
4715
    const makeCellsHeader = run(opMakeCellsHeader, onUnlockedCells, noop, noop, headerCellGenerator);
4754
    const makeCellsHeader = run(opMakeCellsHeader, onUnlockedCells, noop, noop, headerCellGenerator);
4716
    const unmakeCellsHeader = run(opUnmakeCellsHeader, onUnlockedCells, noop, noop, bodyCellGenerator);
4755
    const unmakeCellsHeader = run(opUnmakeCellsHeader, onUnlockedCells, noop, noop, bodyCellGenerator);
4717
    const mergeCells = run(opMergeCells, onUnlockedMergable, resize, noop, Generators.merging);
4756
    const mergeCells = run(opMergeCells, onUnlockedMergable, resize, noop, Generators.merging);
4718
    const unmergeCells = run(opUnmergeCells, onUnlockedUnmergable, resize, noop, Generators.merging);
4757
    const unmergeCells = run(opUnmergeCells, onUnlockedUnmergable, resize, noop, Generators.merging);
4719
    const pasteCells = run(opPasteCells, onPaste, resize, noop, Generators.modification);
4758
    const pasteCells = run(opPasteCells, onPaste, resize, noop, Generators.modification);
Línea 5108... Línea 5147...
5108
      each$2(columns, (column, index) => {
5147
      each$2(columns, (column, index) => {
5109
        const width = sum([newWidths[index]], minWidth());
5148
        const width = sum([newWidths[index]], minWidth());
5110
        set$1(column.element, 'width', width + unit);
5149
        set$1(column.element, 'width', width + unit);
5111
      });
5150
      });
5112
    };
5151
    };
5113
    const redistributeToH = (newHeights, rows, cells, unit) => {
5152
    const redistributeToH = (newHeights, rows, cells) => {
5114
      each$2(cells, cell => {
5153
      each$2(cells, cell => {
5115
        const heights = newHeights.slice(cell.row, cell.rowspan + cell.row);
-
 
5116
        const h = sum(heights, minHeight());
-
 
5117
        set$1(cell.element, 'height', h + unit);
5154
        remove$5(cell.element, 'height');
5118
      });
5155
      });
5119
      each$2(rows, (row, i) => {
5156
      each$2(rows, (row, i) => {
5120
        set$1(row.element, 'height', newHeights[i]);
5157
        set$1(row.element, 'height', newHeights[i]);
5121
      });
5158
      });
5122
    };
5159
    };
Línea 5139... Línea 5176...
5139
          redistributeToW(nuWidths, cells, widthUnit);
5176
          redistributeToW(nuWidths, cells, widthUnit);
5140
        }
5177
        }
5141
        set$1(table, 'width', newWidth);
5178
        set$1(table, 'width', newWidth);
5142
      });
5179
      });
5143
      optHeight.each(newHeight => {
5180
      optHeight.each(newHeight => {
5144
        const hUnit = getUnit(newHeight);
-
 
5145
        const totalHeight = get$8(table);
5181
        const totalHeight = get$8(table);
5146
        const oldHeights = getRawHeights(warehouse, table, height);
5182
        const oldHeights = getRawHeights(warehouse, table);
5147
        const nuHeights = redistribute$1(oldHeights, totalHeight, newHeight);
5183
        const nuHeights = redistribute$1(oldHeights, totalHeight, newHeight);
5148
        redistributeToH(nuHeights, rows, cells, hUnit);
5184
        redistributeToH(nuHeights, rows, cells);
5149
        set$1(table, 'height', newHeight);
5185
        set$1(table, 'height', newHeight);
5150
      });
5186
      });
5151
    };
5187
    };
5152
    const isPercentSizing = isPercentSizing$1;
5188
    const isPercentSizing = isPercentSizing$1;
5153
    const isPixelSizing = isPixelSizing$1;
5189
    const isPixelSizing = isPixelSizing$1;
5154
    const isNoneSizing = isNoneSizing$1;
5190
    const isNoneSizing = isNoneSizing$1;
Línea 5155... Línea 5191...
5155
 
5191
 
5156
    const cleanupLegacyAttributes = element => {
5192
    const cleanupLegacyAttributes = element => {
-
 
5193
      remove$7(element, 'width');
5157
      remove$7(element, 'width');
5194
      remove$7(element, 'height');
5158
    };
5195
    };
5159
    const convertToPercentSize = table => {
5196
    const convertToPercentSizeWidth = table => {
5160
      const newWidth = getPercentTableWidth(table);
5197
      const newWidth = getPercentTableWidth(table);
5161
      redistribute(table, Optional.some(newWidth), Optional.none());
5198
      redistribute(table, Optional.some(newWidth), Optional.none());
5162
      cleanupLegacyAttributes(table);
5199
      cleanupLegacyAttributes(table);
5163
    };
5200
    };
5164
    const convertToPixelSize = table => {
5201
    const convertToPixelSizeWidth = table => {
5165
      const newWidth = getPixelTableWidth(table);
5202
      const newWidth = getPixelTableWidth(table);
5166
      redistribute(table, Optional.some(newWidth), Optional.none());
5203
      redistribute(table, Optional.some(newWidth), Optional.none());
5167
      cleanupLegacyAttributes(table);
5204
      cleanupLegacyAttributes(table);
-
 
5205
    };
-
 
5206
    const convertToPixelSizeHeight = table => {
-
 
5207
      const newHeight = getPixelTableHeight(table);
-
 
5208
      redistribute(table, Optional.none(), Optional.some(newHeight));
-
 
5209
      cleanupLegacyAttributes(table);
5168
    };
5210
    };
5169
    const convertToNoneSize = table => {
5211
    const convertToNoneSizeWidth = table => {
5170
      remove$5(table, 'width');
5212
      remove$5(table, 'width');
5171
      const columns = columns$1(table);
5213
      const columns = columns$1(table);
5172
      const rowElements = columns.length > 0 ? columns : cells$1(table);
5214
      const rowElements = columns.length > 0 ? columns : cells$1(table);
5173
      each$2(rowElements, cell => {
5215
      each$2(rowElements, cell => {
Línea 5272... Línea 5314...
5272
        editor.insertContent(html);
5314
        editor.insertContent(html);
5273
        editor.addVisual();
5315
        editor.addVisual();
5274
      });
5316
      });
5275
      return descendant(getBody(editor), 'table[data-mce-id="__mce"]').map(table => {
5317
      return descendant(getBody(editor), 'table[data-mce-id="__mce"]').map(table => {
5276
        if (isTablePixelsForced(editor)) {
5318
        if (isTablePixelsForced(editor)) {
5277
          convertToPixelSize(table);
5319
          convertToPixelSizeWidth(table);
5278
        } else if (isTableResponsiveForced(editor)) {
5320
        } else if (isTableResponsiveForced(editor)) {
5279
          convertToNoneSize(table);
5321
          convertToNoneSizeWidth(table);
5280
        } else if (isTablePercentagesForced(editor) || isPercentage(defaultStyles.width)) {
5322
        } else if (isTablePercentagesForced(editor) || isPercentage(defaultStyles.width)) {
5281
          convertToPercentSize(table);
5323
          convertToPercentSizeWidth(table);
5282
        }
5324
        }
5283
        removeDataStyle(table);
5325
        removeDataStyle(table);
5284
        remove$7(table, 'data-mce-id');
5326
        remove$7(table, 'data-mce-id');
5285
        fireEvents(editor, table);
5327
        fireEvents(editor, table);
5286
        selectFirstCellInTable(editor, table);
5328
        selectFirstCellInTable(editor, table);
Línea 5353... Línea 5395...
5353
      const setSizingMode = sizing => getSelectionStartCellOrCaption(editor).each(cellOrCaption => {
5395
      const setSizingMode = sizing => getSelectionStartCellOrCaption(editor).each(cellOrCaption => {
5354
        const isForcedSizing = isTableResponsiveForced(editor) || isTablePixelsForced(editor) || isTablePercentagesForced(editor);
5396
        const isForcedSizing = isTableResponsiveForced(editor) || isTablePixelsForced(editor) || isTablePercentagesForced(editor);
5355
        if (!isForcedSizing) {
5397
        if (!isForcedSizing) {
5356
          table(cellOrCaption, isRoot).each(table => {
5398
          table(cellOrCaption, isRoot).each(table => {
5357
            if (sizing === 'relative' && !isPercentSizing(table)) {
5399
            if (sizing === 'relative' && !isPercentSizing(table)) {
5358
              convertToPercentSize(table);
5400
              convertToPercentSizeWidth(table);
5359
            } else if (sizing === 'fixed' && !isPixelSizing(table)) {
5401
            } else if (sizing === 'fixed' && !isPixelSizing(table)) {
5360
              convertToPixelSize(table);
5402
              convertToPixelSizeWidth(table);
5361
            } else if (sizing === 'responsive' && !isNoneSizing(table)) {
5403
            } else if (sizing === 'responsive' && !isNoneSizing(table)) {
5362
              convertToNoneSize(table);
5404
              convertToNoneSizeWidth(table);
5363
            }
5405
            }
5364
            removeDataStyle(table);
5406
            removeDataStyle(table);
5365
            fireTableModified(editor, table.dom, structureModified);
5407
            fireTableModified(editor, table.dom, structureModified);
5366
          });
5408
          });
5367
        }
5409
        }
Línea 6312... Línea 6354...
6312
                const singleCell = boxes[0];
6354
                const singleCell = boxes[0];
6313
                const isNonEditableCell = getRaw(singleCell) === 'false';
6355
                const isNonEditableCell = getRaw(singleCell) === 'false';
6314
                const isCellClosestContentEditable = is(closest(event.target), singleCell, eq$1);
6356
                const isCellClosestContentEditable = is(closest(event.target), singleCell, eq$1);
6315
                if (isNonEditableCell && isCellClosestContentEditable) {
6357
                if (isNonEditableCell && isCellClosestContentEditable) {
6316
                  annotations.selectRange(container, boxes, singleCell, singleCell);
6358
                  annotations.selectRange(container, boxes, singleCell, singleCell);
6317
                  bridge.selectContents(singleCell);
-
 
6318
                }
6359
                }
6319
              } else if (boxes.length > 1) {
6360
              } else if (boxes.length > 1) {
6320
                annotations.selectRange(container, boxes, cellSel.start, cellSel.finish);
6361
                annotations.selectRange(container, boxes, cellSel.start, cellSel.finish);
6321
                bridge.selectContents(finish);
6362
                bridge.selectContents(finish);
6322
              }
6363
              }
Línea 6430... Línea 6471...
6430
      getWin,
6471
      getWin,
6431
      range
6472
      range
6432
    };
6473
    };
Línea 6433... Línea 6474...
6433
 
6474
 
6434
    const caretPositionFromPoint = (doc, x, y) => {
6475
    const caretPositionFromPoint = (doc, x, y) => {
6435
      var _a, _b;
6476
      var _a;
6436
      return Optional.from((_b = (_a = doc.dom).caretPositionFromPoint) === null || _b === void 0 ? void 0 : _b.call(_a, x, y)).bind(pos => {
6477
      return Optional.from((_a = doc.caretPositionFromPoint) === null || _a === void 0 ? void 0 : _a.call(doc, x, y)).bind(pos => {
6437
        if (pos.offsetNode === null) {
6478
        if (pos.offsetNode === null) {
6438
          return Optional.none();
6479
          return Optional.none();
6439
        }
6480
        }
6440
        const r = doc.dom.createRange();
6481
        const r = doc.createRange();
6441
        r.setStart(pos.offsetNode, pos.offset);
6482
        r.setStart(pos.offsetNode, pos.offset);
6442
        r.collapse();
6483
        r.collapse();
6443
        return Optional.some(r);
6484
        return Optional.some(r);
6444
      });
6485
      });
6445
    };
6486
    };
6446
    const caretRangeFromPoint = (doc, x, y) => {
6487
    const caretRangeFromPoint = (doc, x, y) => {
6447
      var _a, _b;
6488
      var _a;
6448
      return Optional.from((_b = (_a = doc.dom).caretRangeFromPoint) === null || _b === void 0 ? void 0 : _b.call(_a, x, y));
6489
      return Optional.from((_a = doc.caretRangeFromPoint) === null || _a === void 0 ? void 0 : _a.call(doc, x, y));
6449
    };
6490
    };
6450
    const availableSearch = (() => {
6491
    const availableSearch = (doc, x, y) => {
6451
      if (document.caretPositionFromPoint) {
6492
      if (doc.caretPositionFromPoint) {
6452
        return caretPositionFromPoint;
6493
        return caretPositionFromPoint(doc, x, y);
6453
      } else if (document.caretRangeFromPoint) {
6494
      } else if (doc.caretRangeFromPoint) {
6454
        return caretRangeFromPoint;
6495
        return caretRangeFromPoint(doc, x, y);
6455
      } else {
6496
      } else {
6456
        return Optional.none;
6497
        return Optional.none();
6457
      }
6498
      }
6458
    })();
6499
    };
6459
    const fromPoint = (win, x, y) => {
6500
    const fromPoint = (win, x, y) => {
6460
      const doc = SugarElement.fromDom(win.document);
6501
      const doc = win.document;
6461
      return availableSearch(doc, x, y).map(rng => SimRange.create(SugarElement.fromDom(rng.startContainer), rng.startOffset, SugarElement.fromDom(rng.endContainer), rng.endOffset));
6502
      return availableSearch(doc, x, y).map(rng => SimRange.create(SugarElement.fromDom(rng.startContainer), rng.startOffset, SugarElement.fromDom(rng.endContainer), rng.endOffset));
Línea 6462... Línea 6503...
6462
    };
6503
    };
6463
 
6504
 
Línea 6522... Línea 6563...
6522
          if (selection.setBaseAndExtent) {
6563
          if (selection.setBaseAndExtent) {
6523
            selection.setBaseAndExtent(start.dom, soffset, finish.dom, foffset);
6564
            selection.setBaseAndExtent(start.dom, soffset, finish.dom, foffset);
6524
          } else if (selection.extend) {
6565
          } else if (selection.extend) {
6525
            try {
6566
            try {
6526
              setLegacyRtlRange(win, selection, start, soffset, finish, foffset);
6567
              setLegacyRtlRange(win, selection, start, soffset, finish, foffset);
6527
            } catch (e) {
6568
            } catch (_a) {
6528
              doSetRange(win, finish, foffset, start, soffset);
6569
              doSetRange(win, finish, foffset, start, soffset);
6529
            }
6570
            }
6530
          } else {
6571
          } else {
6531
            doSetRange(win, finish, foffset, start, soffset);
6572
            doSetRange(win, finish, foffset, start, soffset);
6532
          }
6573
          }
Línea 6993... Línea 7034...
6993
    const TableCellSelectionHandler = (editor, resizeHandler) => {
7034
    const TableCellSelectionHandler = (editor, resizeHandler) => {
6994
      const cellSelection = Selections(() => SugarElement.fromDom(editor.getBody()), () => getSelectionCell(getSelectionStart(editor), getIsRoot(editor)), ephemera.selectedSelector);
7035
      const cellSelection = Selections(() => SugarElement.fromDom(editor.getBody()), () => getSelectionCell(getSelectionStart(editor), getIsRoot(editor)), ephemera.selectedSelector);
6995
      const onSelection = (cells, start, finish) => {
7036
      const onSelection = (cells, start, finish) => {
6996
        const tableOpt = table(start);
7037
        const tableOpt = table(start);
6997
        tableOpt.each(table => {
7038
        tableOpt.each(table => {
-
 
7039
          const cellsDom = map$1(cells, cell => cell.dom);
6998
          const cloneFormats = getTableCloneElements(editor);
7040
          const cloneFormats = getTableCloneElements(editor);
6999
          const generators = cellOperations(noop, SugarElement.fromDom(editor.getDoc()), cloneFormats);
7041
          const generators = cellOperations(noop, SugarElement.fromDom(editor.getDoc()), cloneFormats);
7000
          const selectedCells = getCellsFromSelection(editor);
7042
          const selectedCells = getCellsFromSelection(editor);
7001
          const otherCells = getOtherCells(table, { selection: selectedCells }, generators);
7043
          const otherCellsDom = getOtherCells(table, { selection: selectedCells }, generators).map(otherCells => map(otherCells, cellArr => map$1(cellArr, cell => cell.dom))).getOrUndefined();
7002
          fireTableSelectionChange(editor, cells, start, finish, otherCells);
7044
          fireTableSelectionChange(editor, cellsDom, start.dom, finish.dom, otherCellsDom);
7003
        });
7045
        });
7004
      };
7046
      };
7005
      const onClear = () => fireTableSelectionClear(editor);
7047
      const onClear = () => fireTableSelectionClear(editor);
7006
      const annotations = SelectionAnnotation.byAttr(ephemera, onSelection, onClear);
7048
      const annotations = SelectionAnnotation.byAttr(ephemera, onSelection, onClear);
7007
      editor.on('init', _e => {
7049
      editor.on('init', _e => {
Línea 7705... Línea 7747...
7705
        events.trigger.startAdjust();
7747
        events.trigger.startAdjust();
7706
        mutation.assign(target);
7748
        mutation.assign(target);
7707
        set$2(target, 'data-initial-' + dir, getCssValue(target, dir));
7749
        set$2(target, 'data-initial-' + dir, getCssValue(target, dir));
7708
        add(target, resizeBarDragging);
7750
        add(target, resizeBarDragging);
7709
        set$1(target, 'opacity', '0.2');
7751
        set$1(target, 'opacity', '0.2');
7710
        resizing.go(wire.parent());
7752
        resizing.go(wire.dragContainer());
7711
      };
7753
      };
7712
      const mousedown = bind(wire.parent(), 'mousedown', event => {
7754
      const mousedown = bind(wire.parent(), 'mousedown', event => {
7713
        if (isRowBar(event.target)) {
7755
        if (isRowBar(event.target)) {
7714
          handler(event.target, 'top');
7756
          handler(event.target, 'top');
7715
        }
7757
        }
Línea 7783... Línea 7825...
7783
      });
7825
      });
7784
      manager.events.adjustHeight.bind(event => {
7826
      manager.events.adjustHeight.bind(event => {
7785
        const table = event.table;
7827
        const table = event.table;
7786
        events.trigger.beforeResize(table, 'row');
7828
        events.trigger.beforeResize(table, 'row');
7787
        const delta = hdirection.delta(event.delta, table);
7829
        const delta = hdirection.delta(event.delta, table);
7788
        adjustHeight(table, delta, event.row, hdirection);
7830
        adjustHeight(table, delta, event.row);
7789
        events.trigger.afterResize(table, 'row');
7831
        events.trigger.afterResize(table, 'row');
7790
      });
7832
      });
7791
      manager.events.startAdjust.bind(_event => {
7833
      manager.events.startAdjust.bind(_event => {
7792
        events.trigger.startDrag();
7834
        events.trigger.startDrag();
7793
      });
7835
      });
Línea 7809... Línea 7851...
7809
        events: events.registry
7851
        events: events.registry
7810
      };
7852
      };
7811
    };
7853
    };
7812
    const TableResize = { create };
7854
    const TableResize = { create };
Línea -... Línea 7855...
-
 
7855
 
-
 
7856
    const random = () => window.crypto.getRandomValues(new Uint32Array(1))[0] / 4294967295;
-
 
7857
 
-
 
7858
    let unique = 0;
-
 
7859
    const generate = prefix => {
-
 
7860
      const date = new Date();
-
 
7861
      const time = date.getTime();
-
 
7862
      const random$1 = Math.floor(random() * 1000000000);
-
 
7863
      unique++;
-
 
7864
      return prefix + '_' + random$1 + unique + String(time);
-
 
7865
    };
7813
 
7866
 
7814
    const only = (element, isResizable) => {
7867
    const only = (element, isResizable) => {
7815
      const parent = isDocument(element) ? documentElement(element) : element;
7868
      const parent = isDocument(element) ? documentElement(element) : element;
7816
      return {
7869
      return {
7817
        parent: constant(parent),
7870
        parent: constant(parent),
-
 
7871
        view: constant(element),
7818
        view: constant(element),
7872
        dragContainer: constant(parent),
7819
        origin: constant(SugarPosition(0, 0)),
7873
        origin: constant(SugarPosition(0, 0)),
7820
        isResizable
7874
        isResizable
7821
      };
7875
      };
7822
    };
7876
    };
7823
    const detached = (editable, chrome, isResizable) => {
7877
    const detached = (editable, chrome, isResizable) => {
7824
      const origin = () => absolute(chrome);
7878
      const origin = () => absolute(chrome);
7825
      return {
7879
      return {
7826
        parent: constant(chrome),
7880
        parent: constant(chrome),
-
 
7881
        view: constant(editable),
7827
        view: constant(editable),
7882
        dragContainer: constant(chrome),
7828
        origin,
7883
        origin,
7829
        isResizable
7884
        isResizable
7830
      };
7885
      };
7831
    };
7886
    };
7832
    const body = (editable, chrome, isResizable) => {
7887
    const body = (editable, chrome, isResizable) => {
7833
      return {
7888
      return {
7834
        parent: constant(chrome),
7889
        parent: constant(chrome),
-
 
7890
        view: constant(editable),
7835
        view: constant(editable),
7891
        dragContainer: constant(chrome),
7836
        origin: constant(SugarPosition(0, 0)),
7892
        origin: constant(SugarPosition(0, 0)),
7837
        isResizable
7893
        isResizable
7838
      };
7894
      };
-
 
7895
    };
-
 
7896
    const scrollable = (editable, chrome, dragContainer, isResizable) => {
-
 
7897
      return {
-
 
7898
        parent: constant(chrome),
-
 
7899
        view: constant(editable),
-
 
7900
        dragContainer: constant(dragContainer),
-
 
7901
        origin: () => absolute(chrome),
-
 
7902
        isResizable
-
 
7903
      };
7839
    };
7904
    };
7840
    const ResizeWire = {
7905
    const ResizeWire = {
7841
      only,
7906
      only,
7842
      detached,
7907
      detached,
-
 
7908
      body,
7843
      body
7909
      scrollable
Línea 7844... Línea 7910...
7844
    };
7910
    };
-
 
7911
 
7845
 
7912
    const createContainer = position => {
-
 
7913
      const id = generate('resizer-container');
7846
    const createContainer = () => {
7914
      const container = SugarElement.fromTag('div');
7847
      const container = SugarElement.fromTag('div');
7915
      set$2(container, 'id', id);
7848
      setAll(container, {
7916
      setAll(container, {
7849
        position: 'static',
7917
        position,
7850
        height: '0',
7918
        height: '0',
7851
        width: '0',
7919
        width: '0',
7852
        padding: '0',
7920
        padding: '0',
7853
        margin: '0',
7921
        margin: '0',
7854
        border: '0'
-
 
7855
      });
7922
        border: '0'
7856
      append$1(body$1(), container);
7923
      });
-
 
7924
      return container;
-
 
7925
    };
-
 
7926
    const getInlineResizeWire = (editor, isResizable) => {
-
 
7927
      const isSplitUiMode$1 = isSplitUiMode(editor);
-
 
7928
      const editorBody = SugarElement.fromDom(editor.getBody());
-
 
7929
      const container = createContainer(isSplitUiMode$1 ? 'relative' : 'static');
-
 
7930
      const body = body$1();
-
 
7931
      if (isSplitUiMode$1) {
-
 
7932
        after$5(editorBody, container);
-
 
7933
        return ResizeWire.scrollable(editorBody, container, body, isResizable);
-
 
7934
      }
-
 
7935
      append$1(body, container);
7857
      return container;
7936
      return ResizeWire.body(editorBody, container, isResizable);
-
 
7937
    };
-
 
7938
    const get = (editor, isResizable) => {
-
 
7939
      if (editor.inline) {
7858
    };
7940
        return getInlineResizeWire(editor, isResizable);
7859
    const get = (editor, isResizable) => {
7941
      }
7860
      return editor.inline ? ResizeWire.body(SugarElement.fromDom(editor.getBody()), createContainer(), isResizable) : ResizeWire.only(SugarElement.fromDom(editor.getDoc()), isResizable);
7942
      return ResizeWire.only(SugarElement.fromDom(editor.getDoc()), isResizable);
7861
    };
7943
    };
7862
    const remove = (editor, wire) => {
7944
    const remove = (editor, wire) => {
7863
      if (editor.inline) {
7945
      if (editor.inline) {
7864
        remove$6(wire.parent());
7946
        remove$6(wire.parent());
Línea 7865... Línea 7947...
7865
      }
7947
      }
7866
    };
7948
    };
7867
 
7949
 
7868
    const isTable = node => isNonNullable(node) && node.nodeName === 'TABLE';
7950
    const isTable = node => isNonNullable(node) && node.nodeName === 'TABLE';
7869
    const barResizerPrefix = 'bar-';
7951
    const barResizerPrefix = 'bar-';
7870
    const isResizable = elm => get$b(elm, 'data-mce-resize') !== 'false';
7952
    const isResizable = elm => get$b(elm, 'data-mce-resize') !== 'false';
7871
    const syncPixels = table => {
7953
    const syncTableCellPixels = table => {
7872
      const warehouse = Warehouse.fromTable(table);
7954
      const warehouse = Warehouse.fromTable(table);
7873
      if (!Warehouse.hasColumns(warehouse)) {
7955
      if (!Warehouse.hasColumns(warehouse)) {
7874
        each$2(cells$1(table), cell => {
7956
        each$2(cells$1(table), cell => {
7875
          const computedWidth = get$a(cell, 'width');
7957
          const computedWidth = get$a(cell, 'width');
7876
          set$1(cell, 'width', computedWidth);
7958
          set$1(cell, 'width', computedWidth);
7877
          remove$7(cell, 'width');
7959
          remove$7(cell, 'width');
-
 
7960
        });
-
 
7961
      }
7878
        });
7962
    };
7879
      }
7963
    const isCornerResize = origin => startsWith(origin, 'corner-');
7880
    };
7964
    const getCornerLocation = origin => removeLeading(origin, 'corner-');
7881
    const TableResizeHandler = editor => {
7965
    const TableResizeHandler = editor => {
7882
      const selectionRng = value();
7966
      const selectionRng = value();
7883
      const tableResize = value();
7967
      const tableResize = value();
-
 
7968
      const resizeWire = value();
-
 
7969
      let startW;
7884
      const resizeWire = value();
7970
      let startRawW;
7885
      let startW;
7971
      let startH;
7886
      let startRawW;
7972
      let startRawH;
-
 
7973
      const lazySizing = table => get$5(editor, table);
7887
      const lazySizing = table => get$5(editor, table);
7974
      const lazyResizingBehaviour = () => isPreserveTableColumnResizing(editor) ? preserveTable() : resizeTable();
-
 
7975
      const getNumColumns = table => getGridSize(table).columns;
7888
      const lazyResizingBehaviour = () => isPreserveTableColumnResizing(editor) ? preserveTable() : resizeTable();
7976
      const getNumRows = table => getGridSize(table).rows;
-
 
7977
      const afterCornerResize = (table, origin, width, height) => {
7889
      const getNumColumns = table => getGridSize(table).columns;
7978
        const location = getCornerLocation(origin);
7890
      const afterCornerResize = (table, origin, width) => {
7979
        const isRightEdgeResize = endsWith(location, 'e');
-
 
7980
        const isNorthEdgeResize = startsWith(location, 'n');
-
 
7981
        if (startRawW === '') {
-
 
7982
          convertToPercentSizeWidth(table);
7891
        const isRightEdgeResize = endsWith(origin, 'e');
7983
        }
7892
        if (startRawW === '') {
7984
        if (startRawH === '') {
7893
          convertToPercentSize(table);
7985
          convertToPixelSizeHeight(table);
7894
        }
7986
        }
7895
        if (width !== startW && startRawW !== '') {
7987
        if (width !== startW && startRawW !== '') {
Línea 7902... Línea 7994...
7902
          const percentW = parseFloat(startRawW.replace('%', ''));
7994
          const percentW = parseFloat(startRawW.replace('%', ''));
7903
          const targetPercentW = width * percentW / startW;
7995
          const targetPercentW = width * percentW / startW;
7904
          set$1(table, 'width', targetPercentW + '%');
7996
          set$1(table, 'width', targetPercentW + '%');
7905
        }
7997
        }
7906
        if (isPixel(startRawW)) {
7998
        if (isPixel(startRawW)) {
7907
          syncPixels(table);
7999
          syncTableCellPixels(table);
-
 
8000
        }
-
 
8001
        if (height !== startH && startRawH !== '') {
-
 
8002
          set$1(table, 'height', startRawH);
-
 
8003
          const idx = isNorthEdgeResize ? 0 : getNumRows(table) - 1;
-
 
8004
          adjustHeight(table, height - startH, idx);
7908
        }
8005
        }
7909
      };
8006
      };
7910
      const destroy = () => {
8007
      const destroy = () => {
7911
        tableResize.on(sz => {
8008
        tableResize.on(sz => {
7912
          sz.destroy();
8009
          sz.destroy();
Línea 7919... Línea 8016...
7919
        const rawWire = get(editor, isResizable);
8016
        const rawWire = get(editor, isResizable);
7920
        resizeWire.set(rawWire);
8017
        resizeWire.set(rawWire);
7921
        if (hasTableObjectResizing(editor) && hasTableResizeBars(editor)) {
8018
        if (hasTableObjectResizing(editor) && hasTableResizeBars(editor)) {
7922
          const resizing = lazyResizingBehaviour();
8019
          const resizing = lazyResizingBehaviour();
7923
          const sz = TableResize.create(rawWire, resizing, lazySizing);
8020
          const sz = TableResize.create(rawWire, resizing, lazySizing);
-
 
8021
          if (!editor.mode.isReadOnly()) {
7924
          sz.on();
8022
            sz.on();
-
 
8023
          }
7925
          sz.events.startDrag.bind(_event => {
8024
          sz.events.startDrag.bind(_event => {
7926
            selectionRng.set(editor.selection.getRng());
8025
            selectionRng.set(editor.selection.getRng());
7927
          });
8026
          });
7928
          sz.events.beforeResize.bind(event => {
8027
          sz.events.beforeResize.bind(event => {
7929
            const rawTable = event.table.dom;
8028
            const rawTable = event.table.dom;
Línea 7943... Línea 8042...
7943
          tableResize.set(sz);
8042
          tableResize.set(sz);
7944
        }
8043
        }
7945
      });
8044
      });
7946
      editor.on('ObjectResizeStart', e => {
8045
      editor.on('ObjectResizeStart', e => {
7947
        const targetElm = e.target;
8046
        const targetElm = e.target;
7948
        if (isTable(targetElm)) {
8047
        if (isTable(targetElm) && !editor.mode.isReadOnly()) {
7949
          const table = SugarElement.fromDom(targetElm);
8048
          const table = SugarElement.fromDom(targetElm);
7950
          each$2(editor.dom.select('.mce-clonedresizable'), clone => {
8049
          each$2(editor.dom.select('.mce-clonedresizable'), clone => {
7951
            editor.dom.addClass(clone, 'mce-' + getTableColumnResizingBehaviour(editor) + '-columns');
8050
            editor.dom.addClass(clone, 'mce-' + getTableColumnResizingBehaviour(editor) + '-columns');
7952
          });
8051
          });
7953
          if (!isPixelSizing(table) && isTablePixelsForced(editor)) {
8052
          if (!isPixelSizing(table) && isTablePixelsForced(editor)) {
7954
            convertToPixelSize(table);
8053
            convertToPixelSizeWidth(table);
7955
          } else if (!isPercentSizing(table) && isTablePercentagesForced(editor)) {
8054
          } else if (!isPercentSizing(table) && isTablePercentagesForced(editor)) {
7956
            convertToPercentSize(table);
8055
            convertToPercentSizeWidth(table);
7957
          }
8056
          }
7958
          if (isNoneSizing(table) && startsWith(e.origin, barResizerPrefix)) {
8057
          if (isNoneSizing(table) && startsWith(e.origin, barResizerPrefix)) {
7959
            convertToPercentSize(table);
8058
            convertToPercentSizeWidth(table);
7960
          }
8059
          }
7961
          startW = e.width;
8060
          startW = e.width;
7962
          startRawW = isTableResponsiveForced(editor) ? '' : getRawWidth(editor, targetElm).getOr('');
8061
          startRawW = isTableResponsiveForced(editor) ? '' : getRawWidth(editor, targetElm).getOr('');
-
 
8062
          startH = e.height;
-
 
8063
          startRawH = getRawHeight(editor, targetElm).getOr('');
7963
        }
8064
        }
7964
      });
8065
      });
7965
      editor.on('ObjectResized', e => {
8066
      editor.on('ObjectResized', e => {
7966
        const targetElm = e.target;
8067
        const targetElm = e.target;
7967
        if (isTable(targetElm)) {
8068
        if (isTable(targetElm)) {
7968
          const table = SugarElement.fromDom(targetElm);
8069
          const table = SugarElement.fromDom(targetElm);
7969
          const origin = e.origin;
8070
          const origin = e.origin;
7970
          if (startsWith(origin, 'corner-')) {
8071
          if (isCornerResize(origin)) {
7971
            afterCornerResize(table, origin, e.width);
8072
            afterCornerResize(table, origin, e.width, e.height);
7972
          }
8073
          }
7973
          removeDataStyle(table);
8074
          removeDataStyle(table);
7974
          fireTableModified(editor, table.dom, styleModified);
8075
          fireTableModified(editor, table.dom, styleModified);
7975
        }
8076
        }
7976
      });
8077
      });
7977
      editor.on('SwitchMode', () => {
8078
      const showResizeBars = () => {
7978
        tableResize.on(resize => {
8079
        tableResize.on(resize => {
7979
          if (editor.mode.isReadOnly()) {
-
 
7980
            resize.hideBars();
8080
          resize.on();
7981
          } else {
-
 
7982
            resize.showBars();
8081
          resize.showBars();
7983
          }
-
 
7984
        });
8082
        });
7985
      });
8083
      };
7986
      editor.on('dragstart dragend', e => {
8084
      const hideResizeBars = () => {
7987
        tableResize.on(resize => {
8085
        tableResize.on(resize => {
7988
          if (e.type === 'dragstart') {
-
 
7989
            resize.hideBars();
-
 
7990
            resize.off();
8086
          resize.off();
7991
          } else {
-
 
7992
            resize.on();
-
 
7993
            resize.showBars();
8087
          resize.hideBars();
7994
          }
-
 
7995
        });
8088
        });
-
 
8089
      };
-
 
8090
      editor.on('DisabledStateChange', e => {
-
 
8091
        e.state ? hideResizeBars() : showResizeBars();
-
 
8092
      });
-
 
8093
      editor.on('SwitchMode', () => {
-
 
8094
        editor.mode.isReadOnly() ? hideResizeBars() : showResizeBars();
-
 
8095
      });
-
 
8096
      editor.on('dragstart dragend', e => {
-
 
8097
        e.type === 'dragstart' ? hideResizeBars() : showResizeBars();
7996
      });
8098
      });
7997
      editor.on('remove', () => {
8099
      editor.on('remove', () => {
7998
        destroy();
8100
        destroy();
7999
      });
8101
      });
8000
      const refresh = table => {
8102
      const refresh = table => {