Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 1... Línea 1...
1
/**
1
/**
2
 * TinyMCE version 6.8.3 (2024-02-08)
2
 * TinyMCE version 7.7.1 (2025-03-05)
3
 */
3
 */
Línea 4... Línea 4...
4
 
4
 
5
(function () {
5
(function () {
Línea 455... Línea 455...
455
      return Optional.from(cs[index]).map(SugarElement.fromDom);
455
      return Optional.from(cs[index]).map(SugarElement.fromDom);
456
    };
456
    };
457
    const firstChild = element => child$3(element, 0);
457
    const firstChild = element => child$3(element, 0);
Línea 458... Línea 458...
458
 
458
 
459
    const isShadowRoot = dos => isDocumentFragment(dos) && isNonNullable(dos.dom.host);
-
 
460
    const supported = isFunction(Element.prototype.attachShadow) && isFunction(Node.prototype.getRootNode);
459
    const isShadowRoot = dos => isDocumentFragment(dos) && isNonNullable(dos.dom.host);
461
    const getRootNode = supported ? e => SugarElement.fromDom(e.dom.getRootNode()) : documentOrOwner;
460
    const getRootNode = e => SugarElement.fromDom(e.dom.getRootNode());
462
    const getShadowRoot = e => {
461
    const getShadowRoot = e => {
463
      const r = getRootNode(e);
462
      const r = getRootNode(e);
464
      return isShadowRoot(r) ? Optional.some(r) : Optional.none();
463
      return isShadowRoot(r) ? Optional.some(r) : Optional.none();
465
    };
464
    };
Línea 1501... Línea 1500...
1501
    const fromRgba = rgbaColour => {
1500
    const fromRgba = rgbaColour => {
1502
      const value = toHex(rgbaColour.red) + toHex(rgbaColour.green) + toHex(rgbaColour.blue);
1501
      const value = toHex(rgbaColour.red) + toHex(rgbaColour.green) + toHex(rgbaColour.blue);
1503
      return hexColour(value);
1502
      return hexColour(value);
1504
    };
1503
    };
Línea 1505... Línea 1504...
1505
 
1504
 
1506
    const rgbRegex = /^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i;
1505
    const rgbRegex = /^\s*rgb\s*\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)\s*\)\s*$/i;
1507
    const rgbaRegex = /^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i;
1506
    const rgbaRegex = /^\s*rgba\s*\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*((?:\d?\.\d+|\d+)%?)\s*\)\s*$/i;
1508
    const rgbaColour = (red, green, blue, alpha) => ({
1507
    const rgbaColour = (red, green, blue, alpha) => ({
1509
      red,
1508
      red,
1510
      green,
1509
      green,
1511
      blue,
1510
      blue,
Línea 1517... Línea 1516...
1517
      const b = parseInt(blue, 10);
1516
      const b = parseInt(blue, 10);
1518
      const a = parseFloat(alpha);
1517
      const a = parseFloat(alpha);
1519
      return rgbaColour(r, g, b, a);
1518
      return rgbaColour(r, g, b, a);
1520
    };
1519
    };
1521
    const fromString = rgbaString => {
1520
    const fromString = rgbaString => {
1522
      if (rgbaString === 'transparent') {
-
 
1523
        return Optional.some(rgbaColour(0, 0, 0, 0));
-
 
1524
      }
-
 
1525
      const rgbMatch = rgbRegex.exec(rgbaString);
1521
      const rgbMatch = rgbRegex.exec(rgbaString);
1526
      if (rgbMatch !== null) {
1522
      if (rgbMatch !== null) {
1527
        return Optional.some(fromStringValues(rgbMatch[1], rgbMatch[2], rgbMatch[3], '1'));
1523
        return Optional.some(fromStringValues(rgbMatch[1], rgbMatch[2], rgbMatch[3], '1'));
1528
      }
1524
      }
1529
      const rgbaMatch = rgbaRegex.exec(rgbaString);
1525
      const rgbaMatch = rgbaRegex.exec(rgbaString);
Línea 1619... Línea 1615...
1619
          text,
1615
          text,
1620
          value: item.value
1616
          value: item.value
1621
        };
1617
        };
1622
      }
1618
      }
1623
    });
1619
    });
-
 
