@payloadcms/richtext-slate 3.0.0-canary.b8dd0db → 3.0.0-canary.bb00d64

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.
Files changed (136) hide show
  1. package/dist/cell/rscEntry.d.ts +8 -0
  2. package/dist/cell/rscEntry.d.ts.map +1 -0
  3. package/dist/cell/rscEntry.js +51 -0
  4. package/dist/cell/rscEntry.js.map +1 -0
  5. package/dist/data/populate.d.ts +3 -2
  6. package/dist/data/populate.d.ts.map +1 -1
  7. package/dist/data/populate.js +2 -1
  8. package/dist/data/populate.js.map +1 -1
  9. package/dist/data/recurseNestedFields.d.ts +3 -2
  10. package/dist/data/recurseNestedFields.d.ts.map +1 -1
  11. package/dist/data/recurseNestedFields.js +10 -1
  12. package/dist/data/recurseNestedFields.js.map +1 -1
  13. package/dist/data/richTextRelationshipPromise.d.ts +4 -3
  14. package/dist/data/richTextRelationshipPromise.d.ts.map +1 -1
  15. package/dist/data/richTextRelationshipPromise.js +8 -2
  16. package/dist/data/richTextRelationshipPromise.js.map +1 -1
  17. package/dist/data/validation.d.ts.map +1 -1
  18. package/dist/data/validation.js +3 -1
  19. package/dist/data/validation.js.map +1 -1
  20. package/dist/exports/client/index.d.ts +4 -3
  21. package/dist/exports/client/index.d.ts.map +1 -1
  22. package/dist/exports/client/index.js +4 -3
  23. package/dist/exports/client/index.js.map +1 -1
  24. package/dist/exports/server/rsc.d.ts +3 -0
  25. package/dist/exports/server/rsc.d.ts.map +1 -0
  26. package/dist/exports/server/rsc.js +4 -0
  27. package/dist/exports/server/rsc.js.map +1 -0
  28. package/dist/field/RichText.d.ts.map +1 -1
  29. package/dist/field/RichText.js +22 -37
  30. package/dist/field/RichText.js.map +1 -1
  31. package/dist/field/buttons.scss +11 -10
  32. package/dist/field/createFeatureMap.d.ts +2 -2
  33. package/dist/field/createFeatureMap.d.ts.map +1 -1
  34. package/dist/field/createFeatureMap.js +15 -4
  35. package/dist/field/createFeatureMap.js.map +1 -1
  36. package/dist/field/elements/Button.js +2 -2
  37. package/dist/field/elements/Button.js.map +1 -1
  38. package/dist/field/elements/blockquote/index.scss +7 -5
  39. package/dist/field/elements/h3/Heading3.d.ts.map +1 -1
  40. package/dist/field/elements/h3/Heading3.js.map +1 -1
  41. package/dist/field/elements/h4/Heading4.d.ts.map +1 -1
  42. package/dist/field/elements/h4/Heading4.js.map +1 -1
  43. package/dist/field/elements/h5/Heading5.d.ts.map +1 -1
  44. package/dist/field/elements/h5/Heading5.js.map +1 -1
  45. package/dist/field/elements/h6/Heading6.d.ts.map +1 -1
  46. package/dist/field/elements/h6/Heading6.js.map +1 -1
  47. package/dist/field/elements/isActive.d.ts.map +1 -1
  48. package/dist/field/elements/isActive.js +3 -1
  49. package/dist/field/elements/isActive.js.map +1 -1
  50. package/dist/field/elements/isLastSelectedElementEmpty.d.ts.map +1 -1
  51. package/dist/field/elements/isLastSelectedElementEmpty.js +3 -1
  52. package/dist/field/elements/isLastSelectedElementEmpty.js.map +1 -1
  53. package/dist/field/elements/isListActive.d.ts.map +1 -1
  54. package/dist/field/elements/isListActive.js +6 -2
  55. package/dist/field/elements/isListActive.js.map +1 -1
  56. package/dist/field/elements/link/Button/index.d.ts +3 -1
  57. package/dist/field/elements/link/Button/index.d.ts.map +1 -1
  58. package/dist/field/elements/link/Button/index.js +21 -16
  59. package/dist/field/elements/link/Button/index.js.map +1 -1
  60. package/dist/field/elements/link/Element/index.d.ts.map +1 -1
  61. package/dist/field/elements/link/Element/index.js +29 -20
  62. package/dist/field/elements/link/Element/index.js.map +1 -1
  63. package/dist/field/elements/link/Element/index.scss +65 -67
  64. package/dist/field/elements/link/LinkDrawer/index.d.ts.map +1 -1
  65. package/dist/field/elements/link/LinkDrawer/index.js +49 -43
  66. package/dist/field/elements/link/LinkDrawer/index.js.map +1 -1
  67. package/dist/field/elements/link/LinkDrawer/index.scss +39 -37
  68. package/dist/field/elements/link/LinkDrawer/types.d.ts +1 -0
  69. package/dist/field/elements/link/LinkDrawer/types.d.ts.map +1 -1
  70. package/dist/field/elements/link/LinkDrawer/types.js.map +1 -1
  71. package/dist/field/elements/ol/index.scss +5 -3
  72. package/dist/field/elements/relationship/Button/index.scss +6 -4
  73. package/dist/field/elements/relationship/Element/index.d.ts +1 -7
  74. package/dist/field/elements/relationship/Element/index.d.ts.map +1 -1
  75. package/dist/field/elements/relationship/Element/index.js.map +1 -1
  76. package/dist/field/elements/relationship/Element/index.scss +73 -71
  77. package/dist/field/elements/toggleList.d.ts.map +1 -1
  78. package/dist/field/elements/toggleList.js +6 -2
  79. package/dist/field/elements/toggleList.js.map +1 -1
  80. package/dist/field/elements/ul/index.scss +5 -3
  81. package/dist/field/elements/upload/Button/index.scss +6 -4
  82. package/dist/field/elements/upload/Element/UploadDrawer/index.d.ts.map +1 -1
  83. package/dist/field/elements/upload/Element/UploadDrawer/index.js +68 -57
  84. package/dist/field/elements/upload/Element/UploadDrawer/index.js.map +1 -1
  85. package/dist/field/elements/upload/Element/index.d.ts +1 -7
  86. package/dist/field/elements/upload/Element/index.d.ts.map +1 -1
  87. package/dist/field/elements/upload/Element/index.js +2 -2
  88. package/dist/field/elements/upload/Element/index.js.map +1 -1
  89. package/dist/field/elements/upload/Element/index.scss +116 -114
  90. package/dist/field/icons/IndentLeft/index.scss +12 -10
  91. package/dist/field/icons/IndentRight/index.scss +12 -10
  92. package/dist/field/icons/Link/index.scss +8 -6
  93. package/dist/field/icons/Relationship/index.scss +9 -7
  94. package/dist/field/icons/Upload/index.scss +8 -6
  95. package/dist/field/index.d.ts.map +1 -1
  96. package/dist/field/index.js +16 -14
  97. package/dist/field/index.js.map +1 -1
  98. package/dist/field/index.scss +169 -151
  99. package/dist/field/rscEntry.d.ts +7 -0
  100. package/dist/field/rscEntry.d.ts.map +1 -0
  101. package/dist/field/rscEntry.js +132 -0
  102. package/dist/field/rscEntry.js.map +1 -0
  103. package/dist/field/types.d.ts +5 -6
  104. package/dist/field/types.d.ts.map +1 -1
  105. package/dist/field/types.js.map +1 -1
  106. package/dist/generateSchemaMap.d.ts.map +1 -1
  107. package/dist/generateSchemaMap.js +28 -3
  108. package/dist/generateSchemaMap.js.map +1 -1
  109. package/dist/index.d.ts.map +1 -1
  110. package/dist/index.js +12 -9
  111. package/dist/index.js.map +1 -1
  112. package/dist/scss/app.scss +164 -163
  113. package/dist/scss/colors.scss +256 -254
  114. package/dist/scss/resets.scss +9 -7
  115. package/dist/scss/toastify.scss +42 -41
  116. package/dist/scss/toasts.scss +104 -103
  117. package/dist/scss/type.scss +80 -79
  118. package/dist/types.d.ts +6 -2
  119. package/dist/types.d.ts.map +1 -1
  120. package/dist/types.js.map +1 -1
  121. package/dist/utilities/SlatePropsProvider.d.ts +11 -0
  122. package/dist/utilities/SlatePropsProvider.d.ts.map +1 -0
  123. package/dist/utilities/SlatePropsProvider.js +21 -0
  124. package/dist/utilities/SlatePropsProvider.js.map +1 -0
  125. package/dist/utilities/useSlatePlugin.d.ts.map +1 -1
  126. package/dist/utilities/useSlatePlugin.js +3 -2
  127. package/dist/utilities/useSlatePlugin.js.map +1 -1
  128. package/package.json +20 -19
  129. package/dist/cell/index.d.ts +0 -4
  130. package/dist/cell/index.d.ts.map +0 -1
  131. package/dist/cell/index.js +0 -14
  132. package/dist/cell/index.js.map +0 -1
  133. package/dist/generateComponentMap.d.ts +0 -4
  134. package/dist/generateComponentMap.d.ts.map +0 -1
  135. package/dist/generateComponentMap.js +0 -92
  136. package/dist/generateComponentMap.js.map +0 -1
