@dialpad/dialtone 9.72.0 → 9.72.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tokens/doc.json +10850 -10850
- package/dist/vue2/components/rich_text_editor/extensions/emoji/emoji.cjs +38 -40
- package/dist/vue2/components/rich_text_editor/extensions/emoji/emoji.cjs.map +1 -1
- package/dist/vue2/components/rich_text_editor/extensions/emoji/emoji.js +40 -42
- package/dist/vue2/components/rich_text_editor/extensions/emoji/emoji.js.map +1 -1
- package/dist/vue2/components/rich_text_editor/extensions/emoji/index.cjs +3 -1
- package/dist/vue2/components/rich_text_editor/extensions/emoji/index.cjs.map +1 -1
- package/dist/vue2/components/rich_text_editor/extensions/emoji/index.js +1 -0
- package/dist/vue2/components/rich_text_editor/extensions/emoji/suggestion.cjs +0 -4
- package/dist/vue2/components/rich_text_editor/extensions/emoji/suggestion.cjs.map +1 -1
- package/dist/vue2/components/rich_text_editor/extensions/emoji/suggestion.js +0 -4
- package/dist/vue2/components/rich_text_editor/extensions/emoji/suggestion.js.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/channels/channel.d.ts +1 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/channels/channel.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/emoji/emoji.d.ts +0 -2
- package/dist/vue2/types/components/rich_text_editor/extensions/emoji/emoji.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/emoji/index.d.ts +1 -0
- package/dist/vue2/types/components/rich_text_editor/extensions/emoji/index.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/mentions/mention.d.ts +1 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/mentions/mention.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/slash_command/slash_command.d.ts +1 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/slash_command/slash_command.d.ts.map +1 -1
- package/dist/vue3/components/rich_text_editor/extensions/emoji/emoji.cjs +38 -40
- package/dist/vue3/components/rich_text_editor/extensions/emoji/emoji.cjs.map +1 -1
- package/dist/vue3/components/rich_text_editor/extensions/emoji/emoji.js +40 -42
- package/dist/vue3/components/rich_text_editor/extensions/emoji/emoji.js.map +1 -1
- package/dist/vue3/components/rich_text_editor/extensions/emoji/index.cjs +3 -1
- package/dist/vue3/components/rich_text_editor/extensions/emoji/index.cjs.map +1 -1
- package/dist/vue3/components/rich_text_editor/extensions/emoji/index.js +1 -0
- package/dist/vue3/components/rich_text_editor/extensions/emoji/suggestion.cjs +0 -4
- package/dist/vue3/components/rich_text_editor/extensions/emoji/suggestion.cjs.map +1 -1
- package/dist/vue3/components/rich_text_editor/extensions/emoji/suggestion.js +0 -4
- package/dist/vue3/components/rich_text_editor/extensions/emoji/suggestion.js.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/channels/channel.d.ts +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/channels/channel.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/emoji/emoji.d.ts +0 -2
- package/dist/vue3/types/components/rich_text_editor/extensions/emoji/emoji.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/emoji/index.d.ts +1 -0
- package/dist/vue3/types/components/rich_text_editor/extensions/emoji/index.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/mentions/mention.d.ts +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/mentions/mention.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/slash_command.d.ts +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/slash_command.d.ts.map +1 -1
- package/dist/vue3/types/recipes/conversation_view/message_input/message_input.vue.d.ts +1 -1
- package/package.json +26 -26
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const core = require("@tiptap/core");
|
|
4
|
+
const state = require("@tiptap/pm/state");
|
|
4
5
|
const vue2 = require("@tiptap/vue-2");
|
|
6
|
+
const Suggestion = require("@tiptap/suggestion");
|
|
7
|
+
const regexCombinedEmojis = require("regex-combined-emojis");
|
|
5
8
|
const EmojiComponent = require("./EmojiComponent.vue.cjs");
|
|
6
9
|
const common_emoji = require("../../../../common/emoji.cjs");
|
|
7
|
-
const state = require("@tiptap/pm/state");
|
|
8
|
-
const Suggestion = require("@tiptap/suggestion");
|
|
9
10
|
const suggestion = require("./suggestion.cjs");
|
|
10
|
-
const
|
|
11
|
-
const EmojiPluginKey = new state.PluginKey("emoji");
|
|
12
|
-
const inputShortCodeRegex = new RegExp("(^| |(?<=:))(:\\w+:)$");
|
|
11
|
+
const inputShortCodeRegex = /(:\w+:)$/;
|
|
13
12
|
const inputUnicodeRegex = new RegExp(regexCombinedEmojis.emojiPattern + "$");
|
|
14
13
|
const inputRuleMatch = (match) => {
|
|
15
14
|
if (match && common_emoji.codeToEmojiData(match[0])) {
|
|
16
15
|
const text = match[2] || match[0];
|
|
17
|
-
return {
|
|
18
|
-
index: match.index,
|
|
19
|
-
text,
|
|
20
|
-
match
|
|
21
|
-
};
|
|
16
|
+
return { text };
|
|
22
17
|
}
|
|
23
18
|
};
|
|
24
19
|
const shortCodePasteMatch = (text) => {
|
|
@@ -30,19 +25,16 @@ const shortCodePasteMatch = (text) => {
|
|
|
30
25
|
}));
|
|
31
26
|
};
|
|
32
27
|
const Emoji = core.Node.create({
|
|
28
|
+
name: "emoji",
|
|
33
29
|
addOptions() {
|
|
34
30
|
return {
|
|
35
|
-
HTMLAttributes: {}
|
|
36
|
-
suggestion: {
|
|
37
|
-
char: ":",
|
|
38
|
-
pluginKey: EmojiPluginKey
|
|
39
|
-
}
|
|
31
|
+
HTMLAttributes: {}
|
|
40
32
|
};
|
|
41
33
|
},
|
|
42
|
-
name: "emoji",
|
|
43
34
|
group: "inline",
|
|
44
35
|
inline: true,
|
|
45
|
-
selectable:
|
|
36
|
+
selectable: false,
|
|
37
|
+
atom: true,
|
|
46
38
|
addNodeView() {
|
|
47
39
|
return vue2.VueNodeViewRenderer(EmojiComponent);
|
|
48
40
|
},
|
|
@@ -69,32 +61,17 @@ const Emoji = core.Node.create({
|
|
|
69
61
|
},
|
|
70
62
|
addInputRules() {
|
|
71
63
|
return [
|
|
72
|
-
|
|
73
|
-
core.nodeInputRule({
|
|
64
|
+
new core.InputRule({
|
|
74
65
|
find: (text) => {
|
|
75
|
-
const match = text.match(inputShortCodeRegex);
|
|
66
|
+
const match = text.match(inputShortCodeRegex) || text.match(inputUnicodeRegex);
|
|
76
67
|
if (!match) return;
|
|
77
68
|
return inputRuleMatch(match);
|
|
78
69
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
}),
|
|
86
|
-
core.nodeInputRule({
|
|
87
|
-
find: (text) => {
|
|
88
|
-
const match = text.match(inputUnicodeRegex);
|
|
89
|
-
if (!match) return;
|
|
90
|
-
return inputRuleMatch(match);
|
|
91
|
-
},
|
|
92
|
-
type: this.type,
|
|
93
|
-
getAttributes(attrs) {
|
|
94
|
-
const emoji = common_emoji.codeToEmojiData(attrs[0]).shortname;
|
|
95
|
-
return {
|
|
96
|
-
code: emoji
|
|
97
|
-
};
|
|
70
|
+
handler: ({ state: state2, range, match, commands, chain, can }) => {
|
|
71
|
+
const { tr } = state2;
|
|
72
|
+
const start = range.from;
|
|
73
|
+
const end = range.to;
|
|
74
|
+
tr.replaceWith(start, end, this.type.create({ code: match[0] }));
|
|
98
75
|
}
|
|
99
76
|
})
|
|
100
77
|
];
|
|
@@ -124,13 +101,34 @@ const Emoji = core.Node.create({
|
|
|
124
101
|
addProseMirrorPlugins() {
|
|
125
102
|
return [
|
|
126
103
|
Suggestion({
|
|
104
|
+
char: ":",
|
|
105
|
+
pluginKey: new state.PluginKey("emoji"),
|
|
127
106
|
editor: this.editor,
|
|
128
107
|
...this.options.suggestion,
|
|
129
108
|
...suggestion
|
|
130
109
|
})
|
|
131
110
|
];
|
|
111
|
+
},
|
|
112
|
+
addKeyboardShortcuts() {
|
|
113
|
+
return {
|
|
114
|
+
Backspace: () => this.editor.commands.command(({ tr, state: state2 }) => {
|
|
115
|
+
let isEmoji = false;
|
|
116
|
+
const { selection } = state2;
|
|
117
|
+
const { empty, anchor } = selection;
|
|
118
|
+
if (!empty) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
state2.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
|
|
122
|
+
if (node.type.name === this.name) {
|
|
123
|
+
isEmoji = true;
|
|
124
|
+
tr.insertText("", pos, pos + node.nodeSize);
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
return isEmoji;
|
|
129
|
+
})
|
|
130
|
+
};
|
|
132
131
|
}
|
|
133
132
|
});
|
|
134
133
|
exports.Emoji = Emoji;
|
|
135
|
-
exports.EmojiPluginKey = EmojiPluginKey;
|
|
136
134
|
//# sourceMappingURL=emoji.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emoji.cjs","sources":["../../../../../components/rich_text_editor/extensions/emoji/emoji.js"],"sourcesContent":["import { mergeAttributes, Node,
|
|
1
|
+
{"version":3,"file":"emoji.cjs","sources":["../../../../../components/rich_text_editor/extensions/emoji/emoji.js"],"sourcesContent":["import { InputRule, mergeAttributes, Node, nodePasteRule } from '@tiptap/core';\nimport { PluginKey } from '@tiptap/pm/state';\nimport { VueNodeViewRenderer } from '@tiptap/vue-2';\nimport Suggestion from '@tiptap/suggestion';\nimport { emojiPattern } from 'regex-combined-emojis';\n\nimport EmojiComponent from './EmojiComponent.vue';\nimport { codeToEmojiData, emojiShortCodeRegex, emojiRegex, stringToUnicode } from '@/common/emoji';\nimport suggestionOptions from './suggestion';\n\nconst inputShortCodeRegex = /(:\\w+:)$/;\nconst inputUnicodeRegex = new RegExp(emojiPattern + '$');\n\nconst inputRuleMatch = (match) => {\n if (match && codeToEmojiData(match[0])) {\n const text = match[2] || match[0];\n // needs to be a dict returned\n // ref type InputRuleMatch:\n // https://github.com/ueberdosis/tiptap/blob/main/packages/core/src/InputRule.ts#L16\n return { text };\n }\n};\n\nconst shortCodePasteMatch = (text) => {\n const matches = [...text.matchAll(emojiShortCodeRegex)];\n\n return matches\n .filter(match => codeToEmojiData(match[0]))\n .map(match => ({\n index: match.index,\n text: match[0],\n match,\n }));\n};\n\nexport const Emoji = Node.create({\n name: 'emoji',\n addOptions () {\n return {\n HTMLAttributes: {},\n };\n },\n group: 'inline',\n inline: true,\n selectable: false,\n atom: true,\n\n addNodeView () {\n return VueNodeViewRenderer(EmojiComponent);\n },\n\n addAttributes () {\n return {\n code: {\n default: null,\n },\n };\n },\n\n parseHTML () {\n return [\n {\n tag: 'emoji-component',\n },\n ];\n },\n\n renderText ({ node }) {\n // output emoji in text as unicode character rather than shortname for backwards compatibility with\n // our backend.\n const unicodeEmoji = stringToUnicode(codeToEmojiData(node.attrs.code).unicode_output);\n return unicodeEmoji;\n },\n\n renderHTML ({ HTMLAttributes }) {\n return ['emoji-component', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];\n },\n\n addInputRules () {\n return [\n new InputRule({\n find: (text) => {\n const match = text.match(inputShortCodeRegex) || text.match(inputUnicodeRegex);\n if (!match) return;\n\n return inputRuleMatch(match);\n },\n handler: ({ state, range, match, commands, chain, can }) => {\n const { tr } = state;\n const start = range.from;\n const end = range.to;\n tr.replaceWith(start, end, this.type.create({ code: match[0] }));\n },\n }),\n ];\n },\n\n addPasteRules () {\n return [\n nodePasteRule({\n find: shortCodePasteMatch,\n type: this.type,\n getAttributes (attrs) {\n return {\n code: attrs[0],\n };\n },\n }),\n nodePasteRule({\n find: emojiRegex,\n type: this.type,\n getAttributes (attrs) {\n return {\n code: attrs[0],\n };\n },\n }),\n ];\n },\n\n addProseMirrorPlugins () {\n return [\n Suggestion({\n char: ':',\n pluginKey: new PluginKey('emoji'),\n editor: this.editor,\n ...this.options.suggestion,\n ...suggestionOptions,\n }),\n ];\n },\n\n addKeyboardShortcuts () {\n return {\n Backspace: () => this.editor.commands.command(({ tr, state }) => {\n let isEmoji = false;\n const { selection } = state;\n const { empty, anchor } = selection;\n if (!empty) { return false; }\n state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {\n if (node.type.name === this.name) {\n isEmoji = true;\n tr.insertText('', pos, pos + node.nodeSize);\n return false;\n }\n });\n return isEmoji;\n }),\n };\n },\n});\n"],"names":["emojiPattern","codeToEmojiData","emojiShortCodeRegex","Node","VueNodeViewRenderer","stringToUnicode","mergeAttributes","InputRule","state","nodePasteRule","emojiRegex","PluginKey","suggestionOptions"],"mappings":";;;;;;;;;;AAUA,MAAM,sBAAsB;AAC5B,MAAM,oBAAoB,IAAI,OAAOA,oBAAY,eAAG,GAAG;AAEvD,MAAM,iBAAiB,CAAC,UAAU;AAChC,MAAI,SAASC,aAAe,gBAAC,MAAM,CAAC,CAAC,GAAG;AACtC,UAAM,OAAO,MAAM,CAAC,KAAK,MAAM,CAAC;AAIhC,WAAO,EAAE,KAAI;AAAA,EACd;AACH;AAEA,MAAM,sBAAsB,CAAC,SAAS;AACpC,QAAM,UAAU,CAAC,GAAG,KAAK,SAASC,aAAAA,mBAAmB,CAAC;AAEtD,SAAO,QACJ,OAAO,WAASD,aAAAA,gBAAgB,MAAM,CAAC,CAAC,CAAC,EACzC,IAAI,YAAU;AAAA,IACb,OAAO,MAAM;AAAA,IACb,MAAM,MAAM,CAAC;AAAA,IACb;AAAA,EACD,EAAC;AACN;AAEY,MAAC,QAAQE,KAAI,KAAC,OAAO;AAAA,EAC/B,MAAM;AAAA,EACN,aAAc;AACZ,WAAO;AAAA,MACL,gBAAgB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AA,YACL,MAAM,MAAM,CAAC;AAAA,UACzB;AAAA,QACS;AAAA,MACT,CAAO;AAAA,MACDA,mBAAc;AAAA,QACZ,MAAMC,aAAU;AAAA,QAChB,MAAM,KAAK;AAAA,QACX,cAAe,OAAO;AACpB,iBAAO;AAAA,YACL,MAAM,MAAM,CAAC;AAAA,UACzB;AAAA,QACS;AAAA,MACT,CAAO;AAAA,IACP;AAAA,EACG;AAAA,EAED,wBAAyB;AACvB,WAAO;AAAA,MACL,WAAW;AAAA,QACT,MAAM;AAAA,QACN,WAAW,IAAIC,MAAS,UAAC,OAAO;AAAA,QAChC,QAAQ,KAAK;AAAA,QACb,GAAG,KAAK,QAAQ;AAAA,QAChB,GAAGC;AAAAA,MACX,CAAO;AAAA,IACP;AAAA,EACG;AAAA,EAED,uBAAwB;AACtB,WAAO;AAAA,MACL,WAAW,MAAM,KAAK,OAAO,SAAS,QAAQ,CAAC,EAAE,IAAI,OAAAJ,aAAY;AAC/D,YAAI,UAAU;AACd,cAAM,EAAE,UAAW,IAAGA;AACtB,cAAM,EAAE,OAAO,OAAQ,IAAG;AAC1B,YAAI,CAAC,OAAO;AAAE,iBAAO;AAAA,QAAQ;AAC7B,QAAAA,OAAM,IAAI,aAAa,SAAS,GAAG,QAAQ,CAAC,MAAM,QAAQ;AACxD,cAAI,KAAK,KAAK,SAAS,KAAK,MAAM;AAChC,sBAAU;AACV,eAAG,WAAW,IAAI,KAAK,MAAM,KAAK,QAAQ;AAC1C,mBAAO;AAAA,UACR;AAAA,QACX,CAAS;AACD,eAAO;AAAA,MACf,CAAO;AAAA,IACP;AAAA,EACG;AACH,CAAC;;"}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
import { Node, mergeAttributes,
|
|
1
|
+
import { Node, mergeAttributes, InputRule, nodePasteRule } from "@tiptap/core";
|
|
2
|
+
import { PluginKey } from "@tiptap/pm/state";
|
|
2
3
|
import { VueNodeViewRenderer } from "@tiptap/vue-2";
|
|
4
|
+
import Suggestion from "@tiptap/suggestion";
|
|
5
|
+
import { emojiPattern } from "regex-combined-emojis";
|
|
3
6
|
import EmojiComponent from "./EmojiComponent.vue.js";
|
|
4
7
|
import { stringToUnicode, codeToEmojiData, emojiRegex, emojiShortCodeRegex } from "../../../../common/emoji.js";
|
|
5
|
-
import { PluginKey } from "@tiptap/pm/state";
|
|
6
|
-
import Suggestion from "@tiptap/suggestion";
|
|
7
8
|
import suggestionOptions from "./suggestion.js";
|
|
8
|
-
|
|
9
|
-
const EmojiPluginKey = new PluginKey("emoji");
|
|
10
|
-
const inputShortCodeRegex = new RegExp("(^| |(?<=:))(:\\w+:)$");
|
|
9
|
+
const inputShortCodeRegex = /(:\w+:)$/;
|
|
11
10
|
const inputUnicodeRegex = new RegExp(emojiPattern + "$");
|
|
12
11
|
const inputRuleMatch = (match) => {
|
|
13
12
|
if (match && codeToEmojiData(match[0])) {
|
|
14
13
|
const text = match[2] || match[0];
|
|
15
|
-
return {
|
|
16
|
-
index: match.index,
|
|
17
|
-
text,
|
|
18
|
-
match
|
|
19
|
-
};
|
|
14
|
+
return { text };
|
|
20
15
|
}
|
|
21
16
|
};
|
|
22
17
|
const shortCodePasteMatch = (text) => {
|
|
@@ -28,19 +23,16 @@ const shortCodePasteMatch = (text) => {
|
|
|
28
23
|
}));
|
|
29
24
|
};
|
|
30
25
|
const Emoji = Node.create({
|
|
26
|
+
name: "emoji",
|
|
31
27
|
addOptions() {
|
|
32
28
|
return {
|
|
33
|
-
HTMLAttributes: {}
|
|
34
|
-
suggestion: {
|
|
35
|
-
char: ":",
|
|
36
|
-
pluginKey: EmojiPluginKey
|
|
37
|
-
}
|
|
29
|
+
HTMLAttributes: {}
|
|
38
30
|
};
|
|
39
31
|
},
|
|
40
|
-
name: "emoji",
|
|
41
32
|
group: "inline",
|
|
42
33
|
inline: true,
|
|
43
|
-
selectable:
|
|
34
|
+
selectable: false,
|
|
35
|
+
atom: true,
|
|
44
36
|
addNodeView() {
|
|
45
37
|
return VueNodeViewRenderer(EmojiComponent);
|
|
46
38
|
},
|
|
@@ -67,32 +59,17 @@ const Emoji = Node.create({
|
|
|
67
59
|
},
|
|
68
60
|
addInputRules() {
|
|
69
61
|
return [
|
|
70
|
-
|
|
71
|
-
nodeInputRule({
|
|
62
|
+
new InputRule({
|
|
72
63
|
find: (text) => {
|
|
73
|
-
const match = text.match(inputShortCodeRegex);
|
|
64
|
+
const match = text.match(inputShortCodeRegex) || text.match(inputUnicodeRegex);
|
|
74
65
|
if (!match) return;
|
|
75
66
|
return inputRuleMatch(match);
|
|
76
67
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}),
|
|
84
|
-
nodeInputRule({
|
|
85
|
-
find: (text) => {
|
|
86
|
-
const match = text.match(inputUnicodeRegex);
|
|
87
|
-
if (!match) return;
|
|
88
|
-
return inputRuleMatch(match);
|
|
89
|
-
},
|
|
90
|
-
type: this.type,
|
|
91
|
-
getAttributes(attrs) {
|
|
92
|
-
const emoji = codeToEmojiData(attrs[0]).shortname;
|
|
93
|
-
return {
|
|
94
|
-
code: emoji
|
|
95
|
-
};
|
|
68
|
+
handler: ({ state, range, match, commands, chain, can }) => {
|
|
69
|
+
const { tr } = state;
|
|
70
|
+
const start = range.from;
|
|
71
|
+
const end = range.to;
|
|
72
|
+
tr.replaceWith(start, end, this.type.create({ code: match[0] }));
|
|
96
73
|
}
|
|
97
74
|
})
|
|
98
75
|
];
|
|
@@ -122,15 +99,36 @@ const Emoji = Node.create({
|
|
|
122
99
|
addProseMirrorPlugins() {
|
|
123
100
|
return [
|
|
124
101
|
Suggestion({
|
|
102
|
+
char: ":",
|
|
103
|
+
pluginKey: new PluginKey("emoji"),
|
|
125
104
|
editor: this.editor,
|
|
126
105
|
...this.options.suggestion,
|
|
127
106
|
...suggestionOptions
|
|
128
107
|
})
|
|
129
108
|
];
|
|
109
|
+
},
|
|
110
|
+
addKeyboardShortcuts() {
|
|
111
|
+
return {
|
|
112
|
+
Backspace: () => this.editor.commands.command(({ tr, state }) => {
|
|
113
|
+
let isEmoji = false;
|
|
114
|
+
const { selection } = state;
|
|
115
|
+
const { empty, anchor } = selection;
|
|
116
|
+
if (!empty) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
|
|
120
|
+
if (node.type.name === this.name) {
|
|
121
|
+
isEmoji = true;
|
|
122
|
+
tr.insertText("", pos, pos + node.nodeSize);
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
return isEmoji;
|
|
127
|
+
})
|
|
128
|
+
};
|
|
130
129
|
}
|
|
131
130
|
});
|
|
132
131
|
export {
|
|
133
|
-
Emoji
|
|
134
|
-
EmojiPluginKey
|
|
132
|
+
Emoji
|
|
135
133
|
};
|
|
136
134
|
//# sourceMappingURL=emoji.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emoji.js","sources":["../../../../../components/rich_text_editor/extensions/emoji/emoji.js"],"sourcesContent":["import { mergeAttributes, Node,
|
|
1
|
+
{"version":3,"file":"emoji.js","sources":["../../../../../components/rich_text_editor/extensions/emoji/emoji.js"],"sourcesContent":["import { InputRule, mergeAttributes, Node, nodePasteRule } from '@tiptap/core';\nimport { PluginKey } from '@tiptap/pm/state';\nimport { VueNodeViewRenderer } from '@tiptap/vue-2';\nimport Suggestion from '@tiptap/suggestion';\nimport { emojiPattern } from 'regex-combined-emojis';\n\nimport EmojiComponent from './EmojiComponent.vue';\nimport { codeToEmojiData, emojiShortCodeRegex, emojiRegex, stringToUnicode } from '@/common/emoji';\nimport suggestionOptions from './suggestion';\n\nconst inputShortCodeRegex = /(:\\w+:)$/;\nconst inputUnicodeRegex = new RegExp(emojiPattern + '$');\n\nconst inputRuleMatch = (match) => {\n if (match && codeToEmojiData(match[0])) {\n const text = match[2] || match[0];\n // needs to be a dict returned\n // ref type InputRuleMatch:\n // https://github.com/ueberdosis/tiptap/blob/main/packages/core/src/InputRule.ts#L16\n return { text };\n }\n};\n\nconst shortCodePasteMatch = (text) => {\n const matches = [...text.matchAll(emojiShortCodeRegex)];\n\n return matches\n .filter(match => codeToEmojiData(match[0]))\n .map(match => ({\n index: match.index,\n text: match[0],\n match,\n }));\n};\n\nexport const Emoji = Node.create({\n name: 'emoji',\n addOptions () {\n return {\n HTMLAttributes: {},\n };\n },\n group: 'inline',\n inline: true,\n selectable: false,\n atom: true,\n\n addNodeView () {\n return VueNodeViewRenderer(EmojiComponent);\n },\n\n addAttributes () {\n return {\n code: {\n default: null,\n },\n };\n },\n\n parseHTML () {\n return [\n {\n tag: 'emoji-component',\n },\n ];\n },\n\n renderText ({ node }) {\n // output emoji in text as unicode character rather than shortname for backwards compatibility with\n // our backend.\n const unicodeEmoji = stringToUnicode(codeToEmojiData(node.attrs.code).unicode_output);\n return unicodeEmoji;\n },\n\n renderHTML ({ HTMLAttributes }) {\n return ['emoji-component', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];\n },\n\n addInputRules () {\n return [\n new InputRule({\n find: (text) => {\n const match = text.match(inputShortCodeRegex) || text.match(inputUnicodeRegex);\n if (!match) return;\n\n return inputRuleMatch(match);\n },\n handler: ({ state, range, match, commands, chain, can }) => {\n const { tr } = state;\n const start = range.from;\n const end = range.to;\n tr.replaceWith(start, end, this.type.create({ code: match[0] }));\n },\n }),\n ];\n },\n\n addPasteRules () {\n return [\n nodePasteRule({\n find: shortCodePasteMatch,\n type: this.type,\n getAttributes (attrs) {\n return {\n code: attrs[0],\n };\n },\n }),\n nodePasteRule({\n find: emojiRegex,\n type: this.type,\n getAttributes (attrs) {\n return {\n code: attrs[0],\n };\n },\n }),\n ];\n },\n\n addProseMirrorPlugins () {\n return [\n Suggestion({\n char: ':',\n pluginKey: new PluginKey('emoji'),\n editor: this.editor,\n ...this.options.suggestion,\n ...suggestionOptions,\n }),\n ];\n },\n\n addKeyboardShortcuts () {\n return {\n Backspace: () => this.editor.commands.command(({ tr, state }) => {\n let isEmoji = false;\n const { selection } = state;\n const { empty, anchor } = selection;\n if (!empty) { return false; }\n state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {\n if (node.type.name === this.name) {\n isEmoji = true;\n tr.insertText('', pos, pos + node.nodeSize);\n return false;\n }\n });\n return isEmoji;\n }),\n };\n },\n});\n"],"names":[],"mappings":";;;;;;;;AAUA,MAAM,sBAAsB;AAC5B,MAAM,oBAAoB,IAAI,OAAO,eAAe,GAAG;AAEvD,MAAM,iBAAiB,CAAC,UAAU;AAChC,MAAI,SAAS,gBAAgB,MAAM,CAAC,CAAC,GAAG;AACtC,UAAM,OAAO,MAAM,CAAC,KAAK,MAAM,CAAC;AAIhC,WAAO,EAAE,KAAI;AAAA,EACd;AACH;AAEA,MAAM,sBAAsB,CAAC,SAAS;AACpC,QAAM,UAAU,CAAC,GAAG,KAAK,SAAS,mBAAmB,CAAC;AAEtD,SAAO,QACJ,OAAO,WAAS,gBAAgB,MAAM,CAAC,CAAC,CAAC,EACzC,IAAI,YAAU;AAAA,IACb,OAAO,MAAM;AAAA,IACb,MAAM,MAAM,CAAC;AAAA,IACb;AAAA,EACD,EAAC;AACN;AAEY,MAAC,QAAQ,KAAK,OAAO;AAAA,EAC/B,MAAM;AAAA,EACN,aAAc;AACZ,WAAO;AAAA,MACL,gBAAgB,CAAE;AAAA,IACxB;AAAA,EACG;AAAA,EACD,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,MAAM;AAAA,EAEN,cAAe;AACb,WAAO,oBAAoB,cAAc;AAAA,EAC1C;AAAA,EAED,gBAAiB;AACf,WAAO;AAAA,MACL,MAAM;AAAA,QACJ,SAAS;AAAA,MACV;AAAA,IACP;AAAA,EACG;AAAA,EAED,YAAa;AACX,WAAO;AAAA,MACL;AAAA,QACE,KAAK;AAAA,MACN;AAAA,IACP;AAAA,EACG;AAAA,EAED,WAAY,EAAE,QAAQ;AAGpB,UAAM,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ChB,GAAG;AAAA,MACX,CAAO;AAAA,IACP;AAAA,EACG;AAAA,EAED,uBAAwB;AACtB,WAAO;AAAA,MACL,WAAW,MAAM,KAAK,OAAO,SAAS,QAAQ,CAAC,EAAE,IAAI,YAAY;AAC/D,YAAI,UAAU;AACd,cAAM,EAAE,UAAW,IAAG;AACtB,cAAM,EAAE,OAAO,OAAQ,IAAG;AAC1B,YAAI,CAAC,OAAO;AAAE,iBAAO;AAAA,QAAQ;AAC7B,cAAM,IAAI,aAAa,SAAS,GAAG,QAAQ,CAAC,MAAM,QAAQ;AACxD,cAAI,KAAK,KAAK,SAAS,KAAK,MAAM;AAChC,sBAAU;AACV,eAAG,WAAW,IAAI,KAAK,MAAM,KAAK,QAAQ;AAC1C,mBAAO;AAAA,UACR;AAAA,QACX,CAAS;AACD,eAAO;AAAA,MACf,CAAO;AAAA,IACP;AAAA,EACG;AACH,CAAC;"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
2
3
|
const emoji = require("./emoji.cjs");
|
|
3
|
-
|
|
4
|
+
exports.Emoji = emoji.Emoji;
|
|
5
|
+
exports.default = emoji.Emoji;
|
|
4
6
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestion.cjs","sources":["../../../../../components/rich_text_editor/extensions/emoji/suggestion.js"],"sourcesContent":["import { VueRenderer } from '@tiptap/vue-2';\nimport { emojisIndexed } from '@dialpad/dialtone-emojis';\n\nimport SuggestionList from '../suggestion/SuggestionList.vue';\nimport EmojiSuggestion from './EmojiSuggestion.vue';\n\nimport tippy from 'tippy.js';\nimport hideOnEsc from '../tippy_plugins/hide_on_esc';\n\nexport default {\n items: ({ query }) => {\n if (query.length < 2) {\n return [];\n }\n const emojiList = Object.values(emojisIndexed);\n const filteredEmoji = emojiList.filter(function (item) {\n if (item.shortname.substring(1, item.shortname.length - 1).startsWith(query.toLowerCase())) {\n return true;\n }\n return false;\n });\n return filteredEmoji.map(item => { return { code: item.shortname }; });\n },\n\n command: ({ editor, range, props }) => {\n // increase range.to by one when the next node is of type \"text\"\n // and starts with a space character\n const nodeAfter = editor.view.state.selection.$to.nodeAfter;\n const overrideSpace = nodeAfter?.text?.startsWith(' ');\n\n if (overrideSpace) {\n range.to += 1;\n }\n\n editor\n .chain()\n .focus()\n .insertContentAt(range, [\n {\n type: 'emoji',\n attrs: props,\n },\n
|
|
1
|
+
{"version":3,"file":"suggestion.cjs","sources":["../../../../../components/rich_text_editor/extensions/emoji/suggestion.js"],"sourcesContent":["import { VueRenderer } from '@tiptap/vue-2';\nimport { emojisIndexed } from '@dialpad/dialtone-emojis';\n\nimport SuggestionList from '../suggestion/SuggestionList.vue';\nimport EmojiSuggestion from './EmojiSuggestion.vue';\n\nimport tippy from 'tippy.js';\nimport hideOnEsc from '../tippy_plugins/hide_on_esc';\n\nexport default {\n items: ({ query }) => {\n if (query.length < 2) {\n return [];\n }\n const emojiList = Object.values(emojisIndexed);\n const filteredEmoji = emojiList.filter(function (item) {\n if (item.shortname.substring(1, item.shortname.length - 1).startsWith(query.toLowerCase())) {\n return true;\n }\n return false;\n });\n return filteredEmoji.map(item => { return { code: item.shortname }; });\n },\n\n command: ({ editor, range, props }) => {\n // increase range.to by one when the next node is of type \"text\"\n // and starts with a space character\n const nodeAfter = editor.view.state.selection.$to.nodeAfter;\n const overrideSpace = nodeAfter?.text?.startsWith(' ');\n\n if (overrideSpace) {\n range.to += 1;\n }\n\n editor\n .chain()\n .focus()\n .insertContentAt(range, [\n {\n type: 'emoji',\n attrs: props,\n },\n ])\n .run();\n\n window.getSelection()?.collapseToEnd();\n },\n\n render: () => {\n let component;\n let popup;\n let popupIsOpen = false;\n\n return {\n onStart: props => {\n component = new VueRenderer(SuggestionList, {\n parent: this,\n propsData: {\n itemComponent: EmojiSuggestion,\n itemType: 'emoji',\n ...props,\n },\n editor: props.editor,\n });\n\n if (!props.clientRect) {\n return;\n }\n\n popup = tippy('body', {\n getReferenceClientRect: props.clientRect,\n appendTo: () => document.body,\n content: component.element,\n showOnCreate: false,\n onShow: () => { popupIsOpen = true; },\n onHidden: () => { popupIsOpen = false; },\n interactive: true,\n trigger: 'manual',\n placement: 'top-start',\n zIndex: 650,\n plugins: [hideOnEsc],\n });\n\n if (props.items.length > 0) {\n popup?.[0].show();\n }\n },\n\n onUpdate (props) {\n component?.updateProps(props);\n\n if (props.items.length > 0) {\n popup?.[0].show();\n } else {\n popup?.[0].hide();\n }\n popup?.[0].setProps({\n getReferenceClientRect: props.clientRect,\n });\n },\n\n onKeyDown (props) {\n if (popupIsOpen) {\n return component?.ref?.onKeyDown(props);\n }\n },\n\n onExit () {\n popup?.[0].destroy();\n popup = null;\n component?.destroy();\n component = null;\n },\n };\n },\n};\n"],"names":["emojisIndexed","VueRenderer","this","hideOnEsc"],"mappings":";;;;;;;AASA,MAAe,oBAAA;AAAA,EACb,OAAO,CAAC,EAAE,YAAY;AACpB,QAAI,MAAM,SAAS,GAAG;AACpB,aAAO;IACR;AACD,UAAM,YAAY,OAAO,OAAOA,eAAa,aAAA;AAC7C,UAAM,gBAAgB,UAAU,OAAO,SAAU,MAAM;AACrD,UAAI,KAAK,UAAU,UAAU,GAAG,KAAK,UAAU,SAAS,CAAC,EAAE,WAAW,MAAM,YAAa,CAAA,GAAG;AAC1F,eAAO;AAAA,MACR;AACD,aAAO;AAAA,IACb,CAAK;AACD,WAAO,cAAc,IAAI,UAAQ;AAAE,aAAO,EAAE,MAAM,KAAK;IAAY,CAAE;AAAA,EACtE;AAAA,EAED,SAAS,CAAC,EAAE,QAAQ,OAAO,MAAK,MAAO;;AAG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S;AAAA,UAClB,wBAAwB,MAAM;AAAA,QACxC;AAAA,MACO;AAAA,MAED,UAAW,OAAO;;AAChB,YAAI,aAAa;AACf,kBAAO,4CAAW,QAAX,mBAAgB,UAAU;AAAA,QAClC;AAAA,MACF;AAAA,MAED,SAAU;AACR,uCAAQ,GAAG;AACX,gBAAQ;AACR,+CAAW;AACX,oBAAY;AAAA,MACb;AAAA,IACP;AAAA,EACG;AACH;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestion.js","sources":["../../../../../components/rich_text_editor/extensions/emoji/suggestion.js"],"sourcesContent":["import { VueRenderer } from '@tiptap/vue-2';\nimport { emojisIndexed } from '@dialpad/dialtone-emojis';\n\nimport SuggestionList from '../suggestion/SuggestionList.vue';\nimport EmojiSuggestion from './EmojiSuggestion.vue';\n\nimport tippy from 'tippy.js';\nimport hideOnEsc from '../tippy_plugins/hide_on_esc';\n\nexport default {\n items: ({ query }) => {\n if (query.length < 2) {\n return [];\n }\n const emojiList = Object.values(emojisIndexed);\n const filteredEmoji = emojiList.filter(function (item) {\n if (item.shortname.substring(1, item.shortname.length - 1).startsWith(query.toLowerCase())) {\n return true;\n }\n return false;\n });\n return filteredEmoji.map(item => { return { code: item.shortname }; });\n },\n\n command: ({ editor, range, props }) => {\n // increase range.to by one when the next node is of type \"text\"\n // and starts with a space character\n const nodeAfter = editor.view.state.selection.$to.nodeAfter;\n const overrideSpace = nodeAfter?.text?.startsWith(' ');\n\n if (overrideSpace) {\n range.to += 1;\n }\n\n editor\n .chain()\n .focus()\n .insertContentAt(range, [\n {\n type: 'emoji',\n attrs: props,\n },\n
|
|
1
|
+
{"version":3,"file":"suggestion.js","sources":["../../../../../components/rich_text_editor/extensions/emoji/suggestion.js"],"sourcesContent":["import { VueRenderer } from '@tiptap/vue-2';\nimport { emojisIndexed } from '@dialpad/dialtone-emojis';\n\nimport SuggestionList from '../suggestion/SuggestionList.vue';\nimport EmojiSuggestion from './EmojiSuggestion.vue';\n\nimport tippy from 'tippy.js';\nimport hideOnEsc from '../tippy_plugins/hide_on_esc';\n\nexport default {\n items: ({ query }) => {\n if (query.length < 2) {\n return [];\n }\n const emojiList = Object.values(emojisIndexed);\n const filteredEmoji = emojiList.filter(function (item) {\n if (item.shortname.substring(1, item.shortname.length - 1).startsWith(query.toLowerCase())) {\n return true;\n }\n return false;\n });\n return filteredEmoji.map(item => { return { code: item.shortname }; });\n },\n\n command: ({ editor, range, props }) => {\n // increase range.to by one when the next node is of type \"text\"\n // and starts with a space character\n const nodeAfter = editor.view.state.selection.$to.nodeAfter;\n const overrideSpace = nodeAfter?.text?.startsWith(' ');\n\n if (overrideSpace) {\n range.to += 1;\n }\n\n editor\n .chain()\n .focus()\n .insertContentAt(range, [\n {\n type: 'emoji',\n attrs: props,\n },\n ])\n .run();\n\n window.getSelection()?.collapseToEnd();\n },\n\n render: () => {\n let component;\n let popup;\n let popupIsOpen = false;\n\n return {\n onStart: props => {\n component = new VueRenderer(SuggestionList, {\n parent: this,\n propsData: {\n itemComponent: EmojiSuggestion,\n itemType: 'emoji',\n ...props,\n },\n editor: props.editor,\n });\n\n if (!props.clientRect) {\n return;\n }\n\n popup = tippy('body', {\n getReferenceClientRect: props.clientRect,\n appendTo: () => document.body,\n content: component.element,\n showOnCreate: false,\n onShow: () => { popupIsOpen = true; },\n onHidden: () => { popupIsOpen = false; },\n interactive: true,\n trigger: 'manual',\n placement: 'top-start',\n zIndex: 650,\n plugins: [hideOnEsc],\n });\n\n if (props.items.length > 0) {\n popup?.[0].show();\n }\n },\n\n onUpdate (props) {\n component?.updateProps(props);\n\n if (props.items.length > 0) {\n popup?.[0].show();\n } else {\n popup?.[0].hide();\n }\n popup?.[0].setProps({\n getReferenceClientRect: props.clientRect,\n });\n },\n\n onKeyDown (props) {\n if (popupIsOpen) {\n return component?.ref?.onKeyDown(props);\n }\n },\n\n onExit () {\n popup?.[0].destroy();\n popup = null;\n component?.destroy();\n component = null;\n },\n };\n },\n};\n"],"names":["this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ACnB,cAAc;AAAA,UACd,QAAQ,MAAM;AAAE,0BAAc;AAAA,UAAO;AAAA,UACrC,UAAU,MAAM;AAAE,0BAAc;AAAA,UAAQ;AAAA,UACxC,aAAa;AAAA,UACb,SAAS;AAAA,UACT,WAAW;AAAA,UACX,QAAQ;AAAA,UACR,SAAS,CAAC,SAAS;AAAA,QAC7B,CAAS;AAED,YAAI,MAAM,MAAM,SAAS,GAAG;AAC1B,yCAAQ,GAAG;AAAA,QACZ;AAAA,MACF;AAAA,MAED,SAAU,OAAO;AACf,+CAAW,YAAY;AAEvB,YAAI,MAAM,MAAM,SAAS,GAAG;AAC1B,yCAAQ,GAAG;AAAA,QACrB,OAAe;AACL,yCAAQ,GAAG;AAAA,QACZ;AACD,uCAAQ,GAAG,SAAS;AAAA,UAClB,wBAAwB,MAAM;AAAA,QACxC;AAAA,MACO;AAAA,MAED,UAAW,OAAO;;AAChB,YAAI,aAAa;AACf,kBAAO,4CAAW,QAAX,mBAAgB,UAAU;AAAA,QAClC;AAAA,MACF;AAAA,MAED,SAAU;AACR,uCAAQ,GAAG;AACX,gBAAQ;AACR,+CAAW;AACX,oBAAY;AAAA,MACb;AAAA,IACP;AAAA,EACG;AACH;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const ChannelPlugin: import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions, any>;
|
|
1
|
+
export const ChannelPlugin: import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any>;
|
|
2
2
|
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../../../../components/rich_text_editor/extensions/channels/channel.js"],"names":[],"mappings":"AAQA,
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../../../../components/rich_text_editor/extensions/channels/channel.js"],"names":[],"mappings":"AAQA,4KA0CG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emoji.d.ts","sourceRoot":"","sources":["../../../../../../components/rich_text_editor/extensions/emoji/emoji.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"emoji.d.ts","sourceRoot":"","sources":["../../../../../../components/rich_text_editor/extensions/emoji/emoji.js"],"names":[],"mappings":"AAmCA,mCAmHG;qBAtJ6D,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../components/rich_text_editor/extensions/emoji/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../components/rich_text_editor/extensions/emoji/index.js"],"names":[],"mappings":";;sBAAsB,SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestion.d.ts","sourceRoot":"","sources":["../../../../../../components/rich_text_editor/extensions/emoji/suggestion.js"],"names":[],"mappings":";IAUS;;;;QAYN;IAEQ;;;;
|
|
1
|
+
{"version":3,"file":"suggestion.d.ts","sourceRoot":"","sources":["../../../../../../components/rich_text_editor/extensions/emoji/suggestion.js"],"names":[],"mappings":";IAUS;;;;QAYN;IAEQ;;;;aAsBR;IAEO;;;;;MAkEP"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const MentionPlugin: import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions, any>;
|
|
1
|
+
export const MentionPlugin: import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any>;
|
|
2
2
|
//# sourceMappingURL=mention.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mention.d.ts","sourceRoot":"","sources":["../../../../../../components/rich_text_editor/extensions/mentions/mention.js"],"names":[],"mappings":"AAQA,
|
|
1
|
+
{"version":3,"file":"mention.d.ts","sourceRoot":"","sources":["../../../../../../components/rich_text_editor/extensions/mentions/mention.js"],"names":[],"mappings":"AAQA,4KAyCG"}
|
package/dist/vue2/types/components/rich_text_editor/extensions/slash_command/slash_command.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const SlashCommandPlugin: import("@tiptap/vue-2").Node<import("@tiptap/extension-mention").MentionOptions, any>;
|
|
1
|
+
export const SlashCommandPlugin: import("@tiptap/vue-2").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any>;
|
|
2
2
|
//# sourceMappingURL=slash_command.d.ts.map
|
package/dist/vue2/types/components/rich_text_editor/extensions/slash_command/slash_command.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slash_command.d.ts","sourceRoot":"","sources":["../../../../../../components/rich_text_editor/extensions/slash_command/slash_command.js"],"names":[],"mappings":"AAuBA,
|
|
1
|
+
{"version":3,"file":"slash_command.d.ts","sourceRoot":"","sources":["../../../../../../components/rich_text_editor/extensions/slash_command/slash_command.js"],"names":[],"mappings":"AAuBA,kLAuEG"}
|
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const core = require("@tiptap/core");
|
|
4
|
+
const state = require("@tiptap/pm/state");
|
|
4
5
|
const vue3 = require("@tiptap/vue-3");
|
|
6
|
+
const Suggestion = require("@tiptap/suggestion");
|
|
7
|
+
const regexCombinedEmojis = require("regex-combined-emojis");
|
|
5
8
|
const EmojiComponent = require("./EmojiComponent.vue.cjs");
|
|
6
9
|
const common_emoji = require("../../../../common/emoji.cjs");
|
|
7
|
-
const state = require("@tiptap/pm/state");
|
|
8
|
-
const Suggestion = require("@tiptap/suggestion");
|
|
9
10
|
const suggestion = require("./suggestion.cjs");
|
|
10
|
-
const
|
|
11
|
-
const EmojiPluginKey = new state.PluginKey("emoji");
|
|
12
|
-
const inputShortCodeRegex = new RegExp("(^| |(?<=:))(:\\w+:)$");
|
|
11
|
+
const inputShortCodeRegex = /(:\w+:)$/;
|
|
13
12
|
const inputUnicodeRegex = new RegExp(regexCombinedEmojis.emojiPattern + "$");
|
|
14
13
|
const inputRuleMatch = (match) => {
|
|
15
14
|
if (match && common_emoji.codeToEmojiData(match[0])) {
|
|
16
15
|
const text = match[2] || match[0];
|
|
17
|
-
return {
|
|
18
|
-
index: match.index,
|
|
19
|
-
text,
|
|
20
|
-
match
|
|
21
|
-
};
|
|
16
|
+
return { text };
|
|
22
17
|
}
|
|
23
18
|
};
|
|
24
19
|
const shortCodePasteMatch = (text) => {
|
|
@@ -30,19 +25,16 @@ const shortCodePasteMatch = (text) => {
|
|
|
30
25
|
}));
|
|
31
26
|
};
|
|
32
27
|
const Emoji = core.Node.create({
|
|
28
|
+
name: "emoji",
|
|
33
29
|
addOptions() {
|
|
34
30
|
return {
|
|
35
|
-
HTMLAttributes: {}
|
|
36
|
-
suggestion: {
|
|
37
|
-
char: ":",
|
|
38
|
-
pluginKey: EmojiPluginKey
|
|
39
|
-
}
|
|
31
|
+
HTMLAttributes: {}
|
|
40
32
|
};
|
|
41
33
|
},
|
|
42
|
-
name: "emoji",
|
|
43
34
|
group: "inline",
|
|
44
35
|
inline: true,
|
|
45
|
-
selectable:
|
|
36
|
+
selectable: false,
|
|
37
|
+
atom: true,
|
|
46
38
|
addNodeView() {
|
|
47
39
|
return vue3.VueNodeViewRenderer(EmojiComponent);
|
|
48
40
|
},
|
|
@@ -69,32 +61,17 @@ const Emoji = core.Node.create({
|
|
|
69
61
|
},
|
|
70
62
|
addInputRules() {
|
|
71
63
|
return [
|
|
72
|
-
|
|
73
|
-
core.nodeInputRule({
|
|
64
|
+
new core.InputRule({
|
|
74
65
|
find: (text) => {
|
|
75
|
-
const match = text.match(inputShortCodeRegex);
|
|
66
|
+
const match = text.match(inputShortCodeRegex) || text.match(inputUnicodeRegex);
|
|
76
67
|
if (!match) return;
|
|
77
68
|
return inputRuleMatch(match);
|
|
78
69
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
}),
|
|
86
|
-
core.nodeInputRule({
|
|
87
|
-
find: (text) => {
|
|
88
|
-
const match = text.match(inputUnicodeRegex);
|
|
89
|
-
if (!match) return;
|
|
90
|
-
return inputRuleMatch(match);
|
|
91
|
-
},
|
|
92
|
-
type: this.type,
|
|
93
|
-
getAttributes(attrs) {
|
|
94
|
-
const emoji = common_emoji.codeToEmojiData(attrs[0]).shortname;
|
|
95
|
-
return {
|
|
96
|
-
code: emoji
|
|
97
|
-
};
|
|
70
|
+
handler: ({ state: state2, range, match, commands, chain, can }) => {
|
|
71
|
+
const { tr } = state2;
|
|
72
|
+
const start = range.from;
|
|
73
|
+
const end = range.to;
|
|
74
|
+
tr.replaceWith(start, end, this.type.create({ code: match[0] }));
|
|
98
75
|
}
|
|
99
76
|
})
|
|
100
77
|
];
|
|
@@ -124,13 +101,34 @@ const Emoji = core.Node.create({
|
|
|
124
101
|
addProseMirrorPlugins() {
|
|
125
102
|
return [
|
|
126
103
|
Suggestion({
|
|
104
|
+
char: ":",
|
|
105
|
+
pluginKey: new state.PluginKey("emoji"),
|
|
127
106
|
editor: this.editor,
|
|
128
107
|
...this.options.suggestion,
|
|
129
108
|
...suggestion
|
|
130
109
|
})
|
|
131
110
|
];
|
|
111
|
+
},
|
|
112
|
+
addKeyboardShortcuts() {
|
|
113
|
+
return {
|
|
114
|
+
Backspace: () => this.editor.commands.command(({ tr, state: state2 }) => {
|
|
115
|
+
let isEmoji = false;
|
|
116
|
+
const { selection } = state2;
|
|
117
|
+
const { empty, anchor } = selection;
|
|
118
|
+
if (!empty) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
state2.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
|
|
122
|
+
if (node.type.name === this.name) {
|
|
123
|
+
isEmoji = true;
|
|
124
|
+
tr.insertText("", pos, pos + node.nodeSize);
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
return isEmoji;
|
|
129
|
+
})
|
|
130
|
+
};
|
|
132
131
|
}
|
|
133
132
|
});
|
|
134
133
|
exports.Emoji = Emoji;
|
|
135
|
-
exports.EmojiPluginKey = EmojiPluginKey;
|
|
136
134
|
//# sourceMappingURL=emoji.cjs.map
|