File size: 118,045 Bytes
bb7f1f4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 | /**
* TinyMCE version 6.4.1 (2023-03-29)
*/
(function () {
'use strict';
var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager');
const hasProto = (v, constructor, predicate) => {
var _a;
if (predicate(v, constructor.prototype)) {
return true;
} else {
return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
}
};
const typeOf = x => {
const t = typeof x;
if (x === null) {
return 'null';
} else if (t === 'object' && Array.isArray(x)) {
return 'array';
} else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
return 'string';
} else {
return t;
}
};
const isType$1 = type => value => typeOf(value) === type;
const isSimpleType = type => value => typeof value === type;
const eq$1 = t => a => t === a;
const isString = isType$1('string');
const isArray = isType$1('array');
const isBoolean = isSimpleType('boolean');
const isUndefined = eq$1(undefined);
const isNullable = a => a === null || a === undefined;
const isNonNullable = a => !isNullable(a);
const isFunction = isSimpleType('function');
const isNumber = isSimpleType('number');
const noop = () => {
};
const compose1 = (fbc, fab) => a => fbc(fab(a));
const constant = value => {
return () => {
return value;
};
};
const identity = x => {
return x;
};
const tripleEquals = (a, b) => {
return a === b;
};
function curry(fn, ...initialArgs) {
return (...restArgs) => {
const all = initialArgs.concat(restArgs);
return fn.apply(null, all);
};
}
const call = f => {
f();
};
const never = constant(false);
const always = constant(true);
class Optional {
constructor(tag, value) {
this.tag = tag;
this.value = value;
}
static some(value) {
return new Optional(true, value);
}
static none() {
return Optional.singletonNone;
}
fold(onNone, onSome) {
if (this.tag) {
return onSome(this.value);
} else {
return onNone();
}
}
isSome() {
return this.tag;
}
isNone() {
return !this.tag;
}
map(mapper) {
if (this.tag) {
return Optional.some(mapper(this.value));
} else {
return Optional.none();
}
}
bind(binder) {
if (this.tag) {
return binder(this.value);
} else {
return Optional.none();
}
}
exists(predicate) {
return this.tag && predicate(this.value);
}
forall(predicate) {
return !this.tag || predicate(this.value);
}
filter(predicate) {
if (!this.tag || predicate(this.value)) {
return this;
} else {
return Optional.none();
}
}
getOr(replacement) {
return this.tag ? this.value : replacement;
}
or(replacement) {
return this.tag ? this : replacement;
}
getOrThunk(thunk) {
return this.tag ? this.value : thunk();
}
orThunk(thunk) {
return this.tag ? this : thunk();
}
getOrDie(message) {
if (!this.tag) {
throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
} else {
return this.value;
}
}
static from(value) {
return isNonNullable(value) ? Optional.some(value) : Optional.none();
}
getOrNull() {
return this.tag ? this.value : null;
}
getOrUndefined() {
return this.value;
}
each(worker) {
if (this.tag) {
worker(this.value);
}
}
toArray() {
return this.tag ? [this.value] : [];
}
toString() {
return this.tag ? `some(${ this.value })` : 'none()';
}
}
Optional.singletonNone = new Optional(false);
const keys = Object.keys;
const hasOwnProperty = Object.hasOwnProperty;
const each$1 = (obj, f) => {
const props = keys(obj);
for (let k = 0, len = props.length; k < len; k++) {
const i = props[k];
const x = obj[i];
f(x, i);
}
};
const objAcc = r => (x, i) => {
r[i] = x;
};
const internalFilter = (obj, pred, onTrue, onFalse) => {
each$1(obj, (x, i) => {
(pred(x, i) ? onTrue : onFalse)(x, i);
});
};
const filter$1 = (obj, pred) => {
const t = {};
internalFilter(obj, pred, objAcc(t), noop);
return t;
};
const mapToArray = (obj, f) => {
const r = [];
each$1(obj, (value, name) => {
r.push(f(value, name));
});
return r;
};
const values = obj => {
return mapToArray(obj, identity);
};
const size = obj => {
return keys(obj).length;
};
const get$4 = (obj, key) => {
return has(obj, key) ? Optional.from(obj[key]) : Optional.none();
};
const has = (obj, key) => hasOwnProperty.call(obj, key);
const hasNonNullableKey = (obj, key) => has(obj, key) && obj[key] !== undefined && obj[key] !== null;
const nativeIndexOf = Array.prototype.indexOf;
const nativePush = Array.prototype.push;
const rawIndexOf = (ts, t) => nativeIndexOf.call(ts, t);
const contains = (xs, x) => rawIndexOf(xs, x) > -1;
const exists = (xs, pred) => {
for (let i = 0, len = xs.length; i < len; i++) {
const x = xs[i];
if (pred(x, i)) {
return true;
}
}
return false;
};
const range = (num, f) => {
const r = [];
for (let i = 0; i < num; i++) {
r.push(f(i));
}
return r;
};
const map = (xs, f) => {
const len = xs.length;
const r = new Array(len);
for (let i = 0; i < len; i++) {
const x = xs[i];
r[i] = f(x, i);
}
return r;
};
const each = (xs, f) => {
for (let i = 0, len = xs.length; i < len; i++) {
const x = xs[i];
f(x, i);
}
};
const eachr = (xs, f) => {
for (let i = xs.length - 1; i >= 0; i--) {
const x = xs[i];
f(x, i);
}
};
const partition = (xs, pred) => {
const pass = [];
const fail = [];
for (let i = 0, len = xs.length; i < len; i++) {
const x = xs[i];
const arr = pred(x, i) ? pass : fail;
arr.push(x);
}
return {
pass,
fail
};
};
const filter = (xs, pred) => {
const r = [];
for (let i = 0, len = xs.length; i < len; i++) {
const x = xs[i];
if (pred(x, i)) {
r.push(x);
}
}
return r;
};
const foldr = (xs, f, acc) => {
eachr(xs, (x, i) => {
acc = f(acc, x, i);
});
return acc;
};
const foldl = (xs, f, acc) => {
each(xs, (x, i) => {
acc = f(acc, x, i);
});
return acc;
};
const findUntil = (xs, pred, until) => {
for (let i = 0, len = xs.length; i < len; i++) {
const x = xs[i];
if (pred(x, i)) {
return Optional.some(x);
} else if (until(x, i)) {
break;
}
}
return Optional.none();
};
const find = (xs, pred) => {
return findUntil(xs, pred, never);
};
const flatten$1 = xs => {
const r = [];
for (let i = 0, len = xs.length; i < len; ++i) {
if (!isArray(xs[i])) {
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
}
nativePush.apply(r, xs[i]);
}
return r;
};
const bind = (xs, f) => flatten$1(map(xs, f));
const forall = (xs, pred) => {
for (let i = 0, len = xs.length; i < len; ++i) {
const x = xs[i];
if (pred(x, i) !== true) {
return false;
}
}
return true;
};
const mapToObject = (xs, f) => {
const r = {};
for (let i = 0, len = xs.length; i < len; i++) {
const x = xs[i];
r[String(x)] = f(x, i);
}
return r;
};
const get$3 = (xs, i) => i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
const head = xs => get$3(xs, 0);
const last = xs => get$3(xs, xs.length - 1);
const findMap = (arr, f) => {
for (let i = 0; i < arr.length; i++) {
const r = f(arr[i], i);
if (r.isSome()) {
return r;
}
}
return Optional.none();
};
const COMMENT = 8;
const DOCUMENT = 9;
const DOCUMENT_FRAGMENT = 11;
const ELEMENT = 1;
const TEXT = 3;
const fromHtml = (html, scope) => {
const doc = scope || document;
const div = doc.createElement('div');
div.innerHTML = html;
if (!div.hasChildNodes() || div.childNodes.length > 1) {
const message = 'HTML does not have a single root node';
console.error(message, html);
throw new Error(message);
}
return fromDom$1(div.childNodes[0]);
};
const fromTag = (tag, scope) => {
const doc = scope || document;
const node = doc.createElement(tag);
return fromDom$1(node);
};
const fromText = (text, scope) => {
const doc = scope || document;
const node = doc.createTextNode(text);
return fromDom$1(node);
};
const fromDom$1 = node => {
if (node === null || node === undefined) {
throw new Error('Node cannot be null or undefined');
}
return { dom: node };
};
const fromPoint = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom$1);
const SugarElement = {
fromHtml,
fromTag,
fromText,
fromDom: fromDom$1,
fromPoint
};
const is$2 = (element, selector) => {
const dom = element.dom;
if (dom.nodeType !== ELEMENT) {
return false;
} else {
const elem = dom;
if (elem.matches !== undefined) {
return elem.matches(selector);
} else if (elem.msMatchesSelector !== undefined) {
return elem.msMatchesSelector(selector);
} else if (elem.webkitMatchesSelector !== undefined) {
return elem.webkitMatchesSelector(selector);
} else if (elem.mozMatchesSelector !== undefined) {
return elem.mozMatchesSelector(selector);
} else {
throw new Error('Browser lacks native selectors');
}
}
};
const bypassSelector = dom => dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT && dom.nodeType !== DOCUMENT_FRAGMENT || dom.childElementCount === 0;
const all$1 = (selector, scope) => {
const base = scope === undefined ? document : scope.dom;
return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), SugarElement.fromDom);
};
const one = (selector, scope) => {
const base = scope === undefined ? document : scope.dom;
return bypassSelector(base) ? Optional.none() : Optional.from(base.querySelector(selector)).map(SugarElement.fromDom);
};
const eq = (e1, e2) => e1.dom === e2.dom;
const is$1 = is$2;
typeof window !== 'undefined' ? window : Function('return this;')();
const name = element => {
const r = element.dom.nodeName;
return r.toLowerCase();
};
const type = element => element.dom.nodeType;
const isType = t => element => type(element) === t;
const isComment = element => type(element) === COMMENT || name(element) === '#comment';
const isElement = isType(ELEMENT);
const isText = isType(TEXT);
const isDocument = isType(DOCUMENT);
const isDocumentFragment = isType(DOCUMENT_FRAGMENT);
const isTag = tag => e => isElement(e) && name(e) === tag;
const owner = element => SugarElement.fromDom(element.dom.ownerDocument);
const documentOrOwner = dos => isDocument(dos) ? dos : owner(dos);
const parent = element => Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
const parents = (element, isRoot) => {
const stop = isFunction(isRoot) ? isRoot : never;
let dom = element.dom;
const ret = [];
while (dom.parentNode !== null && dom.parentNode !== undefined) {
const rawParent = dom.parentNode;
const p = SugarElement.fromDom(rawParent);
ret.push(p);
if (stop(p) === true) {
break;
} else {
dom = rawParent;
}
}
return ret;
};
const prevSibling = element => Optional.from(element.dom.previousSibling).map(SugarElement.fromDom);
const nextSibling = element => Optional.from(element.dom.nextSibling).map(SugarElement.fromDom);
const children$3 = element => map(element.dom.childNodes, SugarElement.fromDom);
const child$3 = (element, index) => {
const cs = element.dom.childNodes;
return Optional.from(cs[index]).map(SugarElement.fromDom);
};
const firstChild = element => child$3(element, 0);
const isShadowRoot = dos => isDocumentFragment(dos) && isNonNullable(dos.dom.host);
const supported = isFunction(Element.prototype.attachShadow) && isFunction(Node.prototype.getRootNode);
const getRootNode = supported ? e => SugarElement.fromDom(e.dom.getRootNode()) : documentOrOwner;
const getShadowRoot = e => {
const r = getRootNode(e);
return isShadowRoot(r) ? Optional.some(r) : Optional.none();
};
const getShadowHost = e => SugarElement.fromDom(e.dom.host);
const inBody = element => {
const dom = isText(element) ? element.dom.parentNode : element.dom;
if (dom === undefined || dom === null || dom.ownerDocument === null) {
return false;
}
const doc = dom.ownerDocument;
return getShadowRoot(SugarElement.fromDom(dom)).fold(() => doc.body.contains(dom), compose1(inBody, getShadowHost));
};
var ClosestOrAncestor = (is, ancestor, scope, a, isRoot) => {
if (is(scope, a)) {
return Optional.some(scope);
} else if (isFunction(isRoot) && isRoot(scope)) {
return Optional.none();
} else {
return ancestor(scope, a, isRoot);
}
};
const ancestor$1 = (scope, predicate, isRoot) => {
let element = scope.dom;
const stop = isFunction(isRoot) ? isRoot : never;
while (element.parentNode) {
element = element.parentNode;
const el = SugarElement.fromDom(element);
if (predicate(el)) {
return Optional.some(el);
} else if (stop(el)) {
break;
}
}
return Optional.none();
};
const closest$2 = (scope, predicate, isRoot) => {
const is = (s, test) => test(s);
return ClosestOrAncestor(is, ancestor$1, scope, predicate, isRoot);
};
const child$2 = (scope, predicate) => {
const pred = node => predicate(SugarElement.fromDom(node));
const result = find(scope.dom.childNodes, pred);
return result.map(SugarElement.fromDom);
};
const ancestor = (scope, selector, isRoot) => ancestor$1(scope, e => is$2(e, selector), isRoot);
const child$1 = (scope, selector) => child$2(scope, e => is$2(e, selector));
const descendant = (scope, selector) => one(selector, scope);
const closest$1 = (scope, selector, isRoot) => {
const is = (element, selector) => is$2(element, selector);
return ClosestOrAncestor(is, ancestor, scope, selector, isRoot);
};
const closest = target => closest$1(target, '[contenteditable]');
const isEditable = (element, assumeEditable = false) => {
if (inBody(element)) {
return element.dom.isContentEditable;
} else {
return closest(element).fold(constant(assumeEditable), editable => getRaw$1(editable) === 'true');
}
};
const getRaw$1 = element => element.dom.contentEditable;
const getNodeName = elm => elm.nodeName.toLowerCase();
const getBody = editor => SugarElement.fromDom(editor.getBody());
const getIsRoot = editor => element => eq(element, getBody(editor));
const removePxSuffix = size => size ? size.replace(/px$/, '') : '';
const addPxSuffix = size => /^\d+(\.\d+)?$/.test(size) ? size + 'px' : size;
const getSelectionStart = editor => SugarElement.fromDom(editor.selection.getStart());
const getSelectionEnd = editor => SugarElement.fromDom(editor.selection.getEnd());
const isInEditableContext = cell => closest$2(cell, isTag('table')).forall(isEditable);
const children$2 = (scope, predicate) => filter(children$3(scope), predicate);
const descendants$1 = (scope, predicate) => {
let result = [];
each(children$3(scope), x => {
if (predicate(x)) {
result = result.concat([x]);
}
result = result.concat(descendants$1(x, predicate));
});
return result;
};
const children$1 = (scope, selector) => children$2(scope, e => is$2(e, selector));
const descendants = (scope, selector) => all$1(selector, scope);
const rawSet = (dom, key, value) => {
if (isString(value) || isBoolean(value) || isNumber(value)) {
dom.setAttribute(key, value + '');
} else {
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
throw new Error('Attribute value was not simple');
}
};
const set$2 = (element, key, value) => {
rawSet(element.dom, key, value);
};
const setAll = (element, attrs) => {
const dom = element.dom;
each$1(attrs, (v, k) => {
rawSet(dom, k, v);
});
};
const get$2 = (element, key) => {
const v = element.dom.getAttribute(key);
return v === null ? undefined : v;
};
const getOpt = (element, key) => Optional.from(get$2(element, key));
const remove$2 = (element, key) => {
element.dom.removeAttribute(key);
};
const clone = element => foldl(element.dom.attributes, (acc, attr) => {
acc[attr.name] = attr.value;
return acc;
}, {});
const is = (lhs, rhs, comparator = tripleEquals) => lhs.exists(left => comparator(left, rhs));
const cat = arr => {
const r = [];
const push = x => {
r.push(x);
};
for (let i = 0; i < arr.length; i++) {
arr[i].each(push);
}
return r;
};
const lift2 = (oa, ob, f) => oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none();
const flatten = oot => oot.bind(identity);
const someIf = (b, a) => b ? Optional.some(a) : Optional.none();
const removeFromStart = (str, numChars) => {
return str.substring(numChars);
};
const checkRange = (str, substr, start) => substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
const removeLeading = (str, prefix) => {
return startsWith(str, prefix) ? removeFromStart(str, prefix.length) : str;
};
const startsWith = (str, prefix) => {
return checkRange(str, prefix, 0);
};
const blank = r => s => s.replace(r, '');
const trim = blank(/^\s+|\s+$/g);
const isNotEmpty = s => s.length > 0;
const isEmpty = s => !isNotEmpty(s);
const toInt = (value, radix = 10) => {
const num = parseInt(value, radix);
return isNaN(num) ? Optional.none() : Optional.some(num);
};
const toFloat = value => {
const num = parseFloat(value);
return isNaN(num) ? Optional.none() : Optional.some(num);
};
const isSupported = dom => dom.style !== undefined && isFunction(dom.style.getPropertyValue);
const internalSet = (dom, property, value) => {
if (!isString(value)) {
console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
throw new Error('CSS value must be a string: ' + value);
}
if (isSupported(dom)) {
dom.style.setProperty(property, value);
}
};
const internalRemove = (dom, property) => {
if (isSupported(dom)) {
dom.style.removeProperty(property);
}
};
const set$1 = (element, property, value) => {
const dom = element.dom;
internalSet(dom, property, value);
};
const get$1 = (element, property) => {
const dom = element.dom;
const styles = window.getComputedStyle(dom);
const r = styles.getPropertyValue(property);
return r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;
};
const getUnsafeProperty = (dom, property) => isSupported(dom) ? dom.style.getPropertyValue(property) : '';
const getRaw = (element, property) => {
const dom = element.dom;
const raw = getUnsafeProperty(dom, property);
return Optional.from(raw).filter(r => r.length > 0);
};
const remove$1 = (element, property) => {
const dom = element.dom;
internalRemove(dom, property);
if (is(getOpt(element, 'style').map(trim), '')) {
remove$2(element, 'style');
}
};
const getAttrValue = (cell, name, fallback = 0) => getOpt(cell, name).map(value => parseInt(value, 10)).getOr(fallback);
const firstLayer = (scope, selector) => {
return filterFirstLayer(scope, selector, always);
};
const filterFirstLayer = (scope, selector, predicate) => {
return bind(children$3(scope), x => {
if (is$2(x, selector)) {
return predicate(x) ? [x] : [];
} else {
return filterFirstLayer(x, selector, predicate);
}
});
};
const validSectionList = [
'tfoot',
'thead',
'tbody',
'colgroup'
];
const isValidSection = parentName => contains(validSectionList, parentName);
const grid = (rows, columns) => ({
rows,
columns
});
const detail = (element, rowspan, colspan) => ({
element,
rowspan,
colspan
});
const extended = (element, rowspan, colspan, row, column, isLocked) => ({
element,
rowspan,
colspan,
row,
column,
isLocked
});
const rowdetail = (element, cells, section) => ({
element,
cells,
section
});
const bounds = (startRow, startCol, finishRow, finishCol) => ({
startRow,
startCol,
finishRow,
finishCol
});
const columnext = (element, colspan, column) => ({
element,
colspan,
column
});
const colgroup = (element, columns) => ({
element,
columns
});
const lookup = (tags, element, isRoot = never) => {
if (isRoot(element)) {
return Optional.none();
}
if (contains(tags, name(element))) {
return Optional.some(element);
}
const isRootOrUpperTable = elm => is$2(elm, 'table') || isRoot(elm);
return ancestor(element, tags.join(','), isRootOrUpperTable);
};
const cell = (element, isRoot) => lookup([
'td',
'th'
], element, isRoot);
const cells = ancestor => firstLayer(ancestor, 'th,td');
const columns = ancestor => {
if (is$2(ancestor, 'colgroup')) {
return children$1(ancestor, 'col');
} else {
return bind(columnGroups(ancestor), columnGroup => children$1(columnGroup, 'col'));
}
};
const table = (element, isRoot) => closest$1(element, 'table', isRoot);
const rows = ancestor => firstLayer(ancestor, 'tr');
const columnGroups = ancestor => table(ancestor).fold(constant([]), table => children$1(table, 'colgroup'));
const fromRowsOrColGroups = (elems, getSection) => map(elems, row => {
if (name(row) === 'colgroup') {
const cells = map(columns(row), column => {
const colspan = getAttrValue(column, 'span', 1);
return detail(column, 1, colspan);
});
return rowdetail(row, cells, 'colgroup');
} else {
const cells$1 = map(cells(row), cell => {
const rowspan = getAttrValue(cell, 'rowspan', 1);
const colspan = getAttrValue(cell, 'colspan', 1);
return detail(cell, rowspan, colspan);
});
return rowdetail(row, cells$1, getSection(row));
}
});
const getParentSection = group => parent(group).map(parent => {
const parentName = name(parent);
return isValidSection(parentName) ? parentName : 'tbody';
}).getOr('tbody');
const fromTable$1 = table => {
const rows$1 = rows(table);
const columnGroups$1 = columnGroups(table);
const elems = [
...columnGroups$1,
...rows$1
];
return fromRowsOrColGroups(elems, getParentSection);
};
const LOCKED_COL_ATTR = 'data-snooker-locked-cols';
const getLockedColumnsFromTable = table => getOpt(table, LOCKED_COL_ATTR).bind(lockedColStr => Optional.from(lockedColStr.match(/\d+/g))).map(lockedCols => mapToObject(lockedCols, always));
const key = (row, column) => {
return row + ',' + column;
};
const getAt = (warehouse, row, column) => Optional.from(warehouse.access[key(row, column)]);
const findItem = (warehouse, item, comparator) => {
const filtered = filterItems(warehouse, detail => {
return comparator(item, detail.element);
});
return filtered.length > 0 ? Optional.some(filtered[0]) : Optional.none();
};
const filterItems = (warehouse, predicate) => {
const all = bind(warehouse.all, r => {
return r.cells;
});
return filter(all, predicate);
};
const generateColumns = rowData => {
const columnsGroup = {};
let index = 0;
each(rowData.cells, column => {
const colspan = column.colspan;
range(colspan, columnIndex => {
const colIndex = index + columnIndex;
columnsGroup[colIndex] = columnext(column.element, colspan, colIndex);
});
index += colspan;
});
return columnsGroup;
};
const generate$1 = list => {
const access = {};
const cells = [];
const tableOpt = head(list).map(rowData => rowData.element).bind(table);
const lockedColumns = tableOpt.bind(getLockedColumnsFromTable).getOr({});
let maxRows = 0;
let maxColumns = 0;
let rowCount = 0;
const {
pass: colgroupRows,
fail: rows
} = partition(list, rowData => rowData.section === 'colgroup');
each(rows, rowData => {
const currentRow = [];
each(rowData.cells, rowCell => {
let start = 0;
while (access[key(rowCount, start)] !== undefined) {
start++;
}
const isLocked = hasNonNullableKey(lockedColumns, start.toString());
const current = extended(rowCell.element, rowCell.rowspan, rowCell.colspan, rowCount, start, isLocked);
for (let occupiedColumnPosition = 0; occupiedColumnPosition < rowCell.colspan; occupiedColumnPosition++) {
for (let occupiedRowPosition = 0; occupiedRowPosition < rowCell.rowspan; occupiedRowPosition++) {
const rowPosition = rowCount + occupiedRowPosition;
const columnPosition = start + occupiedColumnPosition;
const newpos = key(rowPosition, columnPosition);
access[newpos] = current;
maxColumns = Math.max(maxColumns, columnPosition + 1);
}
}
currentRow.push(current);
});
maxRows++;
cells.push(rowdetail(rowData.element, currentRow, rowData.section));
rowCount++;
});
const {columns, colgroups} = last(colgroupRows).map(rowData => {
const columns = generateColumns(rowData);
const colgroup$1 = colgroup(rowData.element, values(columns));
return {
colgroups: [colgroup$1],
columns
};
}).getOrThunk(() => ({
colgroups: [],
columns: {}
}));
const grid$1 = grid(maxRows, maxColumns);
return {
grid: grid$1,
access,
all: cells,
columns,
colgroups
};
};
const fromTable = table => {
const list = fromTable$1(table);
return generate$1(list);
};
const justCells = warehouse => bind(warehouse.all, w => w.cells);
const justColumns = warehouse => values(warehouse.columns);
const hasColumns = warehouse => keys(warehouse.columns).length > 0;
const getColumnAt = (warehouse, columnIndex) => Optional.from(warehouse.columns[columnIndex]);
const Warehouse = {
fromTable,
generate: generate$1,
getAt,
findItem,
filterItems,
justCells,
justColumns,
hasColumns,
getColumnAt
};
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools');
const getTDTHOverallStyle = (dom, elm, name) => {
const cells = dom.select('td,th', elm);
let firstChildStyle;
for (let i = 0; i < cells.length; i++) {
const currentStyle = dom.getStyle(cells[i], name);
if (isUndefined(firstChildStyle)) {
firstChildStyle = currentStyle;
}
if (firstChildStyle !== currentStyle) {
return '';
}
}
return firstChildStyle;
};
const setAlign = (editor, elm, name) => {
global$2.each('left center right'.split(' '), align => {
if (align !== name) {
editor.formatter.remove('align' + align, {}, elm);
}
});
if (name) {
editor.formatter.apply('align' + name, {}, elm);
}
};
const setVAlign = (editor, elm, name) => {
global$2.each('top middle bottom'.split(' '), align => {
if (align !== name) {
editor.formatter.remove('valign' + align, {}, elm);
}
});
if (name) {
editor.formatter.apply('valign' + name, {}, elm);
}
};
const fireTableModified = (editor, table, data) => {
editor.dispatch('TableModified', {
...data,
table
});
};
const toNumber = (px, fallback) => toFloat(px).getOr(fallback);
const getProp = (element, name, fallback) => toNumber(get$1(element, name), fallback);
const calcContentBoxSize = (element, size, upper, lower) => {
const paddingUpper = getProp(element, `padding-${ upper }`, 0);
const paddingLower = getProp(element, `padding-${ lower }`, 0);
const borderUpper = getProp(element, `border-${ upper }-width`, 0);
const borderLower = getProp(element, `border-${ lower }-width`, 0);
return size - paddingUpper - paddingLower - borderUpper - borderLower;
};
const getCalculatedWidth = (element, boxSizing) => {
const dom = element.dom;
const width = dom.getBoundingClientRect().width || dom.offsetWidth;
return boxSizing === 'border-box' ? width : calcContentBoxSize(element, width, 'left', 'right');
};
const getInnerWidth = element => getCalculatedWidth(element, 'content-box');
const getInner = getInnerWidth;
var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
const defaultTableToolbar = 'tableprops tabledelete | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol';
const defaultCellBorderWidths = range(5, i => {
const size = `${ i + 1 }px`;
return {
title: size,
value: size
};
});
const defaultCellBorderStyles = map([
'Solid',
'Dotted',
'Dashed',
'Double',
'Groove',
'Ridge',
'Inset',
'Outset',
'None',
'Hidden'
], type => {
return {
title: type,
value: type.toLowerCase()
};
});
const defaultWidth = '100%';
const getPixelForcedWidth = editor => {
var _a;
const dom = editor.dom;
const parentBlock = (_a = dom.getParent(editor.selection.getStart(), dom.isBlock)) !== null && _a !== void 0 ? _a : editor.getBody();
return getInner(SugarElement.fromDom(parentBlock)) + 'px';
};
const determineDefaultStyles = (editor, defaultStyles) => {
if (isResponsiveForced(editor) || !shouldStyleWithCss(editor)) {
return defaultStyles;
} else if (isPixelsForced(editor)) {
return {
...defaultStyles,
width: getPixelForcedWidth(editor)
};
} else {
return {
...defaultStyles,
width: defaultWidth
};
}
};
const determineDefaultAttributes = (editor, defaultAttributes) => {
if (isResponsiveForced(editor) || shouldStyleWithCss(editor)) {
return defaultAttributes;
} else if (isPixelsForced(editor)) {
return {
...defaultAttributes,
width: getPixelForcedWidth(editor)
};
} else {
return {
...defaultAttributes,
width: defaultWidth
};
}
};
const option = name => editor => editor.options.get(name);
const register = editor => {
const registerOption = editor.options.register;
registerOption('table_border_widths', {
processor: 'object[]',
default: defaultCellBorderWidths
});
registerOption('table_border_styles', {
processor: 'object[]',
default: defaultCellBorderStyles
});
registerOption('table_cell_advtab', {
processor: 'boolean',
default: true
});
registerOption('table_row_advtab', {
processor: 'boolean',
default: true
});
registerOption('table_advtab', {
processor: 'boolean',
default: true
});
registerOption('table_appearance_options', {
processor: 'boolean',
default: true
});
registerOption('table_grid', {
processor: 'boolean',
default: !global$1.deviceType.isTouch()
});
registerOption('table_cell_class_list', {
processor: 'object[]',
default: []
});
registerOption('table_row_class_list', {
processor: 'object[]',
default: []
});
registerOption('table_class_list', {
processor: 'object[]',
default: []
});
registerOption('table_toolbar', {
processor: 'string',
default: defaultTableToolbar
});
registerOption('table_background_color_map', {
processor: 'object[]',
default: []
});
registerOption('table_border_color_map', {
processor: 'object[]',
default: []
});
};
const getTableSizingMode = option('table_sizing_mode');
const getTableBorderWidths = option('table_border_widths');
const getTableBorderStyles = option('table_border_styles');
const hasAdvancedCellTab = option('table_cell_advtab');
const hasAdvancedRowTab = option('table_row_advtab');
const hasAdvancedTableTab = option('table_advtab');
const hasAppearanceOptions = option('table_appearance_options');
const hasTableGrid = option('table_grid');
const shouldStyleWithCss = option('table_style_by_css');
const getCellClassList = option('table_cell_class_list');
const getRowClassList = option('table_row_class_list');
const getTableClassList = option('table_class_list');
const getToolbar = option('table_toolbar');
const getTableBackgroundColorMap = option('table_background_color_map');
const getTableBorderColorMap = option('table_border_color_map');
const isPixelsForced = editor => getTableSizingMode(editor) === 'fixed';
const isResponsiveForced = editor => getTableSizingMode(editor) === 'responsive';
const getDefaultStyles = editor => {
const options = editor.options;
const defaultStyles = options.get('table_default_styles');
return options.isSet('table_default_styles') ? defaultStyles : determineDefaultStyles(editor, defaultStyles);
};
const getDefaultAttributes = editor => {
const options = editor.options;
const defaultAttributes = options.get('table_default_attributes');
return options.isSet('table_default_attributes') ? defaultAttributes : determineDefaultAttributes(editor, defaultAttributes);
};
const isWithin = (bounds, detail) => {
return detail.column >= bounds.startCol && detail.column + detail.colspan - 1 <= bounds.finishCol && detail.row >= bounds.startRow && detail.row + detail.rowspan - 1 <= bounds.finishRow;
};
const isRectangular = (warehouse, bounds) => {
let isRect = true;
const detailIsWithin = curry(isWithin, bounds);
for (let i = bounds.startRow; i <= bounds.finishRow; i++) {
for (let j = bounds.startCol; j <= bounds.finishCol; j++) {
isRect = isRect && Warehouse.getAt(warehouse, i, j).exists(detailIsWithin);
}
}
return isRect ? Optional.some(bounds) : Optional.none();
};
const getBounds = (detailA, detailB) => {
return bounds(Math.min(detailA.row, detailB.row), Math.min(detailA.column, detailB.column), Math.max(detailA.row + detailA.rowspan - 1, detailB.row + detailB.rowspan - 1), Math.max(detailA.column + detailA.colspan - 1, detailB.column + detailB.colspan - 1));
};
const getAnyBox = (warehouse, startCell, finishCell) => {
const startCoords = Warehouse.findItem(warehouse, startCell, eq);
const finishCoords = Warehouse.findItem(warehouse, finishCell, eq);
return startCoords.bind(sc => {
return finishCoords.map(fc => {
return getBounds(sc, fc);
});
});
};
const getBox$1 = (warehouse, startCell, finishCell) => {
return getAnyBox(warehouse, startCell, finishCell).bind(bounds => {
return isRectangular(warehouse, bounds);
});
};
const getBox = (table, first, last) => {
const warehouse = getWarehouse(table);
return getBox$1(warehouse, first, last);
};
const getWarehouse = Warehouse.fromTable;
const before = (marker, element) => {
const parent$1 = parent(marker);
parent$1.each(v => {
v.dom.insertBefore(element.dom, marker.dom);
});
};
const after$1 = (marker, element) => {
const sibling = nextSibling(marker);
sibling.fold(() => {
const parent$1 = parent(marker);
parent$1.each(v => {
append$1(v, element);
});
}, v => {
before(v, element);
});
};
const prepend = (parent, element) => {
const firstChild$1 = firstChild(parent);
firstChild$1.fold(() => {
append$1(parent, element);
}, v => {
parent.dom.insertBefore(element.dom, v.dom);
});
};
const append$1 = (parent, element) => {
parent.dom.appendChild(element.dom);
};
const wrap = (element, wrapper) => {
before(element, wrapper);
append$1(wrapper, element);
};
const after = (marker, elements) => {
each(elements, (x, i) => {
const e = i === 0 ? marker : elements[i - 1];
after$1(e, x);
});
};
const append = (parent, elements) => {
each(elements, x => {
append$1(parent, x);
});
};
const remove = element => {
const dom = element.dom;
if (dom.parentNode !== null) {
dom.parentNode.removeChild(dom);
}
};
const unwrap = wrapper => {
const children = children$3(wrapper);
if (children.length > 0) {
after(wrapper, children);
}
remove(wrapper);
};
const NodeValue = (is, name) => {
const get = element => {
if (!is(element)) {
throw new Error('Can only get ' + name + ' value of a ' + name + ' node');
}
return getOption(element).getOr('');
};
const getOption = element => is(element) ? Optional.from(element.dom.nodeValue) : Optional.none();
const set = (element, value) => {
if (!is(element)) {
throw new Error('Can only set raw ' + name + ' value of a ' + name + ' node');
}
element.dom.nodeValue = value;
};
return {
get,
getOption,
set
};
};
const api = NodeValue(isText, 'text');
const get = element => api.get(element);
const set = (element, value) => api.set(element, value);
var TagBoundaries = [
'body',
'p',
'div',
'article',
'aside',
'figcaption',
'figure',
'footer',
'header',
'nav',
'section',
'ol',
'ul',
'li',
'table',
'thead',
'tbody',
'tfoot',
'caption',
'tr',
'td',
'th',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'blockquote',
'pre',
'address'
];
var DomUniverse = () => {
const clone$1 = element => {
return SugarElement.fromDom(element.dom.cloneNode(false));
};
const document = element => documentOrOwner(element).dom;
const isBoundary = element => {
if (!isElement(element)) {
return false;
}
if (name(element) === 'body') {
return true;
}
return contains(TagBoundaries, name(element));
};
const isEmptyTag = element => {
if (!isElement(element)) {
return false;
}
return contains([
'br',
'img',
'hr',
'input'
], name(element));
};
const isNonEditable = element => isElement(element) && get$2(element, 'contenteditable') === 'false';
const comparePosition = (element, other) => {
return element.dom.compareDocumentPosition(other.dom);
};
const copyAttributesTo = (source, destination) => {
const as = clone(source);
setAll(destination, as);
};
const isSpecial = element => {
const tag = name(element);
return contains([
'script',
'noscript',
'iframe',
'noframes',
'noembed',
'title',
'style',
'textarea',
'xmp'
], tag);
};
const getLanguage = element => isElement(element) ? getOpt(element, 'lang') : Optional.none();
return {
up: constant({
selector: ancestor,
closest: closest$1,
predicate: ancestor$1,
all: parents
}),
down: constant({
selector: descendants,
predicate: descendants$1
}),
styles: constant({
get: get$1,
getRaw: getRaw,
set: set$1,
remove: remove$1
}),
attrs: constant({
get: get$2,
set: set$2,
remove: remove$2,
copyTo: copyAttributesTo
}),
insert: constant({
before: before,
after: after$1,
afterAll: after,
append: append$1,
appendAll: append,
prepend: prepend,
wrap: wrap
}),
remove: constant({
unwrap: unwrap,
remove: remove
}),
create: constant({
nu: SugarElement.fromTag,
clone: clone$1,
text: SugarElement.fromText
}),
query: constant({
comparePosition,
prevSibling: prevSibling,
nextSibling: nextSibling
}),
property: constant({
children: children$3,
name: name,
parent: parent,
document,
isText: isText,
isComment: isComment,
isElement: isElement,
isSpecial,
getLanguage,
getText: get,
setText: set,
isBoundary,
isEmptyTag,
isNonEditable
}),
eq: eq,
is: is$1
};
};
const all = (universe, look, elements, f) => {
const head = elements[0];
const tail = elements.slice(1);
return f(universe, look, head, tail);
};
const oneAll = (universe, look, elements) => {
return elements.length > 0 ? all(universe, look, elements, unsafeOne) : Optional.none();
};
const unsafeOne = (universe, look, head, tail) => {
const start = look(universe, head);
return foldr(tail, (b, a) => {
const current = look(universe, a);
return commonElement(universe, b, current);
}, start);
};
const commonElement = (universe, start, end) => {
return start.bind(s => {
return end.filter(curry(universe.eq, s));
});
};
const sharedOne$1 = oneAll;
const universe = DomUniverse();
const sharedOne = (look, elements) => {
return sharedOne$1(universe, (_universe, element) => {
return look(element);
}, elements);
};
const lookupTable = container => {
return ancestor(container, 'table');
};
const retrieve$1 = (container, selector) => {
const sels = descendants(container, selector);
return sels.length > 0 ? Optional.some(sels) : Optional.none();
};
const getEdges = (container, firstSelectedSelector, lastSelectedSelector) => {
return descendant(container, firstSelectedSelector).bind(first => {
return descendant(container, lastSelectedSelector).bind(last => {
return sharedOne(lookupTable, [
first,
last
]).map(table => {
return {
first,
last,
table
};
});
});
});
};
const retrieve = (container, selector) => {
return retrieve$1(container, selector);
};
const retrieveBox = (container, firstSelectedSelector, lastSelectedSelector) => {
return getEdges(container, firstSelectedSelector, lastSelectedSelector).bind(edges => {
const isRoot = ancestor => {
return eq(container, ancestor);
};
const sectionSelector = 'thead,tfoot,tbody,table';
const firstAncestor = ancestor(edges.first, sectionSelector, isRoot);
const lastAncestor = ancestor(edges.last, sectionSelector, isRoot);
return firstAncestor.bind(fA => {
return lastAncestor.bind(lA => {
return eq(fA, lA) ? getBox(edges.table, edges.first, edges.last) : Optional.none();
});
});
});
};
const fromDom = nodes => map(nodes, SugarElement.fromDom);
const strSelected = 'data-mce-selected';
const strSelectedSelector = 'td[' + strSelected + '],th[' + strSelected + ']';
const strFirstSelected = 'data-mce-first-selected';
const strFirstSelectedSelector = 'td[' + strFirstSelected + '],th[' + strFirstSelected + ']';
const strLastSelected = 'data-mce-last-selected';
const strLastSelectedSelector = 'td[' + strLastSelected + '],th[' + strLastSelected + ']';
const ephemera = {
selected: strSelected,
selectedSelector: strSelectedSelector,
firstSelected: strFirstSelected,
firstSelectedSelector: strFirstSelectedSelector,
lastSelected: strLastSelected,
lastSelectedSelector: strLastSelectedSelector
};
const getSelectionCellFallback = element => table(element).bind(table => retrieve(table, ephemera.firstSelectedSelector)).fold(constant(element), cells => cells[0]);
const getSelectionFromSelector = selector => (initCell, isRoot) => {
const cellName = name(initCell);
const cell = cellName === 'col' || cellName === 'colgroup' ? getSelectionCellFallback(initCell) : initCell;
return closest$1(cell, selector, isRoot);
};
const getSelectionCellOrCaption = getSelectionFromSelector('th,td,caption');
const getSelectionCell = getSelectionFromSelector('th,td');
const getCellsFromSelection = editor => fromDom(editor.model.table.getSelectedCells());
const getRowsFromSelection = (selected, selector) => {
const cellOpt = getSelectionCell(selected);
const rowsOpt = cellOpt.bind(cell => table(cell)).map(table => rows(table));
return lift2(cellOpt, rowsOpt, (cell, rows) => filter(rows, row => exists(fromDom(row.dom.cells), rowCell => get$2(rowCell, selector) === '1' || eq(rowCell, cell)))).getOr([]);
};
const verticalAlignValues = [
{
text: 'None',
value: ''
},
{
text: 'Top',
value: 'top'
},
{
text: 'Middle',
value: 'middle'
},
{
text: 'Bottom',
value: 'bottom'
}
];
const hexColour = value => ({ value: normalizeHex(value) });
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
const longformRegex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;
const isHexString = hex => shorthandRegex.test(hex) || longformRegex.test(hex);
const normalizeHex = hex => removeLeading(hex, '#').toUpperCase();
const fromString$1 = hex => isHexString(hex) ? Optional.some({ value: normalizeHex(hex) }) : Optional.none();
const toHex = component => {
const hex = component.toString(16);
return (hex.length === 1 ? '0' + hex : hex).toUpperCase();
};
const fromRgba = rgbaColour => {
const value = toHex(rgbaColour.red) + toHex(rgbaColour.green) + toHex(rgbaColour.blue);
return hexColour(value);
};
const rgbRegex = /^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i;
const rgbaRegex = /^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i;
const rgbaColour = (red, green, blue, alpha) => ({
red,
green,
blue,
alpha
});
const fromStringValues = (red, green, blue, alpha) => {
const r = parseInt(red, 10);
const g = parseInt(green, 10);
const b = parseInt(blue, 10);
const a = parseFloat(alpha);
return rgbaColour(r, g, b, a);
};
const fromString = rgbaString => {
if (rgbaString === 'transparent') {
return Optional.some(rgbaColour(0, 0, 0, 0));
}
const rgbMatch = rgbRegex.exec(rgbaString);
if (rgbMatch !== null) {
return Optional.some(fromStringValues(rgbMatch[1], rgbMatch[2], rgbMatch[3], '1'));
}
const rgbaMatch = rgbaRegex.exec(rgbaString);
if (rgbaMatch !== null) {
return Optional.some(fromStringValues(rgbaMatch[1], rgbaMatch[2], rgbaMatch[3], rgbaMatch[4]));
}
return Optional.none();
};
const anyToHex = color => fromString$1(color).orThunk(() => fromString(color).map(fromRgba)).getOrThunk(() => {
const canvas = document.createElement('canvas');
canvas.height = 1;
canvas.width = 1;
const canvasContext = canvas.getContext('2d');
canvasContext.clearRect(0, 0, canvas.width, canvas.height);
canvasContext.fillStyle = '#FFFFFF';
canvasContext.fillStyle = color;
canvasContext.fillRect(0, 0, 1, 1);
const rgba = canvasContext.getImageData(0, 0, 1, 1).data;
const r = rgba[0];
const g = rgba[1];
const b = rgba[2];
const a = rgba[3];
return fromRgba(rgbaColour(r, g, b, a));
});
const rgbaToHexString = color => fromString(color).map(fromRgba).map(h => '#' + h.value).getOr(color);
const Cell = initial => {
let value = initial;
const get = () => {
return value;
};
const set = v => {
value = v;
};
return {
get,
set
};
};
const singleton = doRevoke => {
const subject = Cell(Optional.none());
const revoke = () => subject.get().each(doRevoke);
const clear = () => {
revoke();
subject.set(Optional.none());
};
const isSet = () => subject.get().isSome();
const get = () => subject.get();
const set = s => {
revoke();
subject.set(Optional.some(s));
};
return {
clear,
isSet,
get,
set
};
};
const unbindable = () => singleton(s => s.unbind());
const onSetupToggle = (editor, formatName, formatValue) => {
return api => {
const boundCallback = unbindable();
const isNone = isEmpty(formatValue);
const init = () => {
const selectedCells = getCellsFromSelection(editor);
const checkNode = cell => editor.formatter.match(formatName, { value: formatValue }, cell.dom, isNone);
if (isNone) {
api.setActive(!exists(selectedCells, checkNode));
boundCallback.set(editor.formatter.formatChanged(formatName, match => api.setActive(!match), true));
} else {
api.setActive(forall(selectedCells, checkNode));
boundCallback.set(editor.formatter.formatChanged(formatName, api.setActive, false, { value: formatValue }));
}
};
editor.initialized ? init() : editor.on('init', init);
return boundCallback.clear;
};
};
const isListGroup = item => hasNonNullableKey(item, 'menu');
const buildListItems = items => map(items, item => {
const text = item.text || item.title || '';
if (isListGroup(item)) {
return {
text,
items: buildListItems(item.menu)
};
} else {
return {
text,
value: item.value
};
}
});
const buildMenuItems = (editor, items, format, onAction) => map(items, item => {
const text = item.text || item.title;
if (isListGroup(item)) {
return {
type: 'nestedmenuitem',
text,
getSubmenuItems: () => buildMenuItems(editor, item.menu, format, onAction)
};
} else {
return {
text,
type: 'togglemenuitem',
onAction: () => onAction(item.value),
onSetup: onSetupToggle(editor, format, item.value)
};
}
});
const applyTableCellStyle = (editor, style) => value => {
editor.execCommand('mceTableApplyCellStyle', false, { [style]: value });
};
const filterNoneItem = list => bind(list, item => {
if (isListGroup(item)) {
return [{
...item,
menu: filterNoneItem(item.menu)
}];
} else {
return isNotEmpty(item.value) ? [item] : [];
}
});
const generateMenuItemsCallback = (editor, items, format, onAction) => callback => callback(buildMenuItems(editor, items, format, onAction));
const buildColorMenu = (editor, colorList, style) => {
const colorMap = map(colorList, entry => ({
text: entry.title,
value: '#' + anyToHex(entry.value).value,
type: 'choiceitem'
}));
return [{
type: 'fancymenuitem',
fancytype: 'colorswatch',
initData: {
colors: colorMap.length > 0 ? colorMap : undefined,
allowCustomColors: false
},
onAction: data => {
const value = data.value === 'remove' ? '' : data.value;
editor.execCommand('mceTableApplyCellStyle', false, { [style]: value });
}
}];
};
const changeRowHeader = editor => () => {
const currentType = editor.queryCommandValue('mceTableRowType');
const newType = currentType === 'header' ? 'body' : 'header';
editor.execCommand('mceTableRowType', false, { type: newType });
};
const changeColumnHeader = editor => () => {
const currentType = editor.queryCommandValue('mceTableColType');
const newType = currentType === 'th' ? 'td' : 'th';
editor.execCommand('mceTableColType', false, { type: newType });
};
const getClassList$1 = editor => {
const classes = buildListItems(getCellClassList(editor));
if (classes.length > 0) {
return Optional.some({
name: 'class',
type: 'listbox',
label: 'Class',
items: classes
});
}
return Optional.none();
};
const children = [
{
name: 'width',
type: 'input',
label: 'Width'
},
{
name: 'height',
type: 'input',
label: 'Height'
},
{
name: 'celltype',
type: 'listbox',
label: 'Cell type',
items: [
{
text: 'Cell',
value: 'td'
},
{
text: 'Header cell',
value: 'th'
}
]
},
{
name: 'scope',
type: 'listbox',
label: 'Scope',
items: [
{
text: 'None',
value: ''
},
{
text: 'Row',
value: 'row'
},
{
text: 'Column',
value: 'col'
},
{
text: 'Row group',
value: 'rowgroup'
},
{
text: 'Column group',
value: 'colgroup'
}
]
},
{
name: 'halign',
type: 'listbox',
label: 'Horizontal align',
items: [
{
text: 'None',
value: ''
},
{
text: 'Left',
value: 'left'
},
{
text: 'Center',
value: 'center'
},
{
text: 'Right',
value: 'right'
}
]
},
{
name: 'valign',
type: 'listbox',
label: 'Vertical align',
items: verticalAlignValues
}
];
const getItems$2 = editor => children.concat(getClassList$1(editor).toArray());
const getAdvancedTab = (editor, dialogName) => {
const emptyBorderStyle = [{
text: 'Select...',
value: ''
}];
const advTabItems = [
{
name: 'borderstyle',
type: 'listbox',
label: 'Border style',
items: emptyBorderStyle.concat(buildListItems(getTableBorderStyles(editor)))
},
{
name: 'bordercolor',
type: 'colorinput',
label: 'Border color'
},
{
name: 'backgroundcolor',
type: 'colorinput',
label: 'Background color'
}
];
const borderWidth = {
name: 'borderwidth',
type: 'input',
label: 'Border width'
};
const items = dialogName === 'cell' ? [borderWidth].concat(advTabItems) : advTabItems;
return {
title: 'Advanced',
name: 'advanced',
items
};
};
const normal = (editor, element) => {
const dom = editor.dom;
const setAttrib = (attr, value) => {
dom.setAttrib(element, attr, value);
};
const setStyle = (prop, value) => {
dom.setStyle(element, prop, value);
};
const setFormat = (formatName, value) => {
if (value === '') {
editor.formatter.remove(formatName, { value: null }, element, true);
} else {
editor.formatter.apply(formatName, { value }, element);
}
};
return {
setAttrib,
setStyle,
setFormat
};
};
const DomModifier = { normal };
const isHeaderCell = isTag('th');
const getRowHeaderType = (isHeaderRow, isHeaderCells) => {
if (isHeaderRow && isHeaderCells) {
return 'sectionCells';
} else if (isHeaderRow) {
return 'section';
} else {
return 'cells';
}
};
const getRowType$1 = row => {
const isHeaderRow = row.section === 'thead';
const isHeaderCells = is(findCommonCellType(row.cells), 'th');
if (row.section === 'tfoot') {
return { type: 'footer' };
} else if (isHeaderRow || isHeaderCells) {
return {
type: 'header',
subType: getRowHeaderType(isHeaderRow, isHeaderCells)
};
} else {
return { type: 'body' };
}
};
const findCommonCellType = cells => {
const headerCells = filter(cells, cell => isHeaderCell(cell.element));
if (headerCells.length === 0) {
return Optional.some('td');
} else if (headerCells.length === cells.length) {
return Optional.some('th');
} else {
return Optional.none();
}
};
const findCommonRowType = rows => {
const rowTypes = map(rows, row => getRowType$1(row).type);
const hasHeader = contains(rowTypes, 'header');
const hasFooter = contains(rowTypes, 'footer');
if (!hasHeader && !hasFooter) {
return Optional.some('body');
} else {
const hasBody = contains(rowTypes, 'body');
if (hasHeader && !hasBody && !hasFooter) {
return Optional.some('header');
} else if (!hasHeader && !hasBody && hasFooter) {
return Optional.some('footer');
} else {
return Optional.none();
}
}
};
const cached = f => {
let called = false;
let r;
return (...args) => {
if (!called) {
called = true;
r = f.apply(null, args);
}
return r;
};
};
const findInWarehouse = (warehouse, element) => findMap(warehouse.all, r => find(r.cells, e => eq(element, e.element)));
const extractCells = (warehouse, target, predicate) => {
const details = map(target.selection, cell$1 => {
return cell(cell$1).bind(lc => findInWarehouse(warehouse, lc)).filter(predicate);
});
const cells = cat(details);
return someIf(cells.length > 0, cells);
};
const onMergable = (_warehouse, target) => target.mergable;
const onUnmergable = (_warehouse, target) => target.unmergable;
const onCells = (warehouse, target) => extractCells(warehouse, target, always);
const isUnlockedTableCell = (warehouse, cell) => findInWarehouse(warehouse, cell).exists(detail => !detail.isLocked);
const allUnlocked = (warehouse, cells) => forall(cells, cell => isUnlockedTableCell(warehouse, cell));
const onUnlockedMergable = (warehouse, target) => onMergable(warehouse, target).filter(mergeable => allUnlocked(warehouse, mergeable.cells));
const onUnlockedUnmergable = (warehouse, target) => onUnmergable(warehouse, target).filter(cells => allUnlocked(warehouse, cells));
const generate = cases => {
if (!isArray(cases)) {
throw new Error('cases must be an array');
}
if (cases.length === 0) {
throw new Error('there must be at least one case');
}
const constructors = [];
const adt = {};
each(cases, (acase, count) => {
const keys$1 = keys(acase);
if (keys$1.length !== 1) {
throw new Error('one and only one name per case');
}
const key = keys$1[0];
const value = acase[key];
if (adt[key] !== undefined) {
throw new Error('duplicate key detected:' + key);
} else if (key === 'cata') {
throw new Error('cannot have a case named cata (sorry)');
} else if (!isArray(value)) {
throw new Error('case arguments must be an array');
}
constructors.push(key);
adt[key] = (...args) => {
const argLength = args.length;
if (argLength !== value.length) {
throw new Error('Wrong number of arguments to case ' + key + '. Expected ' + value.length + ' (' + value + '), got ' + argLength);
}
const match = branches => {
const branchKeys = keys(branches);
if (constructors.length !== branchKeys.length) {
throw new Error('Wrong number of arguments to match. Expected: ' + constructors.join(',') + '\nActual: ' + branchKeys.join(','));
}
const allReqd = forall(constructors, reqKey => {
return contains(branchKeys, reqKey);
});
if (!allReqd) {
throw new Error('Not all branches were specified when using match. Specified: ' + branchKeys.join(', ') + '\nRequired: ' + constructors.join(', '));
}
return branches[key].apply(null, args);
};
return {
fold: (...foldArgs) => {
if (foldArgs.length !== cases.length) {
throw new Error('Wrong number of arguments to fold. Expected ' + cases.length + ', got ' + foldArgs.length);
}
const target = foldArgs[count];
return target.apply(null, args);
},
match,
log: label => {
console.log(label, {
constructors,
constructor: key,
params: args
});
}
};
};
});
return adt;
};
const Adt = { generate };
const adt = Adt.generate([
{ none: [] },
{ only: ['index'] },
{
left: [
'index',
'next'
]
},
{
middle: [
'prev',
'index',
'next'
]
},
{
right: [
'prev',
'index'
]
}
]);
({ ...adt });
const opGetRowsType = (table, target) => {
const house = Warehouse.fromTable(table);
const details = onCells(house, target);
return details.bind(selectedCells => {
const lastSelectedCell = selectedCells[selectedCells.length - 1];
const minRowRange = selectedCells[0].row;
const maxRowRange = lastSelectedCell.row + lastSelectedCell.rowspan;
const selectedRows = house.all.slice(minRowRange, maxRowRange);
return findCommonRowType(selectedRows);
}).getOr('');
};
const getRowsType = opGetRowsType;
const rgbToHex = value => startsWith(value, 'rgb') ? rgbaToHexString(value) : value;
const extractAdvancedStyles = elm => {
const element = SugarElement.fromDom(elm);
return {
borderwidth: getRaw(element, 'border-width').getOr(''),
borderstyle: getRaw(element, 'border-style').getOr(''),
bordercolor: getRaw(element, 'border-color').map(rgbToHex).getOr(''),
backgroundcolor: getRaw(element, 'background-color').map(rgbToHex).getOr('')
};
};
const getSharedValues = data => {
const baseData = data[0];
const comparisonData = data.slice(1);
each(comparisonData, items => {
each(keys(baseData), key => {
each$1(items, (itemValue, itemKey) => {
const comparisonValue = baseData[key];
if (comparisonValue !== '' && key === itemKey) {
if (comparisonValue !== itemValue) {
baseData[key] = '';
}
}
});
});
});
return baseData;
};
const getAlignment = (formats, formatName, editor, elm) => find(formats, name => !isUndefined(editor.formatter.matchNode(elm, formatName + name))).getOr('');
const getHAlignment = curry(getAlignment, [
'left',
'center',
'right'
], 'align');
const getVAlignment = curry(getAlignment, [
'top',
'middle',
'bottom'
], 'valign');
const extractDataFromSettings = (editor, hasAdvTableTab) => {
const style = getDefaultStyles(editor);
const attrs = getDefaultAttributes(editor);
const extractAdvancedStyleData = () => ({
borderstyle: get$4(style, 'border-style').getOr(''),
bordercolor: rgbToHex(get$4(style, 'border-color').getOr('')),
backgroundcolor: rgbToHex(get$4(style, 'background-color').getOr(''))
});
const defaultData = {
height: '',
width: '100%',
cellspacing: '',
cellpadding: '',
caption: false,
class: '',
align: '',
border: ''
};
const getBorder = () => {
const borderWidth = style['border-width'];
if (shouldStyleWithCss(editor) && borderWidth) {
return { border: borderWidth };
}
return get$4(attrs, 'border').fold(() => ({}), border => ({ border }));
};
const advStyle = hasAdvTableTab ? extractAdvancedStyleData() : {};
const getCellPaddingCellSpacing = () => {
const spacing = get$4(style, 'border-spacing').or(get$4(attrs, 'cellspacing')).fold(() => ({}), cellspacing => ({ cellspacing }));
const padding = get$4(style, 'border-padding').or(get$4(attrs, 'cellpadding')).fold(() => ({}), cellpadding => ({ cellpadding }));
return {
...spacing,
...padding
};
};
const data = {
...defaultData,
...style,
...attrs,
...advStyle,
...getBorder(),
...getCellPaddingCellSpacing()
};
return data;
};
const getRowType = elm => table(SugarElement.fromDom(elm)).map(table => {
const target = { selection: fromDom(elm.cells) };
return getRowsType(table, target);
}).getOr('');
const extractDataFromTableElement = (editor, elm, hasAdvTableTab) => {
const getBorder = (dom, elm) => {
const optBorderWidth = getRaw(SugarElement.fromDom(elm), 'border-width');
if (shouldStyleWithCss(editor) && optBorderWidth.isSome()) {
return optBorderWidth.getOr('');
}
return dom.getAttrib(elm, 'border') || getTDTHOverallStyle(editor.dom, elm, 'border-width') || getTDTHOverallStyle(editor.dom, elm, 'border') || '';
};
const dom = editor.dom;
const cellspacing = shouldStyleWithCss(editor) ? dom.getStyle(elm, 'border-spacing') || dom.getAttrib(elm, 'cellspacing') : dom.getAttrib(elm, 'cellspacing') || dom.getStyle(elm, 'border-spacing');
const cellpadding = shouldStyleWithCss(editor) ? getTDTHOverallStyle(dom, elm, 'padding') || dom.getAttrib(elm, 'cellpadding') : dom.getAttrib(elm, 'cellpadding') || getTDTHOverallStyle(dom, elm, 'padding');
return {
width: dom.getStyle(elm, 'width') || dom.getAttrib(elm, 'width'),
height: dom.getStyle(elm, 'height') || dom.getAttrib(elm, 'height'),
cellspacing: cellspacing !== null && cellspacing !== void 0 ? cellspacing : '',
cellpadding: cellpadding !== null && cellpadding !== void 0 ? cellpadding : '',
border: getBorder(dom, elm),
caption: !!dom.select('caption', elm)[0],
class: dom.getAttrib(elm, 'class', ''),
align: getHAlignment(editor, elm),
...hasAdvTableTab ? extractAdvancedStyles(elm) : {}
};
};
const extractDataFromRowElement = (editor, elm, hasAdvancedRowTab) => {
const dom = editor.dom;
return {
height: dom.getStyle(elm, 'height') || dom.getAttrib(elm, 'height'),
class: dom.getAttrib(elm, 'class', ''),
type: getRowType(elm),
align: getHAlignment(editor, elm),
...hasAdvancedRowTab ? extractAdvancedStyles(elm) : {}
};
};
const extractDataFromCellElement = (editor, cell, hasAdvancedCellTab, column) => {
const dom = editor.dom;
const colElm = column.getOr(cell);
const getStyle = (element, style) => dom.getStyle(element, style) || dom.getAttrib(element, style);
return {
width: getStyle(colElm, 'width'),
height: getStyle(cell, 'height'),
scope: dom.getAttrib(cell, 'scope'),
celltype: getNodeName(cell),
class: dom.getAttrib(cell, 'class', ''),
halign: getHAlignment(editor, cell),
valign: getVAlignment(editor, cell),
...hasAdvancedCellTab ? extractAdvancedStyles(cell) : {}
};
};
const getSelectedCells = (table, cells) => {
const warehouse = Warehouse.fromTable(table);
const allCells = Warehouse.justCells(warehouse);
const filtered = filter(allCells, cellA => exists(cells, cellB => eq(cellA.element, cellB)));
return map(filtered, cell => ({
element: cell.element.dom,
column: Warehouse.getColumnAt(warehouse, cell.column).map(col => col.element.dom)
}));
};
const updateSimpleProps$1 = (modifier, colModifier, data, shouldUpdate) => {
if (shouldUpdate('scope')) {
modifier.setAttrib('scope', data.scope);
}
if (shouldUpdate('class')) {
modifier.setAttrib('class', data.class);
}
if (shouldUpdate('height')) {
modifier.setStyle('height', addPxSuffix(data.height));
}
if (shouldUpdate('width')) {
colModifier.setStyle('width', addPxSuffix(data.width));
}
};
const updateAdvancedProps$1 = (modifier, data, shouldUpdate) => {
if (shouldUpdate('backgroundcolor')) {
modifier.setFormat('tablecellbackgroundcolor', data.backgroundcolor);
}
if (shouldUpdate('bordercolor')) {
modifier.setFormat('tablecellbordercolor', data.bordercolor);
}
if (shouldUpdate('borderstyle')) {
modifier.setFormat('tablecellborderstyle', data.borderstyle);
}
if (shouldUpdate('borderwidth')) {
modifier.setFormat('tablecellborderwidth', addPxSuffix(data.borderwidth));
}
};
const applyStyleData$1 = (editor, cells, data, wasChanged) => {
const isSingleCell = cells.length === 1;
each(cells, item => {
const cellElm = item.element;
const shouldOverrideCurrentValue = isSingleCell ? always : wasChanged;
const modifier = DomModifier.normal(editor, cellElm);
const colModifier = item.column.map(col => DomModifier.normal(editor, col)).getOr(modifier);
updateSimpleProps$1(modifier, colModifier, data, shouldOverrideCurrentValue);
if (hasAdvancedCellTab(editor)) {
updateAdvancedProps$1(modifier, data, shouldOverrideCurrentValue);
}
if (wasChanged('halign')) {
setAlign(editor, cellElm, data.halign);
}
if (wasChanged('valign')) {
setVAlign(editor, cellElm, data.valign);
}
});
};
const applyStructureData$1 = (editor, data) => {
editor.execCommand('mceTableCellType', false, {
type: data.celltype,
no_events: true
});
};
const applyCellData = (editor, cells, oldData, data) => {
const modifiedData = filter$1(data, (value, key) => oldData[key] !== value);
if (size(modifiedData) > 0 && cells.length >= 1) {
table(cells[0]).each(table => {
const selectedCells = getSelectedCells(table, cells);
const styleModified = size(filter$1(modifiedData, (_value, key) => key !== 'scope' && key !== 'celltype')) > 0;
const structureModified = has(modifiedData, 'celltype');
if (styleModified || has(modifiedData, 'scope')) {
applyStyleData$1(editor, selectedCells, data, curry(has, modifiedData));
}
if (structureModified) {
applyStructureData$1(editor, data);
}
fireTableModified(editor, table.dom, {
structure: structureModified,
style: styleModified
});
});
}
};
const onSubmitCellForm = (editor, cells, oldData, api) => {
const data = api.getData();
api.close();
editor.undoManager.transact(() => {
applyCellData(editor, cells, oldData, data);
editor.focus();
});
};
const getData$1 = (editor, cells) => {
const cellsData = table(cells[0]).map(table => map(getSelectedCells(table, cells), item => extractDataFromCellElement(editor, item.element, hasAdvancedCellTab(editor), item.column)));
return getSharedValues(cellsData.getOrDie());
};
const open$2 = editor => {
const cells = getCellsFromSelection(editor);
if (cells.length === 0) {
return;
}
const data = getData$1(editor, cells);
const dialogTabPanel = {
type: 'tabpanel',
tabs: [
{
title: 'General',
name: 'general',
items: getItems$2(editor)
},
getAdvancedTab(editor, 'cell')
]
};
const dialogPanel = {
type: 'panel',
items: [{
type: 'grid',
columns: 2,
items: getItems$2(editor)
}]
};
editor.windowManager.open({
title: 'Cell Properties',
size: 'normal',
body: hasAdvancedCellTab(editor) ? dialogTabPanel : dialogPanel,
buttons: [
{
type: 'cancel',
name: 'cancel',
text: 'Cancel'
},
{
type: 'submit',
name: 'save',
text: 'Save',
primary: true
}
],
initialData: data,
onSubmit: curry(onSubmitCellForm, editor, cells, data)
});
};
const getClassList = editor => {
const classes = buildListItems(getRowClassList(editor));
if (classes.length > 0) {
return Optional.some({
name: 'class',
type: 'listbox',
label: 'Class',
items: classes
});
}
return Optional.none();
};
const formChildren = [
{
type: 'listbox',
name: 'type',
label: 'Row type',
items: [
{
text: 'Header',
value: 'header'
},
{
text: 'Body',
value: 'body'
},
{
text: 'Footer',
value: 'footer'
}
]
},
{
type: 'listbox',
name: 'align',
label: 'Alignment',
items: [
{
text: 'None',
value: ''
},
{
text: 'Left',
value: 'left'
},
{
text: 'Center',
value: 'center'
},
{
text: 'Right',
value: 'right'
}
]
},
{
label: 'Height',
name: 'height',
type: 'input'
}
];
const getItems$1 = editor => formChildren.concat(getClassList(editor).toArray());
const updateSimpleProps = (modifier, data, shouldUpdate) => {
if (shouldUpdate('class')) {
modifier.setAttrib('class', data.class);
}
if (shouldUpdate('height')) {
modifier.setStyle('height', addPxSuffix(data.height));
}
};
const updateAdvancedProps = (modifier, data, shouldUpdate) => {
if (shouldUpdate('backgroundcolor')) {
modifier.setStyle('background-color', data.backgroundcolor);
}
if (shouldUpdate('bordercolor')) {
modifier.setStyle('border-color', data.bordercolor);
}
if (shouldUpdate('borderstyle')) {
modifier.setStyle('border-style', data.borderstyle);
}
};
const applyStyleData = (editor, rows, data, wasChanged) => {
const isSingleRow = rows.length === 1;
const shouldOverrideCurrentValue = isSingleRow ? always : wasChanged;
each(rows, rowElm => {
const modifier = DomModifier.normal(editor, rowElm);
updateSimpleProps(modifier, data, shouldOverrideCurrentValue);
if (hasAdvancedRowTab(editor)) {
updateAdvancedProps(modifier, data, shouldOverrideCurrentValue);
}
if (wasChanged('align')) {
setAlign(editor, rowElm, data.align);
}
});
};
const applyStructureData = (editor, data) => {
editor.execCommand('mceTableRowType', false, {
type: data.type,
no_events: true
});
};
const applyRowData = (editor, rows, oldData, data) => {
const modifiedData = filter$1(data, (value, key) => oldData[key] !== value);
if (size(modifiedData) > 0) {
const typeModified = has(modifiedData, 'type');
const styleModified = typeModified ? size(modifiedData) > 1 : true;
if (styleModified) {
applyStyleData(editor, rows, data, curry(has, modifiedData));
}
if (typeModified) {
applyStructureData(editor, data);
}
table(SugarElement.fromDom(rows[0])).each(table => fireTableModified(editor, table.dom, {
structure: typeModified,
style: styleModified
}));
}
};
const onSubmitRowForm = (editor, rows, oldData, api) => {
const data = api.getData();
api.close();
editor.undoManager.transact(() => {
applyRowData(editor, rows, oldData, data);
editor.focus();
});
};
const open$1 = editor => {
const rows = getRowsFromSelection(getSelectionStart(editor), ephemera.selected);
if (rows.length === 0) {
return;
}
const rowsData = map(rows, rowElm => extractDataFromRowElement(editor, rowElm.dom, hasAdvancedRowTab(editor)));
const data = getSharedValues(rowsData);
const dialogTabPanel = {
type: 'tabpanel',
tabs: [
{
title: 'General',
name: 'general',
items: getItems$1(editor)
},
getAdvancedTab(editor, 'row')
]
};
const dialogPanel = {
type: 'panel',
items: [{
type: 'grid',
columns: 2,
items: getItems$1(editor)
}]
};
editor.windowManager.open({
title: 'Row Properties',
size: 'normal',
body: hasAdvancedRowTab(editor) ? dialogTabPanel : dialogPanel,
buttons: [
{
type: 'cancel',
name: 'cancel',
text: 'Cancel'
},
{
type: 'submit',
name: 'save',
text: 'Save',
primary: true
}
],
initialData: data,
onSubmit: curry(onSubmitRowForm, editor, map(rows, r => r.dom), data)
});
};
const getItems = (editor, classes, insertNewTable) => {
const rowColCountItems = !insertNewTable ? [] : [
{
type: 'input',
name: 'cols',
label: 'Cols',
inputMode: 'numeric'
},
{
type: 'input',
name: 'rows',
label: 'Rows',
inputMode: 'numeric'
}
];
const alwaysItems = [
{
type: 'input',
name: 'width',
label: 'Width'
},
{
type: 'input',
name: 'height',
label: 'Height'
}
];
const appearanceItems = hasAppearanceOptions(editor) ? [
{
type: 'input',
name: 'cellspacing',
label: 'Cell spacing',
inputMode: 'numeric'
},
{
type: 'input',
name: 'cellpadding',
label: 'Cell padding',
inputMode: 'numeric'
},
{
type: 'input',
name: 'border',
label: 'Border width'
},
{
type: 'label',
label: 'Caption',
items: [{
type: 'checkbox',
name: 'caption',
label: 'Show caption'
}]
}
] : [];
const alignmentItem = [{
type: 'listbox',
name: 'align',
label: 'Alignment',
items: [
{
text: 'None',
value: ''
},
{
text: 'Left',
value: 'left'
},
{
text: 'Center',
value: 'center'
},
{
text: 'Right',
value: 'right'
}
]
}];
const classListItem = classes.length > 0 ? [{
type: 'listbox',
name: 'class',
label: 'Class',
items: classes
}] : [];
return rowColCountItems.concat(alwaysItems).concat(appearanceItems).concat(alignmentItem).concat(classListItem);
};
const styleTDTH = (dom, elm, name, value) => {
if (elm.tagName === 'TD' || elm.tagName === 'TH') {
if (isString(name) && isNonNullable(value)) {
dom.setStyle(elm, name, value);
} else {
dom.setStyles(elm, name);
}
} else {
if (elm.children) {
for (let i = 0; i < elm.children.length; i++) {
styleTDTH(dom, elm.children[i], name, value);
}
}
}
};
const applyDataToElement = (editor, tableElm, data) => {
const dom = editor.dom;
const attrs = {};
const styles = {};
if (!isUndefined(data.class)) {
attrs.class = data.class;
}
styles.height = addPxSuffix(data.height);
if (shouldStyleWithCss(editor)) {
styles.width = addPxSuffix(data.width);
} else if (dom.getAttrib(tableElm, 'width')) {
attrs.width = removePxSuffix(data.width);
}
if (shouldStyleWithCss(editor)) {
styles['border-width'] = addPxSuffix(data.border);
styles['border-spacing'] = addPxSuffix(data.cellspacing);
} else {
attrs.border = data.border;
attrs.cellpadding = data.cellpadding;
attrs.cellspacing = data.cellspacing;
}
if (shouldStyleWithCss(editor) && tableElm.children) {
for (let i = 0; i < tableElm.children.length; i++) {
styleTDTH(dom, tableElm.children[i], {
'border-width': addPxSuffix(data.border),
'padding': addPxSuffix(data.cellpadding)
});
if (hasAdvancedTableTab(editor)) {
styleTDTH(dom, tableElm.children[i], { 'border-color': data.bordercolor });
}
}
}
if (hasAdvancedTableTab(editor)) {
const advData = data;
styles['background-color'] = advData.backgroundcolor;
styles['border-color'] = advData.bordercolor;
styles['border-style'] = advData.borderstyle;
}
attrs.style = dom.serializeStyle({
...getDefaultStyles(editor),
...styles
});
dom.setAttribs(tableElm, {
...getDefaultAttributes(editor),
...attrs
});
};
const onSubmitTableForm = (editor, tableElm, oldData, api) => {
const dom = editor.dom;
const data = api.getData();
const modifiedData = filter$1(data, (value, key) => oldData[key] !== value);
api.close();
if (data.class === '') {
delete data.class;
}
editor.undoManager.transact(() => {
if (!tableElm) {
const cols = toInt(data.cols).getOr(1);
const rows = toInt(data.rows).getOr(1);
editor.execCommand('mceInsertTable', false, {
rows,
columns: cols
});
tableElm = getSelectionCell(getSelectionStart(editor), getIsRoot(editor)).bind(cell => table(cell, getIsRoot(editor))).map(table => table.dom).getOrDie();
}
if (size(modifiedData) > 0) {
applyDataToElement(editor, tableElm, data);
const captionElm = dom.select('caption', tableElm)[0];
if (captionElm && !data.caption || !captionElm && data.caption) {
editor.execCommand('mceTableToggleCaption');
}
setAlign(editor, tableElm, data.align);
}
editor.focus();
editor.addVisual();
if (size(modifiedData) > 0) {
const captionModified = has(modifiedData, 'caption');
const styleModified = captionModified ? size(modifiedData) > 1 : true;
fireTableModified(editor, tableElm, {
structure: captionModified,
style: styleModified
});
}
});
};
const open = (editor, insertNewTable) => {
const dom = editor.dom;
let tableElm;
let data = extractDataFromSettings(editor, hasAdvancedTableTab(editor));
if (insertNewTable) {
data.cols = '1';
data.rows = '1';
if (hasAdvancedTableTab(editor)) {
data.borderstyle = '';
data.bordercolor = '';
data.backgroundcolor = '';
}
} else {
tableElm = dom.getParent(editor.selection.getStart(), 'table', editor.getBody());
if (tableElm) {
data = extractDataFromTableElement(editor, tableElm, hasAdvancedTableTab(editor));
} else {
if (hasAdvancedTableTab(editor)) {
data.borderstyle = '';
data.bordercolor = '';
data.backgroundcolor = '';
}
}
}
const classes = buildListItems(getTableClassList(editor));
if (classes.length > 0) {
if (data.class) {
data.class = data.class.replace(/\s*mce\-item\-table\s*/g, '');
}
}
const generalPanel = {
type: 'grid',
columns: 2,
items: getItems(editor, classes, insertNewTable)
};
const nonAdvancedForm = () => ({
type: 'panel',
items: [generalPanel]
});
const advancedForm = () => ({
type: 'tabpanel',
tabs: [
{
title: 'General',
name: 'general',
items: [generalPanel]
},
getAdvancedTab(editor, 'table')
]
});
const dialogBody = hasAdvancedTableTab(editor) ? advancedForm() : nonAdvancedForm();
editor.windowManager.open({
title: 'Table Properties',
size: 'normal',
body: dialogBody,
onSubmit: curry(onSubmitTableForm, editor, tableElm, data),
buttons: [
{
type: 'cancel',
name: 'cancel',
text: 'Cancel'
},
{
type: 'submit',
name: 'save',
text: 'Save',
primary: true
}
],
initialData: data
});
};
const registerCommands = editor => {
const runAction = f => {
if (isInEditableContext(getSelectionStart(editor))) {
f();
}
};
each$1({
mceTableProps: curry(open, editor, false),
mceTableRowProps: curry(open$1, editor),
mceTableCellProps: curry(open$2, editor),
mceInsertTableDialog: curry(open, editor, true)
}, (func, name) => editor.addCommand(name, () => runAction(func)));
};
const child = (scope, selector) => child$1(scope, selector).isSome();
const selection = identity;
const unmergable = selectedCells => {
const hasSpan = (elem, type) => getOpt(elem, type).exists(span => parseInt(span, 10) > 1);
const hasRowOrColSpan = elem => hasSpan(elem, 'rowspan') || hasSpan(elem, 'colspan');
return selectedCells.length > 0 && forall(selectedCells, hasRowOrColSpan) ? Optional.some(selectedCells) : Optional.none();
};
const mergable = (table, selectedCells, ephemera) => {
if (selectedCells.length <= 1) {
return Optional.none();
} else {
return retrieveBox(table, ephemera.firstSelectedSelector, ephemera.lastSelectedSelector).map(bounds => ({
bounds,
cells: selectedCells
}));
}
};
const noMenu = cell => ({
element: cell,
mergable: Optional.none(),
unmergable: Optional.none(),
selection: [cell]
});
const forMenu = (selectedCells, table, cell) => ({
element: cell,
mergable: mergable(table, selectedCells, ephemera),
unmergable: unmergable(selectedCells),
selection: selection(selectedCells)
});
const getSelectionTargets = editor => {
const targets = Cell(Optional.none());
const changeHandlers = Cell([]);
let selectionDetails = Optional.none();
const isCaption = isTag('caption');
const isDisabledForSelection = key => selectionDetails.forall(details => !details[key]);
const getStart = () => getSelectionCellOrCaption(getSelectionStart(editor), getIsRoot(editor));
const getEnd = () => getSelectionCellOrCaption(getSelectionEnd(editor), getIsRoot(editor));
const findTargets = () => getStart().bind(startCellOrCaption => flatten(lift2(table(startCellOrCaption), getEnd().bind(table), (startTable, endTable) => {
if (eq(startTable, endTable)) {
if (isCaption(startCellOrCaption)) {
return Optional.some(noMenu(startCellOrCaption));
} else {
return Optional.some(forMenu(getCellsFromSelection(editor), startTable, startCellOrCaption));
}
}
return Optional.none();
})));
const getExtractedDetails = targets => {
const tableOpt = table(targets.element);
return tableOpt.map(table => {
const warehouse = Warehouse.fromTable(table);
const selectedCells = onCells(warehouse, targets).getOr([]);
const locked = foldl(selectedCells, (acc, cell) => {
if (cell.isLocked) {
acc.onAny = true;
if (cell.column === 0) {
acc.onFirst = true;
} else if (cell.column + cell.colspan >= warehouse.grid.columns) {
acc.onLast = true;
}
}
return acc;
}, {
onAny: false,
onFirst: false,
onLast: false
});
return {
mergeable: onUnlockedMergable(warehouse, targets).isSome(),
unmergeable: onUnlockedUnmergable(warehouse, targets).isSome(),
locked
};
});
};
const resetTargets = () => {
targets.set(cached(findTargets)());
selectionDetails = targets.get().bind(getExtractedDetails);
each(changeHandlers.get(), call);
};
const setupHandler = handler => {
handler();
changeHandlers.set(changeHandlers.get().concat([handler]));
return () => {
changeHandlers.set(filter(changeHandlers.get(), h => h !== handler));
};
};
const onSetup = (api, isDisabled) => setupHandler(() => targets.get().fold(() => {
api.setEnabled(false);
}, targets => {
api.setEnabled(!isDisabled(targets));
}));
const onSetupWithToggle = (api, isDisabled, isActive) => setupHandler(() => targets.get().fold(() => {
api.setEnabled(false);
api.setActive(false);
}, targets => {
api.setEnabled(!isDisabled(targets));
api.setActive(isActive(targets));
}));
const isDisabledFromLocked = lockedDisable => selectionDetails.exists(details => details.locked[lockedDisable]);
const onSetupTable = api => onSetup(api, _ => false);
const onSetupCellOrRow = api => onSetup(api, targets => isCaption(targets.element));
const onSetupColumn = lockedDisable => api => onSetup(api, targets => isCaption(targets.element) || isDisabledFromLocked(lockedDisable));
const onSetupPasteable = getClipboardData => api => onSetup(api, targets => isCaption(targets.element) || getClipboardData().isNone());
const onSetupPasteableColumn = (getClipboardData, lockedDisable) => api => onSetup(api, targets => isCaption(targets.element) || getClipboardData().isNone() || isDisabledFromLocked(lockedDisable));
const onSetupMergeable = api => onSetup(api, _targets => isDisabledForSelection('mergeable'));
const onSetupUnmergeable = api => onSetup(api, _targets => isDisabledForSelection('unmergeable'));
const onSetupTableWithCaption = api => {
return onSetupWithToggle(api, never, targets => {
const tableOpt = table(targets.element, getIsRoot(editor));
return tableOpt.exists(table => child(table, 'caption'));
});
};
const onSetupTableHeaders = (command, headerType) => api => {
return onSetupWithToggle(api, targets => isCaption(targets.element), () => editor.queryCommandValue(command) === headerType);
};
const onSetupTableRowHeaders = onSetupTableHeaders('mceTableRowType', 'header');
const onSetupTableColumnHeaders = onSetupTableHeaders('mceTableColType', 'th');
editor.on('NodeChange ExecCommand TableSelectorChange', resetTargets);
return {
onSetupTable,
onSetupCellOrRow,
onSetupColumn,
onSetupPasteable,
onSetupPasteableColumn,
onSetupMergeable,
onSetupUnmergeable,
resetTargets,
onSetupTableWithCaption,
onSetupTableRowHeaders,
onSetupTableColumnHeaders,
targets: targets.get
};
};
var global = tinymce.util.Tools.resolve('tinymce.FakeClipboard');
const tableTypeBase = 'x-tinymce/dom-table-';
const tableTypeRow = tableTypeBase + 'rows';
const tableTypeColumn = tableTypeBase + 'columns';
const getData = type => {
var _a;
const items = (_a = global.read()) !== null && _a !== void 0 ? _a : [];
return findMap(items, item => Optional.from(item.getType(type)));
};
const getRows = () => getData(tableTypeRow);
const getColumns = () => getData(tableTypeColumn);
const addButtons = (editor, selectionTargets) => {
editor.ui.registry.addMenuButton('table', {
tooltip: 'Table',
icon: 'table',
fetch: callback => callback('inserttable | cell row column | advtablesort | tableprops deletetable')
});
const cmd = command => () => editor.execCommand(command);
const addButtonIfRegistered = (name, spec) => {
if (editor.queryCommandSupported(spec.command)) {
editor.ui.registry.addButton(name, {
...spec,
onAction: isFunction(spec.onAction) ? spec.onAction : cmd(spec.command)
});
}
};
const addToggleButtonIfRegistered = (name, spec) => {
if (editor.queryCommandSupported(spec.command)) {
editor.ui.registry.addToggleButton(name, {
...spec,
onAction: isFunction(spec.onAction) ? spec.onAction : cmd(spec.command)
});
}
};
addButtonIfRegistered('tableprops', {
tooltip: 'Table properties',
command: 'mceTableProps',
icon: 'table',
onSetup: selectionTargets.onSetupTable
});
addButtonIfRegistered('tabledelete', {
tooltip: 'Delete table',
command: 'mceTableDelete',
icon: 'table-delete-table',
onSetup: selectionTargets.onSetupTable
});
addButtonIfRegistered('tablecellprops', {
tooltip: 'Cell properties',
command: 'mceTableCellProps',
icon: 'table-cell-properties',
onSetup: selectionTargets.onSetupCellOrRow
});
addButtonIfRegistered('tablemergecells', {
tooltip: 'Merge cells',
command: 'mceTableMergeCells',
icon: 'table-merge-cells',
onSetup: selectionTargets.onSetupMergeable
});
addButtonIfRegistered('tablesplitcells', {
tooltip: 'Split cell',
command: 'mceTableSplitCells',
icon: 'table-split-cells',
onSetup: selectionTargets.onSetupUnmergeable
});
addButtonIfRegistered('tableinsertrowbefore', {
tooltip: 'Insert row before',
command: 'mceTableInsertRowBefore',
icon: 'table-insert-row-above',
onSetup: selectionTargets.onSetupCellOrRow
});
addButtonIfRegistered('tableinsertrowafter', {
tooltip: 'Insert row after',
command: 'mceTableInsertRowAfter',
icon: 'table-insert-row-after',
onSetup: selectionTargets.onSetupCellOrRow
});
addButtonIfRegistered('tabledeleterow', {
tooltip: 'Delete row',
command: 'mceTableDeleteRow',
icon: 'table-delete-row',
onSetup: selectionTargets.onSetupCellOrRow
});
addButtonIfRegistered('tablerowprops', {
tooltip: 'Row properties',
command: 'mceTableRowProps',
icon: 'table-row-properties',
onSetup: selectionTargets.onSetupCellOrRow
});
addButtonIfRegistered('tableinsertcolbefore', {
tooltip: 'Insert column before',
command: 'mceTableInsertColBefore',
icon: 'table-insert-column-before',
onSetup: selectionTargets.onSetupColumn('onFirst')
});
addButtonIfRegistered('tableinsertcolafter', {
tooltip: 'Insert column after',
command: 'mceTableInsertColAfter',
icon: 'table-insert-column-after',
onSetup: selectionTargets.onSetupColumn('onLast')
});
addButtonIfRegistered('tabledeletecol', {
tooltip: 'Delete column',
command: 'mceTableDeleteCol',
icon: 'table-delete-column',
onSetup: selectionTargets.onSetupColumn('onAny')
});
addButtonIfRegistered('tablecutrow', {
tooltip: 'Cut row',
command: 'mceTableCutRow',
icon: 'cut-row',
onSetup: selectionTargets.onSetupCellOrRow
});
addButtonIfRegistered('tablecopyrow', {
tooltip: 'Copy row',
command: 'mceTableCopyRow',
icon: 'duplicate-row',
onSetup: selectionTargets.onSetupCellOrRow
});
addButtonIfRegistered('tablepasterowbefore', {
tooltip: 'Paste row before',
command: 'mceTablePasteRowBefore',
icon: 'paste-row-before',
onSetup: selectionTargets.onSetupPasteable(getRows)
});
addButtonIfRegistered('tablepasterowafter', {
tooltip: 'Paste row after',
command: 'mceTablePasteRowAfter',
icon: 'paste-row-after',
onSetup: selectionTargets.onSetupPasteable(getRows)
});
addButtonIfRegistered('tablecutcol', {
tooltip: 'Cut column',
command: 'mceTableCutCol',
icon: 'cut-column',
onSetup: selectionTargets.onSetupColumn('onAny')
});
addButtonIfRegistered('tablecopycol', {
tooltip: 'Copy column',
command: 'mceTableCopyCol',
icon: 'duplicate-column',
onSetup: selectionTargets.onSetupColumn('onAny')
});
addButtonIfRegistered('tablepastecolbefore', {
tooltip: 'Paste column before',
command: 'mceTablePasteColBefore',
icon: 'paste-column-before',
onSetup: selectionTargets.onSetupPasteableColumn(getColumns, 'onFirst')
});
addButtonIfRegistered('tablepastecolafter', {
tooltip: 'Paste column after',
command: 'mceTablePasteColAfter',
icon: 'paste-column-after',
onSetup: selectionTargets.onSetupPasteableColumn(getColumns, 'onLast')
});
addButtonIfRegistered('tableinsertdialog', {
tooltip: 'Insert table',
command: 'mceInsertTableDialog',
icon: 'table'
});
const tableClassList = filterNoneItem(getTableClassList(editor));
if (tableClassList.length !== 0 && editor.queryCommandSupported('mceTableToggleClass')) {
editor.ui.registry.addMenuButton('tableclass', {
icon: 'table-classes',
tooltip: 'Table styles',
fetch: generateMenuItemsCallback(editor, tableClassList, 'tableclass', value => editor.execCommand('mceTableToggleClass', false, value)),
onSetup: selectionTargets.onSetupTable
});
}
const tableCellClassList = filterNoneItem(getCellClassList(editor));
if (tableCellClassList.length !== 0 && editor.queryCommandSupported('mceTableCellToggleClass')) {
editor.ui.registry.addMenuButton('tablecellclass', {
icon: 'table-cell-classes',
tooltip: 'Cell styles',
fetch: generateMenuItemsCallback(editor, tableCellClassList, 'tablecellclass', value => editor.execCommand('mceTableCellToggleClass', false, value)),
onSetup: selectionTargets.onSetupCellOrRow
});
}
if (editor.queryCommandSupported('mceTableApplyCellStyle')) {
editor.ui.registry.addMenuButton('tablecellvalign', {
icon: 'vertical-align',
tooltip: 'Vertical align',
fetch: generateMenuItemsCallback(editor, verticalAlignValues, 'tablecellverticalalign', applyTableCellStyle(editor, 'vertical-align')),
onSetup: selectionTargets.onSetupCellOrRow
});
editor.ui.registry.addMenuButton('tablecellborderwidth', {
icon: 'border-width',
tooltip: 'Border width',
fetch: generateMenuItemsCallback(editor, getTableBorderWidths(editor), 'tablecellborderwidth', applyTableCellStyle(editor, 'border-width')),
onSetup: selectionTargets.onSetupCellOrRow
});
editor.ui.registry.addMenuButton('tablecellborderstyle', {
icon: 'border-style',
tooltip: 'Border style',
fetch: generateMenuItemsCallback(editor, getTableBorderStyles(editor), 'tablecellborderstyle', applyTableCellStyle(editor, 'border-style')),
onSetup: selectionTargets.onSetupCellOrRow
});
editor.ui.registry.addMenuButton('tablecellbackgroundcolor', {
icon: 'cell-background-color',
tooltip: 'Background color',
fetch: callback => callback(buildColorMenu(editor, getTableBackgroundColorMap(editor), 'background-color')),
onSetup: selectionTargets.onSetupCellOrRow
});
editor.ui.registry.addMenuButton('tablecellbordercolor', {
icon: 'cell-border-color',
tooltip: 'Border color',
fetch: callback => callback(buildColorMenu(editor, getTableBorderColorMap(editor), 'border-color')),
onSetup: selectionTargets.onSetupCellOrRow
});
}
addToggleButtonIfRegistered('tablecaption', {
tooltip: 'Table caption',
icon: 'table-caption',
command: 'mceTableToggleCaption',
onSetup: selectionTargets.onSetupTableWithCaption
});
addToggleButtonIfRegistered('tablerowheader', {
tooltip: 'Row header',
icon: 'table-top-header',
command: 'mceTableRowType',
onAction: changeRowHeader(editor),
onSetup: selectionTargets.onSetupTableRowHeaders
});
addToggleButtonIfRegistered('tablecolheader', {
tooltip: 'Column header',
icon: 'table-left-header',
command: 'mceTableColType',
onAction: changeColumnHeader(editor),
onSetup: selectionTargets.onSetupTableColumnHeaders
});
};
const addToolbars = editor => {
const isTable = table => editor.dom.is(table, 'table') && editor.getBody().contains(table);
const toolbar = getToolbar(editor);
if (toolbar.length > 0) {
editor.ui.registry.addContextToolbar('table', {
predicate: isTable,
items: toolbar,
scope: 'node',
position: 'node'
});
}
};
const addMenuItems = (editor, selectionTargets) => {
const cmd = command => () => editor.execCommand(command);
const addMenuIfRegistered = (name, spec) => {
if (editor.queryCommandSupported(spec.command)) {
editor.ui.registry.addMenuItem(name, {
...spec,
onAction: isFunction(spec.onAction) ? spec.onAction : cmd(spec.command)
});
return true;
} else {
return false;
}
};
const addToggleMenuIfRegistered = (name, spec) => {
if (editor.queryCommandSupported(spec.command)) {
editor.ui.registry.addToggleMenuItem(name, {
...spec,
onAction: isFunction(spec.onAction) ? spec.onAction : cmd(spec.command)
});
}
};
const insertTableAction = data => {
editor.execCommand('mceInsertTable', false, {
rows: data.numRows,
columns: data.numColumns
});
};
const hasRowMenuItems = [
addMenuIfRegistered('tableinsertrowbefore', {
text: 'Insert row before',
icon: 'table-insert-row-above',
command: 'mceTableInsertRowBefore',
onSetup: selectionTargets.onSetupCellOrRow
}),
addMenuIfRegistered('tableinsertrowafter', {
text: 'Insert row after',
icon: 'table-insert-row-after',
command: 'mceTableInsertRowAfter',
onSetup: selectionTargets.onSetupCellOrRow
}),
addMenuIfRegistered('tabledeleterow', {
text: 'Delete row',
icon: 'table-delete-row',
command: 'mceTableDeleteRow',
onSetup: selectionTargets.onSetupCellOrRow
}),
addMenuIfRegistered('tablerowprops', {
text: 'Row properties',
icon: 'table-row-properties',
command: 'mceTableRowProps',
onSetup: selectionTargets.onSetupCellOrRow
}),
addMenuIfRegistered('tablecutrow', {
text: 'Cut row',
icon: 'cut-row',
command: 'mceTableCutRow',
onSetup: selectionTargets.onSetupCellOrRow
}),
addMenuIfRegistered('tablecopyrow', {
text: 'Copy row',
icon: 'duplicate-row',
command: 'mceTableCopyRow',
onSetup: selectionTargets.onSetupCellOrRow
}),
addMenuIfRegistered('tablepasterowbefore', {
text: 'Paste row before',
icon: 'paste-row-before',
command: 'mceTablePasteRowBefore',
onSetup: selectionTargets.onSetupPasteable(getRows)
}),
addMenuIfRegistered('tablepasterowafter', {
text: 'Paste row after',
icon: 'paste-row-after',
command: 'mceTablePasteRowAfter',
onSetup: selectionTargets.onSetupPasteable(getRows)
})
];
const hasColumnMenuItems = [
addMenuIfRegistered('tableinsertcolumnbefore', {
text: 'Insert column before',
icon: 'table-insert-column-before',
command: 'mceTableInsertColBefore',
onSetup: selectionTargets.onSetupColumn('onFirst')
}),
addMenuIfRegistered('tableinsertcolumnafter', {
text: 'Insert column after',
icon: 'table-insert-column-after',
command: 'mceTableInsertColAfter',
onSetup: selectionTargets.onSetupColumn('onLast')
}),
addMenuIfRegistered('tabledeletecolumn', {
text: 'Delete column',
icon: 'table-delete-column',
command: 'mceTableDeleteCol',
onSetup: selectionTargets.onSetupColumn('onAny')
}),
addMenuIfRegistered('tablecutcolumn', {
text: 'Cut column',
icon: 'cut-column',
command: 'mceTableCutCol',
onSetup: selectionTargets.onSetupColumn('onAny')
}),
addMenuIfRegistered('tablecopycolumn', {
text: 'Copy column',
icon: 'duplicate-column',
command: 'mceTableCopyCol',
onSetup: selectionTargets.onSetupColumn('onAny')
}),
addMenuIfRegistered('tablepastecolumnbefore', {
text: 'Paste column before',
icon: 'paste-column-before',
command: 'mceTablePasteColBefore',
onSetup: selectionTargets.onSetupPasteableColumn(getColumns, 'onFirst')
}),
addMenuIfRegistered('tablepastecolumnafter', {
text: 'Paste column after',
icon: 'paste-column-after',
command: 'mceTablePasteColAfter',
onSetup: selectionTargets.onSetupPasteableColumn(getColumns, 'onLast')
})
];
const hasCellMenuItems = [
addMenuIfRegistered('tablecellprops', {
text: 'Cell properties',
icon: 'table-cell-properties',
command: 'mceTableCellProps',
onSetup: selectionTargets.onSetupCellOrRow
}),
addMenuIfRegistered('tablemergecells', {
text: 'Merge cells',
icon: 'table-merge-cells',
command: 'mceTableMergeCells',
onSetup: selectionTargets.onSetupMergeable
}),
addMenuIfRegistered('tablesplitcells', {
text: 'Split cell',
icon: 'table-split-cells',
command: 'mceTableSplitCells',
onSetup: selectionTargets.onSetupUnmergeable
})
];
if (!hasTableGrid(editor)) {
editor.ui.registry.addMenuItem('inserttable', {
text: 'Table',
icon: 'table',
onAction: cmd('mceInsertTableDialog')
});
} else {
editor.ui.registry.addNestedMenuItem('inserttable', {
text: 'Table',
icon: 'table',
getSubmenuItems: () => [{
type: 'fancymenuitem',
fancytype: 'inserttable',
onAction: insertTableAction
}]
});
}
editor.ui.registry.addMenuItem('inserttabledialog', {
text: 'Insert table',
icon: 'table',
onAction: cmd('mceInsertTableDialog')
});
addMenuIfRegistered('tableprops', {
text: 'Table properties',
onSetup: selectionTargets.onSetupTable,
command: 'mceTableProps'
});
addMenuIfRegistered('deletetable', {
text: 'Delete table',
icon: 'table-delete-table',
onSetup: selectionTargets.onSetupTable,
command: 'mceTableDelete'
});
if (contains(hasRowMenuItems, true)) {
editor.ui.registry.addNestedMenuItem('row', {
type: 'nestedmenuitem',
text: 'Row',
getSubmenuItems: constant('tableinsertrowbefore tableinsertrowafter tabledeleterow tablerowprops | tablecutrow tablecopyrow tablepasterowbefore tablepasterowafter')
});
}
if (contains(hasColumnMenuItems, true)) {
editor.ui.registry.addNestedMenuItem('column', {
type: 'nestedmenuitem',
text: 'Column',
getSubmenuItems: constant('tableinsertcolumnbefore tableinsertcolumnafter tabledeletecolumn | tablecutcolumn tablecopycolumn tablepastecolumnbefore tablepastecolumnafter')
});
}
if (contains(hasCellMenuItems, true)) {
editor.ui.registry.addNestedMenuItem('cell', {
type: 'nestedmenuitem',
text: 'Cell',
getSubmenuItems: constant('tablecellprops tablemergecells tablesplitcells')
});
}
editor.ui.registry.addContextMenu('table', {
update: () => {
selectionTargets.resetTargets();
return selectionTargets.targets().fold(constant(''), targets => {
if (name(targets.element) === 'caption') {
return 'tableprops deletetable';
} else {
return 'cell row column | advtablesort | tableprops deletetable';
}
});
}
});
const tableClassList = filterNoneItem(getTableClassList(editor));
if (tableClassList.length !== 0 && editor.queryCommandSupported('mceTableToggleClass')) {
editor.ui.registry.addNestedMenuItem('tableclass', {
icon: 'table-classes',
text: 'Table styles',
getSubmenuItems: () => buildMenuItems(editor, tableClassList, 'tableclass', value => editor.execCommand('mceTableToggleClass', false, value)),
onSetup: selectionTargets.onSetupTable
});
}
const tableCellClassList = filterNoneItem(getCellClassList(editor));
if (tableCellClassList.length !== 0 && editor.queryCommandSupported('mceTableCellToggleClass')) {
editor.ui.registry.addNestedMenuItem('tablecellclass', {
icon: 'table-cell-classes',
text: 'Cell styles',
getSubmenuItems: () => buildMenuItems(editor, tableCellClassList, 'tablecellclass', value => editor.execCommand('mceTableCellToggleClass', false, value)),
onSetup: selectionTargets.onSetupCellOrRow
});
}
if (editor.queryCommandSupported('mceTableApplyCellStyle')) {
editor.ui.registry.addNestedMenuItem('tablecellvalign', {
icon: 'vertical-align',
text: 'Vertical align',
getSubmenuItems: () => buildMenuItems(editor, verticalAlignValues, 'tablecellverticalalign', applyTableCellStyle(editor, 'vertical-align')),
onSetup: selectionTargets.onSetupCellOrRow
});
editor.ui.registry.addNestedMenuItem('tablecellborderwidth', {
icon: 'border-width',
text: 'Border width',
getSubmenuItems: () => buildMenuItems(editor, getTableBorderWidths(editor), 'tablecellborderwidth', applyTableCellStyle(editor, 'border-width')),
onSetup: selectionTargets.onSetupCellOrRow
});
editor.ui.registry.addNestedMenuItem('tablecellborderstyle', {
icon: 'border-style',
text: 'Border style',
getSubmenuItems: () => buildMenuItems(editor, getTableBorderStyles(editor), 'tablecellborderstyle', applyTableCellStyle(editor, 'border-style')),
onSetup: selectionTargets.onSetupCellOrRow
});
editor.ui.registry.addNestedMenuItem('tablecellbackgroundcolor', {
icon: 'cell-background-color',
text: 'Background color',
getSubmenuItems: () => buildColorMenu(editor, getTableBackgroundColorMap(editor), 'background-color'),
onSetup: selectionTargets.onSetupCellOrRow
});
editor.ui.registry.addNestedMenuItem('tablecellbordercolor', {
icon: 'cell-border-color',
text: 'Border color',
getSubmenuItems: () => buildColorMenu(editor, getTableBorderColorMap(editor), 'border-color'),
onSetup: selectionTargets.onSetupCellOrRow
});
}
addToggleMenuIfRegistered('tablecaption', {
icon: 'table-caption',
text: 'Table caption',
command: 'mceTableToggleCaption',
onSetup: selectionTargets.onSetupTableWithCaption
});
addToggleMenuIfRegistered('tablerowheader', {
text: 'Row header',
icon: 'table-top-header',
command: 'mceTableRowType',
onAction: changeRowHeader(editor),
onSetup: selectionTargets.onSetupTableRowHeaders
});
addToggleMenuIfRegistered('tablecolheader', {
text: 'Column header',
icon: 'table-left-header',
command: 'mceTableColType',
onAction: changeColumnHeader(editor),
onSetup: selectionTargets.onSetupTableRowHeaders
});
};
const Plugin = editor => {
const selectionTargets = getSelectionTargets(editor);
register(editor);
registerCommands(editor);
addMenuItems(editor, selectionTargets);
addButtons(editor, selectionTargets);
addToolbars(editor);
};
var Plugin$1 = () => {
global$3.add('table', Plugin);
};
Plugin$1();
})();
|