Rev 637 | Rev 759 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 637 | Rev 679 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. |
2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. |
3 | * Licensed under the LGPL or a commercial license. |
3 | * Licensed under the LGPL or a commercial license. |
4 | * For LGPL see License.txt in the project root for license information. |
4 | * For LGPL see License.txt in the project root for license information. |
5 | * For commercial licenses see https://www.tiny.cloud/ |
5 | * For commercial licenses see https://www.tiny.cloud/ |
6 | * |
6 | * |
7 | * Version: 5.9.2 (2021-09-08) |
7 | * Version: 5.10.2 (2021-11-17) |
8 | */ |
8 | */ |
9 | (function () { |
9 | (function () { |
10 | 'use strict'; |
10 | 'use strict'; |
11 | 11 | ||
12 | var typeOf = function (x) { |
12 | var typeOf = function (x) { |
Line 535... | Line 535... | ||
535 | return s.length > 0; |
535 | return s.length > 0; |
536 | }; |
536 | }; |
537 | var isEmpty$1 = function (s) { |
537 | var isEmpty$1 = function (s) { |
538 | return !isNotEmpty(s); |
538 | return !isNotEmpty(s); |
539 | }; |
539 | }; |
- | 540 | var toFloat = function (value) { |
|
- | 541 | var num = parseFloat(value); |
|
- | 542 | return isNaN(num) ? Optional.none() : Optional.some(num); |
|
- | 543 | }; |
|
540 | 544 | ||
541 | var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/; |
545 | var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/; |
542 | var checkContains = function (target) { |
546 | var checkContains = function (target) { |
543 | return function (uastring) { |
547 | return function (uastring) { |
544 | return contains$1(uastring, target); |
548 | return contains$1(uastring, target); |
Line 1074... | Line 1078... | ||
1074 | return SugarElement.fromDom(documentOrOwner(element).dom.defaultView); |
1078 | return SugarElement.fromDom(documentOrOwner(element).dom.defaultView); |
1075 | }; |
1079 | }; |
1076 | var parent = function (element) { |
1080 | var parent = function (element) { |
1077 | return Optional.from(element.dom.parentNode).map(SugarElement.fromDom); |
1081 | return Optional.from(element.dom.parentNode).map(SugarElement.fromDom); |
1078 | }; |
1082 | }; |
- | 1083 | var parentElement = function (element) { |
|
- | 1084 | return Optional.from(element.dom.parentElement).map(SugarElement.fromDom); |
|
- | 1085 | }; |
|
1079 | var parents = function (element, isRoot) { |
1086 | var parents = function (element, isRoot) { |
1080 | var stop = isFunction(isRoot) ? isRoot : never; |
1087 | var stop = isFunction(isRoot) ? isRoot : never; |
1081 | var dom = element.dom; |
1088 | var dom = element.dom; |
1082 | var ret = []; |
1089 | var ret = []; |
1083 | while (dom.parentNode !== null && dom.parentNode !== undefined) { |
1090 | while (dom.parentNode !== null && dom.parentNode !== undefined) { |
Line 1090... | Line 1097... | ||
1090 | dom = rawParent; |
1097 | dom = rawParent; |
1091 | } |
1098 | } |
1092 | } |
1099 | } |
1093 | return ret; |
1100 | return ret; |
1094 | }; |
1101 | }; |
1095 | var offsetParent = function (element) { |
- | |
1096 | return Optional.from(element.dom.offsetParent).map(SugarElement.fromDom); |
- | |
1097 | }; |
- | |
1098 | var prevSibling = function (element) { |
1102 | var prevSibling = function (element) { |
1099 | return Optional.from(element.dom.previousSibling).map(SugarElement.fromDom); |
1103 | return Optional.from(element.dom.previousSibling).map(SugarElement.fromDom); |
1100 | }; |
1104 | }; |
1101 | var nextSibling = function (element) { |
1105 | var nextSibling = function (element) { |
1102 | return Optional.from(element.dom.nextSibling).map(SugarElement.fromDom); |
1106 | return Optional.from(element.dom.nextSibling).map(SugarElement.fromDom); |
Line 1286... | Line 1290... | ||
1286 | var dom = element.dom; |
1290 | var dom = element.dom; |
1287 | each$1(attrs, function (v, k) { |
1291 | each$1(attrs, function (v, k) { |
1288 | rawSet(dom, k, v); |
1292 | rawSet(dom, k, v); |
1289 | }); |
1293 | }); |
1290 | }; |
1294 | }; |
- | 1295 | var setOptions = function (element, attrs) { |
|
- | 1296 | each$1(attrs, function (v, k) { |
|
- | 1297 | v.fold(function () { |
|
- | 1298 | remove$7(element, k); |
|
- | 1299 | }, function (value) { |
|
- | 1300 | rawSet(element.dom, k, value); |
|
- | 1301 | }); |
|
- | 1302 | }); |
|
- | 1303 | }; |
|
1291 | var get$b = function (element, key) { |
1304 | var get$b = function (element, key) { |
1292 | var v = element.dom.getAttribute(key); |
1305 | var v = element.dom.getAttribute(key); |
1293 | return v === null ? undefined : v; |
1306 | return v === null ? undefined : v; |
1294 | }; |
1307 | }; |
1295 | var getOpt = function (element, key) { |
1308 | var getOpt = function (element, key) { |
Line 1404... | Line 1417... | ||
1404 | }).getOr(fallback); |
1417 | }).getOr(fallback); |
1405 | }; |
1418 | }; |
1406 | var getSpan = function (cell, type) { |
1419 | var getSpan = function (cell, type) { |
1407 | return getAttrValue(cell, type, 1); |
1420 | return getAttrValue(cell, type, 1); |
1408 | }; |
1421 | }; |
1409 | var hasColspan = function (cell) { |
1422 | var hasColspan = function (cellOrCol) { |
- | 1423 | if (isTag('col')(cellOrCol)) { |
|
- | 1424 | return getAttrValue(cellOrCol, 'span', 1) > 1; |
|
- | 1425 | } else { |
|
1410 | return getSpan(cell, 'colspan') > 1; |
1426 | return getSpan(cellOrCol, 'colspan') > 1; |
- | 1427 | } |
|
1411 | }; |
1428 | }; |
1412 | var hasRowspan = function (cell) { |
1429 | var hasRowspan = function (cell) { |
1413 | return getSpan(cell, 'rowspan') > 1; |
1430 | return getSpan(cell, 'rowspan') > 1; |
1414 | }; |
1431 | }; |
1415 | var getCssValue = function (element, property) { |
1432 | var getCssValue = function (element, property) { |
Line 1501... | Line 1518... | ||
1501 | }).getOr('tbody'); |
1518 | }).getOr('tbody'); |
1502 | }; |
1519 | }; |
1503 | var fromTable$1 = function (table) { |
1520 | var fromTable$1 = function (table) { |
1504 | var rows = rows$1(table); |
1521 | var rows = rows$1(table); |
1505 | var columnGroups$1 = columnGroups(table); |
1522 | var columnGroups$1 = columnGroups(table); |
1506 | var elems = __spreadArray(__spreadArray([], columnGroups$1), rows); |
1523 | var elems = __spreadArray(__spreadArray([], columnGroups$1, true), rows, true); |
1507 | return fromRowsOrColGroups(elems, getParentSection); |
1524 | return fromRowsOrColGroups(elems, getParentSection); |
1508 | }; |
1525 | }; |
1509 | var fromPastedRows = function (elems, section) { |
1526 | var fromPastedRows = function (elems, section) { |
1510 | return fromRowsOrColGroups(elems, function () { |
1527 | return fromRowsOrColGroups(elems, function () { |
1511 | return section; |
1528 | return section; |
Line 1612... | Line 1629... | ||
1612 | return columnsGroup; |
1629 | return columnsGroup; |
1613 | }; |
1630 | }; |
1614 | var generate$1 = function (list) { |
1631 | var generate$1 = function (list) { |
1615 | var access = {}; |
1632 | var access = {}; |
1616 | var cells = []; |
1633 | var cells = []; |
1617 | var columns = {}; |
- | |
1618 | var colgroups = []; |
- | |
1619 | var tableOpt = head(list).map(function (rowData) { |
1634 | var tableOpt = head(list).map(function (rowData) { |
1620 | return rowData.element; |
1635 | return rowData.element; |
1621 | }).bind(table); |
1636 | }).bind(table); |
1622 | var lockedColumns = tableOpt.bind(getLockedColumnsFromTable).getOr({}); |
1637 | var lockedColumns = tableOpt.bind(getLockedColumnsFromTable).getOr({}); |
1623 | var maxRows = 0; |
1638 | var maxRows = 0; |
1624 | var maxColumns = 0; |
1639 | var maxColumns = 0; |
1625 | var rowCount = 0; |
1640 | var rowCount = 0; |
1626 | each$2(list, function (rowData) { |
1641 | var _a = partition(list, function (rowData) { |
1627 | if (rowData.section === 'colgroup') { |
1642 | return rowData.section === 'colgroup'; |
1628 | columns = generateColumns(rowData); |
1643 | }), colgroupRows = _a.pass, rows = _a.fail; |
1629 | colgroups = [colgroup(rowData.element, values(columns))]; |
1644 | each$2(rows, function (rowData) { |
1630 | } else { |
- | |
1631 | var currentRow_1 = []; |
1645 | var currentRow = []; |
1632 | each$2(rowData.cells, function (rowCell) { |
1646 | each$2(rowData.cells, function (rowCell) { |
1633 | var start = 0; |
1647 | var start = 0; |
1634 | while (access[key(rowCount, start)] !== undefined) { |
1648 | while (access[key(rowCount, start)] !== undefined) { |
1635 | start++; |
1649 | start++; |
1636 | } |
1650 | } |
Line 1643... | Line 1657... | ||
1643 | var newpos = key(rowPosition, columnPosition); |
1657 | var newpos = key(rowPosition, columnPosition); |
1644 | access[newpos] = current; |
1658 | access[newpos] = current; |
1645 | maxColumns = Math.max(maxColumns, columnPosition + 1); |
1659 | maxColumns = Math.max(maxColumns, columnPosition + 1); |
1646 | } |
1660 | } |
1647 | } |
1661 | } |
1648 | currentRow_1.push(current); |
1662 | currentRow.push(current); |
1649 | }); |
1663 | }); |
1650 | maxRows++; |
1664 | maxRows++; |
1651 | cells.push(rowdetail(rowData.element, currentRow_1, rowData.section)); |
1665 | cells.push(rowdetail(rowData.element, currentRow, rowData.section)); |
1652 | rowCount++; |
1666 | rowCount++; |
1653 | } |
- | |
1654 | }); |
1667 | }); |
- | 1668 | var _b = last$2(colgroupRows).map(function (rowData) { |
|
- | 1669 | var columns = generateColumns(rowData); |
|
- | 1670 | var colgroup$1 = colgroup(rowData.element, values(columns)); |
|
- | 1671 | return { |
|
- | 1672 | colgroups: [colgroup$1], |
|
- | 1673 | columns: columns |
|
- | 1674 | }; |
|
- | 1675 | }).getOrThunk(function () { |
|
- | 1676 | return { |
|
- | 1677 | colgroups: [], |
|
- | 1678 | columns: {} |
|
- | 1679 | }; |
|
- | 1680 | }), columns = _b.columns, colgroups = _b.colgroups; |
|
1655 | var grid$1 = grid(maxRows, maxColumns); |
1681 | var grid$1 = grid(maxRows, maxColumns); |
1656 | return { |
1682 | return { |
1657 | grid: grid$1, |
1683 | grid: grid$1, |
1658 | access: access, |
1684 | access: access, |
1659 | all: cells, |
1685 | all: cells, |
Line 2404... | Line 2430... | ||
2404 | aggregate: aggregate, |
2430 | aggregate: aggregate, |
2405 | max: max |
2431 | max: max |
2406 | }; |
2432 | }; |
2407 | }; |
2433 | }; |
2408 | 2434 | ||
- | 2435 | var needManualCalc = function () { |
|
- | 2436 | var browser = detect$3().browser; |
|
- | 2437 | return browser.isIE() || browser.isEdge(); |
|
- | 2438 | }; |
|
- | 2439 | var toNumber = function (px, fallback) { |
|
- | 2440 | return toFloat(px).getOr(fallback); |
|
- | 2441 | }; |
|
- | 2442 | var getProp = function (element, name, fallback) { |
|
- | 2443 | return toNumber(get$a(element, name), fallback); |
|
- | 2444 | }; |
|
- | 2445 | var getBoxSizing = function (element) { |
|
- | 2446 | return get$a(element, 'box-sizing'); |
|
- | 2447 | }; |
|
- | 2448 | var calcContentBoxSize = function (element, size, upper, lower) { |
|
- | 2449 | var paddingUpper = getProp(element, 'padding-' + upper, 0); |
|
- | 2450 | var paddingLower = getProp(element, 'padding-' + lower, 0); |
|
- | 2451 | var borderUpper = getProp(element, 'border-' + upper + '-width', 0); |
|
- | 2452 | var borderLower = getProp(element, 'border-' + lower + '-width', 0); |
|
- | 2453 | return size - paddingUpper - paddingLower - borderUpper - borderLower; |
|
- | 2454 | }; |
|
- | 2455 | var getCalculatedHeight = function (element, boxSizing) { |
|
- | 2456 | var dom = element.dom; |
|
- | 2457 | var height = dom.getBoundingClientRect().height || dom.offsetHeight; |
|
- | 2458 | return boxSizing === 'border-box' ? height : calcContentBoxSize(element, height, 'top', 'bottom'); |
|
- | 2459 | }; |
|
- | 2460 | var getCalculatedWidth = function (element, boxSizing) { |
|
- | 2461 | var dom = element.dom; |
|
- | 2462 | var width = dom.getBoundingClientRect().width || dom.offsetWidth; |
|
- | 2463 | return boxSizing === 'border-box' ? width : calcContentBoxSize(element, width, 'left', 'right'); |
|
- | 2464 | }; |
|
- | 2465 | var getHeight$1 = function (element) { |
|
- | 2466 | return needManualCalc() ? getCalculatedHeight(element, getBoxSizing(element)) : getProp(element, 'height', element.dom.offsetHeight); |
|
- | 2467 | }; |
|
- | 2468 | var getWidth = function (element) { |
|
- | 2469 | return needManualCalc() ? getCalculatedWidth(element, getBoxSizing(element)) : getProp(element, 'width', element.dom.offsetWidth); |
|
- | 2470 | }; |
|
- | 2471 | var getInnerWidth = function (element) { |
|
- | 2472 | return getCalculatedWidth(element, 'content-box'); |
|
- | 2473 | }; |
|
- | 2474 | ||
2409 | var api$1 = Dimension('width', function (element) { |
2475 | var api$1 = Dimension('width', function (element) { |
2410 | return element.dom.offsetWidth; |
2476 | return element.dom.offsetWidth; |
2411 | }); |
2477 | }); |
2412 | var get$8 = function (element) { |
2478 | var get$8 = function (element) { |
2413 | return api$1.get(element); |
2479 | return api$1.get(element); |
2414 | }; |
2480 | }; |
2415 | var getOuter$2 = function (element) { |
2481 | var getOuter$2 = function (element) { |
2416 | return api$1.getOuter(element); |
2482 | return api$1.getOuter(element); |
2417 | }; |
2483 | }; |
- | 2484 | var getInner = getInnerWidth; |
|
- | 2485 | var getRuntime$1 = getWidth; |
|
2418 | 2486 | ||
2419 | var columns = function (warehouse, isValidCell) { |
2487 | var columns = function (warehouse, isValidCell) { |
2420 | if (isValidCell === void 0) { |
2488 | if (isValidCell === void 0) { |
2421 | isValidCell = always; |
2489 | isValidCell = always; |
2422 | } |
2490 | } |
Line 2535... | Line 2603... | ||
2535 | return api.get(element); |
2603 | return api.get(element); |
2536 | }; |
2604 | }; |
2537 | var getOuter$1 = function (element) { |
2605 | var getOuter$1 = function (element) { |
2538 | return api.getOuter(element); |
2606 | return api.getOuter(element); |
2539 | }; |
2607 | }; |
- | 2608 | var getRuntime = getHeight$1; |
|
2540 | 2609 | ||
2541 | var r = function (left, top) { |
2610 | var r = function (left, top) { |
2542 | var translate = function (x, y) { |
2611 | var translate = function (x, y) { |
2543 | return r(left + x, top + y); |
2612 | return r(left + x, top + y); |
2544 | }; |
2613 | }; |
Line 2742... | Line 2811... | ||
2742 | return Optional.none(); |
2811 | return Optional.none(); |
2743 | } |
2812 | } |
2744 | }); |
2813 | }); |
2745 | }; |
2814 | }; |
2746 | 2815 | ||
2747 | var needManualCalc = function () { |
- | |
2748 | var browser = detect$3().browser; |
- | |
2749 | return browser.isIE() || browser.isEdge(); |
- | |
2750 | }; |
- | |
2751 | var toNumber = function (px, fallback) { |
- | |
2752 | var num = parseFloat(px); |
- | |
2753 | return isNaN(num) ? fallback : num; |
- | |
2754 | }; |
- | |
2755 | var getProp = function (elm, name, fallback) { |
- | |
2756 | return toNumber(get$a(elm, name), fallback); |
- | |
2757 | }; |
- | |
2758 | var getCalculatedHeight = function (cell) { |
- | |
2759 | var height = cell.dom.getBoundingClientRect().height; |
- | |
2760 | var boxSizing = get$a(cell, 'box-sizing'); |
- | |
2761 | if (boxSizing === 'border-box') { |
- | |
2762 | return height; |
- | |
2763 | } else { |
- | |
2764 | var paddingTop = getProp(cell, 'padding-top', 0); |
- | |
2765 | var paddingBottom = getProp(cell, 'padding-bottom', 0); |
- | |
2766 | var borderTop = getProp(cell, 'border-top-width', 0); |
- | |
2767 | var borderBottom = getProp(cell, 'border-bottom-width', 0); |
- | |
2768 | var borders = borderTop + borderBottom; |
- | |
2769 | return height - paddingTop - paddingBottom - borders; |
- | |
2770 | } |
- | |
2771 | }; |
- | |
2772 | var getCalculatedWidth = function (cell) { |
- | |
2773 | var width = cell.dom.getBoundingClientRect().width; |
- | |
2774 | var boxSizing = get$a(cell, 'box-sizing'); |
- | |
2775 | if (boxSizing === 'border-box') { |
- | |
2776 | return width; |
- | |
2777 | } else { |
- | |
2778 | var paddingLeft = getProp(cell, 'padding-left', 0); |
- | |
2779 | var paddingRight = getProp(cell, 'padding-right', 0); |
- | |
2780 | var borderLeft = getProp(cell, 'border-left-width', 0); |
- | |
2781 | var borderRight = getProp(cell, 'border-right-width', 0); |
- | |
2782 | var borders = borderLeft + borderRight; |
- | |
2783 | return width - paddingLeft - paddingRight - borders; |
- | |
2784 | } |
- | |
2785 | }; |
- | |
2786 | var getHeight$1 = function (cell) { |
- | |
2787 | return needManualCalc() ? getCalculatedHeight(cell) : getProp(cell, 'height', get$7(cell)); |
- | |
2788 | }; |
- | |
2789 | var getWidth = function (cell) { |
- | |
2790 | return needManualCalc() ? getCalculatedWidth(cell) : getProp(cell, 'width', get$8(cell)); |
- | |
2791 | }; |
- | |
2792 | - | ||
2793 | var rPercentageBasedSizeRegex = /(\d+(\.\d+)?)%/; |
2816 | var rPercentageBasedSizeRegex = /(\d+(\.\d+)?)%/; |
2794 | var rPixelBasedSizeRegex = /(\d+(\.\d+)?)px|em/; |
2817 | var rPixelBasedSizeRegex = /(\d+(\.\d+)?)px|em/; |
- | 2818 | var isCol$2 = isTag('col'); |
|
2795 | var getPercentSize = function (elm, getter) { |
2819 | var getPercentSize = function (elm, outerGetter, innerGetter) { |
2796 | var relativeParent = offsetParent(elm).getOr(getBody$1(owner(elm))); |
2820 | var relativeParent = parentElement(elm).getOrThunk(function () { |
- | 2821 | return getBody$1(owner(elm)); |
|
- | 2822 | }); |
|
2797 | return getter(elm) / getter(relativeParent) * 100; |
2823 | return outerGetter(elm) / innerGetter(relativeParent) * 100; |
2798 | }; |
2824 | }; |
2799 | var setPixelWidth = function (cell, amount) { |
2825 | var setPixelWidth = function (cell, amount) { |
2800 | set$1(cell, 'width', amount + 'px'); |
2826 | set$1(cell, 'width', amount + 'px'); |
2801 | }; |
2827 | }; |
2802 | var setPercentageWidth = function (cell, amount) { |
2828 | var setPercentageWidth = function (cell, amount) { |
Line 2804... | Line 2830... | ||
2804 | }; |
2830 | }; |
2805 | var setHeight = function (cell, amount) { |
2831 | var setHeight = function (cell, amount) { |
2806 | set$1(cell, 'height', amount + 'px'); |
2832 | set$1(cell, 'height', amount + 'px'); |
2807 | }; |
2833 | }; |
2808 | var getHeightValue = function (cell) { |
2834 | var getHeightValue = function (cell) { |
2809 | return getRaw$2(cell, 'height').getOrThunk(function () { |
- | |
2810 | return getHeight$1(cell) + 'px'; |
2835 | return getRuntime(cell) + 'px'; |
2811 | }); |
- | |
2812 | }; |
2836 | }; |
2813 | var convert = function (cell, number, getter, setter) { |
2837 | var convert = function (cell, number, getter, setter) { |
2814 | var newSize = table(cell).map(function (table) { |
2838 | var newSize = table(cell).map(function (table) { |
2815 | var total = getter(table); |
2839 | var total = getter(table); |
2816 | return Math.floor(number / 100 * total); |
2840 | return Math.floor(number / 100 * total); |
2817 | }).getOr(number); |
2841 | }).getOr(number); |
2818 | setter(cell, newSize); |
2842 | setter(cell, newSize); |
2819 | return newSize; |
2843 | return newSize; |
2820 | }; |
2844 | }; |
2821 | var normalizePixelSize = function (value, cell, getter, setter) { |
2845 | var normalizePixelSize = function (value, cell, getter, setter) { |
2822 | var number = parseInt(value, 10); |
2846 | var number = parseFloat(value); |
2823 | return endsWith(value, '%') && name(cell) !== 'table' ? convert(cell, number, getter, setter) : number; |
2847 | return endsWith(value, '%') && name(cell) !== 'table' ? convert(cell, number, getter, setter) : number; |
2824 | }; |
2848 | }; |
2825 | var getTotalHeight = function (cell) { |
2849 | var getTotalHeight = function (cell) { |
2826 | var value = getHeightValue(cell); |
2850 | var value = getHeightValue(cell); |
2827 | if (!value) { |
2851 | if (!value) { |
Line 2832... | Line 2856... | ||
2832 | var get$6 = function (cell, type, f) { |
2856 | var get$6 = function (cell, type, f) { |
2833 | var v = f(cell); |
2857 | var v = f(cell); |
2834 | var span = getSpan(cell, type); |
2858 | var span = getSpan(cell, type); |
2835 | return v / span; |
2859 | return v / span; |
2836 | }; |
2860 | }; |
2837 | var getRawWidth$1 = function (element) { |
2861 | var getRaw$1 = function (element, prop) { |
2838 | var cssWidth = getRaw$2(element, 'width'); |
- | |
2839 | return cssWidth.fold(function () { |
2862 | return getRaw$2(element, prop).orThunk(function () { |
2840 | return Optional.from(get$b(element, 'width')); |
2863 | return getOpt(element, prop).map(function (val) { |
2841 | }, function (width) { |
- | |
2842 | return Optional.some(width); |
2864 | return val + 'px'; |
2843 | }); |
2865 | }); |
2844 | }; |
- | |
2845 | var normalizePercentageWidth = function (cellWidth, tableSize) { |
- | |
2846 | return cellWidth / tableSize.pixelWidth() * 100; |
- | |
2847 | }; |
- | |
2848 | var choosePercentageSize = function (element, width, tableSize) { |
- | |
2849 | var percentMatch = rPercentageBasedSizeRegex.exec(width); |
- | |
2850 | if (percentMatch !== null) { |
- | |
2851 | return parseFloat(percentMatch[1]); |
- | |
2852 | } else { |
- | |
2853 | var intWidth = getWidth(element); |
- | |
2854 | return normalizePercentageWidth(intWidth, tableSize); |
- | |
2855 | } |
- | |
2856 | }; |
- | |
2857 | var getPercentageWidth = function (cell, tableSize) { |
- | |
2858 | var width = getRawWidth$1(cell); |
- | |
2859 | return width.fold(function () { |
- | |
2860 | var intWidth = get$8(cell); |
- | |
2861 | return normalizePercentageWidth(intWidth, tableSize); |
- | |
2862 | }, function (w) { |
- | |
2863 | return choosePercentageSize(cell, w, tableSize); |
- | |
2864 | }); |
2866 | }); |
2865 | }; |
2867 | }; |
2866 | var normalizePixelWidth = function (cellWidth, tableSize) { |
2868 | var getRawWidth$1 = function (element) { |
2867 | return cellWidth / 100 * tableSize.pixelWidth(); |
2869 | return getRaw$1(element, 'width'); |
2868 | }; |
2870 | }; |
2869 | var choosePixelSize = function (element, width, tableSize) { |
2871 | var getRawHeight = function (element) { |
2870 | var pixelMatch = rPixelBasedSizeRegex.exec(width); |
- | |
2871 | if (pixelMatch !== null) { |
- | |
2872 | return parseInt(pixelMatch[1], 10); |
- | |
2873 | } |
- | |
2874 | var percentMatch = rPercentageBasedSizeRegex.exec(width); |
- | |
2875 | if (percentMatch !== null) { |
- | |
2876 | var floatWidth = parseFloat(percentMatch[1]); |
- | |
2877 | return normalizePixelWidth(floatWidth, tableSize); |
- | |
2878 | } |
- | |
2879 | return getWidth(element); |
2872 | return getRaw$1(element, 'height'); |
2880 | }; |
2873 | }; |
2881 | var getPixelWidth$1 = function (cell, tableSize) { |
2874 | var getPercentageWidth = function (cell) { |
2882 | var width = getRawWidth$1(cell); |
- | |
2883 | return width.fold(function () { |
2875 | return getPercentSize(cell, get$8, getInner); |
2884 | return getWidth(cell); |
2876 | }; |
2885 | }, function (w) { |
2877 | var getPixelWidth$1 = function (cell) { |
2886 | return choosePixelSize(cell, w, tableSize); |
2878 | return isCol$2(cell) ? get$8(cell) : getRuntime$1(cell); |
2887 | }); |
- | |
2888 | }; |
2879 | }; |
2889 | var getHeight = function (cell) { |
2880 | var getHeight = function (cell) { |
2890 | return get$6(cell, 'rowspan', getTotalHeight); |
2881 | return get$6(cell, 'rowspan', getTotalHeight); |
2891 | }; |
2882 | }; |
2892 | var getGenericWidth = function (cell) { |
2883 | var getGenericWidth = function (cell) { |
Line 2903... | Line 2894... | ||
2903 | set$1(cell, 'width', amount + unit); |
2894 | set$1(cell, 'width', amount + unit); |
2904 | }; |
2895 | }; |
2905 | var getPixelTableWidth = function (table) { |
2896 | var getPixelTableWidth = function (table) { |
2906 | return get$8(table) + 'px'; |
2897 | return get$8(table) + 'px'; |
2907 | }; |
2898 | }; |
2908 | var getPercentTableWidth$1 = function (table) { |
2899 | var getPercentTableWidth = function (table) { |
2909 | return getPercentSize(table, get$8) + '%'; |
2900 | return getPercentSize(table, get$8, getInner) + '%'; |
2910 | }; |
2901 | }; |
2911 | var isPercentSizing$1 = function (table) { |
2902 | var isPercentSizing$1 = function (table) { |
2912 | return getRawWidth$1(table).exists(function (size) { |
2903 | return getRawWidth$1(table).exists(function (size) { |
2913 | return rPercentageBasedSizeRegex.test(size); |
2904 | return rPercentageBasedSizeRegex.test(size); |
2914 | }); |
2905 | }); |
Line 2920... | Line 2911... | ||
2920 | }; |
2911 | }; |
2921 | var isNoneSizing$1 = function (table) { |
2912 | var isNoneSizing$1 = function (table) { |
2922 | return getRawWidth$1(table).isNone(); |
2913 | return getRawWidth$1(table).isNone(); |
2923 | }; |
2914 | }; |
2924 | var percentageBasedSizeRegex = constant(rPercentageBasedSizeRegex); |
2915 | var percentageBasedSizeRegex = constant(rPercentageBasedSizeRegex); |
2925 | var pixelBasedSizeRegex = constant(rPixelBasedSizeRegex); |
- | |
2926 | 2916 | ||
2927 | var isCol$1 = isTag('col'); |
2917 | var isCol$1 = isTag('col'); |
2928 | var getRaw$1 = function (cell, property, getter) { |
2918 | var getRawW = function (cell) { |
2929 | return getRaw$2(cell, property).getOrThunk(function () { |
2919 | return getRawWidth$1(cell).getOrThunk(function () { |
2930 | return getter(cell) + 'px'; |
2920 | return getPixelWidth$1(cell) + 'px'; |
2931 | }); |
2921 | }); |
2932 | }; |
2922 | }; |
2933 | var getRawW = function (cell, tableSize) { |
- | |
2934 | var fallback = function (e) { |
- | |
2935 | return isCol$1(e) ? get$8(e) : getPixelWidth$1(e, tableSize); |
- | |
2936 | }; |
- | |
2937 | return getRaw$1(cell, 'width', fallback); |
- | |
2938 | }; |
- | |
2939 | var getRawH = function (cell) { |
2923 | var getRawH = function (cell) { |
2940 | return getRaw$1(cell, 'height', getHeight); |
2924 | return getRawHeight(cell).getOrThunk(function () { |
- | 2925 | return getHeight(cell) + 'px'; |
|
- | 2926 | }); |
|
2941 | }; |
2927 | }; |
2942 | var justCols = function (warehouse) { |
2928 | var justCols = function (warehouse) { |
2943 | return map$1(Warehouse.justColumns(warehouse), function (column) { |
2929 | return map$1(Warehouse.justColumns(warehouse), function (column) { |
2944 | return Optional.from(column.element); |
2930 | return Optional.from(column.element); |
2945 | }); |
2931 | }); |
2946 | }; |
2932 | }; |
2947 | var hasRawStyle = function (cell, prop) { |
- | |
2948 | return getRaw$2(cell, prop).isSome(); |
- | |
2949 | }; |
- | |
2950 | var isValidColumn = function (cell) { |
2933 | var isValidColumn = function (cell) { |
- | 2934 | var browser = detect$3().browser; |
|
- | 2935 | var supportsColWidths = browser.isChrome() || browser.isFirefox(); |
|
2951 | return !isCol$1(cell) || hasRawStyle(cell, 'width'); |
2936 | return isCol$1(cell) ? supportsColWidths : true; |
2952 | }; |
2937 | }; |
2953 | var getDimension = function (cellOpt, index, backups, filter, getter, fallback) { |
2938 | var getDimension = function (cellOpt, index, backups, filter, getter, fallback) { |
2954 | return cellOpt.filter(filter).fold(function () { |
2939 | return cellOpt.filter(filter).fold(function () { |
2955 | return fallback(deduce(backups, index)); |
2940 | return fallback(deduce(backups, index)); |
2956 | }, function (cell) { |
2941 | }, function (cell) { |
2957 | return getter(cell); |
2942 | return getter(cell); |
2958 | }); |
2943 | }); |
2959 | }; |
2944 | }; |
2960 | var getWidthFrom = function (warehouse, table, getWidth, fallback, tableSize) { |
2945 | var getWidthFrom = function (warehouse, table, getWidth, fallback) { |
2961 | var columnCells = columns(warehouse, function (cell) { |
2946 | var columnCells = columns(warehouse); |
2962 | return hasRawStyle(cell, 'width'); |
- | |
2963 | }); |
- | |
2964 | var columns$1 = Warehouse.hasColumns(warehouse) ? justCols(warehouse) : columnCells; |
2947 | var columns$1 = Warehouse.hasColumns(warehouse) ? justCols(warehouse) : columnCells; |
2965 | var backups = [Optional.some(width.edge(table))].concat(map$1(width.positions(columnCells, table), function (pos) { |
2948 | var backups = [Optional.some(width.edge(table))].concat(map$1(width.positions(columnCells, table), function (pos) { |
2966 | return pos.map(function (p) { |
2949 | return pos.map(function (p) { |
2967 | return p.x; |
2950 | return p.x; |
2968 | }); |
2951 | }); |
2969 | })); |
2952 | })); |
2970 | var colFilter = not(hasColspan); |
2953 | var colFilter = not(hasColspan); |
2971 | return map$1(columns$1, function (cellOption, c) { |
2954 | return map$1(columns$1, function (cellOption, c) { |
2972 | return getDimension(cellOption, c, backups, colFilter, function (column) { |
2955 | return getDimension(cellOption, c, backups, colFilter, function (column) { |
2973 | if (isValidColumn(column)) { |
2956 | if (isValidColumn(column)) { |
2974 | return getWidth(column, tableSize); |
2957 | return getWidth(column); |
2975 | } else { |
2958 | } else { |
2976 | var cell = bindFrom(columnCells[c], identity); |
2959 | var cell = bindFrom(columnCells[c], identity); |
2977 | return getDimension(cell, c, backups, colFilter, function (cell) { |
2960 | return getDimension(cell, c, backups, colFilter, function (cell) { |
2978 | return fallback(Optional.some(get$8(cell))); |
2961 | return fallback(Optional.some(get$8(cell))); |
2979 | }, fallback); |
2962 | }, fallback); |
Line 2984... | Line 2967... | ||
2984 | var getDeduced = function (deduced) { |
2967 | var getDeduced = function (deduced) { |
2985 | return deduced.map(function (d) { |
2968 | return deduced.map(function (d) { |
2986 | return d + 'px'; |
2969 | return d + 'px'; |
2987 | }).getOr(''); |
2970 | }).getOr(''); |
2988 | }; |
2971 | }; |
2989 | var getRawWidths = function (warehouse, table, tableSize) { |
2972 | var getRawWidths = function (warehouse, table) { |
2990 | return getWidthFrom(warehouse, table, getRawW, getDeduced, tableSize); |
2973 | return getWidthFrom(warehouse, table, getRawW, getDeduced); |
2991 | }; |
2974 | }; |
2992 | var getPercentageWidths = function (warehouse, table, tableSize) { |
2975 | var getPercentageWidths = function (warehouse, table, tableSize) { |
2993 | return getWidthFrom(warehouse, table, getPercentageWidth, function (deduced) { |
2976 | return getWidthFrom(warehouse, table, getPercentageWidth, function (deduced) { |
2994 | return deduced.fold(function () { |
2977 | return deduced.fold(function () { |
2995 | return tableSize.minCellWidth(); |
2978 | return tableSize.minCellWidth(); |
2996 | }, function (cellWidth) { |
2979 | }, function (cellWidth) { |
2997 | return cellWidth / tableSize.pixelWidth() * 100; |
2980 | return cellWidth / tableSize.pixelWidth() * 100; |
2998 | }); |
2981 | }); |
2999 | }, tableSize); |
2982 | }); |
3000 | }; |
2983 | }; |
3001 | var getPixelWidths = function (warehouse, table, tableSize) { |
2984 | var getPixelWidths = function (warehouse, table, tableSize) { |
3002 | return getWidthFrom(warehouse, table, getPixelWidth$1, function (deduced) { |
2985 | return getWidthFrom(warehouse, table, getPixelWidth$1, function (deduced) { |
3003 | return deduced.getOrThunk(tableSize.minCellWidth); |
2986 | return deduced.getOrThunk(tableSize.minCellWidth); |
3004 | }, tableSize); |
2987 | }); |
3005 | }; |
2988 | }; |
3006 | var getHeightFrom = function (warehouse, table, direction, getHeight, fallback) { |
2989 | var getHeightFrom = function (warehouse, table, direction, getHeight, fallback) { |
3007 | var rows$1 = rows(warehouse); |
2990 | var rows$1 = rows(warehouse); |
3008 | var backups = [Optional.some(direction.edge(table))].concat(map$1(direction.positions(rows$1, table), function (pos) { |
2991 | var backups = [Optional.some(direction.edge(table))].concat(map$1(direction.positions(rows$1, table), function (pos) { |
3009 | return pos.map(function (p) { |
2992 | return pos.map(function (p) { |
Line 3021... | Line 3004... | ||
3021 | }; |
3004 | }; |
3022 | var getRawHeights = function (warehouse, table, direction) { |
3005 | var getRawHeights = function (warehouse, table, direction) { |
3023 | return getHeightFrom(warehouse, table, direction, getRawH, getDeduced); |
3006 | return getHeightFrom(warehouse, table, direction, getRawH, getDeduced); |
3024 | }; |
3007 | }; |
3025 | 3008 | ||
3026 | var Cell = function (initial) { |
3009 | var widthLookup = function (table, getter) { |
3027 | var value = initial; |
- | |
3028 | var get = function () { |
3010 | return function () { |
3029 | return value; |
3011 | if (inBody(table)) { |
3030 | }; |
- | |
3031 | var set = function (v) { |
3012 | return getter(table); |
3032 | value = v; |
3013 | } else { |
3033 | }; |
- | |
3034 | return { |
- | |
3035 | get: get, |
3014 | return parseFloat(getRaw$2(table, 'width').getOr('0')); |
3036 | set: set |
3015 | } |
3037 | }; |
3016 | }; |
3038 | }; |
3017 | }; |
3039 | - | ||
3040 | var noneSize = function (table) { |
3018 | var noneSize = function (table) { |
3041 | var getWidth = function () { |
3019 | var getWidth = widthLookup(table, get$8); |
3042 | return get$8(table); |
- | |
3043 | }; |
- | |
3044 | var zero = constant(0); |
3020 | var zero = constant(0); |
3045 | var getWidths = function (warehouse, tableSize) { |
3021 | var getWidths = function (warehouse, tableSize) { |
3046 | return getPixelWidths(warehouse, table, tableSize); |
3022 | return getPixelWidths(warehouse, table, tableSize); |
3047 | }; |
3023 | }; |
3048 | return { |
3024 | return { |
Line 3056... | Line 3032... | ||
3056 | adjustTableWidth: noop, |
3032 | adjustTableWidth: noop, |
3057 | isRelative: true, |
3033 | isRelative: true, |
3058 | label: 'none' |
3034 | label: 'none' |
3059 | }; |
3035 | }; |
3060 | }; |
3036 | }; |
3061 | var percentageSize = function (initialWidth, table) { |
3037 | var percentageSize = function (table) { |
3062 | var floatWidth = Cell(parseFloat(initialWidth)); |
3038 | var getFloatWidth = widthLookup(table, function (elem) { |
- | 3039 | return parseFloat(getPercentTableWidth(elem)); |
|
- | 3040 | }); |
|
3063 | var pixelWidth = Cell(get$8(table)); |
3041 | var getWidth = widthLookup(table, get$8); |
3064 | var getCellDelta = function (delta) { |
3042 | var getCellDelta = function (delta) { |
3065 | return delta / pixelWidth.get() * 100; |
3043 | return delta / getWidth() * 100; |
3066 | }; |
3044 | }; |
3067 | var singleColumnWidth = function (w, _delta) { |
3045 | var singleColumnWidth = function (w, _delta) { |
3068 | return [100 - w]; |
3046 | return [100 - w]; |
3069 | }; |
3047 | }; |
3070 | var minCellWidth = function () { |
3048 | var minCellWidth = function () { |
3071 | return minWidth() / pixelWidth.get() * 100; |
3049 | return minWidth() / getWidth() * 100; |
3072 | }; |
3050 | }; |
3073 | var adjustTableWidth = function (delta) { |
3051 | var adjustTableWidth = function (delta) { |
3074 | var currentWidth = floatWidth.get(); |
3052 | var currentWidth = getFloatWidth(); |
3075 | var change = delta / 100 * currentWidth; |
3053 | var change = delta / 100 * currentWidth; |
3076 | var newWidth = currentWidth + change; |
3054 | var newWidth = currentWidth + change; |
3077 | setPercentageWidth(table, newWidth); |
3055 | setPercentageWidth(table, newWidth); |
3078 | floatWidth.set(newWidth); |
- | |
3079 | pixelWidth.set(get$8(table)); |
- | |
3080 | }; |
3056 | }; |
3081 | var getWidths = function (warehouse, tableSize) { |
3057 | var getWidths = function (warehouse, tableSize) { |
3082 | return getPercentageWidths(warehouse, table, tableSize); |
3058 | return getPercentageWidths(warehouse, table, tableSize); |
3083 | }; |
3059 | }; |
3084 | return { |
3060 | return { |
3085 | width: floatWidth.get, |
3061 | width: getFloatWidth, |
3086 | pixelWidth: pixelWidth.get, |
3062 | pixelWidth: getWidth, |
3087 | getWidths: getWidths, |
3063 | getWidths: getWidths, |
3088 | getCellDelta: getCellDelta, |
3064 | getCellDelta: getCellDelta, |
3089 | singleColumnWidth: singleColumnWidth, |
3065 | singleColumnWidth: singleColumnWidth, |
3090 | minCellWidth: minCellWidth, |
3066 | minCellWidth: minCellWidth, |
3091 | setElementWidth: setPercentageWidth, |
3067 | setElementWidth: setPercentageWidth, |
3092 | adjustTableWidth: adjustTableWidth, |
3068 | adjustTableWidth: adjustTableWidth, |
3093 | isRelative: true, |
3069 | isRelative: true, |
3094 | label: 'percent' |
3070 | label: 'percent' |
3095 | }; |
3071 | }; |
3096 | }; |
3072 | }; |
3097 | var pixelSize = function (initialWidth, table) { |
3073 | var pixelSize = function (table) { |
3098 | var width = Cell(initialWidth); |
- | |
3099 | var getWidth = width.get; |
3074 | var getWidth = widthLookup(table, get$8); |
3100 | var getCellDelta = identity; |
3075 | var getCellDelta = identity; |
3101 | var singleColumnWidth = function (w, delta) { |
3076 | var singleColumnWidth = function (w, delta) { |
3102 | var newNext = Math.max(minWidth(), w + delta); |
3077 | var newNext = Math.max(minWidth(), w + delta); |
3103 | return [newNext - w]; |
3078 | return [newNext - w]; |
3104 | }; |
3079 | }; |
3105 | var adjustTableWidth = function (delta) { |
3080 | var adjustTableWidth = function (delta) { |
3106 | var newWidth = getWidth() + delta; |
3081 | var newWidth = getWidth() + delta; |
3107 | setPixelWidth(table, newWidth); |
3082 | setPixelWidth(table, newWidth); |
3108 | width.set(newWidth); |
- | |
3109 | }; |
3083 | }; |
3110 | var getWidths = function (warehouse, tableSize) { |
3084 | var getWidths = function (warehouse, tableSize) { |
3111 | return getPixelWidths(warehouse, table, tableSize); |
3085 | return getPixelWidths(warehouse, table, tableSize); |
3112 | }; |
3086 | }; |
3113 | return { |
3087 | return { |
Line 3124... | Line 3098... | ||
3124 | }; |
3098 | }; |
3125 | }; |
3099 | }; |
3126 | var chooseSize = function (element, width) { |
3100 | var chooseSize = function (element, width) { |
3127 | var percentMatch = percentageBasedSizeRegex().exec(width); |
3101 | var percentMatch = percentageBasedSizeRegex().exec(width); |
3128 | if (percentMatch !== null) { |
3102 | if (percentMatch !== null) { |
3129 | return percentageSize(percentMatch[1], element); |
3103 | return percentageSize(element); |
3130 | } |
3104 | } else { |
3131 | var pixelMatch = pixelBasedSizeRegex().exec(width); |
- | |
3132 | if (pixelMatch !== null) { |
- | |
3133 | var intWidth = parseInt(pixelMatch[1], 10); |
- | |
3134 | return pixelSize(intWidth, element); |
3105 | return pixelSize(element); |
3135 | } |
3106 | } |
3136 | var fallbackWidth = get$8(element); |
- | |
3137 | return pixelSize(fallbackWidth, element); |
- | |
3138 | }; |
3107 | }; |
3139 | var getTableSize = function (table) { |
3108 | var getTableSize = function (table) { |
3140 | var width = getRawWidth$1(table); |
3109 | var width = getRawWidth$1(table); |
3141 | return width.fold(function () { |
3110 | return width.fold(function () { |
3142 | return noneSize(table); |
3111 | return noneSize(table); |
Line 3429... | Line 3398... | ||
3429 | col: newCol, |
3398 | col: newCol, |
3430 | colgroup: createColgroup(doc), |
3399 | colgroup: createColgroup(doc), |
3431 | row: createRow$1(doc), |
3400 | row: createRow$1(doc), |
3432 | cell: newCell, |
3401 | cell: newCell, |
3433 | replace: replace$1, |
3402 | replace: replace$1, |
- | 3403 | colGap: createCol(doc), |
|
3434 | gap: createCell(doc) |
3404 | gap: createCell(doc) |
3435 | }; |
3405 | }; |
3436 | }; |
3406 | }; |
3437 | var paste$1 = function (doc) { |
3407 | var paste$1 = function (doc) { |
3438 | return { |
3408 | return { |
3439 | col: createCol(doc), |
3409 | col: createCol(doc), |
3440 | colgroup: createColgroup(doc), |
3410 | colgroup: createColgroup(doc), |
3441 | row: createRow$1(doc), |
3411 | row: createRow$1(doc), |
3442 | cell: createCell(doc), |
3412 | cell: createCell(doc), |
3443 | replace: pasteReplace, |
3413 | replace: pasteReplace, |
- | 3414 | colGap: createCol(doc), |
|
3444 | gap: createCell(doc) |
3415 | gap: createCell(doc) |
3445 | }; |
3416 | }; |
3446 | }; |
3417 | }; |
3447 | 3418 | ||
3448 | var fromHtml = function (html, scope) { |
3419 | var fromHtml = function (html, scope) { |
Line 3483... | Line 3454... | ||
3483 | var removeStyleAttribute = function (element) { |
3454 | var removeStyleAttribute = function (element) { |
3484 | return remove$7(element, 'data-mce-style'); |
3455 | return remove$7(element, 'data-mce-style'); |
3485 | }; |
3456 | }; |
3486 | each$2(cells$1(table), removeStyleAttribute); |
3457 | each$2(cells$1(table), removeStyleAttribute); |
3487 | each$2(columns$1(table), removeStyleAttribute); |
3458 | each$2(columns$1(table), removeStyleAttribute); |
- | 3459 | each$2(rows$1(table), removeStyleAttribute); |
|
3488 | }; |
3460 | }; |
3489 | var getRawWidth = function (editor, elm) { |
3461 | var getRawWidth = function (editor, elm) { |
3490 | var raw = editor.dom.getStyle(elm, 'width') || editor.dom.getAttrib(elm, 'width'); |
3462 | var raw = editor.dom.getStyle(elm, 'width') || editor.dom.getAttrib(elm, 'width'); |
3491 | return Optional.from(raw).filter(isNotEmpty); |
3463 | return Optional.from(raw).filter(isNotEmpty); |
3492 | }; |
3464 | }; |
Line 4167... | Line 4139... | ||
4167 | }); |
4139 | }); |
4168 | }; |
4140 | }; |
4169 | var getUnit = function (newSize) { |
4141 | var getUnit = function (newSize) { |
4170 | return validate(newSize).fold(constant('px'), constant('px'), constant('%')); |
4142 | return validate(newSize).fold(constant('px'), constant('px'), constant('%')); |
4171 | }; |
4143 | }; |
4172 | var redistribute = function (table, optWidth, optHeight, tableSize) { |
4144 | var redistribute = function (table, optWidth, optHeight) { |
4173 | var warehouse = Warehouse.fromTable(table); |
4145 | var warehouse = Warehouse.fromTable(table); |
4174 | var rows = warehouse.all; |
4146 | var rows = warehouse.all; |
4175 | var cells = Warehouse.justCells(warehouse); |
4147 | var cells = Warehouse.justCells(warehouse); |
4176 | var columns = Warehouse.justColumns(warehouse); |
4148 | var columns = Warehouse.justColumns(warehouse); |
4177 | optWidth.each(function (newWidth) { |
4149 | optWidth.each(function (newWidth) { |
4178 | var widthUnit = getUnit(newWidth); |
4150 | var widthUnit = getUnit(newWidth); |
4179 | var totalWidth = get$8(table); |
4151 | var totalWidth = get$8(table); |
4180 | var oldWidths = getRawWidths(warehouse, table, tableSize); |
4152 | var oldWidths = getRawWidths(warehouse, table); |
4181 | var nuWidths = redistribute$1(oldWidths, totalWidth, newWidth); |
4153 | var nuWidths = redistribute$1(oldWidths, totalWidth, newWidth); |
4182 | if (Warehouse.hasColumns(warehouse)) { |
4154 | if (Warehouse.hasColumns(warehouse)) { |
4183 | redistributeToColumns(nuWidths, columns, widthUnit); |
4155 | redistributeToColumns(nuWidths, columns, widthUnit); |
4184 | } else { |
4156 | } else { |
4185 | redistributeToW(nuWidths, cells, widthUnit); |
4157 | redistributeToW(nuWidths, cells, widthUnit); |
Line 4196... | Line 4168... | ||
4196 | }); |
4168 | }); |
4197 | }; |
4169 | }; |
4198 | var isPercentSizing = isPercentSizing$1; |
4170 | var isPercentSizing = isPercentSizing$1; |
4199 | var isPixelSizing = isPixelSizing$1; |
4171 | var isPixelSizing = isPixelSizing$1; |
4200 | var isNoneSizing = isNoneSizing$1; |
4172 | var isNoneSizing = isNoneSizing$1; |
4201 | var getPercentTableWidth = getPercentTableWidth$1; |
- | |
4202 | 4173 | ||
4203 | var getGridSize = function (table) { |
4174 | var getGridSize = function (table) { |
4204 | var warehouse = Warehouse.fromTable(table); |
4175 | var warehouse = Warehouse.fromTable(table); |
4205 | return warehouse.grid; |
4176 | return warehouse.grid; |
4206 | }; |
4177 | }; |
Line 5122... | Line 5093... | ||
5122 | title: type, |
5093 | title: type, |
5123 | value: type.toLowerCase() |
5094 | value: type.toLowerCase() |
5124 | }; |
5095 | }; |
5125 | }); |
5096 | }); |
5126 | var determineDefaultStyles = function (editor) { |
5097 | var determineDefaultStyles = function (editor) { |
- | 5098 | var _a; |
|
5127 | if (isPixelsForced(editor)) { |
5099 | if (isPixelsForced(editor)) { |
5128 | var editorWidth = editor.getBody().offsetWidth; |
5100 | var dom = editor.dom; |
- | 5101 | var parentBlock = (_a = dom.getParent(editor.selection.getStart(), dom.isBlock)) !== null && _a !== void 0 ? _a : editor.getBody(); |
|
- | 5102 | var contentWidth = getInner(SugarElement.fromDom(parentBlock)); |
|
5129 | return __assign(__assign({}, defaultStyles), { width: editorWidth + 'px' }); |
5103 | return __assign(__assign({}, defaultStyles), { width: contentWidth + 'px' }); |
5130 | } else if (isResponsiveForced(editor)) { |
5104 | } else if (isResponsiveForced(editor)) { |
5131 | return filter$1(defaultStyles, function (_value, key) { |
5105 | return filter$1(defaultStyles, function (_value, key) { |
5132 | return key !== 'width'; |
5106 | return key !== 'width'; |
5133 | }); |
5107 | }); |
5134 | } else { |
5108 | } else { |
Line 5255... | Line 5229... | ||
5255 | return editor.getParam('table_border_color_map', [], 'array'); |
5229 | return editor.getParam('table_border_color_map', [], 'array'); |
5256 | }; |
5230 | }; |
5257 | 5231 | ||
5258 | var get$4 = function (editor, table) { |
5232 | var get$4 = function (editor, table) { |
5259 | if (isPercentagesForced(editor)) { |
5233 | if (isPercentagesForced(editor)) { |
5260 | var width = getRawWidth(editor, table.dom).filter(isPercentage$1).getOrThunk(function () { |
- | |
5261 | return getPercentTableWidth(table); |
- | |
5262 | }); |
- | |
5263 | return TableSize.percentageSize(width, table); |
5234 | return TableSize.percentageSize(table); |
5264 | } else if (isPixelsForced(editor)) { |
5235 | } else if (isPixelsForced(editor)) { |
5265 | return TableSize.pixelSize(get$8(table), table); |
5236 | return TableSize.pixelSize(table); |
5266 | } else { |
5237 | } else { |
5267 | return TableSize.getTableSize(table); |
5238 | return TableSize.getTableSize(table); |
5268 | } |
5239 | } |
5269 | }; |
5240 | }; |
5270 | 5241 | ||
5271 | var cleanupLegacyAttributes = function (element) { |
5242 | var cleanupLegacyAttributes = function (element) { |
5272 | remove$7(element, 'width'); |
5243 | remove$7(element, 'width'); |
5273 | }; |
5244 | }; |
5274 | var convertToPercentSize = function (table, tableSize) { |
5245 | var convertToPercentSize = function (table) { |
5275 | var newWidth = getPercentTableWidth$1(table); |
5246 | var newWidth = getPercentTableWidth(table); |
5276 | redistribute(table, Optional.some(newWidth), Optional.none(), tableSize); |
5247 | redistribute(table, Optional.some(newWidth), Optional.none()); |
5277 | cleanupLegacyAttributes(table); |
5248 | cleanupLegacyAttributes(table); |
5278 | }; |
5249 | }; |
5279 | var convertToPixelSize = function (table, tableSize) { |
5250 | var convertToPixelSize = function (table) { |
5280 | var newWidth = getPixelTableWidth(table); |
5251 | var newWidth = getPixelTableWidth(table); |
5281 | redistribute(table, Optional.some(newWidth), Optional.none(), tableSize); |
5252 | redistribute(table, Optional.some(newWidth), Optional.none()); |
5282 | cleanupLegacyAttributes(table); |
5253 | cleanupLegacyAttributes(table); |
5283 | }; |
5254 | }; |
5284 | var convertToNoneSize = function (table) { |
5255 | var convertToNoneSize = function (table) { |
5285 | remove$6(table, 'width'); |
5256 | remove$6(table, 'width'); |
5286 | var columns = columns$1(table); |
5257 | var columns = columns$1(table); |
Line 5290... | Line 5261... | ||
5290 | cleanupLegacyAttributes(cell); |
5261 | cleanupLegacyAttributes(cell); |
5291 | }); |
5262 | }); |
5292 | cleanupLegacyAttributes(table); |
5263 | cleanupLegacyAttributes(table); |
5293 | }; |
5264 | }; |
5294 | 5265 | ||
5295 | var enforcePercentage = function (editor, table) { |
5266 | var enforcePercentage = convertToPercentSize; |
5296 | var tableSizing = get$4(editor, table); |
- | |
5297 | convertToPercentSize(table, tableSizing); |
- | |
5298 | }; |
- | |
5299 | var enforcePixels = function (editor, table) { |
5267 | var enforcePixels = convertToPixelSize; |
5300 | var tableSizing = get$4(editor, table); |
- | |
5301 | convertToPixelSize(table, tableSizing); |
- | |
5302 | }; |
- | |
5303 | var enforceNone = convertToNoneSize; |
5268 | var enforceNone = convertToNoneSize; |
5304 | var syncPixels = function (table) { |
5269 | var syncPixels = function (table) { |
5305 | var warehouse = Warehouse.fromTable(table); |
5270 | var warehouse = Warehouse.fromTable(table); |
5306 | if (!Warehouse.hasColumns(warehouse)) { |
5271 | if (!Warehouse.hasColumns(warehouse)) { |
5307 | each$2(cells$1(table), function (cell) { |
5272 | each$2(cells$1(table), function (cell) { |
Line 5363... | Line 5328... | ||
5363 | return getGridSize(table).columns; |
5328 | return getGridSize(table).columns; |
5364 | }; |
5329 | }; |
5365 | var afterCornerResize = function (table, origin, width) { |
5330 | var afterCornerResize = function (table, origin, width) { |
5366 | var isRightEdgeResize = endsWith(origin, 'e'); |
5331 | var isRightEdgeResize = endsWith(origin, 'e'); |
5367 | if (startRawW === '') { |
5332 | if (startRawW === '') { |
5368 | enforcePercentage(editor, table); |
5333 | enforcePercentage(table); |
5369 | } |
5334 | } |
5370 | if (width !== startW && startRawW !== '') { |
5335 | if (width !== startW && startRawW !== '') { |
5371 | set$1(table, 'width', startRawW); |
5336 | set$1(table, 'width', startRawW); |
5372 | var resizing = lazyResizingBehaviour(); |
5337 | var resizing = lazyResizingBehaviour(); |
5373 | var tableSize = lazySizing(table); |
5338 | var tableSize = lazySizing(table); |
Line 5424... | Line 5389... | ||
5424 | var table = SugarElement.fromDom(targetElm); |
5389 | var table = SugarElement.fromDom(targetElm); |
5425 | each$2(editor.dom.select('.mce-clonedresizable'), function (clone) { |
5390 | each$2(editor.dom.select('.mce-clonedresizable'), function (clone) { |
5426 | editor.dom.addClass(clone, 'mce-' + getColumnResizingBehaviour(editor) + '-columns'); |
5391 | editor.dom.addClass(clone, 'mce-' + getColumnResizingBehaviour(editor) + '-columns'); |
5427 | }); |
5392 | }); |
5428 | if (!isPixelSizing(table) && isPixelsForced(editor)) { |
5393 | if (!isPixelSizing(table) && isPixelsForced(editor)) { |
5429 | enforcePixels(editor, table); |
5394 | enforcePixels(table); |
5430 | } else if (!isPercentSizing(table) && isPercentagesForced(editor)) { |
5395 | } else if (!isPercentSizing(table) && isPercentagesForced(editor)) { |
5431 | enforcePercentage(editor, table); |
5396 | enforcePercentage(table); |
5432 | } |
5397 | } |
5433 | if (isNoneSizing(table) && startsWith(e.origin, barResizerPrefix)) { |
5398 | if (isNoneSizing(table) && startsWith(e.origin, barResizerPrefix)) { |
5434 | enforcePercentage(editor, table); |
5399 | enforcePercentage(table); |
5435 | } |
5400 | } |
5436 | startW = e.width; |
5401 | startW = e.width; |
5437 | startRawW = isResponsiveForced(editor) ? '' : getRawWidth(editor, targetElm).getOr(''); |
5402 | startRawW = isResponsiveForced(editor) ? '' : getRawWidth(editor, targetElm).getOr(''); |
5438 | } |
5403 | } |
5439 | }); |
5404 | }); |
Line 5516... | Line 5481... | ||
5516 | setGenericWidth(other, newWidth, w.unit); |
5481 | setGenericWidth(other, newWidth, w.unit); |
5517 | }); |
5482 | }); |
5518 | } |
5483 | } |
5519 | }; |
5484 | }; |
5520 | 5485 | ||
5521 | var isTableHeaderCell = isTag('th'); |
5486 | var isHeaderCell = isTag('th'); |
- | 5487 | var isHeaderCells = function (cells) { |
|
- | 5488 | return forall(cells, function (cell) { |
|
- | 5489 | return isHeaderCell(cell.element); |
|
- | 5490 | }); |
|
- | 5491 | }; |
|
5522 | var getRowHeaderType = function (isHeaderRow, isHeaderCells) { |
5492 | var getRowHeaderType = function (isHeaderRow, isHeaderCells) { |
5523 | if (isHeaderRow && isHeaderCells) { |
5493 | if (isHeaderRow && isHeaderCells) { |
5524 | return 'sectionCells'; |
5494 | return 'sectionCells'; |
5525 | } else if (isHeaderRow) { |
5495 | } else if (isHeaderRow) { |
5526 | return 'section'; |
5496 | return 'section'; |
Line 5542... | Line 5512... | ||
5542 | return { type: 'body' }; |
5512 | return { type: 'body' }; |
5543 | } |
5513 | } |
5544 | }; |
5514 | }; |
5545 | var findCommonCellType = function (cells) { |
5515 | var findCommonCellType = function (cells) { |
5546 | var headerCells = filter$2(cells, function (cell) { |
5516 | var headerCells = filter$2(cells, function (cell) { |
5547 | return isTableHeaderCell(cell.element); |
5517 | return isHeaderCell(cell.element); |
5548 | }); |
5518 | }); |
5549 | if (headerCells.length === 0) { |
5519 | if (headerCells.length === 0) { |
5550 | return Optional.some('td'); |
5520 | return Optional.some('td'); |
5551 | } else if (headerCells.length === cells.length) { |
5521 | } else if (headerCells.length === cells.length) { |
5552 | return Optional.some('th'); |
5522 | return Optional.some('th'); |
Line 5770... | Line 5740... | ||
5770 | return !comp(first.element, x.element); |
5740 | return !comp(first.element, x.element); |
5771 | }); |
5741 | }); |
5772 | return index.getOr(xs.length); |
5742 | return index.getOr(xs.length); |
5773 | }; |
5743 | }; |
5774 | var subgrid = function (grid, row, column, comparator) { |
5744 | var subgrid = function (grid, row, column, comparator) { |
5775 | var restOfRow = getRow(grid, row).cells.slice(column); |
5745 | var gridRow = getRow(grid, row); |
5776 | var endColIndex = findDiff(restOfRow, comparator); |
5746 | var isColRow = gridRow.section === 'colgroup'; |
5777 | var restOfColumn = getColumn(grid, column).slice(row); |
5747 | var colspan = findDiff(gridRow.cells.slice(column), comparator); |
5778 | var endRowIndex = findDiff(restOfColumn, comparator); |
5748 | var rowspan = isColRow ? 1 : findDiff(getColumn(grid.slice(row), column), comparator); |
5779 | return { |
5749 | return { |
5780 | colspan: endColIndex, |
5750 | colspan: colspan, |
5781 | rowspan: endRowIndex |
5751 | rowspan: rowspan |
5782 | }; |
5752 | }; |
5783 | }; |
5753 | }; |
5784 | 5754 | ||
5785 | var toDetails = function (grid, comparator) { |
5755 | var toDetails = function (grid, comparator) { |
5786 | var seen = map$1(grid, function (row) { |
5756 | var seen = map$1(grid, function (row) { |
Line 5807... | Line 5777... | ||
5807 | }); |
5777 | }); |
5808 | }; |
5778 | }; |
5809 | var toGrid = function (warehouse, generators, isNew) { |
5779 | var toGrid = function (warehouse, generators, isNew) { |
5810 | var grid = []; |
5780 | var grid = []; |
5811 | each$2(warehouse.colgroups, function (colgroup) { |
5781 | each$2(warehouse.colgroups, function (colgroup) { |
- | 5782 | var colgroupCols = []; |
|
- | 5783 | for (var columnIndex = 0; columnIndex < warehouse.grid.columns; columnIndex++) { |
|
5812 | var cols = map$1(colgroup.columns, function (column) { |
5784 | var element = Warehouse.getColumnAt(warehouse, columnIndex).map(function (column) { |
5813 | return elementnew(column.element, isNew, false); |
5785 | return elementnew(column.element, isNew, false); |
- | 5786 | }).getOrThunk(function () { |
|
- | 5787 | return elementnew(generators.colGap(), true, false); |
|
5814 | }); |
5788 | }); |
- | 5789 | colgroupCols.push(element); |
|
- | 5790 | } |
|
5815 | grid.push(rowcells(colgroup.element, cols, 'colgroup', isNew)); |
5791 | grid.push(rowcells(colgroup.element, colgroupCols, 'colgroup', isNew)); |
5816 | }); |
5792 | }); |
5817 | for (var rowIndex = 0; rowIndex < warehouse.grid.rows; rowIndex++) { |
5793 | for (var rowIndex = 0; rowIndex < warehouse.grid.rows; rowIndex++) { |
5818 | var rowCells = []; |
5794 | var rowCells = []; |
5819 | for (var columnIndex = 0; columnIndex < warehouse.grid.columns; columnIndex++) { |
5795 | for (var columnIndex = 0; columnIndex < warehouse.grid.columns; columnIndex++) { |
5820 | var element = Warehouse.getAt(warehouse, rowIndex, columnIndex).map(function (item) { |
5796 | var element = Warehouse.getAt(warehouse, rowIndex, columnIndex).map(function (item) { |
Line 6341... | Line 6317... | ||
6341 | var deleteRowsAt = function (grid, start, finish) { |
6317 | var deleteRowsAt = function (grid, start, finish) { |
6342 | var _a = extractGridDetails(grid), rows = _a.rows, cols = _a.cols; |
6318 | var _a = extractGridDetails(grid), rows = _a.rows, cols = _a.cols; |
6343 | return cols.concat(rows.slice(0, start)).concat(rows.slice(finish + 1)); |
6319 | return cols.concat(rows.slice(0, start)).concat(rows.slice(finish + 1)); |
6344 | }; |
6320 | }; |
6345 | 6321 | ||
- | 6322 | var notInStartRow = function (grid, rowIndex, colIndex, comparator) { |
|
- | 6323 | return getCellElement(grid[rowIndex], colIndex) !== undefined && (rowIndex > 0 && comparator(getCellElement(grid[rowIndex - 1], colIndex), getCellElement(grid[rowIndex], colIndex))); |
|
- | 6324 | }; |
|
- | 6325 | var notInStartColumn = function (row, index, comparator) { |
|
- | 6326 | return index > 0 && comparator(getCellElement(row, index - 1), getCellElement(row, index)); |
|
- | 6327 | }; |
|
- | 6328 | var isDuplicatedCell = function (grid, rowIndex, colIndex, comparator) { |
|
- | 6329 | return notInStartRow(grid, rowIndex, colIndex, comparator) || notInStartColumn(grid[rowIndex], colIndex, comparator); |
|
- | 6330 | }; |
|
- | 6331 | var rowReplacerPredicate = function (targetRow, columnHeaders) { |
|
- | 6332 | var entireTableIsHeader = forall(columnHeaders, identity) && isHeaderCells(targetRow.cells); |
|
- | 6333 | return entireTableIsHeader ? always : function (cell, _rowIndex, colIndex) { |
|
- | 6334 | var type = name(cell.element); |
|
- | 6335 | return !(type === 'th' && columnHeaders[colIndex]); |
|
- | 6336 | }; |
|
- | 6337 | }; |
|
- | 6338 | var columnReplacePredicate = function (targetColumn, rowHeaders) { |
|
- | 6339 | var entireTableIsHeader = forall(rowHeaders, identity) && isHeaderCells(targetColumn); |
|
- | 6340 | return entireTableIsHeader ? always : function (cell, rowIndex, _colIndex) { |
|
- | 6341 | var type = name(cell.element); |
|
- | 6342 | return !(type === 'th' && rowHeaders[rowIndex]); |
|
- | 6343 | }; |
|
- | 6344 | }; |
|
- | 6345 | var determineScope = function (applyScope, element, newScope, isInHeader) { |
|
- | 6346 | var hasSpan = function (scope) { |
|
- | 6347 | return scope === 'row' ? hasRowspan(element) : hasColspan(element); |
|
- | 6348 | }; |
|
- | 6349 | var getScope = function (scope) { |
|
- | 6350 | return hasSpan(scope) ? scope + 'group' : scope; |
|
- | 6351 | }; |
|
- | 6352 | if (applyScope) { |
|
- | 6353 | return isHeaderCell(element) ? getScope(newScope) : null; |
|
- | 6354 | } else if (isInHeader && isHeaderCell(element)) { |
|
- | 6355 | var oppositeScope = newScope === 'row' ? 'col' : 'row'; |
|
- | 6356 | return getScope(oppositeScope); |
|
- | 6357 | } else { |
|
- | 6358 | return null; |
|
- | 6359 | } |
|
- | 6360 | }; |
|
- | 6361 | var rowScopeGenerator = function (applyScope, columnHeaders) { |
|
- | 6362 | return function (cell, rowIndex, columnIndex) { |
|
- | 6363 | return Optional.some(determineScope(applyScope, cell.element, 'col', columnHeaders[columnIndex])); |
|
- | 6364 | }; |
|
- | 6365 | }; |
|
- | 6366 | var columnScopeGenerator = function (applyScope, rowHeaders) { |
|
- | 6367 | return function (cell, rowIndex) { |
|
- | 6368 | return Optional.some(determineScope(applyScope, cell.element, 'row', rowHeaders[rowIndex])); |
|
- | 6369 | }; |
|
- | 6370 | }; |
|
6346 | var replace = function (cell, comparator, substitute) { |
6371 | var replace = function (cell, comparator, substitute) { |
6347 | return elementnew(substitute(cell.element, comparator), true, cell.isLocked); |
6372 | return elementnew(substitute(cell.element, comparator), true, cell.isLocked); |
6348 | }; |
6373 | }; |
6349 | var replaceIn = function (grid, targets, comparator, substitute, replacer) { |
6374 | var replaceIn = function (grid, targets, comparator, substitute, replacer, genScope, shouldReplace) { |
6350 | var isTarget = function (cell) { |
6375 | var isTarget = function (cell) { |
6351 | return exists(targets, function (target) { |
6376 | return exists(targets, function (target) { |
6352 | return comparator(cell.element, target.element); |
6377 | return comparator(cell.element, target.element); |
6353 | }); |
6378 | }); |
6354 | }; |
6379 | }; |
6355 | return map$1(grid, function (row) { |
6380 | return map$1(grid, function (row, rowIndex) { |
6356 | return mapCells(row, function (cell) { |
6381 | return mapCells(row, function (cell, colIndex) { |
- | 6382 | if (isTarget(cell)) { |
|
6357 | return isTarget(cell) ? replacer(cell, comparator, substitute) : cell; |
6383 | var newCell_1 = shouldReplace(cell, rowIndex, colIndex) ? replacer(cell, comparator, substitute) : cell; |
- | 6384 | genScope(newCell_1, rowIndex, colIndex).each(function (scope) { |
|
- | 6385 | setOptions(newCell_1.element, { scope: Optional.from(scope) }); |
|
- | 6386 | }); |
|
- | 6387 | return newCell_1; |
|
- | 6388 | } else { |
|
- | 6389 | return cell; |
|
- | 6390 | } |
|
6358 | }); |
6391 | }); |
6359 | }); |
6392 | }); |
6360 | }; |
6393 | }; |
6361 | var notStartRow = function (grid, rowIndex, colIndex, comparator) { |
6394 | var getColumnCells = function (rows, columnIndex, comparator) { |
- | 6395 | return bind$2(rows, function (row, i) { |
|
6362 | return getCellElement(grid[rowIndex], colIndex) !== undefined && (rowIndex > 0 && comparator(getCellElement(grid[rowIndex - 1], colIndex), getCellElement(grid[rowIndex], colIndex))); |
6396 | return isDuplicatedCell(rows, i, columnIndex, comparator) ? [] : [getCell(row, columnIndex)]; |
- | 6397 | }); |
|
6363 | }; |
6398 | }; |
6364 | var notStartColumn = function (row, index, comparator) { |
6399 | var getRowCells = function (rows, rowIndex, comparator) { |
- | 6400 | var targetRow = rows[rowIndex]; |
|
- | 6401 | return bind$2(targetRow.cells, function (item, i) { |
|
6365 | return index > 0 && comparator(getCellElement(row, index - 1), getCellElement(row, index)); |
6402 | return isDuplicatedCell(rows, rowIndex, i, comparator) ? [] : [item]; |
- | 6403 | }); |
|
6366 | }; |
6404 | }; |
6367 | var replaceColumn = function (grid, index, comparator, substitution) { |
6405 | var replaceColumns = function (grid, indexes, applyScope, comparator, substitution) { |
6368 | var rows = extractGridDetails(grid).rows; |
6406 | var rows = extractGridDetails(grid).rows; |
6369 | var targets = bind$2(rows, function (row, i) { |
6407 | var targets = bind$2(indexes, function (index) { |
6370 | var alreadyAdded = notStartRow(rows, i, index, comparator) || notStartColumn(row, index, comparator); |
6408 | return getColumnCells(rows, index, comparator); |
- | 6409 | }); |
|
- | 6410 | var rowHeaders = map$1(grid, function (row) { |
|
6371 | return alreadyAdded ? [] : [getCell(row, index)]; |
6411 | return isHeaderCells(row.cells); |
6372 | }); |
6412 | }); |
- | 6413 | var shouldReplaceCell = columnReplacePredicate(targets, rowHeaders); |
|
- | 6414 | var scopeGenerator = columnScopeGenerator(applyScope, rowHeaders); |
|
6373 | return replaceIn(grid, targets, comparator, substitution, replace); |
6415 | return replaceIn(grid, targets, comparator, substitution, replace, scopeGenerator, shouldReplaceCell); |
6374 | }; |
6416 | }; |
6375 | var replaceRow = function (grid, index, section, comparator, substitution, tableSection) { |
6417 | var replaceRows = function (grid, indexes, section, applyScope, comparator, substitution, tableSection) { |
6376 | var _a = extractGridDetails(grid), cols = _a.cols, rows = _a.rows; |
6418 | var _a = extractGridDetails(grid), cols = _a.cols, rows = _a.rows; |
6377 | var targetRow = rows[index]; |
6419 | var targetRow = rows[indexes[0]]; |
6378 | var targets = bind$2(targetRow.cells, function (item, i) { |
6420 | var targets = bind$2(indexes, function (index) { |
6379 | var alreadyAdded = notStartRow(rows, index, i, comparator) || notStartColumn(targetRow, i, comparator); |
6421 | return getRowCells(rows, index, comparator); |
- | 6422 | }); |
|
- | 6423 | var columnHeaders = map$1(targetRow.cells, function (_cell, index) { |
|
6380 | return alreadyAdded ? [] : [item]; |
6424 | return isHeaderCells(getColumnCells(rows, index, comparator)); |
6381 | }); |
6425 | }); |
6382 | var newRows = __spreadArray([], rows); |
6426 | var newRows = __spreadArray([], rows, true); |
- | 6427 | each$2(indexes, function (index) { |
|
6383 | newRows[index] = tableSection.transformRow(targetRow, section); |
6428 | newRows[index] = tableSection.transformRow(rows[index], section); |
- | 6429 | }); |
|
- | 6430 | var newGrid = cols.concat(newRows); |
|
- | 6431 | var shouldReplaceCell = rowReplacerPredicate(targetRow, columnHeaders); |
|
- | 6432 | var scopeGenerator = rowScopeGenerator(applyScope, columnHeaders); |
|
6384 | return replaceIn(cols.concat(newRows), targets, comparator, substitution, tableSection.transformCell); |
6433 | return replaceIn(newGrid, targets, comparator, substitution, tableSection.transformCell, scopeGenerator, shouldReplaceCell); |
6385 | }; |
6434 | }; |
6386 | var replaceCell = function (grid, rowIndex, columnIndex, comparator, substitution) { |
6435 | var replaceCells = function (grid, details, comparator, substitution) { |
6387 | var rows = extractGridDetails(grid).rows; |
6436 | var rows = extractGridDetails(grid).rows; |
6388 | var targetRow = rows[rowIndex]; |
6437 | var targetCells = map$1(details, function (detail) { |
6389 | var targetCell = getCell(targetRow, columnIndex); |
6438 | return getCell(rows[detail.row], detail.column); |
- | 6439 | }); |
|
6390 | return replaceIn(grid, [targetCell], comparator, substitution, replace); |
6440 | return replaceIn(grid, targetCells, comparator, substitution, replace, Optional.none, always); |
6391 | }; |
6441 | }; |
6392 | 6442 | ||
6393 | var uniqueColumns = function (details) { |
6443 | var uniqueColumns = function (details) { |
6394 | var uniqueCheck = function (rest, detail) { |
6444 | var uniqueCheck = function (rest, detail) { |
6395 | var columnExists = exists(rest, function (currentDetail) { |
6445 | var columnExists = exists(rest, function (currentDetail) { |
Line 6446... | Line 6496... | ||
6446 | return comparator(element, p.item) ? p.replacement : add(element); |
6496 | return comparator(element, p.item) ? p.replacement : add(element); |
6447 | }); |
6497 | }); |
6448 | }; |
6498 | }; |
6449 | return { getOrInit: getOrInit }; |
6499 | return { getOrInit: getOrInit }; |
6450 | }; |
6500 | }; |
6451 | var transform = function (tag, scope) { |
6501 | var transform = function (tag) { |
6452 | return function (generators) { |
6502 | return function (generators) { |
6453 | var list = []; |
6503 | var list = []; |
6454 | var find = function (element, comparator) { |
6504 | var find = function (element, comparator) { |
6455 | return find$1(list, function (x) { |
6505 | return find$1(list, function (x) { |
6456 | return comparator(x.item, element); |
6506 | return comparator(x.item, element); |
6457 | }); |
6507 | }); |
6458 | }; |
6508 | }; |
6459 | var makeNew = function (element) { |
6509 | var makeNew = function (element) { |
6460 | var attrs = isUndefined(scope) ? {} : { scope: scope }; |
6510 | var attrs = tag === 'td' ? { scope: null } : {}; |
6461 | var cell = generators.replace(element, tag, attrs); |
6511 | var cell = generators.replace(element, tag, attrs); |
6462 | list.push({ |
6512 | list.push({ |
6463 | item: element, |
6513 | item: element, |
6464 | sub: cell |
6514 | sub: cell |
6465 | }); |
6515 | }); |
Line 6740... | Line 6790... | ||
6740 | return insertColumnAt(newG, targetIndex, col.column, comparator, genWrappers.getOrInit); |
6790 | return insertColumnAt(newG, targetIndex, col.column, comparator, genWrappers.getOrInit); |
6741 | }, grid); |
6791 | }, grid); |
6742 | return bundle(newGrid, details[0].row, targetIndex); |
6792 | return bundle(newGrid, details[0].row, targetIndex); |
6743 | }; |
6793 | }; |
6744 | var opMakeColumnsHeader = function (initialGrid, details, comparator, genWrappers) { |
6794 | var opMakeColumnsHeader = function (initialGrid, details, comparator, genWrappers) { |
6745 | var replacer = function (currentGrid, column) { |
- | |
6746 | return replaceColumn(currentGrid, column.column, comparator, genWrappers.replaceOrInit); |
- | |
6747 | }; |
- | |
6748 | var columns = uniqueColumns(details); |
6795 | var columns = uniqueColumns(details); |
6749 | var newGrid = foldl(columns, replacer, initialGrid); |
6796 | var columnIndexes = map$1(columns, function (detail) { |
- | 6797 | return detail.column; |
|
- | 6798 | }); |
|
- | 6799 | var newGrid = replaceColumns(initialGrid, columnIndexes, true, comparator, genWrappers.replaceOrInit); |
|
6750 | return bundle(newGrid, details[0].row, details[0].column); |
6800 | return bundle(newGrid, details[0].row, details[0].column); |
6751 | }; |
6801 | }; |
6752 | var opMakeCellsHeader = function (initialGrid, details, comparator, genWrappers) { |
6802 | var opMakeCellsHeader = function (initialGrid, details, comparator, genWrappers) { |
6753 | var replacer = function (currentGrid, detail) { |
- | |
6754 | return replaceCell(currentGrid, detail.row, detail.column, comparator, genWrappers.replaceOrInit); |
6803 | var newGrid = replaceCells(initialGrid, details, comparator, genWrappers.replaceOrInit); |
6755 | }; |
- | |
6756 | var newGrid = foldl(details, replacer, initialGrid); |
- | |
6757 | return bundle(newGrid, details[0].row, details[0].column); |
6804 | return bundle(newGrid, details[0].row, details[0].column); |
6758 | }; |
6805 | }; |
6759 | var opUnmakeColumnsHeader = function (initialGrid, details, comparator, genWrappers) { |
6806 | var opUnmakeColumnsHeader = function (initialGrid, details, comparator, genWrappers) { |
6760 | var replacer = function (currentGrid, column) { |
- | |
6761 | return replaceColumn(currentGrid, column.column, comparator, genWrappers.replaceOrInit); |
- | |
6762 | }; |
- | |
6763 | var columns = uniqueColumns(details); |
6807 | var columns = uniqueColumns(details); |
6764 | var newGrid = foldl(columns, replacer, initialGrid); |
6808 | var columnIndexes = map$1(columns, function (detail) { |
- | 6809 | return detail.column; |
|
- | 6810 | }); |
|
- | 6811 | var newGrid = replaceColumns(initialGrid, columnIndexes, false, comparator, genWrappers.replaceOrInit); |
|
6765 | return bundle(newGrid, details[0].row, details[0].column); |
6812 | return bundle(newGrid, details[0].row, details[0].column); |
6766 | }; |
6813 | }; |
6767 | var opUnmakeCellsHeader = function (initialGrid, details, comparator, genWrappers) { |
6814 | var opUnmakeCellsHeader = function (initialGrid, details, comparator, genWrappers) { |
6768 | var replacer = function (currentGrid, detail) { |
- | |
6769 | return replaceCell(currentGrid, detail.row, detail.column, comparator, genWrappers.replaceOrInit); |
6815 | var newGrid = replaceCells(initialGrid, details, comparator, genWrappers.replaceOrInit); |
6770 | }; |
- | |
6771 | var newGrid = foldl(details, replacer, initialGrid); |
- | |
6772 | return bundle(newGrid, details[0].row, details[0].column); |
6816 | return bundle(newGrid, details[0].row, details[0].column); |
6773 | }; |
6817 | }; |
6774 | var makeRowsSection = function (section) { |
6818 | var makeRowsSection = function (section, applyScope) { |
6775 | return function (initialGrid, details, comparator, genWrappers, tableSection) { |
6819 | return function (initialGrid, details, comparator, genWrappers, tableSection) { |
6776 | var replacer = function (currentGrid, detail) { |
- | |
6777 | return replaceRow(currentGrid, detail.row, section, comparator, genWrappers.replaceOrInit, tableSection); |
- | |
6778 | }; |
- | |
6779 | var rows = uniqueRows(details); |
6820 | var rows = uniqueRows(details); |
6780 | var newGrid = foldl(rows, replacer, initialGrid); |
6821 | var rowIndexes = map$1(rows, function (detail) { |
- | 6822 | return detail.row; |
|
- | 6823 | }); |
|
- | 6824 | var newGrid = replaceRows(initialGrid, rowIndexes, section, applyScope, comparator, genWrappers.replaceOrInit, tableSection); |
|
6781 | return bundle(newGrid, details[0].row, details[0].column); |
6825 | return bundle(newGrid, details[0].row, details[0].column); |
6782 | }; |
6826 | }; |
6783 | }; |
6827 | }; |
6784 | var opMakeRowsHeader = makeRowsSection('thead'); |
6828 | var opMakeRowsHeader = makeRowsSection('thead', true); |
6785 | var opMakeRowsBody = makeRowsSection('tbody'); |
6829 | var opMakeRowsBody = makeRowsSection('tbody', false); |
6786 | var opMakeRowsFooter = makeRowsSection('tfoot'); |
6830 | var opMakeRowsFooter = makeRowsSection('tfoot', false); |
6787 | var opEraseColumns = function (grid, extractDetail, _comparator, _genWrappers) { |
6831 | var opEraseColumns = function (grid, extractDetail, _comparator, _genWrappers) { |
6788 | var columns = uniqueColumns(extractDetail.details); |
6832 | var columns = uniqueColumns(extractDetail.details); |
6789 | var newGrid = deleteColumnsAt(grid, map$1(columns, function (column) { |
6833 | var newGrid = deleteColumnsAt(grid, map$1(columns, function (column) { |
6790 | return column.column; |
6834 | return column.column; |
6791 | })); |
6835 | })); |
Line 6945... | Line 6989... | ||
6945 | var checkLocked = before ? firstColumnIsLocked : lastColumnIsLocked; |
6989 | var checkLocked = before ? firstColumnIsLocked : lastColumnIsLocked; |
6946 | return !checkLocked(warehouse, details.cells); |
6990 | return !checkLocked(warehouse, details.cells); |
6947 | }); |
6991 | }); |
6948 | }; |
6992 | }; |
6949 | }; |
6993 | }; |
- | 6994 | var headerCellGenerator = Generators.transform('th'); |
|
- | 6995 | var bodyCellGenerator = Generators.transform('td'); |
|
6950 | var insertRowsBefore = run(opInsertRowsBefore, onCells, noop, noop, Generators.modification); |
6996 | var insertRowsBefore = run(opInsertRowsBefore, onCells, noop, noop, Generators.modification); |
6951 | var insertRowsAfter = run(opInsertRowsAfter, onCells, noop, noop, Generators.modification); |
6997 | var insertRowsAfter = run(opInsertRowsAfter, onCells, noop, noop, Generators.modification); |
6952 | var insertColumnsBefore = run(opInsertColumnsBefore, insertColumnsExtractor(true), adjustAndRedistributeWidths, noop, Generators.modification); |
6998 | var insertColumnsBefore = run(opInsertColumnsBefore, insertColumnsExtractor(true), adjustAndRedistributeWidths, noop, Generators.modification); |
6953 | var insertColumnsAfter = run(opInsertColumnsAfter, insertColumnsExtractor(false), adjustAndRedistributeWidths, noop, Generators.modification); |
6999 | var insertColumnsAfter = run(opInsertColumnsAfter, insertColumnsExtractor(false), adjustAndRedistributeWidths, noop, Generators.modification); |
6954 | var eraseColumns = run(opEraseColumns, eraseColumnsExtractor, adjustAndRedistributeWidths, prune, Generators.modification); |
7000 | var eraseColumns = run(opEraseColumns, eraseColumnsExtractor, adjustAndRedistributeWidths, prune, Generators.modification); |
6955 | var eraseRows = run(opEraseRows, onCells, noop, prune, Generators.modification); |
7001 | var eraseRows = run(opEraseRows, onCells, noop, prune, Generators.modification); |
6956 | var makeColumnsHeader = run(opMakeColumnsHeader, onUnlockedCells, noop, noop, Generators.transform('th', 'row')); |
7002 | var makeColumnsHeader = run(opMakeColumnsHeader, onUnlockedCells, noop, noop, headerCellGenerator); |
6957 | var unmakeColumnsHeader = run(opUnmakeColumnsHeader, onUnlockedCells, noop, noop, Generators.transform('td', null)); |
7003 | var unmakeColumnsHeader = run(opUnmakeColumnsHeader, onUnlockedCells, noop, noop, bodyCellGenerator); |
6958 | var makeRowsHeader = run(opMakeRowsHeader, onUnlockedCells, noop, noop, Generators.transform('th', 'col')); |
7004 | var makeRowsHeader = run(opMakeRowsHeader, onUnlockedCells, noop, noop, headerCellGenerator); |
6959 | var makeRowsBody = run(opMakeRowsBody, onUnlockedCells, noop, noop, Generators.transform('td', null)); |
7005 | var makeRowsBody = run(opMakeRowsBody, onUnlockedCells, noop, noop, bodyCellGenerator); |
6960 | var makeRowsFooter = run(opMakeRowsFooter, onUnlockedCells, noop, noop, Generators.transform('td', null)); |
7006 | var makeRowsFooter = run(opMakeRowsFooter, onUnlockedCells, noop, noop, bodyCellGenerator); |
6961 | var makeCellsHeader = run(opMakeCellsHeader, onUnlockedCells, noop, noop, Generators.transform('th')); |
7007 | var makeCellsHeader = run(opMakeCellsHeader, onUnlockedCells, noop, noop, headerCellGenerator); |
6962 | var unmakeCellsHeader = run(opUnmakeCellsHeader, onUnlockedCells, noop, noop, Generators.transform('td')); |
7008 | var unmakeCellsHeader = run(opUnmakeCellsHeader, onUnlockedCells, noop, noop, bodyCellGenerator); |
6963 | var mergeCells = run(opMergeCells, onUnlockedMergable, resize, noop, Generators.merging); |
7009 | var mergeCells = run(opMergeCells, onUnlockedMergable, resize, noop, Generators.merging); |
6964 | var unmergeCells = run(opUnmergeCells, onUnlockedUnmergable, resize, noop, Generators.merging); |
7010 | var unmergeCells = run(opUnmergeCells, onUnlockedUnmergable, resize, noop, Generators.merging); |
6965 | var pasteCells = run(opPasteCells, onPaste, resize, noop, Generators.modification); |
7011 | var pasteCells = run(opPasteCells, onPaste, resize, noop, Generators.modification); |
6966 | var pasteColsBefore = run(opPasteColsBefore, pasteColumnsExtractor(true), noop, noop, Generators.modification); |
7012 | var pasteColsBefore = run(opPasteColsBefore, pasteColumnsExtractor(true), noop, noop, Generators.modification); |
6967 | var pasteColsAfter = run(opPasteColsAfter, pasteColumnsExtractor(false), noop, noop, Generators.modification); |
7013 | var pasteColsAfter = run(opPasteColsAfter, pasteColumnsExtractor(false), noop, noop, Generators.modification); |
Line 7217... | Line 7263... | ||
7217 | editor.insertContent(html); |
7263 | editor.insertContent(html); |
7218 | editor.addVisual(); |
7264 | editor.addVisual(); |
7219 | }); |
7265 | }); |
7220 | return descendant(getBody(editor), 'table[data-mce-id="__mce"]').map(function (table) { |
7266 | return descendant(getBody(editor), 'table[data-mce-id="__mce"]').map(function (table) { |
7221 | if (isPixelsForced(editor)) { |
7267 | if (isPixelsForced(editor)) { |
7222 | enforcePixels(editor, table); |
7268 | enforcePixels(table); |
7223 | } else if (isResponsiveForced(editor)) { |
7269 | } else if (isResponsiveForced(editor)) { |
7224 | enforceNone(table); |
7270 | enforceNone(table); |
7225 | } else if (isPercentagesForced(editor) || isPercentage(defaultStyles.width)) { |
7271 | } else if (isPercentagesForced(editor) || isPercentage(defaultStyles.width)) { |
7226 | enforcePercentage(editor, table); |
7272 | enforcePercentage(table); |
7227 | } |
7273 | } |
7228 | removeDataStyle(table); |
7274 | removeDataStyle(table); |
7229 | remove$7(table, 'data-mce-id'); |
7275 | remove$7(table, 'data-mce-id'); |
7230 | fireEvents(editor, table); |
7276 | fireEvents(editor, table); |
7231 | selectFirstCellInTable(editor, table); |
7277 | selectFirstCellInTable(editor, table); |
Line 7335... | Line 7381... | ||
7335 | var lastSelectedCell = selectedCells[selectedCells.length - 1]; |
7381 | var lastSelectedCell = selectedCells[selectedCells.length - 1]; |
7336 | var minColRange = selectedCells[0].column; |
7382 | var minColRange = selectedCells[0].column; |
7337 | var maxColRange = lastSelectedCell.column + lastSelectedCell.colspan; |
7383 | var maxColRange = lastSelectedCell.column + lastSelectedCell.colspan; |
7338 | var fakeColGroups = generateColGroup(house, minColRange, maxColRange); |
7384 | var fakeColGroups = generateColGroup(house, minColRange, maxColRange); |
7339 | var fakeRows = generateRows(house, minColRange, maxColRange); |
7385 | var fakeRows = generateRows(house, minColRange, maxColRange); |
7340 | return __spreadArray(__spreadArray([], fakeColGroups), fakeRows); |
7386 | return __spreadArray(__spreadArray([], fakeColGroups, true), fakeRows, true); |
7341 | }); |
7387 | }); |
7342 | }; |
7388 | }; |
7343 | 7389 | ||
7344 | var copyRows = function (table, target, generators) { |
7390 | var copyRows = function (table, target, generators) { |
7345 | var warehouse = Warehouse.fromTable(table); |
7391 | var warehouse = Warehouse.fromTable(table); |
Line 7494... | Line 7540... | ||
7494 | var a = rgba[3]; |
7540 | var a = rgba[3]; |
7495 | return fromRgba(rgbaColour(r, g, b, a)); |
7541 | return fromRgba(rgbaColour(r, g, b, a)); |
7496 | }); |
7542 | }); |
7497 | }; |
7543 | }; |
7498 | 7544 | ||
- | 7545 | var Cell = function (initial) { |
|
- | 7546 | var value = initial; |
|
- | 7547 | var get = function () { |
|
- | 7548 | return value; |
|
- | 7549 | }; |
|
- | 7550 | var set = function (v) { |
|
- | 7551 | value = v; |
|
- | 7552 | }; |
|
- | 7553 | return { |
|
- | 7554 | get: get, |
|
- | 7555 | set: set |
|
- | 7556 | }; |
|
- | 7557 | }; |
|
- | 7558 | ||
7499 | var singleton = function (doRevoke) { |
7559 | var singleton = function (doRevoke) { |
7500 | var subject = Cell(Optional.none()); |
7560 | var subject = Cell(Optional.none()); |
7501 | var revoke = function () { |
7561 | var revoke = function () { |
7502 | return subject.get().each(doRevoke); |
7562 | return subject.get().each(doRevoke); |
7503 | }; |
7563 | }; |
Line 8583... | Line 8643... | ||
8583 | return getSelectionStartCellOrCaption(editor).each(function (cellOrCaption) { |
8643 | return getSelectionStartCellOrCaption(editor).each(function (cellOrCaption) { |
8584 | var isForcedSizing = isResponsiveForced(editor) || isPixelsForced(editor) || isPercentagesForced(editor); |
8644 | var isForcedSizing = isResponsiveForced(editor) || isPixelsForced(editor) || isPercentagesForced(editor); |
8585 | if (!isForcedSizing) { |
8645 | if (!isForcedSizing) { |
8586 | table(cellOrCaption, isRoot).each(function (table) { |
8646 | table(cellOrCaption, isRoot).each(function (table) { |
8587 | if (sizing === 'relative' && !isPercentSizing(table)) { |
8647 | if (sizing === 'relative' && !isPercentSizing(table)) { |
8588 | enforcePercentage(editor, table); |
8648 | enforcePercentage(table); |
8589 | } else if (sizing === 'fixed' && !isPixelSizing(table)) { |
8649 | } else if (sizing === 'fixed' && !isPixelSizing(table)) { |
8590 | enforcePixels(editor, table); |
8650 | enforcePixels(table); |
8591 | } else if (sizing === 'responsive' && !isNoneSizing(table)) { |
8651 | } else if (sizing === 'responsive' && !isNoneSizing(table)) { |
8592 | enforceNone(table); |
8652 | enforceNone(table); |
8593 | } |
8653 | } |
8594 | removeDataStyle(table); |
8654 | removeDataStyle(table); |
8595 | fireTableModified(editor, table.dom, structureModified); |
8655 | fireTableModified(editor, table.dom, structureModified); |
Line 10378... | Line 10438... | ||
10378 | var keydown = function (event, start, soffset, finish, foffset, direction) { |
10438 | var keydown = function (event, start, soffset, finish, foffset, direction) { |
10379 | var realEvent = event.raw; |
10439 | var realEvent = event.raw; |
10380 | var keycode = realEvent.which; |
10440 | var keycode = realEvent.which; |
10381 | var shiftKey = realEvent.shiftKey === true; |
10441 | var shiftKey = realEvent.shiftKey === true; |
10382 | var handler = retrieve$1(container, annotations.selectedSelector).fold(function () { |
10442 | var handler = retrieve$1(container, annotations.selectedSelector).fold(function () { |
- | 10443 | if (isNavigation(keycode) && !shiftKey) { |
|
- | 10444 | annotations.clearBeforeUpdate(container); |
|
- | 10445 | } |
|
10383 | if (isDown(keycode) && shiftKey) { |
10446 | if (isDown(keycode) && shiftKey) { |
10384 | return curry(select, bridge, container, isRoot, down, finish, start, annotations.selectRange); |
10447 | return curry(select, bridge, container, isRoot, down, finish, start, annotations.selectRange); |
10385 | } else if (isUp(keycode) && shiftKey) { |
10448 | } else if (isUp(keycode) && shiftKey) { |
10386 | return curry(select, bridge, container, isRoot, up, finish, start, annotations.selectRange); |
10449 | return curry(select, bridge, container, isRoot, up, finish, start, annotations.selectRange); |
10387 | } else if (isDown(keycode)) { |
10450 | } else if (isDown(keycode)) { |
Line 10421... | Line 10484... | ||
10421 | } else if (direction.isForward(keycode) && shiftKey) { |
10484 | } else if (direction.isForward(keycode) && shiftKey) { |
10422 | return update$1([ |
10485 | return update$1([ |
10423 | rc(0, +1), |
10486 | rc(0, +1), |
10424 | rc(+1, 0) |
10487 | rc(+1, 0) |
10425 | ]); |
10488 | ]); |
10426 | } else if (isNavigation(keycode) && shiftKey === false) { |
10489 | } else if (isNavigation(keycode) && !shiftKey) { |
10427 | return clearToNavigate; |
10490 | return clearToNavigate; |
10428 | } else { |
10491 | } else { |
10429 | return Optional.none; |
10492 | return Optional.none; |
10430 | } |
10493 | } |
10431 | }); |
10494 | }); |
Line 10434... | Line 10497... | ||
10434 | var keyup = function (event, start, soffset, finish, foffset) { |
10497 | var keyup = function (event, start, soffset, finish, foffset) { |
10435 | return retrieve$1(container, annotations.selectedSelector).fold(function () { |
10498 | return retrieve$1(container, annotations.selectedSelector).fold(function () { |
10436 | var realEvent = event.raw; |
10499 | var realEvent = event.raw; |
10437 | var keycode = realEvent.which; |
10500 | var keycode = realEvent.which; |
10438 | var shiftKey = realEvent.shiftKey === true; |
10501 | var shiftKey = realEvent.shiftKey === true; |
10439 | if (shiftKey === false) { |
10502 | if (!shiftKey) { |
10440 | return Optional.none(); |
10503 | return Optional.none(); |
10441 | } |
10504 | } |
10442 | if (isNavigation(keycode)) { |
10505 | if (isNavigation(keycode)) { |
10443 | return sync(container, isRoot, start, soffset, finish, foffset, annotations.selectRange); |
10506 | return sync(container, isRoot, start, soffset, finish, foffset, annotations.selectRange); |
10444 | } else { |
10507 | } else { |
Line 10519... | Line 10582... | ||
10519 | var clear = function (container) { |
10582 | var clear = function (container) { |
10520 | clearBeforeUpdate(container); |
10583 | clearBeforeUpdate(container); |
10521 | onClear(); |
10584 | onClear(); |
10522 | }; |
10585 | }; |
10523 | var clearBeforeUpdate = function (container) { |
10586 | var clearBeforeUpdate = function (container) { |
10524 | var sels = descendants(container, ephemera.selectedSelector); |
10587 | var sels = descendants(container, ephemera.selectedSelector + ',' + ephemera.firstSelectedSelector + ',' + ephemera.lastSelectedSelector); |
10525 | each$2(sels, removeSelectionAttributes); |
10588 | each$2(sels, removeSelectionAttributes); |
10526 | }; |
10589 | }; |
10527 | var selectRange = function (container, cells, start, finish) { |
10590 | var selectRange = function (container, cells, start, finish) { |
10528 | clear(container); |
10591 | clear(container); |
10529 | each$2(cells, addSelectionAttribute); |
10592 | each$2(cells, addSelectionAttribute); |