@frontify/fondue 12.0.0-beta.276 → 12.0.0-beta.277
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/components/RichTextEditor/Plugins/MentionPlugin/MentionInline.es.js +15 -11
- package/dist/components/RichTextEditor/Plugins/MentionPlugin/MentionInline.es.js.map +1 -1
- package/dist/components/RichTextEditor/Plugins/MentionPlugin/config.es.js +1 -0
- package/dist/components/RichTextEditor/Plugins/MentionPlugin/config.es.js.map +1 -1
- package/dist/components/RichTextEditor/Plugins/MentionPlugin/getMentionOnSelectItem.d.ts +8 -0
- package/dist/components/RichTextEditor/Plugins/MentionPlugin/getMentionOnSelectItem.es.js +29 -0
- package/dist/components/RichTextEditor/Plugins/MentionPlugin/getMentionOnSelectItem.es.js.map +1 -0
- package/dist/components/RichTextEditor/Plugins/MentionPlugin/types.d.ts +1 -0
- package/dist/components/RichTextEditor/Plugins/MentionPlugin/types.es.js.map +1 -1
- package/dist/index.cjs.js +12 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.umd.js +14 -14
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import o from "react";
|
|
2
|
-
import { MentionCombobox as m, autoUpdate as r } from "@udecode/plate";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
2
|
+
import { MentionCombobox as m, autoUpdate as n, ELEMENT_MENTION as r } from "@udecode/plate";
|
|
3
|
+
import { getMentionOnSelectItem as i } from "./getMentionOnSelectItem.es.js";
|
|
4
|
+
import { filterItems as l } from "./helpers/filterItems.es.js";
|
|
5
|
+
import { MentionComboboxItem as p } from "./MentionCombobox/MentionComboboxItem.es.js";
|
|
6
|
+
import { MentionComboboxStyles as a } from "./MentionCombobox/MentionComboboxStyles.es.js";
|
|
7
|
+
const c = (t) => () => /* @__PURE__ */ o.createElement(
|
|
7
8
|
m,
|
|
8
9
|
{
|
|
9
10
|
items: t,
|
|
10
|
-
filter:
|
|
11
|
-
onRenderItem:
|
|
12
|
-
styles:
|
|
11
|
+
filter: l,
|
|
12
|
+
onRenderItem: p,
|
|
13
|
+
styles: a,
|
|
13
14
|
classNames: {
|
|
14
15
|
item: "tw-group",
|
|
15
16
|
highlightedItem: "tw-group"
|
|
16
17
|
},
|
|
17
18
|
floatingOptions: {
|
|
18
19
|
whileElementsMounted(...e) {
|
|
19
|
-
return
|
|
20
|
+
return n(...e, { animationFrame: !0 });
|
|
20
21
|
}
|
|
21
|
-
}
|
|
22
|
+
},
|
|
23
|
+
onSelectItem: i({
|
|
24
|
+
key: r
|
|
25
|
+
})
|
|
22
26
|
}
|
|
23
27
|
);
|
|
24
28
|
export {
|
|
25
|
-
|
|
29
|
+
c as MentionInline
|
|
26
30
|
};
|
|
27
31
|
//# sourceMappingURL=MentionInline.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MentionInline.es.js","sources":["../../../../../src/components/RichTextEditor/Plugins/MentionPlugin/MentionInline.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React from 'react';\nimport { MentionCombobox, autoUpdate } from '@udecode/plate';\nimport { MentionComboboxItem, MentionComboboxStyles } from './MentionCombobox';\nimport { MentionableItems } from './types';\nimport { filterItems } from './helpers';\n\n// eslint-disable-next-line react/display-name\nexport const MentionInline = (items: MentionableItems) => () => {\n return (\n <MentionCombobox\n items={items}\n filter={filterItems}\n onRenderItem={MentionComboboxItem}\n styles={MentionComboboxStyles}\n classNames={{\n item: 'tw-group',\n highlightedItem: 'tw-group',\n }}\n floatingOptions={{\n whileElementsMounted(...args) {\n return autoUpdate(...args, { animationFrame: true });\n },\n }}\n />\n );\n};\n"],"names":["MentionInline","items","React","MentionCombobox","filterItems","MentionComboboxItem","MentionComboboxStyles","args","autoUpdate"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MentionInline.es.js","sources":["../../../../../src/components/RichTextEditor/Plugins/MentionPlugin/MentionInline.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React from 'react';\nimport { ELEMENT_MENTION, MentionCombobox, autoUpdate } from '@udecode/plate';\nimport { MentionComboboxItem, MentionComboboxStyles } from './MentionCombobox';\nimport { MentionableItems } from './types';\nimport { filterItems } from './helpers';\nimport { getMentionOnSelectItem } from './getMentionOnSelectItem';\n\n// eslint-disable-next-line react/display-name\nexport const MentionInline = (items: MentionableItems) => () => {\n return (\n <MentionCombobox\n items={items}\n filter={filterItems}\n onRenderItem={MentionComboboxItem}\n styles={MentionComboboxStyles}\n classNames={{\n item: 'tw-group',\n highlightedItem: 'tw-group',\n }}\n floatingOptions={{\n whileElementsMounted(...args) {\n return autoUpdate(...args, { animationFrame: true });\n },\n }}\n onSelectItem={getMentionOnSelectItem({\n key: ELEMENT_MENTION,\n })}\n />\n );\n};\n"],"names":["MentionInline","items","React","MentionCombobox","filterItems","MentionComboboxItem","MentionComboboxStyles","args","autoUpdate","getMentionOnSelectItem","ELEMENT_MENTION"],"mappings":";;;;;;AAUa,MAAAA,IAAgB,CAACC,MAA4B,MAElD,gBAAAC,EAAA;AAAA,EAACC;AAAA,EAAA;AAAA,IACG,OAAAF;AAAA,IACA,QAAQG;AAAA,IACR,cAAcC;AAAA,IACd,QAAQC;AAAA,IACR,YAAY;AAAA,MACR,MAAM;AAAA,MACN,iBAAiB;AAAA,IACrB;AAAA,IACA,iBAAiB;AAAA,MACb,wBAAwBC,GAAM;AAC1B,eAAOC,EAAW,GAAGD,GAAM,EAAE,gBAAgB,GAAM,CAAA;AAAA,MACvD;AAAA,IACJ;AAAA,IACA,cAAcE,EAAuB;AAAA,MACjC,KAAKC;AAAA,IAAA,CACR;AAAA,EAAA;AAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.es.js","sources":["../../../../../src/components/RichTextEditor/Plugins/MentionPlugin/config.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { MentionItemData, MentionPlugin } from './types';\n\nexport const mentionPlugin: MentionPlugin<MentionItemData> = {\n options: {\n trigger: '@',\n createMentionNode: (item) => ({\n value: item.text,\n category: item.data.category,\n id: item.data.id,\n }),\n },\n};\n"],"names":["mentionPlugin","item"],"mappings":"AAIO,MAAMA,IAAgD;AAAA,EACzD,SAAS;AAAA,IACL,SAAS;AAAA,IACT,mBAAmB,CAACC,OAAU;AAAA,MAC1B,OAAOA,EAAK;AAAA,MACZ,UAAUA,EAAK,KAAK;AAAA,MACpB,IAAIA,EAAK,KAAK;AAAA,IAAA;AAAA,EAEtB;AACJ;"}
|
|
1
|
+
{"version":3,"file":"config.es.js","sources":["../../../../../src/components/RichTextEditor/Plugins/MentionPlugin/config.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { MentionItemData, MentionPlugin } from './types';\n\nexport const mentionPlugin: MentionPlugin<MentionItemData> = {\n options: {\n trigger: '@',\n insertSpaceAfterMention: true,\n createMentionNode: (item) => ({\n value: item.text,\n category: item.data.category,\n id: item.data.id,\n }),\n },\n};\n"],"names":["mentionPlugin","item"],"mappings":"AAIO,MAAMA,IAAgD;AAAA,EACzD,SAAS;AAAA,IACL,SAAS;AAAA,IACT,yBAAyB;AAAA,IACzB,mBAAmB,CAACC,OAAU;AAAA,MAC1B,OAAOA,EAAK;AAAA,MACZ,UAAUA,EAAK,KAAK;AAAA,MACpB,IAAIA,EAAK,KAAK;AAAA,IAAA;AAAA,EAEtB;AACJ;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ComboboxOnSelectItem, Data, PlatePluginKey, TComboboxItem, TMentionElement, TNodeProps } from '@udecode/plate';
|
|
2
|
+
export interface CreateMentionNode<TData extends Data> {
|
|
3
|
+
(item: TComboboxItem<TData>, meta: CreateMentionNodeMeta): TNodeProps<TMentionElement>;
|
|
4
|
+
}
|
|
5
|
+
export interface CreateMentionNodeMeta {
|
|
6
|
+
search: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const getMentionOnSelectItem: <TData extends unknown = undefined>({ key }?: PlatePluginKey) => ComboboxOnSelectItem<TData>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { comboboxSelectors as o, getPlugin as p, withoutNormalizing as a, select as l, withoutMergingHistory as u, removeNodes as f, isNodeMentionInput as x, insertNodes as N, moveSelection as h, insertText as M, comboboxActions as b, ELEMENT_MENTION as E } from "@udecode/plate";
|
|
2
|
+
const I = ({ key: s = E } = {}) => (t, c) => {
|
|
3
|
+
const n = o.targetRange();
|
|
4
|
+
if (!n)
|
|
5
|
+
return;
|
|
6
|
+
const {
|
|
7
|
+
type: i,
|
|
8
|
+
options: { insertSpaceAfterMention: r, createMentionNode: e }
|
|
9
|
+
} = p(t, s);
|
|
10
|
+
return a(t, () => {
|
|
11
|
+
const g = e == null ? void 0 : e(c, {
|
|
12
|
+
search: o.text() ?? ""
|
|
13
|
+
});
|
|
14
|
+
l(t, n), u(
|
|
15
|
+
t,
|
|
16
|
+
() => f(t, {
|
|
17
|
+
match: (m) => x(t, m)
|
|
18
|
+
})
|
|
19
|
+
), N(t, {
|
|
20
|
+
type: i,
|
|
21
|
+
children: [{ text: "" }],
|
|
22
|
+
...g
|
|
23
|
+
}), h(t, { unit: "offset" }), r && M(t, " ");
|
|
24
|
+
}), b.reset();
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
I as getMentionOnSelectItem
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=getMentionOnSelectItem.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMentionOnSelectItem.es.js","sources":["../../../../../src/components/RichTextEditor/Plugins/MentionPlugin/getMentionOnSelectItem.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n ComboboxOnSelectItem,\n Data,\n ELEMENT_MENTION,\n MentionPlugin,\n NoData,\n PlateEditor,\n PlatePluginKey,\n TComboboxItem,\n TMentionElement,\n TNodeProps,\n Value,\n comboboxActions,\n comboboxSelectors,\n getPlugin,\n insertNodes,\n insertText,\n isNodeMentionInput,\n moveSelection,\n removeNodes,\n select,\n withoutMergingHistory,\n withoutNormalizing,\n} from '@udecode/plate';\n\nexport interface CreateMentionNode<TData extends Data> {\n (item: TComboboxItem<TData>, meta: CreateMentionNodeMeta): TNodeProps<TMentionElement>;\n}\n\nexport interface CreateMentionNodeMeta {\n search: string;\n}\n\nexport const getMentionOnSelectItem =\n <TData extends Data = NoData>({ key = ELEMENT_MENTION }: PlatePluginKey = {}): ComboboxOnSelectItem<TData> =>\n (editor, item) => {\n const targetRange = comboboxSelectors.targetRange();\n if (!targetRange) {\n return;\n }\n\n const {\n type,\n options: { insertSpaceAfterMention, createMentionNode },\n } = getPlugin<MentionPlugin>(editor as PlateEditor<Value>, key);\n\n withoutNormalizing(editor, () => {\n // Selectors are sensitive to operations, it's better to create everything\n // before the editor state is changed. For example, asking for text after\n // removeNodes below will return null.\n const props = createMentionNode?.(item, {\n search: comboboxSelectors.text() ?? '',\n });\n\n select(editor, targetRange);\n\n withoutMergingHistory(editor, () =>\n removeNodes(editor, {\n match: (node) => isNodeMentionInput(editor, node),\n }),\n );\n\n insertNodes<TMentionElement>(editor, {\n type,\n children: [{ text: '' }],\n ...props,\n } as TMentionElement);\n\n // move the selection after the element\n moveSelection(editor, { unit: 'offset' });\n\n if (insertSpaceAfterMention) {\n insertText(editor, ' ');\n }\n });\n\n return comboboxActions.reset();\n };\n"],"names":["getMentionOnSelectItem","key","ELEMENT_MENTION","editor","item","targetRange","comboboxSelectors","type","insertSpaceAfterMention","createMentionNode","getPlugin","withoutNormalizing","props","select","withoutMergingHistory","removeNodes","node","isNodeMentionInput","insertNodes","moveSelection","insertText","comboboxActions"],"mappings":";AAmCa,MAAAA,IACT,CAA8B,EAAE,KAAAC,IAAMC,MAAoC,OAC1E,CAACC,GAAQC,MAAS;AACR,QAAAC,IAAcC,EAAkB;AACtC,MAAI,CAACD;AACD;AAGE,QAAA;AAAA,IACF,MAAAE;AAAA,IACA,SAAS,EAAE,yBAAAC,GAAyB,mBAAAC,EAAkB;AAAA,EAAA,IACtDC,EAAyBP,GAA8BF,CAAG;AAE9D,SAAAU,EAAmBR,GAAQ,MAAM;AAIvB,UAAAS,IAAQH,KAAA,gBAAAA,EAAoBL,GAAM;AAAA,MACpC,QAAQE,EAAkB,KAAA,KAAU;AAAA,IAAA;AAGxC,IAAAO,EAAOV,GAAQE,CAAW,GAE1BS;AAAA,MAAsBX;AAAA,MAAQ,MAC1BY,EAAYZ,GAAQ;AAAA,QAChB,OAAO,CAACa,MAASC,EAAmBd,GAAQa,CAAI;AAAA,MAAA,CACnD;AAAA,IAAA,GAGLE,EAA6Bf,GAAQ;AAAA,MACjC,MAAAI;AAAA,MACA,UAAU,CAAC,EAAE,MAAM,IAAI;AAAA,MACvB,GAAGK;AAAA,IAAA,CACa,GAGpBO,EAAchB,GAAQ,EAAE,MAAM,SAAU,CAAA,GAEpCK,KACAY,EAAWjB,GAAQ,GAAG;AAAA,EAC1B,CACH,GAEMkB,EAAgB;AAC3B;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.es.js","sources":["../../../../../src/components/RichTextEditor/Plugins/MentionPlugin/types.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { CreateMentionNode, Data, NoData, TComboboxItemWithData, WithOverride } from '@udecode/plate';\nimport { PluginProps } from '../Plugin';\n\nexport enum MentionableCategory {\n GROUP = 'group',\n ALL = 'all',\n USER = 'user',\n}\n\nexport type MentionItemData = {\n id: string;\n category: MentionableCategory;\n image?: string;\n};\n\nexport type MentionableItem = TComboboxItemWithData<MentionItemData>;\n\nexport type MentionableItems = MentionableItem[];\n\nexport type MentionPluginProps = PluginProps & {\n mentionableItems: MentionableItems;\n};\n\nexport type MappedMentionableItems = Map<string, string>;\n\nexport interface MentionPlugin<TData extends Data = NoData> {\n withOverrides?: WithOverride;\n options: {\n trigger: string;\n createMentionNode?: CreateMentionNode<TData>;\n };\n}\n"],"names":["MentionableCategory"],"mappings":"AAKY,IAAAA,sBAAAA,OACRA,EAAA,QAAQ,SACRA,EAAA,MAAM,OACNA,EAAA,OAAO,QAHCA,IAAAA,KAAA,CAAA,CAAA;"}
|
|
1
|
+
{"version":3,"file":"types.es.js","sources":["../../../../../src/components/RichTextEditor/Plugins/MentionPlugin/types.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { CreateMentionNode, Data, NoData, TComboboxItemWithData, WithOverride } from '@udecode/plate';\nimport { PluginProps } from '../Plugin';\n\nexport enum MentionableCategory {\n GROUP = 'group',\n ALL = 'all',\n USER = 'user',\n}\n\nexport type MentionItemData = {\n id: string;\n category: MentionableCategory;\n image?: string;\n};\n\nexport type MentionableItem = TComboboxItemWithData<MentionItemData>;\n\nexport type MentionableItems = MentionableItem[];\n\nexport type MentionPluginProps = PluginProps & {\n mentionableItems: MentionableItems;\n};\n\nexport type MappedMentionableItems = Map<string, string>;\n\nexport interface MentionPlugin<TData extends Data = NoData> {\n withOverrides?: WithOverride;\n options: {\n trigger: string;\n insertSpaceAfterMention: boolean;\n createMentionNode?: CreateMentionNode<TData>;\n };\n}\n"],"names":["MentionableCategory"],"mappings":"AAKY,IAAAA,sBAAAA,OACRA,EAAA,QAAQ,SACRA,EAAA,MAAM,OACNA,EAAA,OAAO,QAHCA,IAAAA,KAAA,CAAA,CAAA;"}
|