UNPKG

@atlaskit/adf-schema

Version:

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

83 lines (81 loc) 2.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.emoji = void 0; var _emoji = require("../../utils/confluence/emoji"); /** * @name emoji_node */ var emoji = { inline: true, group: 'inline', selectable: true, attrs: { shortName: { default: '' }, id: { default: '' }, text: { default: '' } }, parseDOM: [ // Handle copy/paste beautiful panel from renderer /> { tag: 'div.ak-editor-panel__icon span', ignore: true }, { tag: 'span[data-emoji-short-name]', getAttrs: function getAttrs(domNode) { var dom = domNode; return { shortName: dom.getAttribute('data-emoji-short-name') || emoji.attrs.shortName.default, id: dom.getAttribute('data-emoji-id') || emoji.attrs.id.default, text: dom.getAttribute('data-emoji-text') || emoji.attrs.text.default }; } }, // Handle copy/paste from old <ac:emoticon /> { tag: 'img[data-emoticon-name]', getAttrs: function getAttrs(dom) { return (0, _emoji.acNameToEmoji)(dom.getAttribute('data-emoticon-name')); } }, // Handle copy/paste from old <ac:hipchat-emoticons /> { tag: 'img[data-hipchat-emoticon]', getAttrs: function getAttrs(dom) { return (0, _emoji.acShortcutToEmoji)(dom.getAttribute('data-hipchat-emoticon')); } }, // Handle copy/paste from bitbucket's <img class="emoji" /> { tag: 'img.emoji[data-emoji-short-name]', getAttrs: function getAttrs(domNode) { var dom = domNode; return { shortName: dom.getAttribute('data-emoji-short-name') || emoji.attrs.shortName.default, id: dom.getAttribute('data-emoji-id') || emoji.attrs.id.default, text: dom.getAttribute('data-emoji-text') || emoji.attrs.text.default }; } }], toDOM: function toDOM(node) { var _node$attrs = node.attrs, shortName = _node$attrs.shortName, id = _node$attrs.id, text = _node$attrs.text; var attrs = { 'data-emoji-short-name': shortName, 'data-emoji-id': id, 'data-emoji-text': text, contenteditable: 'false' }; return ['span', attrs, text]; } }; exports.emoji = emoji;