@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
80 lines (79 loc) • 2.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.unlinkPayload = exports.buildVisitedLinkPayload = exports.buildOpenedSettingsPayload = exports.buildEditLinkPayload = void 0;
var _types = require("./types");
var buildEditLinkPayload = exports.buildEditLinkPayload = function buildEditLinkPayload(type) {
return {
action: _types.ACTION.CLICKED,
actionSubject: type === _types.ACTION_SUBJECT_ID.HYPERLINK ? _types.ACTION_SUBJECT.HYPERLINK : _types.ACTION_SUBJECT.SMART_LINK,
actionSubjectId: _types.ACTION_SUBJECT_ID.EDIT_LINK,
attributes: type !== _types.ACTION_SUBJECT_ID.HYPERLINK ? {
display: type
} : {},
eventType: _types.EVENT_TYPE.UI
};
};
var mapLinkTypeToCardAppearance = function mapLinkTypeToCardAppearance(type) {
switch (type) {
case _types.ACTION_SUBJECT_ID.CARD_INLINE:
{
return 'inline';
}
case _types.ACTION_SUBJECT_ID.CARD_BLOCK:
{
return 'block';
}
case _types.ACTION_SUBJECT_ID.EMBEDS:
{
return 'embed';
}
default:
{
return 'url';
}
}
};
var buildVisitedLinkPayload = exports.buildVisitedLinkPayload = function buildVisitedLinkPayload(type) {
return type === _types.ACTION_SUBJECT_ID.HYPERLINK ? {
action: _types.ACTION.VISITED,
actionSubject: _types.ACTION_SUBJECT.HYPERLINK,
actionSubjectId: undefined,
attributes: {
inputMethod: _types.INPUT_METHOD.TOOLBAR
},
eventType: _types.EVENT_TYPE.TRACK
} : {
action: _types.ACTION.VISITED,
actionSubject: _types.ACTION_SUBJECT.SMART_LINK,
actionSubjectId: type,
attributes: {
inputMethod: _types.INPUT_METHOD.TOOLBAR
},
eventType: _types.EVENT_TYPE.TRACK
};
};
var buildOpenedSettingsPayload = exports.buildOpenedSettingsPayload = function buildOpenedSettingsPayload(type) {
return {
action: _types.ACTION.CLICKED,
actionSubject: _types.ACTION_SUBJECT.BUTTON,
actionSubjectId: _types.ACTION_SUBJECT_ID.GOTO_SMART_LINK_SETTINGS,
attributes: {
inputMethod: _types.INPUT_METHOD.TOOLBAR,
display: mapLinkTypeToCardAppearance(type)
},
eventType: _types.EVENT_TYPE.UI
};
};
var unlinkPayload = exports.unlinkPayload = function unlinkPayload(type) {
return {
action: _types.ACTION.UNLINK,
actionSubject: type === _types.ACTION_SUBJECT_ID.HYPERLINK ? _types.ACTION_SUBJECT.HYPERLINK : _types.ACTION_SUBJECT.SMART_LINK,
actionSubjectId: type === _types.ACTION_SUBJECT_ID.HYPERLINK ? undefined : type,
attributes: {
inputMethod: _types.INPUT_METHOD.TOOLBAR
},
eventType: _types.EVENT_TYPE.TRACK
};
};