@payloadcms/richtext-slate 3.14.0 → 3.14.1-canary.549a973

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/relationship/Button/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAqD,MAAM,OAAO,CAAA;AAOzE,OAAO,cAAc,CAAA;AAmBrB,KAAK,KAAK,GAAG;IACX,sBAAsB,EAAE,MAAM,EAAE,CAAA;IAChC,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAmDD,eAAO,MAAM,kBAAkB,UAAW,KAAK,KAAG,KAAK,CAAC,SAMvD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/relationship/Button/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAqD,MAAM,OAAO,CAAA;AAOzE,OAAO,cAAc,CAAA;AAmBrB,KAAK,KAAK,GAAG;IACX,sBAAsB,EAAE,MAAM,EAAE,CAAA;IAChC,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AA6CD,eAAO,MAAM,kBAAkB,UAAW,KAAK,KAAG,KAAK,CAAC,SAMvD,CAAA"}
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useListDrawer, useTranslation } from '@payloadcms/ui';
4
- import React, { Fragment, useCallback, useEffect, useState } from 'react';
4
+ import React, { Fragment, useCallback, useState } from 'react';
5
5
  import { ReactEditor, useSlate } from 'slate-react';
6
6
  import { RelationshipIcon } from '../../../icons/Relationship/index.js';
7
7
  import { ElementButton } from '../../Button.js';
@@ -44,14 +44,6 @@ const RelationshipButtonComponent = ({ enabledCollectionSlugs })=>{
44
44
  editor,
45
45
  closeDrawer
46
46
  ]);