1620
    const buildClassList = classList => {
-
 
1621
      if (!classList.length) {
-
 
1622
        return Optional.none();
-
 
1623
      }
-
 
1624
      return Optional.some(buildListItems([
-
 
1625
        {
-
 
1626
          text: 'Select...',
-
 
1627
          value: 'mce-no-match'
-
 
1628
        },
-
 
1629
        ...classList
-
 
1630
      ]));
-
 
1631
    };
1624
    const buildMenuItems = (editor, items, format, onAction) => map(items, item => {
1632
    const buildMenuItems = (editor, items, format, onAction) => map(items, item => {
1625
      const text = item.text || item.title;
1633
      const text = item.text || item.title;
1626
      if (isListGroup(item)) {
1634
      if (isListGroup(item)) {
1627
        return {
1635
        return {
1628
          type: 'nestedmenuitem',
1636
          type: 'nestedmenuitem',
Línea 1680... Línea 1688...
1680
      const currentType = editor.queryCommandValue('mceTableColType');
1688
      const currentType = editor.queryCommandValue('mceTableColType');
1681
      const newType = currentType === 'th' ? 'td' : 'th';
1689
      const newType = currentType === 'th' ? 'td' : 'th';
1682
      editor.execCommand('mceTableColType', false, { type: newType });
1690
      editor.execCommand('mceTableColType', false, { type: newType });
1683
    };
1691
    };
Línea 1684... Línea -...
1684
 
-
 
1685
    const getClassList$1 = editor => {
1692
 
1686
      const classes = buildListItems(getCellClassList(editor));
-
 
1687
      if (classes.length > 0) {
-
 
1688
        return Optional.some({
1693
    const getClassList$1 = editor => buildClassList(getCellClassList(editor)).map(items => ({
1689
          name: 'class',
1694
      name: 'class',
1690
          type: 'listbox',
1695
      type: 'listbox',
1691
          label: 'Class',
-
 
1692
          items: classes
1696
      label: 'Class',
1693
        });
-
 
1694
      }
-
 
1695
      return Optional.none();
1697
      items
1696
    };
1698
    }));
1697
    const children = [
1699
    const children = [
1698
      {
1700
      {
1699
        name: 'width',
1701
        name: 'width',
1700
        type: 'input',
1702
        type: 'input',
1701
        label: 'Width'
1703
        label: 'Width'
1702
      },
1704
      },
1703
      {
-
 
1704
        name: 'height',
-
 
1705
        type: 'input',
-
 
1706
        label: 'Height'
-
 
1707
      },
-
 
1708
      {
1705
      {
1709
        name: 'celltype',
1706
        name: 'celltype',
1710
        type: 'listbox',
1707
        type: 'listbox',
1711
        label: 'Cell type',
1708
        label: 'Cell type',
1712
        items: [
1709
        items: [
Línea 2038... Línea 2035...
2038
        each(keys(baseData), key => {
2035
        each(keys(baseData), key => {
2039
          each$1(items, (itemValue, itemKey) => {
2036
          each$1(items, (itemValue, itemKey) => {
2040
            const comparisonValue = baseData[key];
2037
            const comparisonValue = baseData[key];
2041
            if (comparisonValue !== '' && key === itemKey) {
2038
            if (comparisonValue !== '' && key === itemKey) {
2042
              if (comparisonValue !== itemValue) {
2039
              if (comparisonValue !== itemValue) {
2043
                baseData[key] = '';
2040
                baseData[key] = key === 'class' ? 'mce-no-match' : '';
2044
              }
2041
              }
2045
            }
2042
            }
2046
          });
2043
          });
2047
        });
2044
        });
2048
      });
2045
      });
Línea 2144... Línea 2141...
2144
      const dom = editor.dom;
2141
      const dom = editor.dom;
2145
      const colElm = column.getOr(cell);
2142
      const colElm = column.getOr(cell);
2146
      const getStyle = (element, style) => dom.getStyle(element, style) || dom.getAttrib(element, style);
2143
      const getStyle = (element, style) => dom.getStyle(element, style) || dom.getAttrib(element, style);
2147
      return {
2144
      return {
2148
        width: getStyle(colElm, 'width'),
2145
        width: getStyle(colElm, 'width'),
2149
        height: getStyle(cell, 'height'),
-
 
2150
        scope: dom.getAttrib(cell, 'scope'),
2146
        scope: dom.getAttrib(cell, 'scope'),
2151
        celltype: getNodeName(cell),
2147
        celltype: getNodeName(cell),
2152
        class: dom.getAttrib(cell, 'class', ''),
2148
        class: dom.getAttrib(cell, 'class', ''),
2153
        halign: getHAlignment(editor, cell),
2149
        halign: getHAlignment(editor, cell),
2154
        valign: getVAlignment(editor, cell),
2150
        valign: getVAlignment(editor, cell),
Línea 2167... Línea 2163...
2167
    };
2163
    };
2168
    const updateSimpleProps$1 = (modifier, colModifier, data, shouldUpdate) => {
2164
    const updateSimpleProps$1 = (modifier, colModifier, data, shouldUpdate) => {
2169
      if (shouldUpdate('scope')) {
2165
      if (shouldUpdate('scope')) {
2170
        modifier.setAttrib('scope', data.scope);
2166
        modifier.setAttrib('scope', data.scope);
2171
      }
2167
      }
2172
      if (shouldUpdate('class')) {
2168
      if (shouldUpdate('class') && data.class !== 'mce-no-match') {
2173
        modifier.setAttrib('class', data.class);
2169
        modifier.setAttrib('class', data.class);
2174
      }
2170
      }
2175
      if (shouldUpdate('height')) {
-
 
2176
        modifier.setStyle('height', addPxSuffix(data.height));
-
 
2177
      }
-
 
2178
      if (shouldUpdate('width')) {
2171
      if (shouldUpdate('width')) {
2179
        colModifier.setStyle('width', addPxSuffix(data.width));
2172
        colModifier.setStyle('width', addPxSuffix(data.width));
2180
      }
2173
      }
2181
    };
2174
    };
2182
    const updateAdvancedProps$1 = (modifier, data, shouldUpdate) => {
2175
    const updateAdvancedProps$1 = (modifier, data, shouldUpdate) => {
Línea 2295... Línea 2288...
2295
        initialData: data,
2288
        initialData: data,
2296
        onSubmit: curry(onSubmitCellForm, editor, cells, data)
2289
        onSubmit: curry(onSubmitCellForm, editor, cells, data)
2297
      });
2290
      });
2298
    };
2291
    };
Línea 2299... Línea -...
2299
 
-
 
2300
    const getClassList = editor => {
2292
 
2301
      const classes = buildListItems(getRowClassList(editor));
-
 
2302
      if (classes.length > 0) {
-
 
2303
        return Optional.some({
2293
    const getClassList = editor => buildClassList(getRowClassList(editor)).map(items => ({
2304
          name: 'class',
2294
      name: 'class',
2305
          type: 'listbox',
2295
      type: 'listbox',
2306
          label: 'Class',
-
 
2307
          items: classes
2296
      label: 'Class',
2308
        });
-
 
2309
      }
-
 
2310
      return Optional.none();
2297
      items
2311
    };
2298
    }));
2312
    const formChildren = [
2299
    const formChildren = [
2313
      {
2300
      {
2314
        type: 'listbox',
2301
        type: 'listbox',
2315
        name: 'type',
2302
        name: 'type',
Línea 2359... Línea 2346...
2359
      }
2346
      }
2360
    ];
2347
    ];
2361
    const getItems$1 = editor => formChildren.concat(getClassList(editor).toArray());
2348
    const getItems$1 = editor => formChildren.concat(getClassList(editor).toArray());
Línea 2362... Línea 2349...
2362
 
2349
 
2363
    const updateSimpleProps = (modifier, data, shouldUpdate) => {
2350
    const updateSimpleProps = (modifier, data, shouldUpdate) => {
2364
      if (shouldUpdate('class')) {
2351
      if (shouldUpdate('class') && data.class !== 'mce-no-match') {
2365
        modifier.setAttrib('class', data.class);
2352
        modifier.setAttrib('class', data.class);
2366
      }
2353
      }
2367
      if (shouldUpdate('height')) {
2354
      if (shouldUpdate('height')) {
2368
        modifier.setStyle('height', addPxSuffix(data.height));
2355
        modifier.setStyle('height', addPxSuffix(data.height));
Línea 2381... Línea 2368...
2381
    };
2368
    };
2382
    const applyStyleData = (editor, rows, data, wasChanged) => {
2369
    const applyStyleData = (editor, rows, data, wasChanged) => {
2383
      const isSingleRow = rows.length === 1;
2370
      const isSingleRow = rows.length === 1;
2384
      const shouldOverrideCurrentValue = isSingleRow ? always : wasChanged;
2371
      const shouldOverrideCurrentValue = isSingleRow ? always : wasChanged;
2385
      each(rows, rowElm => {
2372
      each(rows, rowElm => {
-
 
2373
        const rowCells = children$1(SugarElement.fromDom(rowElm), 'td,th');
2386
        const modifier = DomModifier.normal(editor, rowElm);
2374
        const modifier = DomModifier.normal(editor, rowElm);
2387
        updateSimpleProps(modifier, data, shouldOverrideCurrentValue);
2375
        updateSimpleProps(modifier, data, shouldOverrideCurrentValue);
2388
        if (hasAdvancedRowTab(editor)) {
2376
        if (hasAdvancedRowTab(editor)) {
2389
          updateAdvancedProps(modifier, data, shouldOverrideCurrentValue);
2377
          updateAdvancedProps(modifier, data, shouldOverrideCurrentValue);
2390
        }
2378
        }
-
 
2379
        if (wasChanged('height')) {
-
 
2380
          each(rowCells, cell => {
-
 
2381
            editor.dom.setStyle(cell.dom, 'height', null);
-
 
2382
          });
-
 
2383
        }
2391
        if (wasChanged('align')) {
2384
        if (wasChanged('align')) {
2392
          setAlign(editor, rowElm, data.align);
2385
          setAlign(editor, rowElm, data.align);
2393
        }
2386
        }
2394
      });
2387
      });
2395
    };
2388
    };
Línea 2549... Línea 2542...
2549
              value: 'right'
2542
              value: 'right'
2550
            }
2543
            }
2551
          ]
2544
          ]
2552
        }];
