@frontify/fondue 12.0.0-beta.310 → 12.0.0-beta.312

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.
@@ -1 +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
+ {"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 unknown 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,GAAyCF,CAAG;AAEzE,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;"}