47
- useEffect(()=>{
48
- // always reset back to first option
49
- // TODO: this is not working, see the ListDrawer component
50
- setSelectedCollectionSlug(enabledCollectionSlugs[0]);
51
- }, [
52
- isDrawerOpen,
53
- enabledCollectionSlugs
54
- ]);
55
47
  return /*#__PURE__*/ _jsxs(Fragment, {
56
48
  children: [
57
49
  /*#__PURE__*/ _jsx(ListDrawerToggler, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/elements/relationship/Button/index.tsx"],"sourcesContent":["'use client'\n\nimport { useListDrawer, useTranslation } from '@payloadcms/ui'\nimport React, { Fragment, useCallback, useEffect, useState } from 'react'\nimport { ReactEditor, useSlate } from 'slate-react'\n\nimport { RelationshipIcon } from '../../../icons/Relationship/index.js'\nimport { ElementButton } from '../../Button.js'\nimport { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js'\nimport { injectVoidElement } from '../../injectVoid.js'\nimport './index.scss'\n\nconst baseClass = 'relationship-rich-text-button'\n\nconst insertRelationship = (editor, { relationTo, value }) => {\n const text = { text: ' ' }\n\n const relationship = {\n type: 'relationship',\n children: [text],\n relationTo,\n value,\n }\n\n injectVoidElement(editor, relationship)\n\n ReactEditor.focus(editor)\n}\n\ntype Props = {\n enabledCollectionSlugs: string[]\n path: string\n}\nconst RelationshipButtonComponent: React.FC<Props> = ({ enabledCollectionSlugs }) => {\n const { t } = useTranslation()\n const editor = useSlate()\n const [selectedCollectionSlug, setSelectedCollectionSlug] = useState(\n () => enabledCollectionSlugs[0],\n )\n const [ListDrawer, ListDrawerToggler, { closeDrawer, isDrawerOpen }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: selectedCollectionSlug,\n })\n\n const onSelect = useCallback(\n ({ collectionSlug, docID }) => {\n insertRelationship(editor, {\n relationTo: collectionSlug,\n value: {\n id: docID,\n },\n })\n closeDrawer()\n },\n [editor, closeDrawer],\n )\n\n useEffect(() => {\n // always reset back to first option\n // TODO: this is not working, see the ListDrawer component\n setSelectedCollectionSlug(enabledCollectionSlugs[0])\n }, [isDrawerOpen, enabledCollectionSlugs])\n\n return (\n <Fragment>\n <ListDrawerToggler>\n <ElementButton\n className={baseClass}\n el=\"div\"\n format=\"relationship\"\n onClick={() => {\n // do nothing\n }}\n tooltip={t('fields:addRelationship')}\n >\n <RelationshipIcon />\n </ElementButton>\n </ListDrawerToggler>\n <ListDrawer onSelect={onSelect} />\n </Fragment>\n )\n}\n\nexport const RelationshipButton = (props: Props): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props}>\n <RelationshipButtonComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["useListDrawer","useTranslation","React","Fragment","useCallback","useEffect","useState","ReactEditor","useSlate","RelationshipIcon","ElementButton","EnabledRelationshipsCondition","injectVoidElement","baseClass","insertRelationship","editor","relationTo","value","text","relationship","type","children","focus","RelationshipButtonComponent","enabledCollectionSlugs","t","selectedCollectionSlug","setSelectedCollectionSlug","ListDrawer","ListDrawerToggler","closeDrawer","isDrawerOpen","collectionSlugs","selectedCollection","onSelect","collectionSlug","docID","id","className","el","format","onClick","tooltip","RelationshipButton","props"],"mappings":"AAAA;;AAEA,SAASA,aAAa,EAAEC,cAAc,QAAQ,iBAAgB;AAC9D,OAAOC,SAASC,QAAQ,EAAEC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AACzE,SAASC,WAAW,EAAEC,QAAQ,QAAQ,cAAa;AAEnD,SAASC,gBAAgB,QAAQ,uCAAsC;AACvE,SAASC,aAAa,QAAQ,kBAAiB;AAC/C,SAASC,6BAA6B,QAAQ,yCAAwC;AACtF,SAASC,iBAAiB,QAAQ,sBAAqB;AACvD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,MAAMC,qBAAqB,CAACC,QAAQ,EAAEC,UAAU,EAAEC,KAAK,EAAE;IACvD,MAAMC,OAAO;QAAEA,MAAM;IAAI;IAEzB,MAAMC,eAAe;QACnBC,MAAM;QACNC,UAAU;YAACH;SAAK;QAChBF;QACAC;IACF;IAEAL,kBAAkBG,QAAQI;IAE1BZ,YAAYe,KAAK,CAACP;AACpB;AAMA,MAAMQ,8BAA+C,CAAC,EAAEC,sBAAsB,EAAE;IAC9E,MAAM,EAAEC,CAAC,EAAE,GAAGxB;IACd,MAAMc,SAASP;IACf,MAAM,CAACkB,wBAAwBC,0BAA0B,GAAGrB,SAC1D,IAAMkB,sBAAsB,CAAC,EAAE;IAEjC,MAAM,CAACI,YAAYC,mBAAmB,EAAEC,WAAW,EAAEC,YAAY,EAAE,CAAC,GAAG/B,cAAc;QACnFgC,iBAAiBR;QACjBS,oBAAoBP;IACtB;IAEA,MAAMQ,WAAW9B,YACf,CAAC,EAAE+B,cAAc,EAAEC,KAAK,EAAE;QACxBtB,mBAAmBC,QAAQ;YACzBC,YAAYmB;YACZlB,OAAO;gBACLoB,IAAID;YACN;QACF;QACAN;IACF,GACA;QAACf;QAAQe;KAAY;IAGvBzB,UAAU;QACR,oCAAoC;QACpC,0DAA0D;QAC1DsB,0BAA0BH,sBAAsB,CAAC,EAAE;IACrD,GAAG;QAACO;QAAcP;KAAuB;IAEzC,qBACE,MAACrB;;0BACC,KAAC0B;0BACC,cAAA,KAACnB;oBACC4B,WAAWzB;oBACX0B,IAAG;oBACHC,QAAO;oBACPC,SAAS;oBACP,aAAa;oBACf;oBACAC,SAASjB,EAAE;8BAEX,cAAA,KAAChB;;;0BAGL,KAACmB;gBAAWM,UAAUA;;;;AAG5B;AAEA,OAAO,MAAMS,qBAAqB,CAACC;IACjC,qBACE,KAACjC;QAA+B,GAAGiC,KAAK;kBACtC,cAAA,KAACrB;YAA6B,GAAGqB,KAAK;;;AAG5C,EAAC"}
1
+ {"version":3,"sources":["../../../../../src/field/elements/relationship/Button/index.tsx"],"sourcesContent":["'use client'\n\nimport { useListDrawer, useTranslation } from '@payloadcms/ui'\nimport React, { Fragment, useCallback, useEffect, useState } from 'react'\nimport { ReactEditor, useSlate } from 'slate-react'\n\nimport { RelationshipIcon } from '../../../icons/Relationship/index.js'\nimport { ElementButton } from '../../Button.js'\nimport { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js'\nimport { injectVoidElement } from '../../injectVoid.js'\nimport './index.scss'\n\nconst baseClass = 'relationship-rich-text-button'\n\nconst insertRelationship = (editor, { relationTo, value }) => {\n const text = { text: ' ' }\n\n const relationship = {\n type: 'relationship',\n children: [text],\n relationTo,\n value,\n }\n\n injectVoidElement(editor, relationship)\n\n ReactEditor.focus(editor)\n}\n\ntype Props = {\n enabledCollectionSlugs: string[]\n path: string\n}\nconst RelationshipButtonComponent: React.FC<Props> = ({ enabledCollectionSlugs }) => {\n const { t } = useTranslation()\n const editor = useSlate()\n const [selectedCollectionSlug, setSelectedCollectionSlug] = useState(\n () => enabledCollectionSlugs[0],\n )\n const [ListDrawer, ListDrawerToggler, { closeDrawer, isDrawerOpen }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: selectedCollectionSlug,\n })\n\n const onSelect = useCallback(\n ({ collectionSlug, docID }) => {\n insertRelationship(editor, {\n relationTo: collectionSlug,\n value: {\n id: docID,\n },\n })\n closeDrawer()\n },\n [editor, closeDrawer],\n )\n\n return (\n <Fragment>\n <ListDrawerToggler>\n <ElementButton\n className={baseClass}\n el=\"div\"\n format=\"relationship\"\n onClick={() => {\n // do nothing\n }}\n tooltip={t('fields:addRelationship')}\n >\n <RelationshipIcon />\n </ElementButton>\n </ListDrawerToggler>\n <ListDrawer onSelect={onSelect} />\n </Fragment>\n )\n}\n\nexport const RelationshipButton = (props: Props): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props}>\n <RelationshipButtonComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["useListDrawer","useTranslation","React","Fragment","useCallback","useState","ReactEditor","useSlate","RelationshipIcon","ElementButton","EnabledRelationshipsCondition","injectVoidElement","baseClass","insertRelationship","editor","relationTo","value","text","relationship","type","children","focus","RelationshipButtonComponent","enabledCollectionSlugs","t","selectedCollectionSlug","setSelectedCollectionSlug","ListDrawer","ListDrawerToggler","closeDrawer","isDrawerOpen","collectionSlugs","selectedCollection","onSelect","collectionSlug","docID","id","className","el","format","onClick","tooltip","RelationshipButton","props"],"mappings":"AAAA;;AAEA,SAASA,aAAa,EAAEC,cAAc,QAAQ,iBAAgB;AAC9D,OAAOC,SAASC,QAAQ,EAAEC,WAAW,EAAaC,QAAQ,QAAQ,QAAO;AACzE,SAASC,WAAW,EAAEC,QAAQ,QAAQ,cAAa;AAEnD,SAASC,gBAAgB,QAAQ,uCAAsC;AACvE,SAASC,aAAa,QAAQ,kBAAiB;AAC/C,SAASC,6BAA6B,QAAQ,yCAAwC;AACtF,SAASC,iBAAiB,QAAQ,sBAAqB;AACvD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,MAAMC,qBAAqB,CAACC,QAAQ,EAAEC,UAAU,EAAEC,KAAK,EAAE;IACvD,MAAMC,OAAO;QAAEA,MAAM;IAAI;IAEzB,MAAMC,eAAe;QACnBC,MAAM;QACNC,UAAU;YAACH;SAAK;QAChBF;QACAC;IACF;IAEAL,kBAAkBG,QAAQI;IAE1BZ,YAAYe,KAAK,CAACP;AACpB;AAMA,MAAMQ,8BAA+C,CAAC,EAAEC,sBAAsB,EAAE;IAC9E,MAAM,EAAEC,CAAC,EAAE,GAAGvB;IACd,MAAMa,SAASP;IACf,MAAM,CAACkB,wBAAwBC,0BAA0B,GAAGrB,SAC1D,IAAMkB,sBAAsB,CAAC,EAAE;IAEjC,MAAM,CAACI,YAAYC,mBAAmB,EAAEC,WAAW,EAAEC,YAAY,EAAE,CAAC,GAAG9B,cAAc;QACnF+B,iBAAiBR;QACjBS,oBAAoBP;IACtB;IAEA,MAAMQ,WAAW7B,YACf,CAAC,EAAE8B,cAAc,EAAEC,KAAK,EAAE;QACxBtB,mBAAmBC,QAAQ;YACzBC,YAAYmB;YACZlB,OAAO;gBACLoB,IAAID;YACN;QACF;QACAN;IACF,GACA;QAACf;QAAQe;KAAY;IAGvB,qBACE,MAAC1B;;0BACC,KAACyB;0BACC,cAAA,KAACnB;oBACC4B,WAAWzB;oBACX0B,IAAG;oBACHC,QAAO;oBACPC,SAAS;oBACP,aAAa;oBACf;oBACAC,SAASjB,EAAE;8BAEX,cAAA,KAAChB;;;0BAGL,KAACmB;gBAAWM,UAAUA;;;;AAG5B;AAEA,OAAO,MAAMS,qBAAqB,CAACC;IACjC,qBACE,KAACjC;QAA+B,GAAGiC,KAAK;kBACtC,cAAA,KAACrB;YAA6B,GAAGqB,KAAK;;;AAG5C,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-slate",
3
- "version": "3.14.0",
3
+ "version": "3.14.1-canary.549a973",
4
4
  "description": "The officially supported Slate richtext adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -46,20 +46,20 @@
46
46
  "slate-history": "0.86.0",
47
47
  "slate-hyperscript": "0.81.3",
48
48
  "slate-react": "0.92.0",
49
- "@payloadcms/translations": "3.14.0",
50
- "@payloadcms/ui": "3.14.0"
49
+ "@payloadcms/translations": "3.14.1-canary.549a973",
50
+ "@payloadcms/ui": "3.14.1-canary.549a973"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/is-hotkey": "^0.1.10",
54
54
  "@types/node": "22.5.4",
55
55
  "@types/react": "19.0.1",
56
56
  "@types/react-dom": "19.0.1",
57
- "payload": "3.14.0",
58
- "@payloadcms/eslint-config": "3.9.0"
57
+ "@payloadcms/eslint-config": "3.9.0",
58
+ "payload": "3.14.1-canary.549a973"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
62
- "payload": "3.14.0"
62
+ "payload": "3.14.1-canary.549a973"
63
63
  },
64
64
  "engines": {
65
65
  "node": "^18.20.2 || >=20.9.0"