2545
        }];
2553
      const classListItem = classes.length > 0 ? [{
2546
      const classListItem = classes.length > 0 ? [{
2554
          type: 'listbox',
-
 
2555
          name: 'class',
2547
          name: 'class',
-
 
2548
          type: 'listbox',
2556
          label: 'Class',
2549
          label: 'Class',
2557
          items: classes
2550
          items: classes
2558
        }] : [];
2551
        }] : [];
2559
      return rowColCountItems.concat(alwaysItems).concat(appearanceItems).concat(alignmentItem).concat(classListItem);
2552
      return rowColCountItems.concat(alwaysItems).concat(appearanceItems).concat(alignmentItem).concat(classListItem);
2560
    };
2553
    };
Línea 2578... Línea 2571...
2578
      const dom = editor.dom;
2571
      const dom = editor.dom;
2579
      const attrs = {};
2572
      const attrs = {};
2580
      const styles = {};
2573
      const styles = {};
2581
      const shouldStyleWithCss$1 = shouldStyleWithCss(editor);
2574
      const shouldStyleWithCss$1 = shouldStyleWithCss(editor);
2582
      const hasAdvancedTableTab$1 = hasAdvancedTableTab(editor);
2575
      const hasAdvancedTableTab$1 = hasAdvancedTableTab(editor);