@@ -1,49 +1,51 @@
1
1
  @import '../../../../scss/styles.scss';
2
2
 
3
- .rich-text-link-edit-modal {
4
- &__template {
5
- position: relative;
6
- z-index: 1;
7
- padding-top: base(1);
8
- padding-bottom: base(2);
9
- }
3
+ @layer payload-default {
4
+ .rich-text-link-edit-modal {
5
+ &__template {
6
+ position: relative;
7
+ z-index: 1;
8
+ padding-top: base(1);
9
+ padding-bottom: base(2);
10
+ }
10
11
 
11
- &__header {
12
- width: 100%;
13
- margin-bottom: $baseline;
14
- display: flex;
15
- justify-content: space-between;
16
- margin-top: base(2.5);
17
- margin-bottom: base(1);
12
+ &__header {
13
+ width: 100%;
14
+ margin-bottom: $baseline;
15
+ display: flex;
16
+ justify-content: space-between;
17
+ margin-top: base(2.5);
18
+ margin-bottom: base(1);
18
19
 
19
- @include mid-break {
20
- margin-top: base(1.5);
20
+ @include mid-break {
21
+ margin-top: base(1.5);
22
+ }
21
23
  }
22
- }
23
24
 
24
- &__header-text {
25
- margin: 0;
26
- }
25
+ &__header-text {
26
+ margin: 0;
27
+ }
27
28
 
28
- &__header-close {
29
- border: 0;
30
- background-color: transparent;
31
- padding: 0;
32
- cursor: pointer;
33
- overflow: hidden;
34
- width: base(1);
35
- height: base(1);
29
+ &__header-close {
30
+ border: 0;
31
+ background-color: transparent;
32
+ padding: 0;
33
+ cursor: pointer;
34
+ overflow: hidden;
35
+ width: base(1);
36
+ height: base(1);
36
37
 
37
- svg {
38
- width: base(2);
39
- height: base(2);
40
- position: relative;
41
- inset-inline-start: base(-0.5);
42
- top: base(-0.5);
38
+ svg {
39
+ width: base(2);
40
+ height: base(2);
41
+ position: relative;
42
+ inset-inline-start: base(-0.5);
43
+ top: base(-0.5);
43
44
 
44
- .stroke {
45
- stroke-width: 2px;
46
- vector-effect: non-scaling-stroke;
45
+ .stroke {
46
+ stroke-width: 2px;
47
+ vector-effect: non-scaling-stroke;
48
+ }
47
49
  }
48
50
  }
49
51
  }
@@ -5,5 +5,6 @@ export type Props = {
5
5
  readonly handleClose: () => void;
6
6
  readonly handleModalSubmit: (fields: FormState, data: Record<string, unknown>) => void;
7
7
  readonly initialState?: FormState;
8
+ readonly schemaPath: string;
8
9
  };
9
10
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/link/LinkDrawer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAErD,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,CAAA;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,IAAI,CAAA;IAChC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;IACtF,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAA;CAClC,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/link/LinkDrawer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAErD,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,CAAA;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,IAAI,CAAA;IAChC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;IACtF,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAA;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/elements/link/LinkDrawer/types.ts"],"sourcesContent":["import type { ClientField, FormState } from 'payload'\n\nexport type Props = {\n readonly drawerSlug: string\n readonly fields: ClientField[]\n readonly handleClose: () => void\n readonly handleModalSubmit: (fields: FormState, data: Record<string, unknown>) => void\n readonly initialState?: FormState\n}\n"],"names":[],"mappings":"AAEA,WAMC"}
1
+ {"version":3,"sources":["../../../../../src/field/elements/link/LinkDrawer/types.ts"],"sourcesContent":["import type { ClientField, FormState } from 'payload'\n\nexport type Props = {\n readonly drawerSlug: string\n readonly fields: ClientField[]\n readonly handleClose: () => void\n readonly handleModalSubmit: (fields: FormState, data: Record<string, unknown>) => void\n readonly initialState?: FormState\n readonly schemaPath: string\n}\n"],"names":[],"mappings":"AAEA,WAOC"}
@@ -1,7 +1,9 @@
1
1
  @import '../../../scss/styles.scss';
2
2
 
3
- .rich-text-ol {
4
- &[data-slate-node='element'] {
5
- margin: base(0.625) 0;
3
+ @layer payload-default {
4
+ .rich-text-ol {
5
+ &[data-slate-node='element'] {
6
+ margin: base(0.625) 0;
7
+ }
6
8
  }
7
9
  }
@@ -1,7 +1,9 @@
1
1
  @import '../../../../scss/styles.scss';
2
2
 
3
- .relationship-rich-text-button {
4
- display: flex;
5
- align-items: center;
6
- height: 100%;
3
+ @layer payload-default {
4
+ .relationship-rich-text-button {
5
+ display: flex;
6
+ align-items: center;
7
+ height: 100%;
8
+ }
7
9
  }
@@ -1,10 +1,4 @@
1
- import type { FormFieldBase, MappedComponent } from 'payload';
2
1
  import React from 'react';
3
2
  import './index.scss';
4
- type Props = {
5
- name: string;
6
- richTextComponentMap: Map<string, MappedComponent>;
7
- } & FormFieldBase;
8
- export declare const RelationshipElement: (props: Props) => React.ReactNode;
9
- export {};
3
+ export declare const RelationshipElement: (props: any) => React.ReactNode;
10
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/relationship/Element/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAW7D,OAAO,KAA4C,MAAM,OAAO,CAAA;AAQhE,OAAO,cAAc,CAAA;AAQrB,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CACnD,GAAG,aAAa,CAAA;AAoKjB,eAAO,MAAM,mBAAmB,UAAW,KAAK,KAAG,KAAK,CAAC,SAMxD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/relationship/Element/index.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA4C,MAAM,OAAO,CAAA;AAQhE,OAAO,cAAc,CAAA;AA0KrB,eAAO,MAAM,mBAAmB,UAAW,GAAG,KAAG,KAAK,CAAC,SAMtD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/elements/relationship/Element/index.tsx"],"sourcesContent":["'use client'\n\nimport type { FormFieldBase, MappedComponent } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n useConfig,\n useDocumentDrawer,\n useListDrawer,\n usePayloadAPI,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback, useReducer, useState } from 'react'\nimport { Transforms } from 'slate'\nimport { ReactEditor, useFocused, useSelected, useSlateStatic } from 'slate-react'\n\nimport type { RelationshipElementType } from '../types.js'\n\nimport { useElement } from '../../../providers/ElementProvider.js'\nimport { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js'\nimport './index.scss'\n\nconst baseClass = 'rich-text-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n name: string\n richTextComponentMap: Map<string, MappedComponent>\n} & FormFieldBase\n\nconst RelationshipElementComponent: React.FC<Props> = () => {\n const {\n attributes,\n children,\n element,\n element: { relationTo, value },\n fieldProps,\n } = useElement<RelationshipElementType>()\n\n const {\n config: {\n collections,\n routes: { api },\n serverURL,\n },\n } = useConfig()\n const [enabledCollectionSlugs] = useState(() =>\n collections\n .filter(({ admin: { enableRichTextRelationship } }) => enableRichTextRelationship)\n .map(({ slug }) => slug),\n )\n const [relatedCollection, setRelatedCollection] = useState(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const selected = useSelected()\n const focused = useFocused()\n const { i18n, t } = useTranslation()\n const editor = useSlateStatic()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value?.id}`,\n { initialParams },\n )\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value?.id,\n collectionSlug: relatedCollection.slug,\n })\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer: closeListDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.removeNodes(editor, { at: elementPath })\n }, [editor, element])\n\n const updateRelationship = React.useCallback(\n ({ doc }) => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.setNodes(\n editor,\n {\n type: 'relationship',\n children: [{ text: ' ' }],\n relationTo: relatedCollection.slug,\n value: { id: doc.id },\n },\n { at: elementPath },\n )\n\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDrawer()\n dispatchCacheBust()\n },\n [editor, element, relatedCollection, cacheBust, setParams, closeDrawer],\n )\n\n const swapRelationship = React.useCallback(\n ({ collectionSlug, docID }) => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.setNodes(\n editor,\n {\n type: 'relationship',\n children: [{ text: ' ' }],\n relationTo: collectionSlug,\n value: { id: docID },\n },\n { at: elementPath },\n )\n\n setRelatedCollection(collections.find((coll) => coll.slug === collectionSlug))\n\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeListDrawer()\n dispatchCacheBust()\n },\n [closeListDrawer, editor, element, cacheBust, setParams, collections],\n )\n\n return (\n <div\n className={[baseClass, selected && focused && `${baseClass}--selected`]\n .filter(Boolean)\n .join(' ')}\n contentEditable={false}\n {...attributes}\n >\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data[relatedCollection?.admin?.useAsTitle || 'id']}\n </p>\n </DocumentDrawerToggler>\n </div>\n <div className={`${baseClass}__actions`}>\n <ListDrawerToggler\n className={`${baseClass}__list-drawer-toggler`}\n disabled={fieldProps?.field?.admin?.readOnly}\n >\n <Button\n buttonStyle=\"icon-label\"\n disabled={fieldProps?.field?.admin?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n // do nothing\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n </ListDrawerToggler>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={fieldProps?.field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n {value?.id && <DocumentDrawer onSave={updateRelationship} />}\n <ListDrawer onSelect={swapRelationship} />\n {children}\n </div>\n )\n}\n\nexport const RelationshipElement = (props: Props): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props}>\n <RelationshipElementComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["getTranslation","Button","useConfig","useDocumentDrawer","useListDrawer","usePayloadAPI","useTranslation","React","useCallback","useReducer","useState","Transforms","ReactEditor","useFocused","useSelected","useSlateStatic","useElement","EnabledRelationshipsCondition","baseClass","initialParams","depth","RelationshipElementComponent","attributes","children","element","relationTo","value","fieldProps","config","collections","routes","api","serverURL","enabledCollectionSlugs","filter","admin","enableRichTextRelationship","map","slug","relatedCollection","setRelatedCollection","find","coll","selected","focused","i18n","t","editor","cacheBust","dispatchCacheBust","state","data","setParams","id","DocumentDrawer","DocumentDrawerToggler","closeDrawer","collectionSlug","ListDrawer","ListDrawerToggler","closeListDrawer","collectionSlugs","selectedCollection","removeRelationship","elementPath","findPath","removeNodes","at","updateRelationship","doc","setNodes","type","text","swapRelationship","docID","div","className","Boolean","join","contentEditable","p","label","labels","singular","useAsTitle","disabled","field","readOnly","buttonStyle","el","icon","onClick","round","tooltip","e","preventDefault","onSave","onSelect","RelationshipElement","props"],"mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SACEC,MAAM,EACNC,SAAS,EACTC,iBAAiB,EACjBC,aAAa,EACbC,aAAa,EACbC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,QAAO;AAChE,SAASC,UAAU,QAAQ,QAAO;AAClC,SAASC,WAAW,EAAEC,UAAU,EAAEC,WAAW,EAAEC,cAAc,QAAQ,cAAa;AAIlF,SAASC,UAAU,QAAQ,wCAAuC;AAClE,SAASC,6BAA6B,QAAQ,yCAAwC;AACtF,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,MAAMC,gBAAgB;IACpBC,OAAO;AACT;AAOA,MAAMC,+BAAgD;IACpD,MAAM,EACJC,UAAU,EACVC,QAAQ,EACRC,OAAO,EACPA,SAAS,EAAEC,UAAU,EAAEC,KAAK,EAAE,EAC9BC,UAAU,EACX,GAAGX;IAEJ,MAAM,EACJY,QAAQ,EACNC,WAAW,EACXC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAG9B;IACJ,MAAM,CAAC+B,uBAAuB,GAAGvB,SAAS,IACxCmB,YACGK,MAAM,CAAC,CAAC,EAAEC,OAAO,EAAEC,0BAA0B,EAAE,EAAE,GAAKA,4BACtDC,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA;IAEvB,MAAM,CAACC,mBAAmBC,qBAAqB,GAAG9B,SAAS,IACzDmB,YAAYY,IAAI,CAAC,CAACC,OAASA,KAAKJ,IAAI,KAAKb;IAG3C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AAIC,WAAW,CAAC,EAAE1D,UAAU,SAAS,CAAC;;kCACrC,KAACyC;wBACCiB,WAAW,CAAC,EAAE1D,UAAU,qBAAqB,CAAC;wBAC9CmE,UAAU1D,YAAY2D,OAAOnD,OAAOoD;kCAEpC,cAAA,KAACtF;4BACCuF,aAAY;4BACZH,UAAU1D,YAAY2D,OAAOnD,OAAOoD;4BACpCE,IAAG;4BACHC,MAAK;4BACLC,SAAS;4BACP,aAAa;4BACf;4BACAC,KAAK;4BACLC,SAAS/C,EAAE;;;kCAGf,KAAC7C;wBACCuF,aAAY;wBACZZ,WAAW,CAAC,EAAE1D,UAAU,cAAc,CAAC;wBACvCmE,UAAU1D,YAAY2D,OAAOnD,OAAOoD;wBACpCG,MAAK;wBACLC,SAAS,CAACG;4BACRA,EAAEC,cAAc;4BAChBhC;wBACF;wBACA6B,KAAK;wBACLC,SAAS/C,EAAE;;;;YAGdpB,OAAO2B,oBAAM,KAACC;gBAAe0C,QAAQ5B;;0BACtC,KAACV;gBAAWuC,UAAUxB;;YACrBlD;;;AAGP;AAEA,OAAO,MAAM2E,sBAAsB,CAACC;IAClC,qBACE,KAAClF;QAA+B,GAAGkF,KAAK;kBACtC,cAAA,KAAC9E;YAA8B,GAAG8E,KAAK;;;AAG7C,EAAC"}
1
+ {"version":3,"sources":["../../../../../src/field/elements/relationship/Element/index.tsx"],"sourcesContent":["'use client'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n useConfig,\n useDocumentDrawer,\n useListDrawer,\n usePayloadAPI,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback, useReducer, useState } from 'react'\nimport { Transforms } from 'slate'\nimport { ReactEditor, useFocused, useSelected, useSlateStatic } from 'slate-react'\n\nimport type { RelationshipElementType } from '../types.js'\n\nimport { useElement } from '../../../providers/ElementProvider.js'\nimport { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js'\nimport './index.scss'\n\nconst baseClass = 'rich-text-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\nconst RelationshipElementComponent: React.FC = () => {\n const {\n attributes,\n children,\n element,\n element: { relationTo, value },\n fieldProps,\n } = useElement<RelationshipElementType>()\n\n const {\n config: {\n collections,\n routes: { api },\n serverURL,\n },\n } = useConfig()\n const [enabledCollectionSlugs] = useState(() =>\n collections\n .filter(({ admin: { enableRichTextRelationship } }) => enableRichTextRelationship)\n .map(({ slug }) => slug),\n )\n const [relatedCollection, setRelatedCollection] = useState(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const selected = useSelected()\n const focused = useFocused()\n const { i18n, t } = useTranslation()\n const editor = useSlateStatic()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value?.id}`,\n { initialParams },\n )\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value?.id,\n collectionSlug: relatedCollection.slug,\n })\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer: closeListDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.removeNodes(editor, { at: elementPath })\n }, [editor, element])\n\n const updateRelationship = React.useCallback(\n ({ doc }) => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.setNodes(\n editor,\n {\n type: 'relationship',\n children: [{ text: ' ' }],\n relationTo: relatedCollection.slug,\n value: { id: doc.id },\n },\n { at: elementPath },\n )\n\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDrawer()\n dispatchCacheBust()\n },\n [editor, element, relatedCollection, cacheBust, setParams, closeDrawer],\n )\n\n const swapRelationship = React.useCallback(\n ({ collectionSlug, docID }) => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.setNodes(\n editor,\n {\n type: 'relationship',\n children: [{ text: ' ' }],\n relationTo: collectionSlug,\n value: { id: docID },\n },\n { at: elementPath },\n )\n\n setRelatedCollection(collections.find((coll) => coll.slug === collectionSlug))\n\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeListDrawer()\n dispatchCacheBust()\n },\n [closeListDrawer, editor, element, cacheBust, setParams, collections],\n )\n\n return (\n <div\n className={[baseClass, selected && focused && `${baseClass}--selected`]\n .filter(Boolean)\n .join(' ')}\n contentEditable={false}\n {...attributes}\n >\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data[relatedCollection?.admin?.useAsTitle || 'id']}\n </p>\n </DocumentDrawerToggler>\n </div>\n <div className={`${baseClass}__actions`}>\n <ListDrawerToggler\n className={`${baseClass}__list-drawer-toggler`}\n disabled={fieldProps?.field?.admin?.readOnly}\n >\n <Button\n buttonStyle=\"icon-label\"\n disabled={fieldProps?.field?.admin?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n // do nothing\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n </ListDrawerToggler>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={fieldProps?.field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n {value?.id && <DocumentDrawer onSave={updateRelationship} />}\n <ListDrawer onSelect={swapRelationship} />\n {children}\n </div>\n )\n}\n\nexport const RelationshipElement = (props: any): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props}>\n <RelationshipElementComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["getTranslation","Button","useConfig","useDocumentDrawer","useListDrawer","usePayloadAPI","useTranslation","React","useCallback","useReducer","useState","Transforms","ReactEditor","useFocused","useSelected","useSlateStatic","useElement","EnabledRelationshipsCondition","baseClass","initialParams","depth","RelationshipElementComponent","attributes","children","element","relationTo","value","fieldProps","config","collections","routes","api","serverURL","enabledCollectionSlugs","filter","admin","enableRichTextRelationship","map","slug","relatedCollection","setRelatedCollection","find","coll","selected","focused","i18n","t","editor","cacheBust","dispatchCacheBust","state","data","setParams","id","DocumentDrawer","DocumentDrawerToggler","closeDrawer","collectionSlug","ListDrawer","ListDrawerToggler","closeListDrawer","collectionSlugs","selectedCollection","removeRelationship","elementPath","findPath","removeNodes","at","updateRelationship","doc","setNodes","type","text","swapRelationship","docID","div","className","Boolean","join","contentEditable","p","label","labels","singular","useAsTitle","disabled","field","readOnly","buttonStyle","el","icon","onClick","round","tooltip","e","preventDefault","onSave","onSelect","RelationshipElement","props"],"mappings":"AAAA;;AAEA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SACEC,MAAM,EACNC,SAAS,EACTC,iBAAiB,EACjBC,aAAa,EACbC,aAAa,EACbC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,QAAO;AAChE,SAASC,UAAU,QAAQ,QAAO;AAClC,SAASC,WAAW,EAAEC,UAAU,EAAEC,WAAW,EAAEC,cAAc,QAAQ,cAAa;AAIlF,SAASC,UAAU,QAAQ,wCAAuC;AAClE,SAASC,6BAA6B,QAAQ,yCAAwC;AACtF,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,MAAMC,gBAAgB;IACpBC,OAAO;AACT;AAEA,MAAMC,+BAAyC;IAC7C,MAAM,EACJC,UAAU,EACVC,QAAQ,EACRC,OAAO,EACPA,SAAS,EAAEC,UAAU,EAAEC,KAAK,EAAE,EAC9BC,UAAU,EACX,GAAGX;IAEJ,MAAM,EACJY,QAAQ,EACNC,WAAW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body;
5
- @include shadow-sm;
6
- padding: base(0.75);
7
- display: flex;
8
- align-items: center;
9
- background: var(--theme-input-bg);
10
- border: 1px solid var(--theme-elevation-100);
11
- max-width: base(15);
12
- font-family: var(--font-body);
13
-
14
- &:hover {
15
- border: 1px solid var(--theme-elevation-150);
16
- }
17
-
18
- &[data-slate-node='element'] {
19
- margin: base(0.625) 0;
20
- }
21
-
22
- &__label {
23
- margin-bottom: base(0.25);
24
- }
25
-
26
- &__title {
27
- margin: 0;
28
- }
3
+ @layer payload-default {
4
+ .rich-text-relationship {
5
+ @extend %body;
6
+ @include shadow-sm;
7
+ padding: base(0.75);
8
+ display: flex;
9
+ align-items: center;
10
+ background: var(--theme-input-bg);
11
+ border: 1px solid var(--theme-elevation-100);
12
+ max-width: base(15);
13
+ font-family: var(--font-body);
29
14
 
30
- &__label,
31
- &__title {
32
- white-space: nowrap;
33
- text-overflow: ellipsis;
34
- overflow: hidden;
35
- line-height: 1 !important;
36
- }
15
+ &:hover {
16
+ border: 1px solid var(--theme-elevation-150);
17
+ }
37
18
 
38
- &__title {
39
- font-weight: bold;
40
- }
19
+ &[data-slate-node='element'] {
20
+ margin: base(0.625) 0;
21
+ }
41
22
 
42
- &__wrap {
43
- flex-grow: 1;
44
- overflow: hidden;
45
- }
23
+ &__label {
24
+ margin-bottom: base(0.25);
25
+ }
46
26
 
47
- &--selected {
48
- box-shadow: $focus-box-shadow;
49
- outline: none;
50
- }
27
+ &__title {
28
+ margin: 0;
29
+ }
51
30
 
52
- .rich-text-relationship__doc-drawer-toggler {
53
- text-decoration: underline;
54
- pointer-events: all;
55
- line-height: inherit;
56
- }
31
+ &__label,
32
+ &__title {
33
+ white-space: nowrap;
34
+ text-overflow: ellipsis;
35
+ overflow: hidden;
36
+ line-height: 1 !important;
37
+ }
57
38
 
58
- &__actions {
59
- display: flex;
60
- align-items: center;
61
- flex-shrink: 0;
62
- margin-left: base(0.5);
39
+ &__title {
40
+ font-weight: bold;
41
+ }
63
42
 
64
- & > *:not(:last-child) {
65
- margin-right: base(0.25);
43
+ &__wrap {
44
+ flex-grow: 1;
45
+ overflow: hidden;
66
46
  }
67
- }
68
47
 
69
- &__removeButton {
70
- margin: 0;
48
+ &--selected {
49
+ box-shadow: $focus-box-shadow;
50
+ outline: none;
51
+ }
71
52
 
72
- line {
73
- stroke-width: $style-stroke-width-m;
53
+ .rich-text-relationship__doc-drawer-toggler {
54
+ text-decoration: underline;
55
+ pointer-events: all;
56
+ line-height: inherit;
74
57
  }
75
58
 
76
- &:disabled {
77
- color: var(--theme-elevation-300);
78
- pointer-events: none;
59
+ &__actions {
60
+ display: flex;
61
+ align-items: center;
62
+ flex-shrink: 0;
63
+ margin-left: base(0.5);
64
+
65
+ & > *:not(:last-child) {
66
+ margin-right: base(0.25);
67
+ }
79
68
  }
80
- }
81
69
 
82
- &__doc-drawer-toggler,
83
- &__list-drawer-toggler {
84
- & > * {
70
+ &__removeButton {
85
71
  margin: 0;
72
+
73
+ line {
74
+ stroke-width: $style-stroke-width-m;
75
+ }
76
+
77
+ &:disabled {
78
+ color: var(--theme-elevation-300);
79
+ pointer-events: none;
80
+ }
86
81
  }
87
82
 
88
- &:disabled {
89
- color: var(--theme-elevation-300);
90
- pointer-events: none;
83
+ &__doc-drawer-toggler,
84
+ &__list-drawer-toggler {
85
+ & > * {
86
+ margin: 0;
87
+ }
88
+
89
+ &:disabled {
90
+ color: var(--theme-elevation-300);
91
+ pointer-events: none;
92
+ }
91
93
  }
92
94
  }
93
95
  }
@@ -1 +1 @@
1
- {"version":3,"file":"toggleList.d.ts","sourceRoot":"","sources":["../../../src/field/elements/toggleList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmC,MAAM,OAAO,CAAA;AAQ/D,eAAO,MAAM,UAAU,WAAY,MAAM,UAAU,MAAM,KAAG,IAyF3D,CAAA"}
1
+ {"version":3,"file":"toggleList.d.ts","sourceRoot":"","sources":["../../../src/field/elements/toggleList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmC,MAAM,OAAO,CAAA;AAQ/D,eAAO,MAAM,UAAU,WAAY,MAAM,UAAU,MAAM,KAAG,IA6F3D,CAAA"}
@@ -6,8 +6,12 @@ import { listTypes } from './listTypes.js';
6
6
  import { unwrapList } from './unwrapList.js';
7
7
  export const toggleList = (editor, format)=>{
8
8
  let currentListFormat;
9
- if (isListActive(editor, 'ol')) currentListFormat = 'ol';
10
- if (isListActive(editor, 'ul')) currentListFormat = 'ul';
9
+ if (isListActive(editor, 'ol')) {
10
+ currentListFormat = 'ol';
11
+ }
12
+ if (isListActive(editor, 'ul')) {
13
+ currentListFormat = 'ul';
14
+ }
11
15
  // If the format is currently active,
12
16
  // remove the list
13
17
  if (currentListFormat === format) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/field/elements/toggleList.tsx"],"sourcesContent":["import { Editor, Element, Node, Text, Transforms } from 'slate'\nimport { ReactEditor } from 'slate-react'\n\nimport { getCommonBlock } from './getCommonBlock.js'\nimport { isListActive } from './isListActive.js'\nimport { listTypes } from './listTypes.js'\nimport { unwrapList } from './unwrapList.js'\n\nexport const toggleList = (editor: Editor, format: string): void => {\n let currentListFormat: string\n\n if (isListActive(editor, 'ol')) currentListFormat = 'ol'\n if (isListActive(editor, 'ul')) currentListFormat = 'ul'\n\n // If the format is currently active,\n // remove the list\n if (currentListFormat === format) {\n const selectedLeaf = Node.descendant(editor, editor.selection.anchor.path)\n\n // If on an empty bullet, leave the above list alone\n // and unwrap only the active bullet\n if (Text.isText(selectedLeaf) && String(selectedLeaf.text).length === 0) {\n Transforms.unwrapNodes(editor, {\n match: (n) => Element.isElement(n) && listTypes.includes(n.type),\n mode: 'lowest',\n split: true,\n })\n\n Transforms.setNodes(editor, { type: undefined })\n } else {\n // Otherwise, we need to unset li on all lis in the parent list\n // and unwrap the parent list itself\n const [, listPath] = getCommonBlock(editor, (n) => Element.isElement(n) && n.type === format)\n unwrapList(editor, listPath)\n }\n\n // Otherwise, if a list is active and we are changing it,\n // change it\n } else if (currentListFormat && currentListFormat !== format) {\n Transforms.setNodes(\n editor,\n {\n type: format,\n },\n {\n match: (node) => Element.isElement(node) && listTypes.includes(node.type),\n mode: 'lowest',\n },\n )\n // Otherwise we can assume that we should just activate the list\n } else {\n Transforms.wrapNodes(editor, { type: format, children: [] })\n\n const [, parentNodePath] = getCommonBlock(\n editor,\n (node) => Element.isElement(node) && node.type === format,\n )\n\n // Only set li on nodes that don't have type\n Transforms.setNodes(\n editor,\n { type: 'li' },\n {\n match: (node, path) => {\n const match =\n Element.isElement(node) &&\n typeof node.type === 'undefined' &&\n path.length === parentNodePath.length + 1\n\n return match\n },\n voids: true,\n },\n )\n\n // Wrap nodes that do have a type with an li\n // so as to not lose their existing formatting\n const nodesToWrap = Array.from(\n Editor.nodes(editor, {\n match: (node, path) => {\n const match =\n Element.isElement(node) &&\n typeof node.type !== 'undefined' &&\n node.type !== 'li' &&\n path.length === parentNodePath.length + 1\n\n return match\n },\n }),\n )\n\n nodesToWrap.forEach(([, path]) => {\n Transforms.wrapNodes(editor, { type: 'li', children: [] }, { at: path })\n })\n }\n\n ReactEditor.focus(editor)\n}\n"],"names":["Editor","Element","Node","Text","Transforms","ReactEditor","getCommonBlock","isListActive","listTypes","unwrapList","toggleList","editor","format","currentListFormat","selectedLeaf","descendant","selection","anchor","path","isText","String","text","length","unwrapNodes","match","n","isElement","includes","type","mode","split","setNodes","undefined","listPath","node","wrapNodes","children","parentNodePath","voids","nodesToWrap","Array","from","nodes","forEach","at","focus"],"mappings":"AAAA,SAASA,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAAEC,UAAU,QAAQ,QAAO;AAC/D,SAASC,WAAW,QAAQ,cAAa;AAEzC,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,UAAU,QAAQ,kBAAiB;AAE5C,OAAO,MAAMC,aAA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N,IAAI,KAAKhB;QAGrD,4CAA4C;QAC5CR,WAAW2B,QAAQ,CACjBpB,QACA;YAAEiB,MAAM;QAAK,GACb;YACEJ,OAAO,CAACU,MAAMhB;gBACZ,MAAMM,QACJvB,QAAQyB,SAAS,CAACQ,SAClB,OAAOA,KAAKN,IAAI,KAAK,eACrBV,KAAKI,MAAM,KAAKe,eAAef,MAAM,GAAG;gBAE1C,OAAOE;YACT;YACAc,OAAO;QACT;QAGF,4CAA4C;QAC5C,8CAA8C;QAC9C,MAAMC,cAAcC,MAAMC,IAAI,CAC5BzC,OAAO0C,KAAK,CAAC/B,QAAQ;YACnBa,OAAO,CAACU,MAAMhB;gBACZ,MAAMM,QACJvB,QAAQyB,SAAS,CAACQ,SAClB,OAAOA,KAAKN,IAAI,KAAK,eACrBM,KAAKN,IAAI,KAAK,QACdV,KAAKI,MAAM,KAAKe,eAAef,MAAM,GAAG;gBAE1C,OAAOE;YACT;QACF;QAGFe,YAAYI,OAAO,CAAC,CAAC,GAAGzB,KAAK;YAC3Bd,WAAW+B,SAAS,CAACxB,QAAQ;gBAAEiB,MAAM;gBAAMQ,UAAU,EAAE;YAAC,GAAG;gBAAEQ,IAAI1B;YAAK;QACxE;IACF;IAEAb,YAAYwC,KAAK,CAAClC;AACpB,EAAC"}
1
+ {"version":3,"sources":["../../../src/field/elements/toggleList.tsx"],"sourcesContent":["import { Editor, Element, Node, Text, Transforms } from 'slate'\nimport { ReactEditor } from 'slate-react'\n\nimport { getCommonBlock } from './getCommonBlock.js'\nimport { isListActive } from './isListActive.js'\nimport { listTypes } from './listTypes.js'\nimport { unwrapList } from './unwrapList.js'\n\nexport const toggleList = (editor: Editor, format: string): void => {\n let currentListFormat: string\n\n if (isListActive(editor, 'ol')) {\n currentListFormat = 'ol'\n }\n if (isListActive(editor, 'ul')) {\n currentListFormat = 'ul'\n }\n\n // If the format is currently active,\n // remove the list\n if (currentListFormat === format) {\n const selectedLeaf = Node.descendant(editor, editor.selection.anchor.path)\n\n // If on an empty bullet, leave the above list alone\n // and unwrap only the active bullet\n if (Text.isText(selectedLeaf) && String(selectedLeaf.text).length === 0) {\n Transforms.unwrapNodes(editor, {\n match: (n) => Element.isElement(n) && listTypes.includes(n.type),\n mode: 'lowest',\n split: true,\n })\n\n Transforms.setNodes(editor, { type: undefined })\n } else {\n // Otherwise, we need to unset li on all lis in the parent list\n // and unwrap the parent list itself\n const [, listPath] = getCommonBlock(editor, (n) => Element.isElement(n) && n.type === format)\n unwrapList(editor, listPath)\n }\n\n // Otherwise, if a list is active and we are changing it,\n // change it\n } else if (currentListFormat && currentListFormat !== format) {\n Transforms.setNodes(\n editor,\n {\n type: format,\n },\n {\n match: (node) => Element.isElement(node) && listTypes.includes(node.type),\n mode: 'lowest',\n },\n )\n // Otherwise we can assume that we should just activate the list\n } else {\n Transforms.wrapNodes(editor, { type: format, children: [] })\n\n const [, parentNodePath] = getCommonBlock(\n editor,\n (node) => Element.isElement(node) && node.type === format,\n )\n\n // Only set li on nodes that don't have type\n Transforms.setNodes(\n editor,\n { type: 'li' },\n {\n match: (node, path) => {\n const match =\n Element.isElement(node) &&\n typeof node.type === 'undefined' &&\n path.length === parentNodePath.length + 1\n\n return match\n },\n voids: true,\n },\n )\n\n // Wrap nodes that do have a type with an li\n // so as to not lose their existing formatting\n const nodesToWrap = Array.from(\n Editor.nodes(editor, {\n match: (node, path) => {\n const match =\n Element.isElement(node) &&\n typeof node.type !== 'undefined' &&\n node.type !== 'li' &&\n path.length === parentNodePath.length + 1\n\n return match\n },\n }),\n )\n\n nodesToWrap.forEach(([, path]) => {\n Transforms.wrapNodes(editor, { type: 'li', children: [] }, { at: path })\n })\n }\n\n ReactEditor.focus(editor)\n}\n"],"names":["Editor","Element","Node","Text","Transforms","ReactEditor","getCommonBlock","isListActive","listTypes","unwrapList","toggleList","editor","format","currentListFormat","selectedLeaf","descendant","selection","anchor","path","isText","String","text","length","unwrapNodes","match","n","isElement","includes","type","mode","split","setNodes","undefined","listPath","node","wrapNodes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slate-node='element'] {
5
- margin: base(0.625) 0;
3
+ @layer payload-default {
4
+ .rich-text-ul {
5
+ &[data-slate-node='element'] {
6
+ margin: base(0.625) 0;
7
+ }
6
8
  }
7
9
  }
@@ -1,7 +1,9 @@
1
1
  @import '../../../../scss/styles.scss';
2
2
 
3
- .upload-rich-text-button {
4
- display: flex;
5
- align-items: center;
6
- height: 100%;
3
+ @layer payload-default {
4
+ .upload-rich-text-button {
5
+ display: flex;
6
+ align-items: center;
7
+ height: 100%;
8
+ }
7
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/elements/upload/Element/UploadDrawer/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAiBrD,OAAO,KAA2C,MAAM,OAAO,CAAA;AAI/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAIvD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAA;IACnC,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAA;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,sBAAsB,CAAA;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B,CA2GA,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/elements/upload/Element/UploadDrawer/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAiBrD,OAAO,KAA2C,MAAM,OAAO,CAAA;AAI/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAIvD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAA;IACnC,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAA;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,sBAAsB,CAAA;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B,CA8HA,CAAA"}
@@ -1,8 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { getTranslation } from '@payloadcms/translations';
4
- import { Drawer, Form, FormSubmit, RenderFields, useAuth, useConfig, useDocumentInfo, useLocale, useModal, useTranslation } from '@payloadcms/ui';
5
- import { getFormState } from '@payloadcms/ui/shared';
4
+ import { Drawer, EditDepthProvider, Form, FormSubmit, RenderFields, useConfig, useDocumentInfo, useLocale, useModal, useServerFunctions, useTranslation } from '@payloadcms/ui';
6
5
  import { deepCopyObject } from 'payload/shared';
7
6
  import React, { useCallback, useEffect, useState } from 'react';
8
7
  import { Transforms } from 'slate';
@@ -13,13 +12,13 @@ export const UploadDrawer = (props)=>{
13
12
  const { drawerSlug, element, fieldProps, relatedCollection, schemaPath } = props;
14
13
  const { i18n, t } = useTranslation();
15
14
  const { code: locale } = useLocale();
16
- const { user } = useAuth();
17
15
  const { closeModal } = useModal();
18
- const { id, collectionSlug } = useDocumentInfo();
16
+ const { id, collectionSlug, docPermissions, getDocPreferences, globalSlug } = useDocumentInfo();
17
+ const { getFormState } = useServerFunctions();
19
18
  const [initialState, setInitialState] = useState({});
20
- const { field: { richTextComponentMap } } = fieldProps;
19
+ const { componentMap } = fieldProps;
21
20
  const relatedFieldSchemaPath = `${uploadFieldsSchemaPath}.${relatedCollection.slug}`;
22
- const fields = richTextComponentMap.get(relatedFieldSchemaPath);
21
+ const fields = componentMap[relatedFieldSchemaPath];
23
22
  const { config } = useConfig();
24
23
  const handleUpdateEditData = useCallback((_, data)=>{
25
24
  const newNode = {
@@ -39,16 +38,17 @@ export const UploadDrawer = (props)=>{
39
38
  useEffect(()=>{
40
39
  const data = deepCopyObject(element?.fields || {});
41
40
  const awaitInitialState = async ()=>{
42
- const state = await getFormState({
43
- apiRoute: config.routes.api,
44
- body: {
45
- id,
46
- collectionSlug,
47
- data,
48
- operation: 'update',
49
- schemaPath: `${schemaPath}.${uploadFieldsSchemaPath}.${relatedCollection.slug}`
50
- },
51
- serverURL: config.serverURL
41
+ const { state } = await getFormState({
42
+ id,
43
+ collectionSlug,
44
+ data,
45
+ docPermissions,
46
+ docPreferences: await getDocPreferences(),
47
+ doNotAbort: true,
48
+ globalSlug,
49
+ operation: 'update',
50
+ renderAllFields: true,
51
+ schemaPath: `${schemaPath}.${uploadFieldsSchemaPath}.${relatedCollection.slug}`
52
52
  });
53
53
  setInitialState(state);
54
54
  };
@@ -56,58 +56,69 @@ export const UploadDrawer = (props)=>{
56
56
  }, [
57
57
  config,
58
58
  element?.fields,
59
- user,
60
59
  locale,
61
60
  t,
62
61
  collectionSlug,
63
62
  id,
64
63
  schemaPath,
65
- relatedCollection.slug
64
+ relatedCollection.slug,
65
+ getFormState,
66
+ globalSlug,
67
+ getDocPreferences,
68
+ docPermissions
66
69
  ]);
67
70
  const onChange = useCallback(async ({ formState: prevFormState })=>{
68
- return await getFormState({
69
- apiRoute: config.routes.api,
70
- body: {
71
- id,
72
- formState: prevFormState,
73
- operation: 'update',
74
- schemaPath: `${schemaPath}.${uploadFieldsSchemaPath}.${relatedCollection.slug}`
75
- },
76
- serverURL: config.serverURL
71
+ const { state } = await getFormState({
72
+ id,
73
+ collectionSlug,
74
+ docPermissions,
75
+ docPreferences: await getDocPreferences(),
76
+ formState: prevFormState,
77
+ globalSlug,
78
+ operation: 'update',
79
+ schemaPath: `${schemaPath}.${uploadFieldsSchemaPath}.${relatedCollection.slug}`
77
80
  });
81
+ return state;
78
82
  }, [
79
- config.routes.api,
80
- config.serverURL,
81
- relatedCollection.slug,
83
+ getFormState,
84
+ id,
85
+ collectionSlug,
86
+ docPermissions,
87
+ getDocPreferences,
88
+ globalSlug,
82
89
  schemaPath,
83
- id
90
+ relatedCollection.slug
84
91
  ]);
85
- return /*#__PURE__*/ _jsx(Drawer, {
86
- slug: drawerSlug,
87
- title: t('general:editLabel', {
88
- label: getTranslation(relatedCollection.labels.singular, i18n)
89
- }),
90
- children: /*#__PURE__*/ _jsxs(Form, {
91
- beforeSubmit: [
92
- onChange
93
- ],
94
- disableValidationOnSubmit: true,
95
- initialState: initialState,
96
- onChange: [
97
- onChange
98
- ],
99
- onSubmit: handleUpdateEditData,
100
- children: [
101
- /*#__PURE__*/ _jsx(RenderFields, {
102
- fields: Array.isArray(fields) ? fields : [],
103
- path: "",
104
- readOnly: false,
105
- schemaPath: ""
106
- }),
107
- /*#__PURE__*/ _jsx(FormSubmit, {
108
- children: t('fields:saveChanges')
109
- })
110
- ]
92
+ return /*#__PURE__*/ _jsx(EditDepthProvider, {
93
+ children: /*#__PURE__*/ _jsx(Drawer, {
94
+ slug: drawerSlug,
95
+ title: t('general:editLabel', {
96
+ label: getTranslation(relatedCollection.labels.singular, i18n)
97
+ }),
98
+ children: /*#__PURE__*/ _jsxs(Form, {
99
+ beforeSubmit: [
100
+ onChange
101
+ ],
102
+ disableValidationOnSubmit: true,
103
+ initialState: initialState,
104
+ onChange: [
105
+ onChange
106
+ ],
107
+ onSubmit: handleUpdateEditData,
108
+ children: [
109
+ /*#__PURE__*/ _jsx(RenderFields, {
110
+ fields: Array.isArray(fields) ? fields : [],
111
+ parentIndexPath: "",
112
+ parentPath: "",
113
+ parentSchemaPath: "",
114
+ permissions: {},
115
+ readOnly: false
116
+ }),
117
+ /*#__PURE__*/ _jsx(FormSubmit, {
118
+ children: t('fields:saveChanges')
119
+ })
120
+ ]
121
+ })
111
122
  })
112
123
  });
113
124
  };