UNPKG

@atlaskit/editor-plugin-card

Version:

Card plugin for @atlaskit/editor-core

55 lines 3.11 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 { blockCard, blockCardWithLocalId } from '@atlaskit/adf-schema'; import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view'; import { fg } from '@atlaskit/platform-feature-flags'; // @nodeSpecException:toDOM patch export var blockCardSpecWithFixedToDOM = function blockCardSpecWithFixedToDOM() { var blockCardNode = fg('platform_editor_adf_with_localid') ? blockCardWithLocalId : blockCard; return _objectSpread(_objectSpread({}, blockCardNode), {}, { toDOM: function toDOM(node) { var _node$attrs; var _ref = node.attrs, url = _ref.url; var _ref2 = node.attrs, data = _ref2.data; var _ref3 = node.attrs, layout = _ref3.layout, width = _ref3.width, datasource = _ref3.datasource; var attrs = _objectSpread({ 'data-block-card': '', 'data-card-url': url || '', 'data-card-data': data ? JSON.stringify(data) : '', 'data-datasource': datasource ? JSON.stringify(datasource) : '', 'data-layout': layout, 'data-width': "".concat(width), class: 'blockCardView-content-wrap' }, fg('platform_editor_adf_with_localid') ? { 'data-local-id': node.attrs.localId } : {}); return ['div', attrs, ['a', { // To match `packages/linking-platform/smart-card/src/view/CardWithUrl/component-lazy/LoadingCardLink.tsx` // Which uses frame styling `packages/linking-platform/smart-card/src/view/InlineCard/Frame/styled.ts` style: convertToInlineCss({ padding: "var(--ds-space-025, 2px)".concat(" 0px"), marginLeft: "var(--ds-space-negative-025, -2px)", display: 'inline', boxDecorationBreak: 'clone', WebkitBoxDecorationBreak: 'clone', borderRadius: "var(--ds-radius-small, 4px)", color: "var(--ds-link, #1868DB)", lineHeight: '22px', WebkitTransition: '0.1s all ease-in-out', transition: '0.1s all ease-in-out', userSelect: 'text', WebkitUserSelect: 'text', msUserSelect: 'text', MozUserSelect: 'none' // -moz-user-select }), href: url || '' }, (node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.url) || ' ']]; } }); };