-
 
2576
      const borderIsZero = parseFloat(data.border) === 0;
2583
      if (!isUndefined(data.class)) {
2577
      if (!isUndefined(data.class) && data.class !== 'mce-no-match') {
2584
        attrs.class = data.class;
2578
        attrs.class = data.class;
2585
      }
2579
      }
2586
      styles.height = addPxSuffix(data.height);
2580
      styles.height = addPxSuffix(data.height);
2587
      if (shouldStyleWithCss$1) {
2581
      if (shouldStyleWithCss$1) {
2588
        styles.width = addPxSuffix(data.width);
2582
        styles.width = addPxSuffix(data.width);
2589
      } else if (dom.getAttrib(tableElm, 'width')) {
2583
      } else if (dom.getAttrib(tableElm, 'width')) {
2590
        attrs.width = removePxSuffix(data.width);
2584
        attrs.width = removePxSuffix(data.width);
2591
      }
2585
      }
2592
      if (shouldStyleWithCss$1) {
2586
      if (shouldStyleWithCss$1) {
-
 
2587
        if (borderIsZero) {
-
 
2588
          attrs.border = 0;
-
 
2589
          styles['border-width'] = '';
-
 
2590
        } else {
2593
        styles['border-width'] = addPxSuffix(data.border);
2591
          styles['border-width'] = addPxSuffix(data.border);
-
 
2592
          attrs.border = 1;
-
 
2593
        }
2594
        styles['border-spacing'] = addPxSuffix(data.cellspacing);
2594
        styles['border-spacing'] = addPxSuffix(data.cellspacing);
2595
      } else {
2595
      } else {
2596
        attrs.border = data.border;
2596
        attrs.border = borderIsZero ? 0 : data.border;
2597
        attrs.cellpadding = data.cellpadding;
2597
        attrs.cellpadding = data.cellpadding;
2598
        attrs.cellspacing = data.cellspacing;
2598
        attrs.cellspacing = data.cellspacing;
2599
      }
2599
      }
