How to use the tinymce/core/api/util/Tools.map function in tinymce

To help you get started, we’ve selected a few tinymce examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tinymce / tinymce / modules / tinymce / src / plugins / table / main / ts / ui / CellDialog.ts View on Github external
// Get selected cells or the current cell
  cells = editor.dom.select('td[data-mce-selected],th[data-mce-selected]');
  cellElm = editor.dom.getParent(editor.selection.getStart(), 'td,th');
  if (!cells.length && cellElm) {
    cells.push(cellElm);
  }

  cellElm = cellElm || cells[0];

  if (!cellElm) {
    // If this element is null, return now to avoid crashing.
    return;
  }

  // Get current data and find shared values between cells
  const cellsData: CellData[] = Tools.map(cells,
    (cellElm) => Helpers.extractDataFromCellElement(editor, cellElm, hasAdvancedCellTab(editor))
  );
  const data: CellData = Helpers.getSharedValues(cellsData);

  const dialogTabPanel: Types.Dialog.TabPanelApi = {
    type: 'tabpanel',
    tabs: [
      {
        title: 'General',
        name: 'general',
        items: CellDialogGeneralTab.getItems(editor)
      },
      Helpers.getAdvancedTab()
    ]
  };
  const dialogPanel: Types.Dialog.PanelApi = {
github tinymce / tinymce / modules / tinymce / src / plugins / spellchecker / main / ts / ui / Buttons.ts View on Github external
const getItems = function (editor) {
  return Tools.map(Settings.getLanguages(editor).split(','), function (langPair) {
    langPair = langPair.split('=');

    return {
      name: langPair[0],
      value: langPair[1]
    };
  });
};
github tinymce / tinymce / modules / tinymce / src / plugins / paste / main / ts / core / Newlines.ts View on Github external
const toBlockElements = function (text: string, rootTag: string, rootAttrs: RootAttrs) {
  const blocks = text.split(/\n\n/);
  const tagOpen = openContainer(rootTag, rootAttrs);
  const tagClose = '';

  const paragraphs = Tools.map(blocks, function (p) {
    return p.split(/\n/).join('<br>');
  });

  const stitch = function (p) {
    return tagOpen + p + tagClose;
  };

  return paragraphs.length === 1 ? paragraphs[0] : Tools.map(paragraphs, stitch).join('');
};
github tinymce / tinymce / modules / tinymce / src / plugins / spellchecker / main / ts / ui / Buttons.ts View on Github external
fetch : (callback) => {
        const items = Tools.map(languageMenuItems, (languageItem) => {
          return {
            type: 'choiceitem',
            value: languageItem.data,
            text: languageItem.text
          };
        });
        callback(items);
      },
      onItemAction: (splitButtonApi, value) => {
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / dialog / imagetools / CropRect.ts View on Github external
function toggleVisibility(state: boolean) {
    let selectors;

    selectors = Tools.map(handles, function (handle) {
      return '#' + id + '-' + handle.name;
    }).concat(Tools.map(blockers, function (blocker) {
      return '#' + id + '-' + blocker;
    })).join(',');

    if (state) {
      DomQuery(selectors, containerElm).show();
    } else {
      DomQuery(selectors, containerElm).hide();
    }
  }
github tinymce / tinymce / modules / tinymce / src / plugins / importcss / main / ts / core / ImportCss.ts View on Github external
const compileUserDefinedGroups = function (groups): Group[] {
  return Tools.map(groups, function (group) {
    return Tools.extend({}, group, {
      original: group,
      selectors: {},
      filter: compileFilter(group.filter),
      item: {
        text: group.title,
        menu: []
      }
    });
  });
};
github tinymce / tinymce / modules / tinymce / src / plugins / lists / main / ts / core / Selection.ts View on Github external
const findParentListItemsNodes = function (editor, elms) {
  const listItemsElms = Tools.map(elms, function (elm) {
    const parentLi = editor.dom.getParent(elm, 'li,dd,dt', getClosestListRootElm(editor, elm));

    return parentLi ? parentLi : elm;
  });

  return DomQuery.unique(listItemsElms);
};
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / dialog / imagetools / CropRect.ts View on Github external
function toggleVisibility(state: boolean) {
    let selectors;

    selectors = Tools.map(handles, function (handle) {
      return '#' + id + '-' + handle.name;
    }).concat(Tools.map(blockers, function (blocker) {
      return '#' + id + '-' + blocker;
    })).join(',');

    if (state) {
      DomQuery(selectors, containerElm).show();
    } else {
      DomQuery(selectors, containerElm).hide();
    }
  }