@atlaskit/editor-plugin-card
Version:
Card plugin for @atlaskit/editor-core
52 lines • 2.97 kB
JavaScript
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 { inlineCard, inlineCardWithLocalId } 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 inlineCardSpecWithFixedToDOM = function inlineCardSpecWithFixedToDOM() {
var inlineCardNode = fg('platform_editor_adf_with_localid') ? inlineCardWithLocalId : 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: 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
})
}, 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]]];
}
}
});
};