UNPKG

@atlaskit/adf-schema

Version:

Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs

29 lines 2.13 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } import { uuid } from '../../utils/uuid'; import { PanelType } from './panel'; export var getParseDOMAttrs = function getParseDOMAttrs(allowCustomPanel, dom, generateLocalId) { var parseDOMAttrs = { // eslint-disable-next-line @atlaskit/editor/no-as-casting, @typescript-eslint/no-non-null-assertion panelType: dom.getAttribute('data-panel-type') }; if (generateLocalId) { parseDOMAttrs.localId = uuid.generate(); } if (allowCustomPanel) { parseDOMAttrs = _objectSpread(_objectSpread({}, parseDOMAttrs), {}, { // eslint-disable-next-line @atlaskit/editor/no-as-casting, @typescript-eslint/no-non-null-assertion panelIcon: dom.getAttribute('data-panel-icon'), // eslint-disable-next-line @atlaskit/editor/no-as-casting, @typescript-eslint/no-non-null-assertion panelIconId: dom.getAttribute('data-panel-icon-id'), // eslint-disable-next-line @atlaskit/editor/no-as-casting, @typescript-eslint/no-non-null-assertion panelIconText: dom.getAttribute('data-panel-icon-text'), // eslint-disable-next-line @atlaskit/editor/no-as-casting, @typescript-eslint/no-non-null-assertion panelColor: dom.getAttribute('data-panel-color') }); } else { parseDOMAttrs.panelType = parseDOMAttrs.panelType === PanelType.CUSTOM ? PanelType.INFO : parseDOMAttrs.panelType; } return parseDOMAttrs; };