2600
      if (shouldStyleWithCss$1 && tableElm.children) {
2600
      if (shouldStyleWithCss$1 && tableElm.children) {
2601
        const cellStyles = {};
2601
        const cellStyles = {};
-
 
2602
        if (borderIsZero) {
-
 
2603
          cellStyles['border-width'] = '';
2602
        if (shouldApplyOnCell.border) {
2604
        } else if (shouldApplyOnCell.border) {
2603
          cellStyles['border-width'] = addPxSuffix(data.border);
2605
          cellStyles['border-width'] = addPxSuffix(data.border);
2604
        }
2606
        }
2605
        if (shouldApplyOnCell.cellpadding) {
2607
        if (shouldApplyOnCell.cellpadding) {
2606
          cellStyles.padding = addPxSuffix(data.cellpadding);
2608
          cellStyles.padding = addPxSuffix(data.cellpadding);
2607
        }
2609
        }
Línea 2632... Línea 2634...
2632
    const onSubmitTableForm = (editor, tableElm, oldData, api) => {
2634
    const onSubmitTableForm = (editor, tableElm, oldData, api) => {
2633
      const dom = editor.dom;
2635
      const dom = editor.dom;
2634
      const data = api.getData();
2636
      const data = api.getData();
2635
      const modifiedData = filter$1(data, (value, key) => oldData[key] !== value);
2637
      const modifiedData = filter$1(data, (value, key) => oldData[key] !== value);
2636
      api.close();
2638
      api.close();
2637
      if (data.class === '') {
-
 
2638
        delete data.class;
-
 
2639
      }
-
 
2640
      editor.undoManager.transact(() => {
2639
      editor.undoManager.transact(() => {
2641
        if (!tableElm) {
2640
        if (!tableElm) {
2642
          const cols = toInt(data.cols).getOr(1);
2641
          const cols = toInt(data.cols).getOr(1);
2643
          const rows = toInt(data.rows).getOr(1);
2642
          const rows = toInt(data.rows).getOr(1);
2644
          editor.execCommand('mceInsertTable', false, {
2643
          editor.execCommand('mceInsertTable', false, {
Línea 2694... Línea 2693...
2694
            data.bordercolor = '';
2693
            data.bordercolor = '';
2695
            data.backgroundcolor = '';
2694
            data.backgroundcolor = '';
2696
          }
2695
          }
2697
        }
2696
        }
2698
      }
2697
      }
2699
      const classes = buildListItems(getTableClassList(editor));
2698
      const classes = buildClassList(getTableClassList(editor));
2700
      if (classes.length > 0) {
2699
      if (classes.isSome()) {
2701
        if (data.class) {
2700
        if (data.class) {
2702
          data.class = data.class.replace(/\s*mce\-item\-table\s*/g, '');
2701
          data.class = data.class.replace(/\s*mce\-item\-table\s*/g, '');
2703
        }
2702
        }
2704
      }
2703
      }
2705
      const generalPanel = {
2704
      const generalPanel = {
2706
        type: 'grid',
2705
        type: 'grid',
2707
        columns: 2,
2706
        columns: 2,
2708
        items: getItems(editor, classes, insertNewTable)
2707
        items: getItems(editor, classes.getOr([]), insertNewTable)
2709
      };
2708
      };
2710
      const nonAdvancedForm = () => ({
2709
      const nonAdvancedForm = () => ({
2711
        type: 'panel',
2710
        type: 'panel',
2712
        items: [generalPanel]
2711
        items: [generalPanel]
2713
      });
2712
      });