UNPKG

@atlaskit/editor-plugin-card

Version:

Card plugin for @atlaskit/editor-core

59 lines (58 loc) 3.34 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.inlineCardSpecWithFixedToDOM = void 0; var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _adfSchema = require("@atlaskit/adf-schema"); var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view"); var _platformFeatureFlags = require("@atlaskit/platform-feature-flags"); 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) { (0, _defineProperty2.default)(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; } // @nodeSpecException:toDOM patch var inlineCardSpecWithFixedToDOM = exports.inlineCardSpecWithFixedToDOM = function inlineCardSpecWithFixedToDOM() { var inlineCardNode = (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _adfSchema.inlineCardWithLocalId : _adfSchema.inlineCard; return _objectSpread(_objectSpread({}, inlineCardNode), {}, { toDOM: function toDOM(node) { var wrapperAttrs = { class: 'inlineCardView-content-wrap inlineNodeView' }; var cardAttrs = { 'aria-busy': 'true', class: 'card' }; var attrs = _objectSpread({ 'data-inline-card': '', href: node.attrs.url || '', 'data-card-data': node.attrs.data ? JSON.stringify(node.attrs.data) : '', // LoadingCardLink used for Suspense in `packages/linking-platform/smart-card/src/view/CardWithUrl/loader.tsx` // We need to match the style of LoadingCardLink // Which uses frame styling `packages/linking-platform/smart-card/src/view/InlineCard/Frame/styled.ts`, with withoutBackground=true style: (0, _lazyNodeView.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 }) }, (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? { 'data-local-id': node.attrs.localId } : {}); if (node.attrs.url) { return ['span', wrapperAttrs, ['span', cardAttrs, ['a', attrs, node.attrs.url]]]; } else { return ['span', wrapperAttrs, ['span', cardAttrs, ['a', attrs]]]; } } }); };