"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.transformToCheckList = exports.isMenuDisabled = exports.getCheckListEntryList = void 0;
var _slate = require("slate");
var _elementTypes = require("../../constants/element-types");
var _core = require("../../core");
const isMenuDisabled = (editor, isReadonly) => {
  if (isReadonly || !editor.selection) return true;
  const disabledElementTypes = [_elementTypes.CODE_LINE, _elementTypes.CODE_BLOCK, _elementTypes.LIST_ITEM, _elementTypes.TABLE, _elementTypes.TABLE_ROW, _elementTypes.TABLE_CELL];
  const isSelectedDisableElement = !!(0, _core.getSelectedElems)(editor).find(elem => disabledElementTypes.includes(elem.type));
  if (isSelectedDisableElement) return true;
  return false;
};
exports.isMenuDisabled = isMenuDisabled;
const getCheckListEntryList = editor => {
  const checkListEntries = _slate.Editor.nodes(editor, {
    match: node => node.type === _elementTypes.CHECK_LIST_ITEM,
    universal: true
  });
  const checkListEntryList = Array.from(checkListEntries);
  return checkListEntryList;
};
exports.getCheckListEntryList = getCheckListEntryList;
const transformToCheckList = editor => {
  if (!editor.selection) return;
  _slate.Transforms.setNodes(editor, {
    type: _elementTypes.CHECK_LIST_ITEM
  });
  (0, _core.focusEditor)(editor);
};
exports.transformToCheckList = transformToCheckList;