@frontify/guideline-blocks-settings 0.28.1 → 0.28.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/CHANGELOG.md +11 -0
- package/dist/components/Attachments/AttachmentItem.es.js +54 -54
- package/dist/components/Attachments/AttachmentItem.es.js.map +1 -1
- package/dist/components/Attachments/Attachments.es.js +69 -69
- package/dist/components/Attachments/Attachments.es.js.map +1 -1
- package/dist/components/BlockInjectButton/BlockInjectButton.es.js +42 -42
- package/dist/components/BlockInjectButton/BlockInjectButton.es.js.map +1 -1
- package/dist/components/BlockItemWrapper/BlockItemWrapper.es.js +28 -28
- package/dist/components/BlockItemWrapper/BlockItemWrapper.es.js.map +1 -1
- package/dist/components/BlockItemWrapper/Toolbar.es.js.map +1 -1
- package/dist/components/RichTextEditor/RichTextEditor.es.js +23 -23
- package/dist/components/RichTextEditor/RichTextEditor.es.js.map +1 -1
- package/dist/components/RichTextEditor/SerializedText.es.js +7 -7
- package/dist/components/RichTextEditor/SerializedText.es.js.map +1 -1
- package/dist/components/RichTextEditor/pluginPresets/defaultPluginsWithLinkChooser.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/ButtonMarkupElement/ButtonMarkupElementNode.es.js +11 -11
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/ButtonMarkupElement/ButtonMarkupElementNode.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/ButtonToolbarButton.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/FloatingButtonEditButton.es.js +10 -10
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/FloatingButtonEditButton.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/FloatingButtonUrlInput.es.js +13 -13
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/FloatingButtonUrlInput.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/InsertButtonModal.es.js +2 -2
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/InsertButtonModal.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/useInsertModal.es.js +30 -30
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/useInsertModal.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/UnlinkButton.es.js +7 -7
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/UnlinkButton.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEdit.es.js +30 -30
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEdit.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEnter.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEscape.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonInsert.es.js +8 -8
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonInsert.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/createButtonPlugin.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/insertButton.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/unwrapButton.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButton.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButtonText.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/wrapButton.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/createButtonNode.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButton.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButtonInsert.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/withButton.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/useFloatingLinkEdit.es.js +30 -30
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/useFloatingLinkEdit.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useFloatingLinkInsert.es.js +7 -7
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useFloatingLinkInsert.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useInsertModal.es.js +29 -29
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useInsertModal.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/LinkPlugin/LinkButton.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/LinkPlugin/utils/url.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/DocumentLink.es.js +14 -14
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/DocumentLink.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/DocumentLinks.es.js +27 -27
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/DocumentLinks.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/LinkSelector.es.js +27 -27
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/LinkSelector.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/PageLink.es.js +15 -15
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/PageLink.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/PageLinks.es.js +13 -13
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/PageLinks.es.js.map +1 -1
- package/dist/components/RichTextEditor/serializer/nodes/button.es.js.map +1 -1
- package/dist/components/RichTextEditor/serializer/nodes/checkItemNode.es.js.map +1 -1
- package/dist/components/RichTextEditor/serializer/nodes/default.es.js.map +1 -1
- package/dist/components/RichTextEditor/serializer/nodes/link.es.js.map +1 -1
- package/dist/components/RichTextEditor/serializer/nodes/mentionHtmlNode.es.js +1 -1
- package/dist/components/RichTextEditor/serializer/serializeNodesToHtmlRecursive.es.js.map +1 -1
- package/dist/components/RichTextEditor/serializer/serializeToHtml.es.js.map +1 -1
- package/dist/components/RichTextEditor/serializer/utlis/reactCssPropsToCss.es.js.map +1 -1
- package/dist/components/RichTextEditor/serializer/utlis/serializeLeafToHtml.es.js.map +1 -1
- package/dist/helpers/addHttps.es.js.map +1 -1
- package/dist/helpers/customCoordinatesGetterFactory.es.js.map +1 -1
- package/dist/helpers/hasRichTextValue.es.js.map +1 -1
- package/dist/hooks/useAttachments.es.js.map +1 -1
- package/dist/hooks/useDndSensors.es.js.map +1 -1
- package/dist/index.cjs.js +22 -229
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +12 -10
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +22 -229
- package/dist/index.umd.js.map +1 -1
- package/dist/settings/background.es.js.map +1 -1
- package/dist/settings/border.es.js +1 -1
- package/dist/settings/border.es.js.map +1 -1
- package/dist/settings/borderRadius.es.js +1 -1
- package/dist/settings/borderRadius.es.js.map +1 -1
- package/dist/settings/borderRadiusExtended.es.js +1 -1
- package/dist/settings/borderRadiusExtended.es.js.map +1 -1
- package/dist/settings/gutter.es.js +1 -1
- package/dist/settings/margin.es.js +1 -1
- package/dist/settings/margin.es.js.map +1 -1
- package/dist/settings/marginExtended.es.js +1 -1
- package/dist/settings/marginExtended.es.js.map +1 -1
- package/dist/settings/padding.es.js +1 -1
- package/dist/settings/padding.es.js.map +1 -1
- package/dist/settings/paddingExtended.es.js +1 -1
- package/dist/settings/paddingExtended.es.js.map +1 -1
- package/dist/settings/securityGlobalControl.es.js +1 -1
- package/dist/styles.css +1 -0
- package/dist/styles.css.es.js +5 -0
- package/dist/styles.css.es.js.map +1 -0
- package/dist/utilities/moveItemInArray.es.js.map +1 -1
- package/dist/utilities/react/getBorderStyles.es.js.map +1 -1
- package/package.json +25 -24
- package/src/components/Attachments/AttachmentItem.tsx +2 -2
- package/src/components/Attachments/Attachments.spec.ct.tsx +4 -4
- package/src/components/Attachments/Attachments.tsx +2 -2
- package/src/components/BlockInjectButton/BlockInjectButton.spec.ct.tsx +2 -2
- package/src/components/BlockItemWrapper/BlockItemWrapper.spec.ct.tsx +8 -8
- package/src/components/BlockItemWrapper/Toolbar.tsx +1 -1
- package/src/components/RichTextEditor/RichTextEditor.spec.ct.tsx +8 -8
- package/src/components/RichTextEditor/pluginPresets/defaultPluginsWithLinkChooser.tsx +2 -2
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/ButtonToolbarButton.tsx +1 -1
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/FloatingButtonUrlInput.tsx +1 -1
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/useInsertModal.ts +1 -1
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEdit.ts +1 -1
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEnter.ts +1 -1
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEscape.ts +1 -1
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonInsert.ts +1 -1
- package/src/components/RichTextEditor/plugins/ButtonPlugin/createButtonPlugin.ts +2 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/insertButton.ts +2 -2
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/unwrapButton.ts +1 -1
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButton.ts +5 -5
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/wrapButton.ts +2 -2
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/createButtonNode.ts +1 -1
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButton.ts +1 -1
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButtonInsert.ts +1 -1
- package/src/components/RichTextEditor/plugins/ButtonPlugin/withButton.ts +1 -1
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/useFloatingLinkEdit.ts +1 -1
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useFloatingLinkInsert.ts +1 -1
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useInsertModal.ts +1 -1
- package/src/components/RichTextEditor/plugins/LinkPlugin/LinkButton.tsx +1 -1
- package/src/components/RichTextEditor/plugins/LinkPlugin/utils/relativeUrlRegex.spec.ts +24 -27
- package/src/components/RichTextEditor/serializer/nodes/checkItemNode.ts +1 -1
- package/src/components/RichTextEditor/serializer/nodes/default.ts +2 -2
- package/src/components/RichTextEditor/serializer/nodes/link.ts +1 -1
- package/src/components/RichTextEditor/serializer/serializeNodesToHtmlRecursive.ts +4 -4
- package/src/components/RichTextEditor/serializer/serializeToHtml.ts +2 -2
- package/src/hooks/useAttachments.ts +1 -1
- package/src/hooks/useDndSensors.ts +1 -1
- package/src/index.ts +3 -3
- package/src/settings/background.spec.ts +1 -1
- package/src/settings/border.spec.ts +1 -1
- package/src/settings/borderRadiusExtended.spec.ts +4 -4
- package/src/settings/marginExtended.spec.ts +4 -4
- package/src/settings/paddingExtended.spec.ts +4 -4
- package/src/styles.css +3 -0
- package/src/utilities/react/getBorderStyles.ts +1 -1
- package/vite.config.ts +22 -2
- package/dist/_virtual/_commonjsHelpers.es.js +0 -7
- package/dist/_virtual/_commonjsHelpers.es.js.map +0 -1
- package/dist/_virtual/index.es.js +0 -5
- package/dist/_virtual/index.es.js.map +0 -1
- package/dist/_virtual/index.es2.js +0 -5
- package/dist/_virtual/index.es2.js.map +0 -1
- package/dist/_virtual/index.es3.js +0 -5
- package/dist/_virtual/index.es3.js.map +0 -1
- package/dist/_virtual/react-dom.development.es.js +0 -5
- package/dist/_virtual/react-dom.development.es.js.map +0 -1
- package/dist/_virtual/react-dom.production.min.es.js +0 -5
- package/dist/_virtual/react-dom.production.min.es.js.map +0 -1
- package/dist/_virtual/react.development.es.js +0 -5
- package/dist/_virtual/react.development.es.js.map +0 -1
- package/dist/_virtual/react.production.min.es.js +0 -5
- package/dist/_virtual/react.production.min.es.js.map +0 -1
- package/dist/_virtual/scheduler.development.es.js +0 -5
- package/dist/_virtual/scheduler.development.es.js.map +0 -1
- package/dist/_virtual/scheduler.production.min.es.js +0 -5
- package/dist/_virtual/scheduler.production.min.es.js.map +0 -1
- package/dist/style.css +0 -1
package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/insertButton.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insertButton.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/transforms/insertButton.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { InsertNodesOptions, PlateEditor, TText, Value, insertNodes } from '@udecode/plate';\nimport { TButtonElement } from '../types';\nimport { CreateButtonNodeOptions, createButtonNode } from '../utils/index';\n\nexport const insertButton = <V extends Value>(\n editor: PlateEditor<V>,\n createButtonNodeOptions: CreateButtonNodeOptions,\n options?: InsertNodesOptions<V
|
|
1
|
+
{"version":3,"file":"insertButton.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/transforms/insertButton.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { InsertNodesOptions, PlateEditor, TText, Value, insertNodes } from '@udecode/plate';\nimport { TButtonElement } from '../types';\nimport { CreateButtonNodeOptions, createButtonNode } from '../utils/index';\n\nexport const insertButton = <V extends Value>(\n editor: PlateEditor<V>,\n createButtonNodeOptions: CreateButtonNodeOptions,\n options?: InsertNodesOptions<V>,\n) => {\n insertNodes<TButtonElement | TText>(\n editor,\n [createButtonNode(editor, createButtonNodeOptions)],\n options as InsertNodesOptions,\n );\n};\n"],"names":["insertButton","editor","createButtonNodeOptions","options","insertNodes","createButtonNode"],"mappings":";;AAMO,MAAMA,IAAe,CACxBC,GACAC,GACAC,MACC;AACD,EAAAC;AAAA,IACIH;AAAA,IACA,CAACI,EAAiBJ,GAAQC,CAAuB,CAAC;AAAA,IAClDC;AAAA,EAAA;AAER;"}
|
package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/unwrapButton.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unwrapButton.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/transforms/unwrapButton.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n PlateEditor,\n UnwrapNodesOptions,\n Value,\n getAboveNode,\n getPluginType,\n isElement,\n splitNodes,\n unwrapNodes,\n withoutNormalizing,\n} from '@udecode/plate';\nimport { ELEMENT_BUTTON } from '../createButtonPlugin';\n\n/**\n * Unwrap button node.\n */\nexport const unwrapButton = <V extends Value>(\n editor: PlateEditor<V>,\n options?: UnwrapNodesOptions & {\n split?: boolean;\n }
|
|
1
|
+
{"version":3,"file":"unwrapButton.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/transforms/unwrapButton.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n PlateEditor,\n UnwrapNodesOptions,\n Value,\n getAboveNode,\n getPluginType,\n isElement,\n splitNodes,\n unwrapNodes,\n withoutNormalizing,\n} from '@udecode/plate';\nimport { ELEMENT_BUTTON } from '../createButtonPlugin';\n\n/**\n * Unwrap button node.\n */\nexport const unwrapButton = <V extends Value>(\n editor: PlateEditor<V>,\n options?: UnwrapNodesOptions & {\n split?: boolean;\n },\n) => {\n return withoutNormalizing(editor, () => {\n if (options?.split) {\n const buttonAboveAnchor = getAboveNode(editor, {\n at: editor.selection?.anchor,\n match: { type: getPluginType(editor, ELEMENT_BUTTON) },\n });\n\n // anchor in button\n if (buttonAboveAnchor) {\n splitNodes(editor, {\n at: editor.selection?.anchor,\n match: (n) => isElement(n) && n.type === getPluginType(editor, ELEMENT_BUTTON),\n });\n unwrapButton(editor, {\n at: editor.selection?.anchor,\n });\n return true;\n }\n const buttonAboveFocus = getAboveNode(editor, {\n at: editor.selection?.focus,\n match: { type: getPluginType(editor, ELEMENT_BUTTON) },\n });\n\n // focus in button\n if (buttonAboveFocus) {\n splitNodes(editor, {\n at: editor.selection?.focus,\n match: (n) => isElement(n) && n.type === getPluginType(editor, ELEMENT_BUTTON),\n });\n unwrapButton(editor, {\n at: editor.selection?.focus,\n });\n return true;\n }\n }\n\n unwrapNodes(editor, {\n match: { type: getPluginType(editor, ELEMENT_BUTTON) },\n ...options,\n });\n\n return;\n });\n};\n"],"names":["unwrapButton","editor","options","withoutNormalizing","getAboveNode","_a","getPluginType","ELEMENT_BUTTON","splitNodes","_b","n","isElement","_c","_d","_e","_f","unwrapNodes"],"mappings":";;AAkBa,MAAAA,IAAe,CACxBC,GACAC,MAIOC,EAAmBF,GAAQ,MAAM;;AACpC,MAAIC,KAAA,QAAAA,EAAS,OAAO;AAOhB,QAN0BE,EAAaH,GAAQ;AAAA,MAC3C,KAAII,IAAAJ,EAAO,cAAP,gBAAAI,EAAkB;AAAA,MACtB,OAAO,EAAE,MAAMC,EAAcL,GAAQM,CAAc,EAAE;AAAA,IAAA,CACxD;AAIG,aAAAC,EAAWP,GAAQ;AAAA,QACf,KAAIQ,IAAAR,EAAO,cAAP,gBAAAQ,EAAkB;AAAA,QACtB,OAAO,CAACC,MAAMC,EAAUD,CAAC,KAAKA,EAAE,SAASJ,EAAcL,GAAQM,CAAc;AAAA,MAAA,CAChF,GACDP,EAAaC,GAAQ;AAAA,QACjB,KAAIW,IAAAX,EAAO,cAAP,gBAAAW,EAAkB;AAAA,MAAA,CACzB,GACM;AAQX,QANyBR,EAAaH,GAAQ;AAAA,MAC1C,KAAIY,IAAAZ,EAAO,cAAP,gBAAAY,EAAkB;AAAA,MACtB,OAAO,EAAE,MAAMP,EAAcL,GAAQM,CAAc,EAAE;AAAA,IAAA,CACxD;AAIG,aAAAC,EAAWP,GAAQ;AAAA,QACf,KAAIa,IAAAb,EAAO,cAAP,gBAAAa,EAAkB;AAAA,QACtB,OAAO,CAACJ,MAAMC,EAAUD,CAAC,KAAKA,EAAE,SAASJ,EAAcL,GAAQM,CAAc;AAAA,MAAA,CAChF,GACDP,EAAaC,GAAQ;AAAA,QACjB,KAAIc,IAAAd,EAAO,cAAP,gBAAAc,EAAkB;AAAA,MAAA,CACzB,GACM;AAAA,EAEf;AAEA,EAAAC,EAAYf,GAAQ;AAAA,IAChB,OAAO,EAAE,MAAMK,EAAcL,GAAQM,CAAc,EAAE;AAAA,IACrD,GAAGL;AAAA,EAAA,CACN;AAED,CACH;"}
|
package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButton.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsertButton.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButton.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n InsertNodesOptions,\n PlateEditor,\n TNode,\n TNodeEntry,\n UnwrapNodesOptions,\n Value,\n WrapNodesOptions,\n findNode,\n getAboveNode,\n getEditorString,\n getNodeLeaf,\n getNodeProps,\n getPluginOptions,\n getPluginType,\n isDefined,\n isExpanded,\n removeNodes,\n setNodes,\n} from '@udecode/plate';\nimport { Path } from 'slate';\nimport { ButtonPlugin, ELEMENT_BUTTON } from '../createButtonPlugin';\nimport { RichTextButtonStyle, TButtonElement } from '../types';\nimport { CreateButtonNodeOptions } from '../utils/index';\nimport { insertButton, unwrapButton, upsertButtonText, wrapButton } from '.';\n\nexport type UpsertButtonOptions<V extends Value = Value> = CreateButtonNodeOptions & {\n /**\n * If true, insert text when selection is in url.\n */\n insertTextInButton?: boolean;\n insertNodesOptions?: InsertNodesOptions<V>;\n unwrapNodesOptions?: UnwrapNodesOptions<V>;\n wrapNodesOptions?: WrapNodesOptions<V>;\n isUrl?: (url: string) => boolean;\n};\n\n/**\n * If selection in a button or is not url:\n * - insert text with url, exit\n * If selection is expanded or `update` in a button:\n * - remove button node, get button text\n * Then:\n * - insert button node\n */\nexport const upsertButton = <V extends Value>(\n editor: PlateEditor<V>,\n {\n url,\n text,\n buttonStyle,\n target,\n insertTextInButton,\n insertNodesOptions,\n isUrl = getPluginOptions<ButtonPlugin, V>(editor, ELEMENT_BUTTON).isUrl,\n }: UpsertButtonOptions<V
|
|
1
|
+
{"version":3,"file":"upsertButton.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButton.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n InsertNodesOptions,\n PlateEditor,\n TNode,\n TNodeEntry,\n UnwrapNodesOptions,\n Value,\n WrapNodesOptions,\n findNode,\n getAboveNode,\n getEditorString,\n getNodeLeaf,\n getNodeProps,\n getPluginOptions,\n getPluginType,\n isDefined,\n isExpanded,\n removeNodes,\n setNodes,\n} from '@udecode/plate';\nimport { Path } from 'slate';\nimport { ButtonPlugin, ELEMENT_BUTTON } from '../createButtonPlugin';\nimport { RichTextButtonStyle, TButtonElement } from '../types';\nimport { CreateButtonNodeOptions } from '../utils/index';\nimport { insertButton, unwrapButton, upsertButtonText, wrapButton } from '.';\n\nexport type UpsertButtonOptions<V extends Value = Value> = CreateButtonNodeOptions & {\n /**\n * If true, insert text when selection is in url.\n */\n insertTextInButton?: boolean;\n insertNodesOptions?: InsertNodesOptions<V>;\n unwrapNodesOptions?: UnwrapNodesOptions<V>;\n wrapNodesOptions?: WrapNodesOptions<V>;\n isUrl?: (url: string) => boolean;\n};\n\n/**\n * If selection in a button or is not url:\n * - insert text with url, exit\n * If selection is expanded or `update` in a button:\n * - remove button node, get button text\n * Then:\n * - insert button node\n */\nexport const upsertButton = <V extends Value>(\n editor: PlateEditor<V>,\n {\n url,\n text,\n buttonStyle,\n target,\n insertTextInButton,\n insertNodesOptions,\n isUrl = getPluginOptions<ButtonPlugin, V>(editor, ELEMENT_BUTTON).isUrl,\n }: UpsertButtonOptions<V>,\n) => {\n const at = editor.selection;\n if (!at) {\n return;\n }\n\n const buttonAbove = getAboveNode<TButtonElement>(editor, {\n at,\n match: { type: getPluginType(editor, ELEMENT_BUTTON) },\n });\n\n // anchor and focus in button -> insert text\n if (insertTextInButton && buttonAbove) {\n // we don't want to insert marks in buttons\n editor.insertText(url);\n return true;\n }\n\n if (!isUrl?.(url)) {\n return;\n }\n\n if (isDefined(text) && text.length === 0) {\n text = url;\n }\n\n if (buttonAbove) {\n editButtonUrlAndTarget<V>(url, editor, buttonAbove, target, buttonStyle, text);\n return true;\n }\n\n // selection contains at one edge edge or between the edges\n const buttonEntry = findNode<TButtonElement>(editor, {\n at,\n match: { type: getPluginType(editor, ELEMENT_BUTTON) },\n });\n\n const [buttonNode, buttonPath] = buttonEntry ?? [];\n\n const shouldReplaceText = shouldReplaceButtonText<V>(editor, buttonPath, text);\n\n if (isExpanded(at)) {\n anchorAndFocusInButton<V>(buttonAbove, editor, url, buttonStyle, target, text);\n return true;\n }\n\n if (shouldReplaceText) {\n removeNodes(editor, {\n at: buttonPath,\n });\n }\n\n const props = getNodeProps(buttonNode ?? ({} as TNode));\n\n const path = editor.selection?.focus.path;\n if (!path) {\n return;\n }\n\n // button text should have the focused leaf marks\n const leaf = getNodeLeaf(editor, path);\n\n // if text is empty, text is url\n if (!text?.length) {\n text = url;\n }\n\n insertButton(\n editor,\n {\n ...props,\n url,\n target,\n children: [\n {\n ...leaf,\n text,\n },\n ],\n },\n insertNodesOptions,\n );\n return true;\n};\n\nfunction shouldReplaceButtonText<V extends Value>(editor: PlateEditor<V>, buttonPath?: Path, text?: string) {\n return buttonPath && text?.length && text !== getEditorString(editor, buttonPath);\n}\n\nfunction anchorAndFocusInButton<V extends Value>(\n buttonAbove: undefined,\n editor: PlateEditor<V>,\n url: string,\n buttonStyle?: RichTextButtonStyle,\n target?: string,\n text?: string,\n) {\n if (buttonAbove) {\n unwrapButton(editor, {\n at: buttonAbove[1],\n });\n } else {\n unwrapButton(editor, {\n split: true,\n });\n }\n\n wrapButton(editor, {\n url,\n buttonStyle,\n target,\n });\n\n upsertButtonText(editor, { url, target, text });\n}\n\nfunction editButtonUrlAndTarget<V extends Value>(\n url: string,\n editor: PlateEditor<V>,\n buttonAbove: TNodeEntry<TButtonElement>,\n target?: string,\n buttonStyle?: string,\n text?: string,\n) {\n if (\n url !== buttonAbove[0]?.url ||\n target !== buttonAbove[0]?.target ||\n buttonStyle !== buttonAbove[0]?.buttonStyle\n ) {\n setNodes<TButtonElement>(\n editor,\n { url, target, buttonStyle },\n {\n at: buttonAbove[1],\n },\n );\n }\n\n upsertButtonText(editor, { url, text, target });\n}\n"],"names":["upsertButton","editor","url","text","buttonStyle","target","insertTextInButton","insertNodesOptions","isUrl","getPluginOptions","ELEMENT_BUTTON","at","buttonAbove","getAboveNode","getPluginType","isDefined","editButtonUrlAndTarget","buttonEntry","findNode","buttonNode","buttonPath","shouldReplaceText","shouldReplaceButtonText","isExpanded","anchorAndFocusInButton","removeNodes","props","getNodeProps","path","_a","leaf","getNodeLeaf","insertButton","getEditorString","unwrapButton","wrapButton","upsertButtonText","_b","_c","setNodes"],"mappings":";;;;;;AA+Ca,MAAAA,IAAe,CACxBC,GACA;AAAA,EACI,KAAAC;AAAA,EACA,MAAAC;AAAA,EACA,aAAAC;AAAA,EACA,QAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,OAAAC,IAAQC,EAAkCR,GAAQS,CAAc,EAAE;AACtE,MACC;;AACD,QAAMC,IAAKV,EAAO;AAClB,MAAI,CAACU;AACD;AAGE,QAAAC,IAAcC,EAA6BZ,GAAQ;AAAA,IACrD,IAAAU;AAAA,IACA,OAAO,EAAE,MAAMG,EAAcb,GAAQS,CAAc,EAAE;AAAA,EAAA,CACxD;AAGD,MAAIJ,KAAsBM;AAEtB,WAAAX,EAAO,WAAWC,CAAG,GACd;AAGP,MAAA,EAACM,KAAA,QAAAA,EAAQN;AACT;AAOJ,MAJIa,EAAUZ,CAAI,KAAKA,EAAK,WAAW,MAC5BA,IAAAD,IAGPU;AACA,WAAAI,EAA0Bd,GAAKD,GAAQW,GAAaP,GAAQD,GAAaD,CAAI,GACtE;AAIL,QAAAc,IAAcC,EAAyBjB,GAAQ;AAAA,IACjD,IAAAU;AAAA,IACA,OAAO,EAAE,MAAMG,EAAcb,GAAQS,CAAc,EAAE;AAAA,EAAA,CACxD,GAEK,CAACS,GAAYC,CAAU,IAAIH,KAAe,CAAA,GAE1CI,IAAoBC,EAA2BrB,GAAQmB,GAAYjB,CAAI;AAEzE,MAAAoB,EAAWZ,CAAE;AACb,WAAAa,EAA0BZ,GAAaX,GAAQC,GAAKE,GAAaC,GAAQF,CAAI,GACtE;AAGX,EAAIkB,KACAI,EAAYxB,GAAQ;AAAA,IAChB,IAAImB;AAAA,EAAA,CACP;AAGL,QAAMM,IAAQC,EAAaR,KAAe,CAAY,CAAA,GAEhDS,KAAOC,IAAA5B,EAAO,cAAP,gBAAA4B,EAAkB,MAAM;AACrC,MAAI,CAACD;AACD;AAIE,QAAAE,IAAOC,EAAY9B,GAAQ2B,CAAI;AAGjC,SAACzB,KAAA,QAAAA,EAAM,WACAA,IAAAD,IAGX8B;AAAA,IACI/B;AAAA,IACA;AAAA,MACI,GAAGyB;AAAA,MACH,KAAAxB;AAAA,MACA,QAAAG;AAAA,MACA,UAAU;AAAA,QACN;AAAA,UACI,GAAGyB;AAAA,UACH,MAAA3B;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,IACAI;AAAA,EAAA,GAEG;AACX;AAEA,SAASe,EAAyCrB,GAAwBmB,GAAmBjB,GAAe;AACxG,SAAOiB,MAAcjB,KAAA,gBAAAA,EAAM,WAAUA,MAAS8B,EAAgBhC,GAAQmB,CAAU;AACpF;AAEA,SAASI,EACLZ,GACAX,GACAC,GACAE,GACAC,GACAF,GACF;AACE,EAAIS,IACAsB,EAAajC,GAAQ;AAAA,IACjB,IAAIW,EAAY,CAAC;AAAA,EAAA,CACpB,IAEDsB,EAAajC,GAAQ;AAAA,IACjB,OAAO;AAAA,EAAA,CACV,GAGLkC,EAAWlC,GAAQ;AAAA,IACf,KAAAC;AAAA,IACA,aAAAE;AAAA,IACA,QAAAC;AAAA,EAAA,CACH,GAED+B,EAAiBnC,GAAQ,EAAE,KAAAC,GAAK,QAAAG,GAAQ,MAAAF,EAAM,CAAA;AAClD;AAEA,SAASa,EACLd,GACAD,GACAW,GACAP,GACAD,GACAD,GACF;;AACE,GACID,QAAQ2B,IAAAjB,EAAY,CAAC,MAAb,gBAAAiB,EAAgB,QACxBxB,QAAWgC,IAAAzB,EAAY,CAAC,MAAb,gBAAAyB,EAAgB,WAC3BjC,QAAgBkC,IAAA1B,EAAY,CAAC,MAAb,gBAAA0B,EAAgB,iBAEhCC;AAAA,IACItC;AAAA,IACA,EAAE,KAAAC,GAAK,QAAAG,GAAQ,aAAAD,EAAY;AAAA,IAC3B;AAAA,MACI,IAAIQ,EAAY,CAAC;AAAA,IACrB;AAAA,EAAA,GAIRwB,EAAiBnC,GAAQ,EAAE,KAAAC,GAAK,MAAAC,GAAM,QAAAE,EAAQ,CAAA;AAClD;"}
|
package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButtonText.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsertButtonText.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButtonText.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n PlateEditor,\n TText,\n Value,\n getAboveNode,\n getEditorString,\n getPluginType,\n replaceNodeChildren,\n} from '@udecode/plate';\nimport { ELEMENT_BUTTON, TButtonElement } from '..';\nimport { UpsertButtonOptions } from './upsertButton';\n\n/**\n * If the text is different than the button above text, replace button children by a new text.\n * The new text has the same marks than the first text replaced.\n */\nexport const upsertButtonText = <V extends Value>(editor: PlateEditor<V>, { text }: UpsertButtonOptions<V>) => {\n const newButton = getAboveNode<TButtonElement>(editor, {\n match: { type: getPluginType(editor, ELEMENT_BUTTON) },\n });\n\n if (newButton) {\n const [newButtonNode, newButtonPath] = newButton;\n\n if (text?.length && text !== getEditorString(editor, newButtonPath)) {\n const firstText = newButtonNode.children[0];\n\n // remove button children\n replaceNodeChildren<TText>(editor, {\n at: newButtonPath,\n nodes: { ...firstText, text },\n insertOptions: {\n select: true,\n },\n });\n }\n }\n};\n"],"names":["upsertButtonText","editor","text","newButton","getAboveNode","getPluginType","ELEMENT_BUTTON","newButtonNode","newButtonPath","getEditorString","firstText","replaceNodeChildren"],"mappings":";;AAkBO,MAAMA,IAAmB,CAAkBC,GAAwB,EAAE,MAAAC,QAAmC;AACrG,QAAAC,IAAYC,EAA6BH,GAAQ;AAAA,IACnD,OAAO,EAAE,MAAMI,EAAcJ,GAAQK,CAAc,EAAE;AAAA,EAAA,CACxD;AAED,MAAIH,GAAW;AACL,UAAA,CAACI,GAAeC,CAAa,IAAIL;AAEvC,QAAID,KAAA,QAAAA,EAAM,UAAUA,MAASO,EAAgBR,GAAQO,CAAa,GAAG;AAC3D,YAAAE,IAAYH,EAAc,SAAS,CAAC;AAG1C,MAAAI,EAA2BV,GAAQ;AAAA,QAC/B,IAAIO;AAAA,QACJ,OAAO,EAAE,GAAGE,GAAW,MAAAR,EAAK;AAAA,QAC5B,eAAe;AAAA,UACX,QAAQ;AAAA,QACZ;AAAA,MAAA,CACH;AAAA;AAAA;
|
|
1
|
+
{"version":3,"file":"upsertButtonText.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButtonText.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n PlateEditor,\n TText,\n Value,\n getAboveNode,\n getEditorString,\n getPluginType,\n replaceNodeChildren,\n} from '@udecode/plate';\nimport { ELEMENT_BUTTON, TButtonElement } from '..';\nimport { UpsertButtonOptions } from './upsertButton';\n\n/**\n * If the text is different than the button above text, replace button children by a new text.\n * The new text has the same marks than the first text replaced.\n */\nexport const upsertButtonText = <V extends Value>(editor: PlateEditor<V>, { text }: UpsertButtonOptions<V>) => {\n const newButton = getAboveNode<TButtonElement>(editor, {\n match: { type: getPluginType(editor, ELEMENT_BUTTON) },\n });\n\n if (newButton) {\n const [newButtonNode, newButtonPath] = newButton;\n\n if (text?.length && text !== getEditorString(editor, newButtonPath)) {\n const firstText = newButtonNode.children[0];\n\n // remove button children\n replaceNodeChildren<TText>(editor, {\n at: newButtonPath,\n nodes: { ...firstText, text },\n insertOptions: {\n select: true,\n },\n });\n }\n }\n};\n"],"names":["upsertButtonText","editor","text","newButton","getAboveNode","getPluginType","ELEMENT_BUTTON","newButtonNode","newButtonPath","getEditorString","firstText","replaceNodeChildren"],"mappings":";;AAkBO,MAAMA,IAAmB,CAAkBC,GAAwB,EAAE,MAAAC,QAAmC;AACrG,QAAAC,IAAYC,EAA6BH,GAAQ;AAAA,IACnD,OAAO,EAAE,MAAMI,EAAcJ,GAAQK,CAAc,EAAE;AAAA,EAAA,CACxD;AAED,MAAIH,GAAW;AACL,UAAA,CAACI,GAAeC,CAAa,IAAIL;AAEvC,QAAID,KAAA,QAAAA,EAAM,UAAUA,MAASO,EAAgBR,GAAQO,CAAa,GAAG;AAC3D,YAAAE,IAAYH,EAAc,SAAS,CAAC;AAG1C,MAAAI,EAA2BV,GAAQ;AAAA,QAC/B,IAAIO;AAAA,QACJ,OAAO,EAAE,GAAGE,GAAW,MAAAR,EAAK;AAAA,QAC5B,eAAe;AAAA,UACX,QAAQ;AAAA,QACZ;AAAA,MAAA,CACH;AAAA,IACL;AAAA,EACJ;AACJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapButton.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/transforms/wrapButton.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { PlateEditor, Value, WrapNodesOptions, getPluginType, wrapNodes } from '@udecode/plate';\nimport { ELEMENT_BUTTON, RichTextButtonStyle, TButtonElement } from '..';\n\nexport interface WrapButtonOptions<V extends Value = Value> extends WrapNodesOptions<V> {\n url: string;\n buttonStyle?: RichTextButtonStyle;\n target?: string;\n}\n\n/**\n * Wrap a button node with split.\n */\nexport const wrapButton = <V extends Value>(\n editor: PlateEditor<V>,\n { url, buttonStyle, target, ...options }: WrapButtonOptions<V
|
|
1
|
+
{"version":3,"file":"wrapButton.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/transforms/wrapButton.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { PlateEditor, Value, WrapNodesOptions, getPluginType, wrapNodes } from '@udecode/plate';\nimport { ELEMENT_BUTTON, RichTextButtonStyle, TButtonElement } from '..';\n\nexport interface WrapButtonOptions<V extends Value = Value> extends WrapNodesOptions<V> {\n url: string;\n buttonStyle?: RichTextButtonStyle;\n target?: string;\n}\n\n/**\n * Wrap a button node with split.\n */\nexport const wrapButton = <V extends Value>(\n editor: PlateEditor<V>,\n { url, buttonStyle, target, ...options }: WrapButtonOptions<V>,\n) => {\n wrapNodes<TButtonElement, Value>(\n editor,\n {\n type: getPluginType(editor, ELEMENT_BUTTON),\n url,\n buttonStyle,\n target,\n children: [],\n },\n { split: true, ...options } as WrapNodesOptions,\n );\n};\n"],"names":["wrapButton","editor","url","buttonStyle","target","options","wrapNodes","getPluginType","ELEMENT_BUTTON"],"mappings":";;AAca,MAAAA,IAAa,CACtBC,GACA,EAAE,KAAAC,GAAK,aAAAC,GAAa,QAAAC,GAAQ,GAAGC,QAC9B;AACD,EAAAC;AAAA,IACIL;AAAA,IACA;AAAA,MACI,MAAMM,EAAcN,GAAQO,CAAc;AAAA,MAC1C,KAAAN;AAAA,MACA,aAAAC;AAAA,MACA,QAAAC;AAAA,MACA,UAAU,CAAC;AAAA,IACf;AAAA,IACA,EAAE,OAAO,IAAM,GAAGC,EAAQ;AAAA,EAAA;AAElC;"}
|
package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/createButtonNode.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createButtonNode.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/utils/createButtonNode.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { PlateEditor, TText, Value, getPluginType } from '@udecode/plate';\nimport { RichTextButtonStyle, TButtonElement } from '..';\nimport { ELEMENT_BUTTON } from '../createButtonPlugin';\n\nexport interface CreateButtonNodeOptions {\n url: string;\n text?: string;\n buttonStyle?: RichTextButtonStyle;\n target?: string;\n children?: TText[];\n}\n\nexport const createButtonNode = <V extends Value>(\n editor: PlateEditor<V>,\n { url, text = '', buttonStyle = 'primary', target, children }: CreateButtonNodeOptions
|
|
1
|
+
{"version":3,"file":"createButtonNode.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/utils/createButtonNode.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { PlateEditor, TText, Value, getPluginType } from '@udecode/plate';\nimport { RichTextButtonStyle, TButtonElement } from '..';\nimport { ELEMENT_BUTTON } from '../createButtonPlugin';\n\nexport interface CreateButtonNodeOptions {\n url: string;\n text?: string;\n buttonStyle?: RichTextButtonStyle;\n target?: string;\n children?: TText[];\n}\n\nexport const createButtonNode = <V extends Value>(\n editor: PlateEditor<V>,\n { url, text = '', buttonStyle = 'primary', target, children }: CreateButtonNodeOptions,\n): TButtonElement => {\n const type = getPluginType(editor, ELEMENT_BUTTON);\n\n return {\n type,\n url,\n target,\n buttonStyle,\n children: children ?? [{ text }],\n };\n};\n"],"names":["createButtonNode","editor","url","text","buttonStyle","target","children","getPluginType","ELEMENT_BUTTON"],"mappings":";;AAca,MAAAA,IAAmB,CAC5BC,GACA,EAAE,KAAAC,GAAK,MAAAC,IAAO,IAAI,aAAAC,IAAc,WAAW,QAAAC,GAAQ,UAAAC,SAI5C;AAAA,EACH,MAHSC,EAAcN,GAAQO,CAAc;AAAA,EAI7C,KAAAN;AAAA,EACA,QAAAG;AAAA,EACA,aAAAD;AAAA,EACA,UAAUE,KAAY,CAAC,EAAE,MAAAH,GAAM;AAAA;"}
|
package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButton.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"triggerFloatingButton.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButton.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { PlateEditor, Value } from '@udecode/plate';\nimport { floatingButtonSelectors } from '../components';\nimport { triggerFloatingButtonEdit, triggerFloatingButtonInsert } from '.';\n\nexport const triggerFloatingButton = <V extends Value>(\n editor: PlateEditor<V>,\n {\n focused,\n }: {\n focused?: boolean;\n } = {}
|
|
1
|
+
{"version":3,"file":"triggerFloatingButton.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButton.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { PlateEditor, Value } from '@udecode/plate';\nimport { floatingButtonSelectors } from '../components';\nimport { triggerFloatingButtonEdit, triggerFloatingButtonInsert } from '.';\n\nexport const triggerFloatingButton = <V extends Value>(\n editor: PlateEditor<V>,\n {\n focused,\n }: {\n focused?: boolean;\n } = {},\n) => {\n if (floatingButtonSelectors.mode() === 'edit') {\n triggerFloatingButtonEdit(editor);\n return;\n }\n\n triggerFloatingButtonInsert(editor, {\n focused,\n });\n};\n"],"names":["triggerFloatingButton","editor","focused","floatingButtonSelectors","triggerFloatingButtonEdit","triggerFloatingButtonInsert"],"mappings":";;;AAMa,MAAAA,IAAwB,CACjCC,GACA;AAAA,EACI,SAAAC;AACJ,IAEI,OACH;AACG,MAAAC,EAAwB,KAAK,MAAM,QAAQ;AAC3C,IAAAC,EAA0BH,CAAM;AAChC;AAAA,EACJ;AAEA,EAAAI,EAA4BJ,GAAQ;AAAA,IAChC,SAAAC;AAAA,EAAA,CACH;AACL;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"triggerFloatingButtonInsert.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButtonInsert.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { PlateEditor, Value, getEditorString, getPluginType, isRangeAcrossBlocks, someNode } from '@udecode/plate';\nimport { floatingButtonActions, floatingButtonSelectors } from '../components/FloatingButton/floatingButtonStore';\nimport { ELEMENT_BUTTON } from '../createButtonPlugin';\n\n/**\n * Trigger floating button.\n *\n * Do not trigger when:\n * - selection is across blocks\n * - selection has more than one leaf node\n * - lowest selection is not text\n * - selection has a button node\n */\nexport const triggerFloatingButtonInsert = <V extends Value>(\n editor: PlateEditor<V>,\n {\n focused,\n }: {\n focused?: boolean;\n } = {}
|
|
1
|
+
{"version":3,"file":"triggerFloatingButtonInsert.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButtonInsert.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { PlateEditor, Value, getEditorString, getPluginType, isRangeAcrossBlocks, someNode } from '@udecode/plate';\nimport { floatingButtonActions, floatingButtonSelectors } from '../components/FloatingButton/floatingButtonStore';\nimport { ELEMENT_BUTTON } from '../createButtonPlugin';\n\n/**\n * Trigger floating button.\n *\n * Do not trigger when:\n * - selection is across blocks\n * - selection has more than one leaf node\n * - lowest selection is not text\n * - selection has a button node\n */\nexport const triggerFloatingButtonInsert = <V extends Value>(\n editor: PlateEditor<V>,\n {\n focused,\n }: {\n focused?: boolean;\n } = {},\n) => {\n if (floatingButtonSelectors.mode()) {\n return;\n }\n\n if (!focused) {\n return;\n }\n\n if (isRangeAcrossBlocks(editor, { at: editor.selection })) {\n return;\n }\n\n const hasButton = someNode(editor, {\n match: { type: getPluginType(editor, ELEMENT_BUTTON) },\n });\n if (hasButton) {\n return;\n }\n\n floatingButtonActions.text(getEditorString(editor, editor.selection));\n floatingButtonActions.show('insert', editor.id);\n};\n"],"names":["triggerFloatingButtonInsert","editor","focused","floatingButtonSelectors","isRangeAcrossBlocks","someNode","getPluginType","ELEMENT_BUTTON","floatingButtonActions","getEditorString"],"mappings":";;;AAea,MAAAA,IAA8B,CACvCC,GACA;AAAA,EACI,SAAAC;AACJ,IAEI,OACH;AAgBD,EAfIC,EAAwB,UAIxB,CAACD,KAIDE,EAAoBH,GAAQ,EAAE,IAAIA,EAAO,UAAA,CAAW,KAItCI,EAASJ,GAAQ;AAAA,IAC/B,OAAO,EAAE,MAAMK,EAAcL,GAAQM,CAAc,EAAE;AAAA,EAAA,CACxD,MAKDC,EAAsB,KAAKC,EAAgBR,GAAQA,EAAO,SAAS,CAAC,GAC9CO,EAAA,KAAK,UAAUP,EAAO,EAAE;AAClD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withButton.es.js","sources":["../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/withButton.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n AnyObject,\n EText,\n PlateEditor,\n Value,\n WithOverride,\n getAboveNode,\n getNextNodeStartPoint,\n getPluginType,\n getPreviousNodeEndPoint,\n insertNodes,\n isCollapsed,\n isEndPoint,\n isStartPoint,\n mockPlugin,\n select,\n withRemoveEmptyNodes,\n} from '@udecode/plate';\nimport { Path, Point, Range } from 'slate';\nimport { ELEMENT_BUTTON } from './createButtonPlugin';\n\n/**\n * Insert space after a url to wrap a button.\n * Lookup from the block start to the cursor to check if there is an url.\n * If not found, lookup before the cursor for a space character to check the url.\n *\n * On insert data:\n * Paste a string inside a button element will edit its children text but not its url.\n *\n */\n\nexport const withButton: WithOverride = (editor, { type }) => {\n const { apply, normalizeNode } = editor;\n\n editor.apply = (operation) => {\n if (operation.type !== 'set_selection') {\n apply(operation);\n return;\n }\n\n const range = operation.newProperties;\n if (!range?.focus || !range.anchor || !isCollapsed(range as Range)) {\n apply(operation);\n return;\n }\n\n const entry = getAboveNode(editor, {\n at: range as Range,\n match: { type: getPluginType(editor, ELEMENT_BUTTON) },\n });\n\n if (entry) {\n const [, path] = entry;\n\n let newPoint: Point | undefined;\n\n if (isStartPoint(editor, range.focus, path)) {\n newPoint = getPreviousNodeEndPoint(editor, path);\n }\n\n if (isEndPoint(editor, range.focus, path)) {\n newPoint = getNextNodeStartPoint(editor, path);\n }\n\n if (newPoint) {\n operation.newProperties = {\n anchor: newPoint,\n focus: newPoint,\n };\n }\n }\n\n apply(operation);\n };\n\n editor.normalizeNode = ([node, path]) => {\n if (node.type === getPluginType(editor, ELEMENT_BUTTON)) {\n const range = editor.selection as Range | null;\n\n if (range && isCollapsed(range) && isEndPoint(editor, range.focus, path)) {\n const nextPoint = getNextNodeStartPoint(editor, path);\n\n // select next text node if any\n if (nextPoint) {\n select(editor, nextPoint);\n } else {\n // insert text node then select\n const nextPath = Path.next(path);\n insertNodes(editor, { text: '' } as EText<Value>, { at: nextPath });\n select(editor, nextPath);\n }\n }\n }\n\n normalizeNode([node, path]);\n };\n\n return withRemoveEmptyNodes<Value, PlateEditor<Value>>(\n editor,\n mockPlugin<AnyObject, Value, PlateEditor<Value>>({\n options: { types: type },\n })
|
|
1
|
+
{"version":3,"file":"withButton.es.js","sources":["../../../../../src/components/RichTextEditor/plugins/ButtonPlugin/withButton.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n AnyObject,\n EText,\n PlateEditor,\n Value,\n WithOverride,\n getAboveNode,\n getNextNodeStartPoint,\n getPluginType,\n getPreviousNodeEndPoint,\n insertNodes,\n isCollapsed,\n isEndPoint,\n isStartPoint,\n mockPlugin,\n select,\n withRemoveEmptyNodes,\n} from '@udecode/plate';\nimport { Path, Point, Range } from 'slate';\nimport { ELEMENT_BUTTON } from './createButtonPlugin';\n\n/**\n * Insert space after a url to wrap a button.\n * Lookup from the block start to the cursor to check if there is an url.\n * If not found, lookup before the cursor for a space character to check the url.\n *\n * On insert data:\n * Paste a string inside a button element will edit its children text but not its url.\n *\n */\n\nexport const withButton: WithOverride = (editor, { type }) => {\n const { apply, normalizeNode } = editor;\n\n editor.apply = (operation) => {\n if (operation.type !== 'set_selection') {\n apply(operation);\n return;\n }\n\n const range = operation.newProperties;\n if (!range?.focus || !range.anchor || !isCollapsed(range as Range)) {\n apply(operation);\n return;\n }\n\n const entry = getAboveNode(editor, {\n at: range as Range,\n match: { type: getPluginType(editor, ELEMENT_BUTTON) },\n });\n\n if (entry) {\n const [, path] = entry;\n\n let newPoint: Point | undefined;\n\n if (isStartPoint(editor, range.focus, path)) {\n newPoint = getPreviousNodeEndPoint(editor, path);\n }\n\n if (isEndPoint(editor, range.focus, path)) {\n newPoint = getNextNodeStartPoint(editor, path);\n }\n\n if (newPoint) {\n operation.newProperties = {\n anchor: newPoint,\n focus: newPoint,\n };\n }\n }\n\n apply(operation);\n };\n\n editor.normalizeNode = ([node, path]) => {\n if (node.type === getPluginType(editor, ELEMENT_BUTTON)) {\n const range = editor.selection as Range | null;\n\n if (range && isCollapsed(range) && isEndPoint(editor, range.focus, path)) {\n const nextPoint = getNextNodeStartPoint(editor, path);\n\n // select next text node if any\n if (nextPoint) {\n select(editor, nextPoint);\n } else {\n // insert text node then select\n const nextPath = Path.next(path);\n insertNodes(editor, { text: '' } as EText<Value>, { at: nextPath });\n select(editor, nextPath);\n }\n }\n }\n\n normalizeNode([node, path]);\n };\n\n return withRemoveEmptyNodes<Value, PlateEditor<Value>>(\n editor,\n mockPlugin<AnyObject, Value, PlateEditor<Value>>({\n options: { types: type },\n }),\n );\n};\n"],"names":["withButton","editor","type","apply","normalizeNode","operation","range","isCollapsed","entry","getAboveNode","getPluginType","ELEMENT_BUTTON","path","newPoint","isStartPoint","getPreviousNodeEndPoint","isEndPoint","getNextNodeStartPoint","node","nextPoint","select","nextPath","Path","insertNodes","withRemoveEmptyNodes","mockPlugin"],"mappings":";;;AAiCO,MAAMA,IAA2B,CAACC,GAAQ,EAAE,MAAAC,QAAW;AACpD,QAAA,EAAE,OAAAC,GAAO,eAAAC,EAAkB,IAAAH;AAE1B,SAAAA,EAAA,QAAQ,CAACI,MAAc;AACtB,QAAAA,EAAU,SAAS,iBAAiB;AACpC,MAAAF,EAAME,CAAS;AACf;AAAA,IACJ;AAEA,UAAMC,IAAQD,EAAU;AACpB,QAAA,EAACC,KAAA,QAAAA,EAAO,UAAS,CAACA,EAAM,UAAU,CAACC,EAAYD,CAAc,GAAG;AAChE,MAAAH,EAAME,CAAS;AACf;AAAA,IACJ;AAEM,UAAAG,IAAQC,EAAaR,GAAQ;AAAA,MAC/B,IAAIK;AAAA,MACJ,OAAO,EAAE,MAAMI,EAAcT,GAAQU,CAAc,EAAE;AAAA,IAAA,CACxD;AAED,QAAIH,GAAO;AACD,YAAA,CAAG,EAAAI,CAAI,IAAIJ;AAEb,UAAAK;AAEJ,MAAIC,EAAab,GAAQK,EAAM,OAAOM,CAAI,MAC3BC,IAAAE,EAAwBd,GAAQW,CAAI,IAG/CI,EAAWf,GAAQK,EAAM,OAAOM,CAAI,MACzBC,IAAAI,EAAsBhB,GAAQW,CAAI,IAG7CC,MACAR,EAAU,gBAAgB;AAAA,QACtB,QAAQQ;AAAA,QACR,OAAOA;AAAA,MAAA;AAAA,IAGnB;AAEA,IAAAV,EAAME,CAAS;AAAA,EAAA,GAGnBJ,EAAO,gBAAgB,CAAC,CAACiB,GAAMN,CAAI,MAAM;AACrC,QAAIM,EAAK,SAASR,EAAcT,GAAQU,CAAc,GAAG;AACrD,YAAML,IAAQL,EAAO;AAEjB,UAAAK,KAASC,EAAYD,CAAK,KAAKU,EAAWf,GAAQK,EAAM,OAAOM,CAAI,GAAG;AAChE,cAAAO,IAAYF,EAAsBhB,GAAQW,CAAI;AAGpD,YAAIO;AACA,UAAAC,EAAOnB,GAAQkB,CAAS;AAAA,aACrB;AAEG,gBAAAE,IAAWC,EAAK,KAAKV,CAAI;AACnB,UAAAW,EAAAtB,GAAQ,EAAE,MAAM,MAAsB,EAAE,IAAIoB,GAAU,GAClED,EAAOnB,GAAQoB,CAAQ;AAAA,QAC3B;AAAA,MACJ;AAAA,IACJ;AAEc,IAAAjB,EAAA,CAACc,GAAMN,CAAI,CAAC;AAAA,EAAA,GAGvBY;AAAA,IACHvB;AAAA,IACAwB,EAAiD;AAAA,MAC7C,SAAS,EAAE,OAAOvB,EAAK;AAAA,IAAA,CAC1B;AAAA,EAAA;AAET;"}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { useEditorRef as
|
|
2
|
-
import {
|
|
3
|
-
import { getUrlFromEditor as
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
match: { type: d(
|
|
1
|
+
import { useEditorRef as y, usePlateSelectors as F, useFloatingLinkSelectors as l, getPluginOptions as h, ELEMENT_LINK as n, getAboveNode as C, getPluginType as d, getRangeBoundingClientRect as R, getStartPoint as P, getEndPoint as b, getDefaultBoundingClientRect as N, useVirtualFloatingLink as O, floatingLinkActions as o, someNode as S, floatingLinkSelectors as c, useHotkeys as B, triggerFloatingLinkEdit as I, useFloatingLinkEnter as v, useFloatingLinkEscape as x, useComposedRef as A } from "@udecode/plate";
|
|
2
|
+
import { useCallback as D, useEffect as H } from "react";
|
|
3
|
+
import { getUrlFromEditor as T } from "../../utils/getUrl.es.js";
|
|
4
|
+
const M = ({ floatingOptions: g, ...i }) => {
|
|
5
|
+
const e = y(), u = F().keyEditor(), a = l().mode(), f = l().isOpen(e.id), { triggerFloatingLinkHotkeys: m = "command+k, ctrl+k" } = h(e, n), k = D(() => {
|
|
6
|
+
const t = C(e, {
|
|
7
|
+
match: { type: d(e, n) }
|
|
8
8
|
});
|
|
9
|
-
if (
|
|
10
|
-
const [, s] =
|
|
11
|
-
return
|
|
12
|
-
anchor:
|
|
13
|
-
focus:
|
|
9
|
+
if (t) {
|
|
10
|
+
const [, s] = t;
|
|
11
|
+
return R(e, {
|
|
12
|
+
anchor: P(e, s),
|
|
13
|
+
focus: b(e, s)
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
return
|
|
17
|
-
}, [
|
|
18
|
-
editorId:
|
|
19
|
-
open:
|
|
20
|
-
getBoundingClientRect:
|
|
16
|
+
return N();
|
|
17
|
+
}, [e]), p = f && a === "edit", { update: r, style: E, floating: L } = O({
|
|
18
|
+
editorId: e.id,
|
|
19
|
+
open: p,
|
|
20
|
+
getBoundingClientRect: k,
|
|
21
21
|
...g
|
|
22
22
|
});
|
|
23
|
-
return
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
match: { type: d(
|
|
23
|
+
return H(() => {
|
|
24
|
+
const t = T(e);
|
|
25
|
+
if (t && o.url(t), e.selection && S(e, {
|
|
26
|
+
match: { type: d(e, n) }
|
|
27
27
|
})) {
|
|
28
|
-
o.show("edit",
|
|
28
|
+
o.show("edit", e.id), r();
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
c.mode() === "edit" && o.hide();
|
|
32
|
-
}, [
|
|
33
|
-
|
|
34
|
-
(
|
|
35
|
-
|
|
32
|
+
}, [e, u, r]), B(
|
|
33
|
+
m,
|
|
34
|
+
(t) => {
|
|
35
|
+
t.preventDefault(), c.mode() === "edit" && I(e);
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
enableOnContentEditable: !0
|
|
39
39
|
},
|
|
40
40
|
[]
|
|
41
|
-
), v(),
|
|
41
|
+
), v(), x(), {
|
|
42
42
|
style: {
|
|
43
|
-
...
|
|
43
|
+
...E,
|
|
44
44
|
zIndex: 1e3
|
|
45
45
|
},
|
|
46
46
|
...i,
|
|
47
|
-
ref:
|
|
47
|
+
ref: A(i.ref, L)
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
50
|
export {
|
|
51
|
-
|
|
51
|
+
M as useFloatingLinkEdit
|
|
52
52
|
};
|
|
53
53
|
//# sourceMappingURL=useFloatingLinkEdit.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFloatingLinkEdit.es.js","sources":["../../../../../../../src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/useFloatingLinkEdit.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n ELEMENT_LINK,\n FloatingLinkProps,\n HTMLPropsAs,\n LinkPlugin,\n floatingLinkActions,\n floatingLinkSelectors,\n getAboveNode,\n getDefaultBoundingClientRect,\n getEndPoint,\n getPluginOptions,\n getPluginType,\n getRangeBoundingClientRect,\n getStartPoint,\n someNode,\n triggerFloatingLinkEdit,\n useComposedRef,\n useEditorRef,\n useFloatingLinkEnter,\n useFloatingLinkEscape,\n useFloatingLinkSelectors,\n useHotkeys,\n usePlateSelectors,\n useVirtualFloatingLink,\n} from '@udecode/plate';\nimport { useCallback, useEffect } from 'react';\nimport { getUrlFromEditor } from '../../utils';\n\nexport const useFloatingLinkEdit = ({ floatingOptions, ...props }: FloatingLinkProps): HTMLPropsAs<'div'> => {\n const editor = useEditorRef();\n const keyEditor = usePlateSelectors().keyEditor();\n const mode = useFloatingLinkSelectors().mode();\n const open = useFloatingLinkSelectors().isOpen(editor.id);\n\n const { triggerFloatingLinkHotkeys = 'command+k, ctrl+k' } = getPluginOptions<LinkPlugin>(editor, ELEMENT_LINK);\n\n const getBoundingClientRect = useCallback(() => {\n const entry = getAboveNode(editor, {\n match: { type: getPluginType(editor, ELEMENT_LINK) },\n });\n\n if (entry) {\n const [, path] = entry;\n return getRangeBoundingClientRect(editor, {\n anchor: getStartPoint(editor, path),\n focus: getEndPoint(editor, path),\n });\n }\n\n return getDefaultBoundingClientRect();\n }, [editor]);\n\n const isOpen = open && mode === 'edit';\n\n const { update, style, floating } = useVirtualFloatingLink({\n editorId: editor.id,\n open: isOpen,\n getBoundingClientRect,\n ...floatingOptions,\n });\n\n useEffect(() => {\n const url = getUrlFromEditor(editor);\n if (url) {\n floatingLinkActions.url(url);\n }\n\n if (\n editor.selection &&\n someNode(editor, {\n match: { type: getPluginType(editor, ELEMENT_LINK) },\n })\n ) {\n floatingLinkActions.show('edit', editor.id);\n update();\n return;\n }\n\n if (floatingLinkSelectors.mode() === 'edit') {\n floatingLinkActions.hide();\n }\n }, [editor, keyEditor, update]);\n\n useHotkeys(\n triggerFloatingLinkHotkeys,\n (e) => {\n e.preventDefault();\n\n if (floatingLinkSelectors.mode() === 'edit') {\n triggerFloatingLinkEdit(editor);\n }\n },\n {\n enableOnContentEditable: true,\n },\n []
|
|
1
|
+
{"version":3,"file":"useFloatingLinkEdit.es.js","sources":["../../../../../../../src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/useFloatingLinkEdit.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n ELEMENT_LINK,\n FloatingLinkProps,\n HTMLPropsAs,\n LinkPlugin,\n floatingLinkActions,\n floatingLinkSelectors,\n getAboveNode,\n getDefaultBoundingClientRect,\n getEndPoint,\n getPluginOptions,\n getPluginType,\n getRangeBoundingClientRect,\n getStartPoint,\n someNode,\n triggerFloatingLinkEdit,\n useComposedRef,\n useEditorRef,\n useFloatingLinkEnter,\n useFloatingLinkEscape,\n useFloatingLinkSelectors,\n useHotkeys,\n usePlateSelectors,\n useVirtualFloatingLink,\n} from '@udecode/plate';\nimport { useCallback, useEffect } from 'react';\nimport { getUrlFromEditor } from '../../utils';\n\nexport const useFloatingLinkEdit = ({ floatingOptions, ...props }: FloatingLinkProps): HTMLPropsAs<'div'> => {\n const editor = useEditorRef();\n const keyEditor = usePlateSelectors().keyEditor();\n const mode = useFloatingLinkSelectors().mode();\n const open = useFloatingLinkSelectors().isOpen(editor.id);\n\n const { triggerFloatingLinkHotkeys = 'command+k, ctrl+k' } = getPluginOptions<LinkPlugin>(editor, ELEMENT_LINK);\n\n const getBoundingClientRect = useCallback(() => {\n const entry = getAboveNode(editor, {\n match: { type: getPluginType(editor, ELEMENT_LINK) },\n });\n\n if (entry) {\n const [, path] = entry;\n return getRangeBoundingClientRect(editor, {\n anchor: getStartPoint(editor, path),\n focus: getEndPoint(editor, path),\n });\n }\n\n return getDefaultBoundingClientRect();\n }, [editor]);\n\n const isOpen = open && mode === 'edit';\n\n const { update, style, floating } = useVirtualFloatingLink({\n editorId: editor.id,\n open: isOpen,\n getBoundingClientRect,\n ...floatingOptions,\n });\n\n useEffect(() => {\n const url = getUrlFromEditor(editor);\n if (url) {\n floatingLinkActions.url(url);\n }\n\n if (\n editor.selection &&\n someNode(editor, {\n match: { type: getPluginType(editor, ELEMENT_LINK) },\n })\n ) {\n floatingLinkActions.show('edit', editor.id);\n update();\n return;\n }\n\n if (floatingLinkSelectors.mode() === 'edit') {\n floatingLinkActions.hide();\n }\n }, [editor, keyEditor, update]);\n\n useHotkeys(\n triggerFloatingLinkHotkeys,\n (e) => {\n e.preventDefault();\n\n if (floatingLinkSelectors.mode() === 'edit') {\n triggerFloatingLinkEdit(editor);\n }\n },\n {\n enableOnContentEditable: true,\n },\n [],\n );\n\n useFloatingLinkEnter();\n\n useFloatingLinkEscape();\n\n return {\n style: {\n ...style,\n zIndex: 1000,\n },\n ...props,\n ref: useComposedRef<HTMLElement | null>(props.ref, floating),\n };\n};\n"],"names":["useFloatingLinkEdit","floatingOptions","props","editor","useEditorRef","keyEditor","usePlateSelectors","mode","useFloatingLinkSelectors","open","triggerFloatingLinkHotkeys","getPluginOptions","ELEMENT_LINK","getBoundingClientRect","useCallback","entry","getAboveNode","getPluginType","path","getRangeBoundingClientRect","getStartPoint","getEndPoint","getDefaultBoundingClientRect","isOpen","update","style","floating","useVirtualFloatingLink","useEffect","url","getUrlFromEditor","floatingLinkActions","someNode","floatingLinkSelectors","useHotkeys","e","triggerFloatingLinkEdit","useFloatingLinkEnter","useFloatingLinkEscape","useComposedRef"],"mappings":";;;AA8BO,MAAMA,IAAsB,CAAC,EAAE,iBAAAC,GAAiB,GAAGC,QAAmD;AACzG,QAAMC,IAASC,KACTC,IAAYC,IAAoB,aAChCC,IAAOC,IAA2B,QAClCC,IAAOD,EAA2B,EAAA,OAAOL,EAAO,EAAE,GAElD,EAAE,4BAAAO,IAA6B,oBAAA,IAAwBC,EAA6BR,GAAQS,CAAY,GAExGC,IAAwBC,EAAY,MAAM;AACtC,UAAAC,IAAQC,EAAab,GAAQ;AAAA,MAC/B,OAAO,EAAE,MAAMc,EAAcd,GAAQS,CAAY,EAAE;AAAA,IAAA,CACtD;AAED,QAAIG,GAAO;AACD,YAAA,CAAG,EAAAG,CAAI,IAAIH;AACjB,aAAOI,EAA2BhB,GAAQ;AAAA,QACtC,QAAQiB,EAAcjB,GAAQe,CAAI;AAAA,QAClC,OAAOG,EAAYlB,GAAQe,CAAI;AAAA,MAAA,CAClC;AAAA,IACL;AAEA,WAAOI,EAA6B;AAAA,EAAA,GACrC,CAACnB,CAAM,CAAC,GAELoB,IAASd,KAAQF,MAAS,QAE1B,EAAE,QAAAiB,GAAQ,OAAAC,GAAO,UAAAC,EAAA,IAAaC,EAAuB;AAAA,IACvD,UAAUxB,EAAO;AAAA,IACjB,MAAMoB;AAAA,IACN,uBAAAV;AAAA,IACA,GAAGZ;AAAA,EAAA,CACN;AAED,SAAA2B,EAAU,MAAM;AACN,UAAAC,IAAMC,EAAiB3B,CAAM;AAM/B,QALA0B,KACAE,EAAoB,IAAIF,CAAG,GAI3B1B,EAAO,aACP6B,EAAS7B,GAAQ;AAAA,MACb,OAAO,EAAE,MAAMc,EAAcd,GAAQS,CAAY,EAAE;AAAA,IAAA,CACtD,GACH;AACsB,MAAAmB,EAAA,KAAK,QAAQ5B,EAAO,EAAE,GACnCqB;AACP;AAAA,IACJ;AAEI,IAAAS,EAAsB,KAAK,MAAM,UACjCF,EAAoB,KAAK;AAAA,EAE9B,GAAA,CAAC5B,GAAQE,GAAWmB,CAAM,CAAC,GAE9BU;AAAA,IACIxB;AAAA,IACA,CAACyB,MAAM;AACH,MAAAA,EAAE,eAAe,GAEbF,EAAsB,KAAK,MAAM,UACjCG,EAAwBjC,CAAM;AAAA,IAEtC;AAAA,IACA;AAAA,MACI,yBAAyB;AAAA,IAC7B;AAAA,IACA,CAAC;AAAA,EAAA,GAGgBkC,KAECC,KAEf;AAAA,IACH,OAAO;AAAA,MACH,GAAGb;AAAA,MACH,QAAQ;AAAA,IACZ;AAAA,IACA,GAAGvB;AAAA,IACH,KAAKqC,EAAmCrC,EAAM,KAAKwB,CAAQ;AAAA,EAAA;AAEnE;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useEditorRef as f, useFloatingLinkSelectors as s, getPluginOptions as p, ELEMENT_LINK as m, useHotkeys as k, triggerFloatingLinkInsert as
|
|
2
|
-
import {
|
|
1
|
+
import { useEditorRef as f, useFloatingLinkSelectors as s, getPluginOptions as p, ELEMENT_LINK as m, useHotkeys as k, triggerFloatingLinkInsert as L, useVirtualFloatingLink as E, getSelectionBoundingClientRect as F, floatingLinkActions as r, useFloatingLinkEscape as I, useComposedRef as y } from "@udecode/plate";
|
|
2
|
+
import { useEffect as C } from "react";
|
|
3
3
|
import { useFocused as R } from "slate-react";
|
|
4
4
|
const B = ({ floatingOptions: l, ...n }) => {
|
|
5
5
|
const e = f(), o = R(), u = s().mode(), t = s().isOpen(e.id), { triggerFloatingLinkHotkeys: d } = p(e, m);
|
|
@@ -7,14 +7,14 @@ const B = ({ floatingOptions: l, ...n }) => {
|
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
8
8
|
d,
|
|
9
9
|
(c) => {
|
|
10
|
-
|
|
10
|
+
L(e, { focused: o }) && c.preventDefault();
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
enableOnContentEditable: !0
|
|
14
14
|
},
|
|
15
15
|
[o]
|
|
16
16
|
);
|
|
17
|
-
const { update: i, style:
|
|
17
|
+
const { update: i, style: g, floating: a } = E({
|
|
18
18
|
editorId: e.id,
|
|
19
19
|
open: t && u === "insert",
|
|
20
20
|
getBoundingClientRect: F,
|
|
@@ -23,15 +23,15 @@ const B = ({ floatingOptions: l, ...n }) => {
|
|
|
23
23
|
},
|
|
24
24
|
...l
|
|
25
25
|
});
|
|
26
|
-
return C
|
|
26
|
+
return C(() => {
|
|
27
27
|
t ? (i(), r.updated(!0)) : r.updated(!1);
|
|
28
28
|
}, [t, i]), I(), {
|
|
29
29
|
style: {
|
|
30
|
-
...
|
|
30
|
+
...g,
|
|
31
31
|
zIndex: 1e3
|
|
32
32
|
},
|
|
33
33
|
...n,
|
|
34
|
-
ref: y(n.ref,
|
|
34
|
+
ref: y(n.ref, a)
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
37
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFloatingLinkInsert.es.js","sources":["../../../../../../../src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useFloatingLinkInsert.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n ELEMENT_LINK,\n FloatingLinkProps,\n HTMLPropsAs,\n LinkPlugin,\n floatingLinkActions,\n getPluginOptions,\n getSelectionBoundingClientRect,\n triggerFloatingLinkInsert,\n useComposedRef,\n useEditorRef,\n useFloatingLinkEscape,\n useFloatingLinkSelectors,\n useHotkeys,\n useVirtualFloatingLink,\n} from '@udecode/plate';\nimport { useEffect } from 'react';\nimport { useFocused } from 'slate-react';\n\nexport const useFloatingLinkInsert = ({ floatingOptions, ...props }: FloatingLinkProps): HTMLPropsAs<'div'> => {\n const editor = useEditorRef();\n const focused = useFocused();\n const mode = useFloatingLinkSelectors().mode();\n const open = useFloatingLinkSelectors().isOpen(editor.id);\n\n const { triggerFloatingLinkHotkeys } = getPluginOptions<LinkPlugin>(editor, ELEMENT_LINK);\n\n useHotkeys(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n triggerFloatingLinkHotkeys!,\n (e) => {\n if (triggerFloatingLinkInsert(editor, { focused })) {\n e.preventDefault();\n }\n },\n {\n enableOnContentEditable: true,\n },\n [focused]
|
|
1
|
+
{"version":3,"file":"useFloatingLinkInsert.es.js","sources":["../../../../../../../src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useFloatingLinkInsert.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n ELEMENT_LINK,\n FloatingLinkProps,\n HTMLPropsAs,\n LinkPlugin,\n floatingLinkActions,\n getPluginOptions,\n getSelectionBoundingClientRect,\n triggerFloatingLinkInsert,\n useComposedRef,\n useEditorRef,\n useFloatingLinkEscape,\n useFloatingLinkSelectors,\n useHotkeys,\n useVirtualFloatingLink,\n} from '@udecode/plate';\nimport { useEffect } from 'react';\nimport { useFocused } from 'slate-react';\n\nexport const useFloatingLinkInsert = ({ floatingOptions, ...props }: FloatingLinkProps): HTMLPropsAs<'div'> => {\n const editor = useEditorRef();\n const focused = useFocused();\n const mode = useFloatingLinkSelectors().mode();\n const open = useFloatingLinkSelectors().isOpen(editor.id);\n\n const { triggerFloatingLinkHotkeys } = getPluginOptions<LinkPlugin>(editor, ELEMENT_LINK);\n\n useHotkeys(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n triggerFloatingLinkHotkeys!,\n (e) => {\n if (triggerFloatingLinkInsert(editor, { focused })) {\n e.preventDefault();\n }\n },\n {\n enableOnContentEditable: true,\n },\n [focused],\n );\n\n const { update, style, floating } = useVirtualFloatingLink({\n editorId: editor.id,\n open: open && mode === 'insert',\n getBoundingClientRect: getSelectionBoundingClientRect,\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n whileElementsMounted: () => {},\n ...floatingOptions,\n });\n\n // wait for update before focusing input\n useEffect(() => {\n if (open) {\n update();\n floatingLinkActions.updated(true);\n } else {\n floatingLinkActions.updated(false);\n }\n }, [open, update]);\n\n useFloatingLinkEscape();\n\n return {\n style: {\n ...style,\n zIndex: 1000,\n },\n ...props,\n ref: useComposedRef<HTMLElement | null>(props.ref, floating),\n };\n};\n"],"names":["useFloatingLinkInsert","floatingOptions","props","editor","useEditorRef","focused","useFocused","mode","useFloatingLinkSelectors","open","triggerFloatingLinkHotkeys","getPluginOptions","ELEMENT_LINK","useHotkeys","e","triggerFloatingLinkInsert","update","style","floating","useVirtualFloatingLink","getSelectionBoundingClientRect","useEffect","floatingLinkActions","useFloatingLinkEscape","useComposedRef"],"mappings":";;;AAqBO,MAAMA,IAAwB,CAAC,EAAE,iBAAAC,GAAiB,GAAGC,QAAmD;AAC3G,QAAMC,IAASC,KACTC,IAAUC,KACVC,IAAOC,IAA2B,QAClCC,IAAOD,EAA2B,EAAA,OAAOL,EAAO,EAAE,GAElD,EAAE,4BAAAO,EAA+B,IAAAC,EAA6BR,GAAQS,CAAY;AAExF,EAAAC;AAAA;AAAA,IAEIH;AAAA,IACA,CAACI,MAAM;AACH,MAAIC,EAA0BZ,GAAQ,EAAE,SAAAE,EAAS,CAAA,KAC7CS,EAAE,eAAe;AAAA,IAEzB;AAAA,IACA;AAAA,MACI,yBAAyB;AAAA,IAC7B;AAAA,IACA,CAACT,CAAO;AAAA,EAAA;AAGZ,QAAM,EAAE,QAAAW,GAAQ,OAAAC,GAAO,UAAAC,EAAA,IAAaC,EAAuB;AAAA,IACvD,UAAUhB,EAAO;AAAA,IACjB,MAAMM,KAAQF,MAAS;AAAA,IACvB,uBAAuBa;AAAA;AAAA,IAEvB,sBAAsB,MAAM;AAAA,IAAC;AAAA,IAC7B,GAAGnB;AAAA,EAAA,CACN;AAGD,SAAAoB,EAAU,MAAM;AACZ,IAAIZ,KACOO,KACPM,EAAoB,QAAQ,EAAI,KAEhCA,EAAoB,QAAQ,EAAK;AAAA,EACrC,GACD,CAACb,GAAMO,CAAM,CAAC,GAEKO,KAEf;AAAA,IACH,OAAO;AAAA,MACH,GAAGN;AAAA,MACH,QAAQ;AAAA,IACZ;AAAA,IACA,GAAGf;AAAA,IACH,KAAKsB,EAAmCtB,EAAM,KAAKgB,CAAQ;AAAA,EAAA;AAEnE;"}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { CheckboxState as
|
|
2
|
-
import { useEditorRef as
|
|
3
|
-
import {
|
|
1
|
+
import { CheckboxState as r } from "@frontify/fondue";
|
|
2
|
+
import { useEditorRef as m, floatingLinkSelectors as u, getPluginOptions as h, ELEMENT_LINK as y, useHotkeys as E, floatingLinkActions as a, submitFloatingLink as b } from "@udecode/plate";
|
|
3
|
+
import { useEffect as k, useReducer as U } from "react";
|
|
4
4
|
import { isValidUrlOrEmpty as d } from "../../utils/url.es.js";
|
|
5
|
-
import { getLegacyUrl as x, getUrl as
|
|
6
|
-
import { addHttps as
|
|
7
|
-
const
|
|
5
|
+
import { getLegacyUrl as x, getUrl as w } from "../../utils/getUrl.es.js";
|
|
6
|
+
import { addHttps as I } from "../../../../../../helpers/addHttps.es.js";
|
|
7
|
+
const L = {
|
|
8
8
|
url: "",
|
|
9
9
|
text: "",
|
|
10
|
-
newTab:
|
|
11
|
-
},
|
|
12
|
-
const [o,
|
|
10
|
+
newTab: r.Unchecked
|
|
11
|
+
}, S = () => {
|
|
12
|
+
const [o, n] = U((e, c) => {
|
|
13
13
|
const { type: s, payload: l } = c;
|
|
14
14
|
switch (s) {
|
|
15
15
|
case "NEW_TAB":
|
|
16
16
|
return {
|
|
17
17
|
...e,
|
|
18
|
-
newTab:
|
|
18
|
+
newTab: r.Checked
|
|
19
19
|
};
|
|
20
20
|
case "SAME_TAB":
|
|
21
21
|
return {
|
|
22
22
|
...e,
|
|
23
|
-
newTab:
|
|
23
|
+
newTab: r.Unchecked
|
|
24
24
|
};
|
|
25
25
|
case "URL":
|
|
26
26
|
case "TEXT":
|
|
@@ -32,17 +32,17 @@ const I = {
|
|
|
32
32
|
default:
|
|
33
33
|
return e;
|
|
34
34
|
}
|
|
35
|
-
},
|
|
36
|
-
return [o,
|
|
37
|
-
},
|
|
38
|
-
const o =
|
|
39
|
-
|
|
40
|
-
const t = x(o), i =
|
|
35
|
+
}, L);
|
|
36
|
+
return [o, n];
|
|
37
|
+
}, R = () => {
|
|
38
|
+
const o = m(), [n, e] = S();
|
|
39
|
+
k(() => {
|
|
40
|
+
const t = x(o), i = w(o);
|
|
41
41
|
e({
|
|
42
42
|
type: "INIT",
|
|
43
43
|
payload: {
|
|
44
44
|
text: u.text(),
|
|
45
|
-
newTab: u.newTab() ?
|
|
45
|
+
newTab: u.newTab() ? r.Checked : r.Unchecked,
|
|
46
46
|
url: t && i === "" ? t : u.url()
|
|
47
47
|
}
|
|
48
48
|
});
|
|
@@ -59,15 +59,15 @@ const I = {
|
|
|
59
59
|
});
|
|
60
60
|
}, l = (t) => {
|
|
61
61
|
e(t ? { type: "NEW_TAB" } : { type: "SAME_TAB" });
|
|
62
|
-
},
|
|
62
|
+
}, f = () => {
|
|
63
63
|
a.hide();
|
|
64
64
|
}, p = (t) => {
|
|
65
|
-
if (!d(
|
|
65
|
+
if (!d(n.url) || !T)
|
|
66
66
|
return;
|
|
67
|
-
const i =
|
|
68
|
-
a.text(
|
|
69
|
-
}, T =
|
|
70
|
-
return
|
|
67
|
+
const i = I(n.url);
|
|
68
|
+
a.text(n.text), a.url(i), a.newTab(n.newTab === r.Checked), b(o) && (t == null || t.preventDefault());
|
|
69
|
+
}, T = n.url !== "" && n.text !== "", { appBridge: g } = h(o, y);
|
|
70
|
+
return E(
|
|
71
71
|
"enter",
|
|
72
72
|
p,
|
|
73
73
|
{
|
|
@@ -75,19 +75,19 @@ const I = {
|
|
|
75
75
|
},
|
|
76
76
|
[]
|
|
77
77
|
), {
|
|
78
|
-
state:
|
|
78
|
+
state: n,
|
|
79
79
|
onTextChange: c,
|
|
80
80
|
onUrlChange: s,
|
|
81
81
|
onToggleTab: l,
|
|
82
|
-
onCancel:
|
|
82
|
+
onCancel: f,
|
|
83
83
|
onSave: p,
|
|
84
84
|
hasValues: T,
|
|
85
85
|
isValidUrlOrEmpty: d,
|
|
86
|
-
appBridge:
|
|
86
|
+
appBridge: g
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
89
|
export {
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
S as InsertModalState,
|
|
91
|
+
R as useInsertModal
|
|
92
92
|
};
|
|
93
93
|
//# sourceMappingURL=useInsertModal.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInsertModal.es.js","sources":["../../../../../../../src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useInsertModal.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { AppBridgeBlock } from '@frontify/app-bridge';\nimport { CheckboxState } from '@frontify/fondue';\nimport {\n ELEMENT_LINK,\n floatingLinkActions,\n floatingLinkSelectors,\n getPluginOptions,\n submitFloatingLink,\n useEditorRef,\n useHotkeys,\n} from '@udecode/plate';\nimport { Dispatch, Reducer, useEffect, useReducer } from 'react';\nimport { getLegacyUrl, getUrl } from '../../utils';\nimport { InsertModalDispatchType, InsertModalStateProps } from './types';\nimport { addHttps } from '../../../../../../helpers';\nimport { isValidUrlOrEmpty } from '../../utils/url';\n\nconst initialState: InsertModalStateProps = {\n url: '',\n text: '',\n newTab: CheckboxState.Unchecked,\n};\n\nexport const InsertModalState = (): [InsertModalStateProps, Dispatch<InsertModalDispatchType>] => {\n const [state, dispatch] = useReducer<Reducer<InsertModalStateProps, InsertModalDispatchType>>((state, action) => {\n const { type, payload } = action;\n\n switch (type) {\n case 'NEW_TAB':\n return {\n ...state,\n newTab: CheckboxState.Checked,\n };\n case 'SAME_TAB':\n return {\n ...state,\n newTab: CheckboxState.Unchecked,\n };\n case 'URL':\n case 'TEXT':\n case 'INIT':\n return {\n ...state,\n ...payload,\n };\n default:\n return state;\n }\n }, initialState);\n\n return [state, dispatch];\n};\n\nexport const useInsertModal = () => {\n const editor = useEditorRef();\n const [state, dispatch] = InsertModalState();\n\n useEffect(() => {\n const legacyUrl = getLegacyUrl(editor);\n const url = getUrl(editor);\n\n dispatch({\n type: 'INIT',\n payload: {\n text: floatingLinkSelectors.text(),\n newTab: floatingLinkSelectors.newTab() ? CheckboxState.Checked : CheckboxState.Unchecked,\n url: legacyUrl && url === '' ? legacyUrl : floatingLinkSelectors.url(),\n },\n });\n }, [dispatch, editor]);\n\n const onTextChange = (value: string) => {\n dispatch({\n type: 'TEXT',\n payload: { text: value },\n });\n };\n\n const onUrlChange = (value: string) => {\n dispatch({\n type: 'URL',\n payload: { url: value },\n });\n };\n\n const onToggleTab = (checked: boolean) => {\n checked ? dispatch({ type: 'NEW_TAB' }) : dispatch({ type: 'SAME_TAB' });\n };\n\n const onCancel = () => {\n floatingLinkActions.hide();\n };\n\n const onSave = (event: React.MouseEvent<HTMLButtonElement, MouseEvent> | KeyboardEvent | undefined) => {\n if (!isValidUrlOrEmpty(state.url) || !hasValues) {\n return;\n }\n\n const urlToSave = addHttps(state.url);\n\n floatingLinkActions.text(state.text);\n floatingLinkActions.url(urlToSave);\n floatingLinkActions.newTab(state.newTab === CheckboxState.Checked);\n\n if (submitFloatingLink(editor)) {\n event?.preventDefault();\n }\n };\n\n const hasValues = state.url !== '' && state.text !== '';\n\n const { appBridge } = getPluginOptions<{ appBridge: AppBridgeBlock }>(editor, ELEMENT_LINK);\n\n useHotkeys(\n 'enter',\n onSave,\n {\n enableOnFormTags: ['INPUT'],\n },\n []
|
|
1
|
+
{"version":3,"file":"useInsertModal.es.js","sources":["../../../../../../../src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useInsertModal.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { AppBridgeBlock } from '@frontify/app-bridge';\nimport { CheckboxState } from '@frontify/fondue';\nimport {\n ELEMENT_LINK,\n floatingLinkActions,\n floatingLinkSelectors,\n getPluginOptions,\n submitFloatingLink,\n useEditorRef,\n useHotkeys,\n} from '@udecode/plate';\nimport { Dispatch, Reducer, useEffect, useReducer } from 'react';\nimport { getLegacyUrl, getUrl } from '../../utils';\nimport { InsertModalDispatchType, InsertModalStateProps } from './types';\nimport { addHttps } from '../../../../../../helpers';\nimport { isValidUrlOrEmpty } from '../../utils/url';\n\nconst initialState: InsertModalStateProps = {\n url: '',\n text: '',\n newTab: CheckboxState.Unchecked,\n};\n\nexport const InsertModalState = (): [InsertModalStateProps, Dispatch<InsertModalDispatchType>] => {\n const [state, dispatch] = useReducer<Reducer<InsertModalStateProps, InsertModalDispatchType>>((state, action) => {\n const { type, payload } = action;\n\n switch (type) {\n case 'NEW_TAB':\n return {\n ...state,\n newTab: CheckboxState.Checked,\n };\n case 'SAME_TAB':\n return {\n ...state,\n newTab: CheckboxState.Unchecked,\n };\n case 'URL':\n case 'TEXT':\n case 'INIT':\n return {\n ...state,\n ...payload,\n };\n default:\n return state;\n }\n }, initialState);\n\n return [state, dispatch];\n};\n\nexport const useInsertModal = () => {\n const editor = useEditorRef();\n const [state, dispatch] = InsertModalState();\n\n useEffect(() => {\n const legacyUrl = getLegacyUrl(editor);\n const url = getUrl(editor);\n\n dispatch({\n type: 'INIT',\n payload: {\n text: floatingLinkSelectors.text(),\n newTab: floatingLinkSelectors.newTab() ? CheckboxState.Checked : CheckboxState.Unchecked,\n url: legacyUrl && url === '' ? legacyUrl : floatingLinkSelectors.url(),\n },\n });\n }, [dispatch, editor]);\n\n const onTextChange = (value: string) => {\n dispatch({\n type: 'TEXT',\n payload: { text: value },\n });\n };\n\n const onUrlChange = (value: string) => {\n dispatch({\n type: 'URL',\n payload: { url: value },\n });\n };\n\n const onToggleTab = (checked: boolean) => {\n checked ? dispatch({ type: 'NEW_TAB' }) : dispatch({ type: 'SAME_TAB' });\n };\n\n const onCancel = () => {\n floatingLinkActions.hide();\n };\n\n const onSave = (event: React.MouseEvent<HTMLButtonElement, MouseEvent> | KeyboardEvent | undefined) => {\n if (!isValidUrlOrEmpty(state.url) || !hasValues) {\n return;\n }\n\n const urlToSave = addHttps(state.url);\n\n floatingLinkActions.text(state.text);\n floatingLinkActions.url(urlToSave);\n floatingLinkActions.newTab(state.newTab === CheckboxState.Checked);\n\n if (submitFloatingLink(editor)) {\n event?.preventDefault();\n }\n };\n\n const hasValues = state.url !== '' && state.text !== '';\n\n const { appBridge } = getPluginOptions<{ appBridge: AppBridgeBlock }>(editor, ELEMENT_LINK);\n\n useHotkeys(\n 'enter',\n onSave,\n {\n enableOnFormTags: ['INPUT'],\n },\n [],\n );\n\n return {\n state,\n onTextChange,\n onUrlChange,\n onToggleTab,\n onCancel,\n onSave,\n hasValues,\n isValidUrlOrEmpty,\n appBridge,\n };\n};\n"],"names":["initialState","CheckboxState","InsertModalState","state","dispatch","useReducer","action","type","payload","useInsertModal","editor","useEditorRef","useEffect","legacyUrl","getLegacyUrl","url","getUrl","floatingLinkSelectors","onTextChange","value","onUrlChange","onToggleTab","checked","onCancel","floatingLinkActions","onSave","event","isValidUrlOrEmpty","hasValues","urlToSave","addHttps","submitFloatingLink","appBridge","getPluginOptions","ELEMENT_LINK","useHotkeys"],"mappings":";;;;;;AAmBA,MAAMA,IAAsC;AAAA,EACxC,KAAK;AAAA,EACL,MAAM;AAAA,EACN,QAAQC,EAAc;AAC1B,GAEaC,IAAmB,MAAkE;AAC9F,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAAoE,CAACF,GAAOG,MAAW;AACvG,UAAA,EAAE,MAAAC,GAAM,SAAAC,EAAY,IAAAF;AAE1B,YAAQC,GAAM;AAAA,MACV,KAAK;AACM,eAAA;AAAA,UACH,GAAGJ;AAAAA,UACH,QAAQF,EAAc;AAAA,QAAA;AAAA,MAE9B,KAAK;AACM,eAAA;AAAA,UACH,GAAGE;AAAAA,UACH,QAAQF,EAAc;AAAA,QAAA;AAAA,MAE9B,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AACM,eAAA;AAAA,UACH,GAAGE;AAAAA,UACH,GAAGK;AAAA,QAAA;AAAA,MAEX;AACWL,eAAAA;AAAAA,IACf;AAAA,KACDH,CAAY;AAER,SAAA,CAACG,GAAOC,CAAQ;AAC3B,GAEaK,IAAiB,MAAM;AAChC,QAAMC,IAASC,KACT,CAACR,GAAOC,CAAQ,IAAIF,EAAiB;AAE3C,EAAAU,EAAU,MAAM;AACN,UAAAC,IAAYC,EAAaJ,CAAM,GAC/BK,IAAMC,EAAON,CAAM;AAEhB,IAAAN,EAAA;AAAA,MACL,MAAM;AAAA,MACN,SAAS;AAAA,QACL,MAAMa,EAAsB,KAAK;AAAA,QACjC,QAAQA,EAAsB,OAAA,IAAWhB,EAAc,UAAUA,EAAc;AAAA,QAC/E,KAAKY,KAAaE,MAAQ,KAAKF,IAAYI,EAAsB,IAAI;AAAA,MACzE;AAAA,IAAA,CACH;AAAA,EAAA,GACF,CAACb,GAAUM,CAAM,CAAC;AAEf,QAAAQ,IAAe,CAACC,MAAkB;AAC3B,IAAAf,EAAA;AAAA,MACL,MAAM;AAAA,MACN,SAAS,EAAE,MAAMe,EAAM;AAAA,IAAA,CAC1B;AAAA,EAAA,GAGCC,IAAc,CAACD,MAAkB;AAC1B,IAAAf,EAAA;AAAA,MACL,MAAM;AAAA,MACN,SAAS,EAAE,KAAKe,EAAM;AAAA,IAAA,CACzB;AAAA,EAAA,GAGCE,IAAc,CAACC,MAAqB;AAC5B,IAAAlB,EAAAkB,IAAS,EAAE,MAAM,UAAU,IAAc,EAAE,MAAM,WAAA,CAArB;AAAA,EAAiC,GAGrEC,IAAW,MAAM;AACnB,IAAAC,EAAoB,KAAK;AAAA,EAAA,GAGvBC,IAAS,CAACC,MAAuF;AACnG,QAAI,CAACC,EAAkBxB,EAAM,GAAG,KAAK,CAACyB;AAClC;AAGE,UAAAC,IAAYC,EAAS3B,EAAM,GAAG;AAEhB,IAAAqB,EAAA,KAAKrB,EAAM,IAAI,GACnCqB,EAAoB,IAAIK,CAAS,GACjCL,EAAoB,OAAOrB,EAAM,WAAWF,EAAc,OAAO,GAE7D8B,EAAmBrB,CAAM,MACzBgB,KAAA,QAAAA,EAAO;AAAA,EACX,GAGEE,IAAYzB,EAAM,QAAQ,MAAMA,EAAM,SAAS,IAE/C,EAAE,WAAA6B,EAAc,IAAAC,EAAgDvB,GAAQwB,CAAY;AAE1F,SAAAC;AAAA,IACI;AAAA,IACAV;AAAA,IACA;AAAA,MACI,kBAAkB,CAAC,OAAO;AAAA,IAC9B;AAAA,IACA,CAAC;AAAA,EAAA,GAGE;AAAA,IACH,OAAAtB;AAAA,IACA,cAAAe;AAAA,IACA,aAAAE;AAAA,IACA,aAAAC;AAAA,IACA,UAAAE;AAAA,IACA,QAAAE;AAAA,IACA,WAAAG;AAAA,IACA,mBAAAD;AAAA,IACA,WAAAK;AAAA,EAAA;AAER;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkButton.es.js","sources":["../../../../../src/components/RichTextEditor/plugins/LinkPlugin/LinkButton.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n IconLink,\n IconSize,\n PluginButtonProps,\n getButtonClassNames,\n getHotkeyByPlatform,\n getTooltip,\n} from '@frontify/fondue';\nimport { LinkToolbarButton, isRangeInSameBlock, useEventPlateId, usePlateEditorState } from '@udecode/plate';\n\nexport const LinkButton = ({ id, editorId }: PluginButtonProps) => {\n const editor = usePlateEditorState(useEventPlateId(editorId));\n const isEnabled = !!isRangeInSameBlock(editor, {\n at: editor.selection,\n });\n\n return (\n <div data-plugin-id={id}>\n <LinkToolbarButton\n tooltip={getTooltip(\n isEnabled\n ? `Link\\n${getHotkeyByPlatform('Ctrl+K')}`\n : 'Links can only be set for a single text block.'
|
|
1
|
+
{"version":3,"file":"LinkButton.es.js","sources":["../../../../../src/components/RichTextEditor/plugins/LinkPlugin/LinkButton.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n IconLink,\n IconSize,\n PluginButtonProps,\n getButtonClassNames,\n getHotkeyByPlatform,\n getTooltip,\n} from '@frontify/fondue';\nimport { LinkToolbarButton, isRangeInSameBlock, useEventPlateId, usePlateEditorState } from '@udecode/plate';\n\nexport const LinkButton = ({ id, editorId }: PluginButtonProps) => {\n const editor = usePlateEditorState(useEventPlateId(editorId));\n const isEnabled = !!isRangeInSameBlock(editor, {\n at: editor.selection,\n });\n\n return (\n <div data-plugin-id={id}>\n <LinkToolbarButton\n tooltip={getTooltip(\n isEnabled\n ? `Link\\n${getHotkeyByPlatform('Ctrl+K')}`\n : 'Links can only be set for a single text block.',\n )}\n icon={\n <span className=\"tw-p-2 tw-h-8 tw-justify-center tw-items-center tw-flex\">\n <IconLink size={IconSize.Size16} />\n </span>\n }\n classNames={getButtonClassNames(isEnabled)}\n styles={{ root: { width: '24px', height: '24px' } }}\n actionHandler=\"onMouseDown\"\n />\n </div>\n );\n};\n"],"names":["LinkButton","id","editorId","editor","usePlateEditorState","useEventPlateId","isEnabled","isRangeInSameBlock","jsx","LinkToolbarButton","getTooltip","getHotkeyByPlatform","IconLink","IconSize","getButtonClassNames"],"mappings":";;;AAYO,MAAMA,IAAa,CAAC,EAAE,IAAAC,GAAI,UAAAC,QAAkC;AAC/D,QAAMC,IAASC,EAAoBC,EAAgBH,CAAQ,CAAC,GACtDI,IAAY,CAAC,CAACC,EAAmBJ,GAAQ;AAAA,IAC3C,IAAIA,EAAO;AAAA,EAAA,CACd;AAGG,SAAAK,gBAAAA,EAAAA,IAAC,OAAI,EAAA,kBAAgBP,GACjB,UAAAO,gBAAAA,EAAA;AAAA,IAACC;AAAA,IAAA;AAAA,MACG,SAASC;AAAA,QACLJ,IACM;AAAA,EAASK,EAAoB,QAAQ,CAAC,KACtC;AAAA,MACV;AAAA,MACA,MACKH,gBAAAA,EAAAA,IAAA,QAAA,EAAK,WAAU,2DACZ,gCAACI,GAAS,EAAA,MAAMC,EAAS,OAAA,CAAQ,EACrC,CAAA;AAAA,MAEJ,YAAYC,EAAoBR,CAAS;AAAA,MACzC,QAAQ,EAAE,MAAM,EAAE,OAAO,QAAQ,QAAQ,SAAS;AAAA,MAClD,eAAc;AAAA,IAAA;AAAA,EAEtB,EAAA,CAAA;AAER;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/LinkPlugin/utils/url.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { addHttps } from '../../../../../helpers';\nimport { relativeUrlRegex } from './relativeUrlRegex';\n\nexport const isValidUrl = (url: string) => {\n if (relativeUrlRegex.test(url)) {\n return true;\n }\n try {\n const parsedUrl = new URL(url);\n const validProtocols = ['http:', 'https:', 'mailto:', 'tel:'];\n return validProtocols.includes(parsedUrl.protocol) && parsedUrl.pathname !== '';\n } catch (error) {\n return false;\n }\n};\n\nexport const isValidUrlOrEmpty = (url: string) => {\n return isValidUrl(addHttps(url)) || url === '';\n};\n"],"names":["isValidUrl","url","relativeUrlRegex","parsedUrl","isValidUrlOrEmpty","addHttps"],"mappings":";;AAKa,MAAAA,IAAa,CAACC,MAAgB;AACnC,MAAAC,EAAiB,KAAKD,CAAG;AAClB,WAAA;AAEP,MAAA;AACM,UAAAE,IAAY,IAAI,IAAIF,CAAG;AAE7B,WADuB,CAAC,SAAS,UAAU,WAAW,MAAM,EACtC,SAASE,EAAU,QAAQ,KAAKA,EAAU,aAAa;AAAA;
|
|
1
|
+
{"version":3,"file":"url.es.js","sources":["../../../../../../src/components/RichTextEditor/plugins/LinkPlugin/utils/url.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { addHttps } from '../../../../../helpers';\nimport { relativeUrlRegex } from './relativeUrlRegex';\n\nexport const isValidUrl = (url: string) => {\n if (relativeUrlRegex.test(url)) {\n return true;\n }\n try {\n const parsedUrl = new URL(url);\n const validProtocols = ['http:', 'https:', 'mailto:', 'tel:'];\n return validProtocols.includes(parsedUrl.protocol) && parsedUrl.pathname !== '';\n } catch (error) {\n return false;\n }\n};\n\nexport const isValidUrlOrEmpty = (url: string) => {\n return isValidUrl(addHttps(url)) || url === '';\n};\n"],"names":["isValidUrl","url","relativeUrlRegex","parsedUrl","isValidUrlOrEmpty","addHttps"],"mappings":";;AAKa,MAAAA,IAAa,CAACC,MAAgB;AACnC,MAAAC,EAAiB,KAAKD,CAAG;AAClB,WAAA;AAEP,MAAA;AACM,UAAAE,IAAY,IAAI,IAAIF,CAAG;AAE7B,WADuB,CAAC,SAAS,UAAU,WAAW,MAAM,EACtC,SAASE,EAAU,QAAQ,KAAKA,EAAU,aAAa;AAAA,UACjE;AACL,WAAA;AAAA,EACX;AACJ,GAEaC,IAAoB,CAACH,MACvBD,EAAWK,EAASJ,CAAG,CAAC,KAAKA,MAAQ;"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { j as t } from "../../../../../node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.es.js";
|
|
2
|
-
import {
|
|
3
|
-
import { PageLinks as
|
|
4
|
-
import { merge as i, IconColorFan16 as
|
|
5
|
-
const
|
|
2
|
+
import { useState as c, useEffect as d } from "react";
|
|
3
|
+
import { PageLinks as l } from "./PageLinks.es.js";
|
|
4
|
+
import { merge as i, IconColorFan16 as b } from "@frontify/fondue";
|
|
5
|
+
const v = ({
|
|
6
6
|
document: e,
|
|
7
|
-
appBridge:
|
|
8
|
-
selectedUrl:
|
|
7
|
+
appBridge: a,
|
|
8
|
+
selectedUrl: w,
|
|
9
9
|
onSelectUrl: o,
|
|
10
10
|
itemsToExpandInitially: r
|
|
11
11
|
}) => {
|
|
12
|
-
const [s, n] =
|
|
13
|
-
return
|
|
12
|
+
const [s, n] = c(e.id === r.documentId), x = e.permanentLink === w;
|
|
13
|
+
return d(() => {
|
|
14
14
|
e.id === r.documentId && n(!0);
|
|
15
15
|
}, [r, e.id]), /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
16
16
|
/* @__PURE__ */ t.jsxs(
|
|
@@ -19,7 +19,7 @@ const f = ({
|
|
|
19
19
|
"data-test-id": "internal-link-selector-document-link",
|
|
20
20
|
className: i([
|
|
21
21
|
"tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-py-2 tw-px-2.5 tw-leading-5 tw-cursor-pointer tw-w-full",
|
|
22
|
-
|
|
22
|
+
x ? "tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover" : "hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"
|
|
23
23
|
]),
|
|
24
24
|
onClick: () => o(e.permanentLink),
|
|
25
25
|
onFocus: () => o(e.permanentLink),
|
|
@@ -44,18 +44,18 @@ const f = ({
|
|
|
44
44
|
)
|
|
45
45
|
}
|
|
46
46
|
),
|
|
47
|
-
/* @__PURE__ */ t.jsx(
|
|
47
|
+
/* @__PURE__ */ t.jsx(b, {}),
|
|
48
48
|
/* @__PURE__ */ t.jsx("span", { className: "tw-text-s", children: e.title }),
|
|
49
49
|
/* @__PURE__ */ t.jsx("span", { className: "tw-flex-auto tw-font-sans tw-text-xs tw-text-right", children: "Document" })
|
|
50
50
|
]
|
|
51
51
|
}
|
|
52
52
|
),
|
|
53
53
|
s && /* @__PURE__ */ t.jsx(
|
|
54
|
-
|
|
54
|
+
l,
|
|
55
55
|
{
|
|
56
|
-
appBridge:
|
|
56
|
+
appBridge: a,
|
|
57
57
|
documentId: e.id,
|
|
58
|
-
selectedUrl:
|
|
58
|
+
selectedUrl: w,
|
|
59
59
|
onSelectUrl: o,
|
|
60
60
|
itemsToExpandInitially: r
|
|
61
61
|
}
|
|
@@ -63,6 +63,6 @@ const f = ({
|
|
|
63
63
|
] });
|
|
64
64
|
};
|
|
65
65
|
export {
|
|
66
|
-
|
|
66
|
+
v as DocumentLink
|
|
67
67
|
};
|
|
68
68
|
//# sourceMappingURL=DocumentLink.es.js.map
|