@payloadcms/richtext-lexical 3.36.0-canary.6 → 3.36.0-canary.7

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/features/indent/client/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAmE5D,eAAO,MAAM,mBAAmB,sGAiB9B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/indent/client/index.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AA0D5D,eAAO,MAAM,mBAAmB,sGAiB9B,CAAA"}
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import { $findMatchingParent } from '@lexical/utils';
4
- import { $isElementNode, $isRangeSelection, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND } from 'lexical';
4
+ import { $isElementNode, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND } from 'lexical';
5
5
  import { IndentDecreaseIcon } from '../../../lexical/ui/icons/IndentDecrease/index.js';
6
6
  import { IndentIncreaseIcon } from '../../../lexical/ui/icons/IndentIncrease/index.js';
7
7
  import { createClientFeature } from '../../../utilities/createClientFeature.js';
@@ -15,27 +15,13 @@ const toolbarGroups = ({
15
15
  isEnabled: ({
16
16
  selection
17
17
  }) => {
18
- const nodes = selection?.getNodes();
19
- if (!nodes?.length) {
20
- return false;
21
- }
22
- let atLeastOneNodeCanOutdent = false;
23
- const isIndentable = node => $isElementNode(node) && node.canIndent();
24
- for (const node of nodes) {
25
- if (isIndentable(node)) {
26
- if (node.getIndent() <= 0) {
27
- return false;
28
- } else {
29
- atLeastOneNodeCanOutdent = true;
30
- }
31
- }
32
- }
33
- if (!atLeastOneNodeCanOutdent) {
34
- if ($pointsAncestorMatch(selection, node => isIndentable(node) && node.getIndent() > 0)) {
35
- return true;
36
- }
37
- }
38
- return atLeastOneNodeCanOutdent;
18
+ const nodes = selection?.getNodes() ?? [];
19
+ const isOutdentable = node => {
20
+ return isIndentable(node) && node.getIndent() > 0;
21
+ };
22
+ return nodes.some(node => {
23
+ return isOutdentable(node) || Boolean($findMatchingParent(node, isOutdentable));
24
+ });
39
25
  },
40
26
  key: 'indentDecrease',
41
27
  label: ({
@@ -55,11 +41,13 @@ const toolbarGroups = ({
55
41
  isEnabled: ({
56
42
  selection
57
43
  }) => {
58
- const nodes = selection?.getNodes();
59
- if (!nodes?.length) {
60
- return false;
61
- }
62
- return !nodes.some(node => disabledNodes?.includes(node.getType()));
44
+ const nodes = selection?.getNodes() ?? [];
45
+ const isIndentableAndNotDisabled = node => {
46
+ return isIndentable(node) && !(disabledNodes ?? []).includes(node.getType());
47
+ };
48
+ return nodes.some(node => {
49
+ return isIndentableAndNotDisabled(node) || Boolean($findMatchingParent(node, isIndentableAndNotDisabled));
50
+ });
63
51
  },
64
52
  key: 'indentIncrease',
65
53
  label: ({
@@ -96,7 +84,5 @@ export const IndentFeatureClient = createClientFeature(({
96
84
  }
97
85
  };
98
86
  });
99
- function $pointsAncestorMatch(selection, fn) {
100
- return $isRangeSelection(selection) && (!!$findMatchingParent(selection.anchor.getNode(), fn) || !!$findMatchingParent(selection.focus.getNode(), fn));
101
- }
87
+ const isIndentable = node => $isElementNode(node) && node.canIndent();
102
88
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["$findMatchingParent","$isElementNode","$isRangeSelection","INDENT_CONTENT_COMMAND","OUTDENT_CONTENT_COMMAND","IndentDecreaseIcon","IndentIncreaseIcon","createClientFeature","IndentPlugin","toolbarIndentGroupWithItems","toolbarGroups","disabledNodes","ChildComponent","isActive","isEnabled","selection","nodes","getNodes","length","atLeastOneNodeCanOutdent","isIndentable","node","canIndent","getIndent","$pointsAncestorMatch","key","label","i18n","t","onSelect","editor","dispatchCommand","undefined","order","some","includes","getType","IndentFeatureClient","props","plugins","Component","position","sanitizedClientFeatureProps","toolbarFixed","groups","toolbarInline","fn","anchor","getNode","focus"],"sources":["../../../../src/features/indent/client/index.tsx"],"sourcesContent":["'use client'\n\nimport type { BaseSelection, ElementNode, LexicalNode } from 'lexical'\n\nimport { $findMatchingParent } from '@lexical/utils'\nimport {\n $isElementNode,\n $isRangeSelection,\n INDENT_CONTENT_COMMAND,\n OUTDENT_CONTENT_COMMAND,\n} from 'lexical'\n\nimport type { ToolbarGroup } from '../../toolbars/types.js'\n\nimport { IndentDecreaseIcon } from '../../../lexical/ui/icons/IndentDecrease/index.js'\nimport { IndentIncreaseIcon } from '../../../lexical/ui/icons/IndentIncrease/index.js'\nimport { createClientFeature } from '../../../utilities/createClientFeature.js'\nimport { type IndentFeatureProps } from '../server/index.js'\nimport { IndentPlugin } from './IndentPlugin.js'\nimport { toolbarIndentGroupWithItems } from './toolbarIndentGroup.js'\n\nconst toolbarGroups = ({ disabledNodes }: IndentFeatureProps): ToolbarGroup[] => [\n toolbarIndentGroupWithItems([\n {\n ChildComponent: IndentDecreaseIcon,\n isActive: () => false,\n isEnabled: ({ selection }) => {\n const nodes = selection?.getNodes()\n if (!nodes?.length) {\n return false\n }\n let atLeastOneNodeCanOutdent = false\n const isIndentable = (node: LexicalNode): node is ElementNode =>\n $isElementNode(node) && node.canIndent()\n for (const node of nodes) {\n if (isIndentable(node)) {\n if (node.getIndent() <= 0) {\n return false\n } else {\n atLeastOneNodeCanOutdent = true\n }\n }\n }\n\n if (!atLeastOneNodeCanOutdent) {\n if (\n $pointsAncestorMatch(selection, (node) => isIndentable(node) && node.getIndent() > 0)\n ) {\n return true\n }\n }\n return atLeastOneNodeCanOutdent\n },\n key: 'indentDecrease',\n label: ({ i18n }) => {\n return i18n.t('lexical:indent:decreaseLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(OUTDENT_CONTENT_COMMAND, undefined)\n },\n order: 1,\n },\n {\n ChildComponent: IndentIncreaseIcon,\n isActive: () => false,\n isEnabled: ({ selection }) => {\n const nodes = selection?.getNodes()\n if (!nodes?.length) {\n return false\n }\n return !nodes.some((node) => disabledNodes?.includes(node.getType()))\n },\n key: 'indentIncrease',\n label: ({ i18n }) => {\n return i18n.t('lexical:indent:increaseLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(INDENT_CONTENT_COMMAND, undefined)\n },\n order: 2,\n },\n ]),\n]\n\nexport const IndentFeatureClient = createClientFeature<IndentFeatureProps>(({ props }) => {\n const disabledNodes = props.disabledNodes ?? []\n return {\n plugins: [\n {\n Component: IndentPlugin,\n position: 'normal',\n },\n ],\n sanitizedClientFeatureProps: props,\n toolbarFixed: {\n groups: toolbarGroups({ disabledNodes }),\n },\n toolbarInline: {\n groups: toolbarGroups({ disabledNodes }),\n },\n }\n})\n\nfunction $pointsAncestorMatch(\n selection: BaseSelection,\n fn: (node: LexicalNode) => boolean,\n): boolean {\n return (\n $isRangeSelection(selection) &&\n (!!$findMatchingParent(selection.anchor.getNode(), fn) ||\n !!$findMatchingParent(selection.focus.getNode(), fn))\n )\n}\n"],"mappings":"AAAA;;AAIA,SAASA,mBAAmB,QAAQ;AACpC,SACEC,cAAc,EACdC,iBAAiB,EACjBC,sBAAsB,EACtBC,uBAAuB,QAClB;AAIP,SAASC,kBAAkB,QAAQ;AACnC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,mBAAmB,QAAQ;AAEpC,SAASC,YAAY,QAAQ;AAC7B,SAASC,2BAA2B,QAAQ;AAE5C,MAAMC,aAAA,GAAgBA,CAAC;EAAEC;AAAa,CAAsB,KAAqB,CAC/EF,2BAAA,CAA4B,CAC1B;EACEG,cAAA,EAAgBP,kBAAA;EAChBQ,QAAA,EAAUA,CAAA,KAAM;EAChBC,SAAA,EAAWA,CAAC;IAAEC;EAAS,CAAE;IACvB,MAAMC,KAAA,GAAQD,SAAA,EAAWE,QAAA;IACzB,IA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CAAC;IAAEC;EAAM,CAAE;IACnBA,MAAA,CAAOC,eAAe,CAAC5B,sBAAA,EAAwB6B,SAAA;EACjD;EACAC,KAAA,EAAO;AACT,EACD,EACF;AAED,OAAO,MAAMI,mBAAA,GAAsB9B,mBAAA,CAAwC,CAAC;EAAE+B;AAAK,CAAE;EACnF,MAAM3B,aAAA,GAAgB2B,KAAA,CAAM3B,aAAa,IAAI,EAAE;EAC/C,OAAO;IACL4B,OAAA,EAAS,CACP;MACEC,SAAA,EAAWhC,YAAA;MACXiC,QAAA,EAAU;IACZ,EACD;IACDC,2BAAA,EAA6BJ,KAAA;IAC7BK,YAAA,EAAc;MACZC,MAAA,EAAQlC,aAAA,CAAc;QAAEC;MAAc;IACxC;IACAkC,aAAA,EAAe;MACbD,MAAA,EAAQlC,aAAA,CAAc;QAAEC;MAAc;IACxC;EACF;AACF;AAEA,SAASa,qBACPT,SAAwB,EACxB+B,EAAkC;EAElC,OACE5C,iBAAA,CAAkBa,SAAA,MACjB,CAAC,CAACf,mBAAA,CAAoBe,SAAA,CAAUgC,MAAM,CAACC,OAAO,IAAIF,EAAA,KACjD,CAAC,CAAC9C,mBAAA,CAAoBe,SAAA,CAAUkC,KAAK,CAACD,OAAO,IAAIF,EAAA,CAAE;AAEzD","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["$findMatchingParent","$isElementNode","INDENT_CONTENT_COMMAND","OUTDENT_CONTENT_COMMAND","IndentDecreaseIcon","IndentIncreaseIcon","createClientFeature","IndentPlugin","toolbarIndentGroupWithItems","toolbarGroups","disabledNodes","ChildComponent","isActive","isEnabled","selection","nodes","getNodes","isOutdentable","node","isIndentable","getIndent","some","Boolean","key","label","i18n","t","onSelect","editor","dispatchCommand","undefined","order","isIndentableAndNotDisabled","includes","getType","IndentFeatureClient","props","plugins","Component","position","sanitizedClientFeatureProps","toolbarFixed","groups","toolbarInline","canIndent"],"sources":["../../../../src/features/indent/client/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ElementNode, LexicalNode } from 'lexical'\n\nimport { $findMatchingParent } from '@lexical/utils'\nimport { $isElementNode, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND } from 'lexical'\n\nimport type { ToolbarGroup } from '../../toolbars/types.js'\n\nimport { IndentDecreaseIcon } from '../../../lexical/ui/icons/IndentDecrease/index.js'\nimport { IndentIncreaseIcon } from '../../../lexical/ui/icons/IndentIncrease/index.js'\nimport { createClientFeature } from '../../../utilities/createClientFeature.js'\nimport { type IndentFeatureProps } from '../server/index.js'\nimport { IndentPlugin } from './IndentPlugin.js'\nimport { toolbarIndentGroupWithItems } from './toolbarIndentGroup.js'\n\nconst toolbarGroups = ({ disabledNodes }: IndentFeatureProps): ToolbarGroup[] => [\n toolbarIndentGroupWithItems([\n {\n ChildComponent: IndentDecreaseIcon,\n isActive: () => false,\n isEnabled: ({ selection }) => {\n const nodes = selection?.getNodes() ?? []\n\n const isOutdentable = (node: LexicalNode) => {\n return isIndentable(node) && node.getIndent() > 0\n }\n\n return nodes.some((node) => {\n return isOutdentable(node) || Boolean($findMatchingParent(node, isOutdentable))\n })\n },\n key: 'indentDecrease',\n label: ({ i18n }) => {\n return i18n.t('lexical:indent:decreaseLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(OUTDENT_CONTENT_COMMAND, undefined)\n },\n order: 1,\n },\n {\n ChildComponent: IndentIncreaseIcon,\n isActive: () => false,\n isEnabled: ({ selection }) => {\n const nodes = selection?.getNodes() ?? []\n\n const isIndentableAndNotDisabled = (node: LexicalNode) => {\n return isIndentable(node) && !(disabledNodes ?? []).includes(node.getType())\n }\n\n return nodes.some((node) => {\n return (\n isIndentableAndNotDisabled(node) ||\n Boolean($findMatchingParent(node, isIndentableAndNotDisabled))\n )\n })\n },\n key: 'indentIncrease',\n label: ({ i18n }) => {\n return i18n.t('lexical:indent:increaseLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(INDENT_CONTENT_COMMAND, undefined)\n },\n order: 2,\n },\n ]),\n]\n\nexport const IndentFeatureClient = createClientFeature<IndentFeatureProps>(({ props }) => {\n const disabledNodes = props.disabledNodes ?? []\n return {\n plugins: [\n {\n Component: IndentPlugin,\n position: 'normal',\n },\n ],\n sanitizedClientFeatureProps: props,\n toolbarFixed: {\n groups: toolbarGroups({ disabledNodes }),\n },\n toolbarInline: {\n groups: toolbarGroups({ disabledNodes }),\n },\n }\n})\n\nconst isIndentable = (node: LexicalNode): node is ElementNode =>\n $isElementNode(node) && node.canIndent()\n"],"mappings":"AAAA;;AAIA,SAASA,mBAAmB,QAAQ;AACpC,SAASC,cAAc,EAAEC,sBAAsB,EAAEC,uBAAuB,QAAQ;AAIhF,SAASC,kBAAkB,QAAQ;AACnC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,mBAAmB,QAAQ;AAEpC,SAASC,YAAY,QAAQ;AAC7B,SAASC,2BAA2B,QAAQ;AAE5C,MAAMC,aAAA,GAAgBA,CAAC;EAAEC;AAAa,CAAsB,KAAqB,CAC/EF,2BAAA,CAA4B,CAC1B;EACEG,cAAA,EAAgBP,kBAAA;EAChBQ,QAAA,EAAUA,CAAA,KAAM;EAChBC,SAAA,EAAWA,CAAC;IAAEC;EAAS,CAAE;IACvB,MAAMC,KAAA,GAAQD,SAAA,EAAWE,QAAA,MAAc,EAAE;IAEzC,MAAMC,aAAA,GAAiBC,IAAA;MACrB,OAAOC,YAAA,CAAaD,IAAA,KAASA,IAAA,CAAKE,SAAS,KAAK;IAClD;IAEA,OAAOL,KAAA,CAAMM,IAAI,CAAEH,IAAA;MACjB,OAAOD,aAAA,CAAcC,IAAA,KAASI,OAAA,CAAQtB,mBAAA,CAAoBkB,IAAA,EAAMD,aAAA;IAClE;EACF;EACAM,GAAA,EAAK;EACLC,KAAA,EAAOA,CAAC;IAAEC;EAAI,CAAE;IACd,OAAOA,IAAA,CAAKC,CAAC,CAAC;EAChB;EACAC,QAAA,EAAUA,CAAC;IAAEC;EAAM,CAAE;IACnBA,MAAA,CAAOC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gBD,IAAA,IACpBjB,cAAA,CAAeiB,IAAA,KAASA,IAAA,CAAK0B,SAAS","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-lexical",
3
- "version": "3.36.0-canary.6",
3
+ "version": "3.36.0-canary.7",
4
4
  "description": "The officially supported Lexical richtext adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -364,8 +364,8 @@
364
364
  "react-error-boundary": "4.1.2",
365
365
  "ts-essentials": "10.0.3",
366
366
  "uuid": "10.0.0",
367
- "@payloadcms/translations": "3.36.0-canary.6",
368
- "@payloadcms/ui": "3.36.0-canary.6"
367
+ "@payloadcms/translations": "3.36.0-canary.7",
368
+ "@payloadcms/ui": "3.36.0-canary.7"
369
369
  },
370
370
  "devDependencies": {
371
371
  "@babel/cli": "7.26.4",
@@ -385,16 +385,16 @@
385
385
  "esbuild-sass-plugin": "3.3.1",
386
386
  "eslint-plugin-react-compiler": "19.0.0-beta-e993439-20250405",
387
387
  "swc-plugin-transform-remove-imports": "3.1.0",
388
- "@payloadcms/eslint-config": "3.28.0",
389
- "payload": "3.36.0-canary.6"
388
+ "payload": "3.36.0-canary.7",
389
+ "@payloadcms/eslint-config": "3.28.0"
390
390
  },
391
391
  "peerDependencies": {
392
392
  "@faceless-ui/modal": "3.0.0-beta.2",
393
393
  "@faceless-ui/scroll-info": "2.0.0",
394
394
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
395
395
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
396
- "payload": "3.36.0-canary.6",
397
- "@payloadcms/next": "3.36.0-canary.6"
396
+ "@payloadcms/next": "3.36.0-canary.7",
397
+ "payload": "3.36.0-canary.7"
398
398
  },
399
399
  "engines": {
400
400
  "node": "^18.20.2 || >=20.9.0"