@payloadcms/richtext-lexical 3.39.0-canary.5 → 3.39.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.
Files changed (37) hide show
  1. package/dist/exports/client/bundled.css +1 -1
  2. package/dist/exports/client/index.d.ts +1 -0
  3. package/dist/exports/client/index.d.ts.map +1 -1
  4. package/dist/exports/client/index.js +10 -10
  5. package/dist/exports/client/index.js.map +4 -4
  6. package/dist/features/converters/lexicalToJSX/Component/index.d.ts +0 -1
  7. package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
  8. package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
  9. package/dist/features/experimental_table/client/utils/debounce.d.ts +4 -4
  10. package/dist/features/experimental_table/client/utils/debounce.js +4 -4
  11. package/dist/features/experimental_table/client/utils/debounce.js.map +1 -1
  12. package/dist/features/textState/defaultColors.d.ts +91 -0
  13. package/dist/features/textState/defaultColors.d.ts.map +1 -0
  14. package/dist/features/textState/defaultColors.js +386 -0
  15. package/dist/features/textState/defaultColors.js.map +1 -0
  16. package/dist/features/textState/feature.client.d.ts +3 -0
  17. package/dist/features/textState/feature.client.d.ts.map +1 -0
  18. package/dist/features/textState/feature.client.js +69 -0
  19. package/dist/features/textState/feature.client.js.map +1 -0
  20. package/dist/features/textState/feature.server.d.ts +60 -0
  21. package/dist/features/textState/feature.server.d.ts.map +1 -0
  22. package/dist/features/textState/feature.server.js +25 -0
  23. package/dist/features/textState/feature.server.js.map +1 -0
  24. package/dist/features/textState/textState.d.ts +6 -0
  25. package/dist/features/textState/textState.d.ts.map +1 -0
  26. package/dist/features/textState/textState.js +67 -0
  27. package/dist/features/textState/textState.js.map +1 -0
  28. package/dist/field/bundled.css +1 -1
  29. package/dist/index.d.ts +2 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +2 -0
  32. package/dist/index.js.map +1 -1
  33. package/dist/lexical/ui/icons/TextState/index.d.ts +5 -0
  34. package/dist/lexical/ui/icons/TextState/index.d.ts.map +1 -0
  35. package/dist/lexical/ui/icons/TextState/index.js +23 -0
  36. package/dist/lexical/ui/icons/TextState/index.js.map +1 -0
  37. package/package.json +7 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultColors.js","names":["tailwindColors","amber","black","blue","current","cyan","emerald","fuchsia","gray","green","indigo","inherit","lime","neutral","orange","pink","purple","red","rose","sky","slate","stone","teal","transparent","violet","white","yellow","zinc","defaultColors","text","css","label","background"],"sources":["../../../src/features/textState/defaultColors.ts"],"sourcesContent":["import type { StateValues } from './feature.server.js'\n\nconst tailwindColors = {\n amber: {\n '50': 'oklch(0.987 0.022 95.277)',\n '100': 'oklch(0.962 0.059 95.617)',\n '200': 'oklch(0.924 0.12 95.746)',\n '300': 'oklch(0.879 0.169 91.605)',\n '400': 'oklch(0.828 0.189 84.429)',\n '500': 'oklch(0.769 0.188 70.08)',\n '600': 'oklch(0.666 0.179 58.318)',\n '700': 'oklch(0.555 0.163 48.998)',\n '800': 'oklch(0.473 0.137 46.201)',\n '900': 'oklch(0.414 0.112 45.904)',\n '950': 'oklch(0.279 0.077 45.635)',\n },\n black: '#000',\n blue: {\n '50': 'oklch(0.97 0.014 254.604)',\n '100': 'oklch(0.932 0.032 255.585)',\n '200': 'oklch(0.882 0.059 254.128)',\n '300': 'oklch(0.809 0.105 251.813)',\n '400': 'oklch(0.707 0.165 254.624)',\n '500': 'oklch(0.623 0.214 259.815)',\n '600': 'oklch(0.546 0.245 262.881)',\n '700': 'oklch(0.488 0.243 264.376)',\n '800': 'oklch(0.424 0.199 265.638)',\n '900': 'oklch(0.379 0.146 265.522)',\n '950': 'oklch(0.282 0.091 267.935)',\n },\n current: 'currentColor',\n cyan: {\n '50': 'oklch(0.984 0.019 200.873)',\n '100': 'oklch(0.956 0.045 203.388)',\n '200': 'oklch(0.917 0.08 205.041)',\n '300': 'oklch(0.865 0.127 207.078)',\n '400': 'oklch(0.789 0.154 211.53)',\n '500': 'oklch(0.715 0.143 215.221)',\n '600': 'oklch(0.609 0.126 221.723)',\n '700': 'oklch(0.52 0.105 223.128)',\n '800': 'oklch(0.45 0.085 224.283)',\n '900': 'oklch(0.398 0.07 227.392)',\n '950': 'oklch(0.302 0.056 229.695)',\n },\n emerald: {\n '50': 'oklch(0.979 0.021 166.113)',\n '100': 'oklch(0.95 0.052 163.051)',\n '200': 'oklch(0.905 0.093 164.15)',\n '300': 'oklch(0.845 0.143 164.978)',\n '400': 'oklch(0.765 0.177 163.223)',\n '500': 'oklch(0.696 0.17 162.48)',\n '600': 'oklch(0.596 0.145 163.225)',\n '700': 'oklch(0.508 0.118 165.612)',\n '800': 'oklch(0.432 0.095 166.913)',\n '900': 'oklch(0.378 0.077 168.94)',\n '950': 'oklch(0.262 0.051 172.552)',\n },\n fuchsia: {\n '50': 'oklch(0.977 0.017 320.058)',\n '100': 'oklch(0.952 0.037 318.852)',\n '200': 'oklch(0.903 0.076 319.62)',\n '300': 'oklch(0.833 0.145 321.434)',\n '400': 'oklch(0.74 0.238 322.16)',\n '500': 'oklch(0.667 0.295 322.15)',\n '600': 'oklch(0.591 0.293 322.896)',\n '700': 'oklch(0.518 0.253 323.949)',\n '800': 'oklch(0.452 0.211 324.591)',\n '900': 'oklch(0.401 0.17 325.612)',\n '950': 'oklch(0.293 0.136 325.661)',\n },\n gray: {\n '50': 'oklch(0.985 0.002 247.839)',\n '100': 'oklch(0.967 0.003 264.542)',\n '200': 'oklch(0.928 0.006 264.531)',\n '300': 'oklch(0.872 0.01 258.338)',\n '400': 'oklch(0.707 0.022 261.325)',\n '500': 'oklch(0.551 0.027 264.364)',\n '600': 'oklch(0.446 0.03 256.802)',\n '700': 'oklch(0.373 0.034 259.733)',\n '800': 'oklch(0.278 0.033 256.848)',\n '900': 'oklch(0.21 0.034 264.665)',\n '950': 'oklch(0.13 0.028 261.692)',\n },\n green: {\n '50': 'oklch(0.982 0.018 155.826)',\n '100': 'oklch(0.962 0.044 156.743)',\n '200': 'oklch(0.925 0.084 155.995)',\n '300': 'oklch(0.871 0.15 154.449)',\n '400': 'oklch(0.792 0.209 151.711)',\n '500': 'oklch(0.723 0.219 149.579)',\n '600': 'oklch(0.627 0.194 149.214)',\n '700': 'oklch(0.527 0.154 150.069)',\n '800': 'oklch(0.448 0.119 151.328)',\n '900': 'oklch(0.393 0.095 152.535)',\n '950': 'oklch(0.266 0.065 152.934)',\n },\n indigo: {\n '50': 'oklch(0.962 0.018 272.314)',\n '100': 'oklch(0.93 0.034 272.788)',\n '200': 'oklch(0.87 0.065 274.039)',\n '300': 'oklch(0.785 0.115 274.713)',\n '400': 'oklch(0.673 0.182 276.935)',\n '500': 'oklch(0.585 0.233 277.117)',\n '600': 'oklch(0.511 0.262 276.966)',\n '700': 'oklch(0.457 0.24 277.023)',\n '800': 'oklch(0.398 0.195 277.366)',\n '900': 'oklch(0.359 0.144 278.697)',\n '950': 'oklch(0.257 0.09 281.288)',\n },\n inherit: 'inherit',\n lime: {\n '50': 'oklch(0.986 0.031 120.757)',\n '100': 'oklch(0.967 0.067 122.328)',\n '200': 'oklch(0.938 0.127 124.321)',\n '300': 'oklch(0.897 0.196 126.665)',\n '400': 'oklch(0.841 0.238 128.85)',\n '500': 'oklch(0.768 0.233 130.85)',\n '600': 'oklch(0.648 0.2 131.684)',\n '700': 'oklch(0.532 0.157 131.589)',\n '800': 'oklch(0.453 0.124 130.933)',\n '900': 'oklch(0.405 0.101 131.063)',\n '950': 'oklch(0.274 0.072 132.109)',\n },\n neutral: {\n '50': 'oklch(0.985 0 0)',\n '100': 'oklch(0.97 0 0)',\n '200': 'oklch(0.922 0 0)',\n '300': 'oklch(0.87 0 0)',\n '400': 'oklch(0.708 0 0)',\n '500': 'oklch(0.556 0 0)',\n '600': 'oklch(0.439 0 0)',\n '700': 'oklch(0.371 0 0)',\n '800': 'oklch(0.269 0 0)',\n '900': 'oklch(0.205 0 0)',\n '950': 'oklch(0.145 0 0)',\n },\n orange: {\n '50': 'oklch(0.98 0.016 73.684)',\n '100': 'oklch(0.954 0.038 75.164)',\n '200': 'oklch(0.901 0.076 70.697)',\n '300': 'oklch(0.837 0.128 66.29)',\n '400': 'oklch(0.75 0.183 55.934)',\n '500': 'oklch(0.705 0.213 47.604)',\n '600': 'oklch(0.646 0.222 41.116)',\n '700': 'oklch(0.553 0.195 38.402)',\n '800': 'oklch(0.47 0.157 37.304)',\n '900': 'oklch(0.408 0.123 38.172)',\n '950': 'oklch(0.266 0.079 36.259)',\n },\n pink: {\n '50': 'oklch(0.971 0.014 343.198)',\n '100': 'oklch(0.948 0.028 342.258)',\n '200': 'oklch(0.899 0.061 343.231)',\n '300': 'oklch(0.823 0.12 346.018)',\n '400': 'oklch(0.718 0.202 349.761)',\n '500': 'oklch(0.656 0.241 354.308)',\n '600': 'oklch(0.592 0.249 0.584)',\n '700': 'oklch(0.525 0.223 3.958)',\n '800': 'oklch(0.459 0.187 3.815)',\n '900': 'oklch(0.408 0.153 2.432)',\n '950': 'oklch(0.284 0.109 3.907)',\n },\n purple: {\n '50': 'oklch(0.977 0.014 308.299)',\n '100': 'oklch(0.946 0.033 307.174)',\n '200': 'oklch(0.902 0.063 306.703)',\n '300': 'oklch(0.827 0.119 306.383)',\n '400': 'oklch(0.714 0.203 305.504)',\n '500': 'oklch(0.627 0.265 303.9)',\n '600': 'oklch(0.558 0.288 302.321)',\n '700': 'oklch(0.496 0.265 301.924)',\n '800': 'oklch(0.438 0.218 303.724)',\n '900': 'oklch(0.381 0.176 304.987)',\n '950': 'oklch(0.291 0.149 302.717)',\n },\n red: {\n '50': 'oklch(0.971 0.013 17.38)',\n '100': 'oklch(0.936 0.032 17.717)',\n '200': 'oklch(0.885 0.062 18.334)',\n '300': 'oklch(0.808 0.114 19.571)',\n '400': 'oklch(0.704 0.191 22.216)',\n '500': 'oklch(0.637 0.237 25.331)',\n '600': 'oklch(0.577 0.245 27.325)',\n '700': 'oklch(0.505 0.213 27.518)',\n '800': 'oklch(0.444 0.177 26.899)',\n '900': 'oklch(0.396 0.141 25.723)',\n '950': 'oklch(0.258 0.092 26.042)',\n },\n rose: {\n '50': 'oklch(0.969 0.015 12.422)',\n '100': 'oklch(0.941 0.03 12.58)',\n '200': 'oklch(0.892 0.058 10.001)',\n '300': 'oklch(0.81 0.117 11.638)',\n '400': 'oklch(0.712 0.194 13.428)',\n '500': 'oklch(0.645 0.246 16.439)',\n '600': 'oklch(0.586 0.253 17.585)',\n '700': 'oklch(0.514 0.222 16.935)',\n '800': 'oklch(0.455 0.188 13.697)',\n '900': 'oklch(0.41 0.159 10.272)',\n '950': 'oklch(0.271 0.105 12.094)',\n },\n sky: {\n '50': 'oklch(0.977 0.013 236.62)',\n '100': 'oklch(0.951 0.026 236.824)',\n '200': 'oklch(0.901 0.058 230.902)',\n '300': 'oklch(0.828 0.111 230.318)',\n '400': 'oklch(0.746 0.16 232.661)',\n '500': 'oklch(0.685 0.169 237.323)',\n '600': 'oklch(0.588 0.158 241.966)',\n '700': 'oklch(0.5 0.134 242.749)',\n '800': 'oklch(0.443 0.11 240.79)',\n '900': 'oklch(0.391 0.09 240.876)',\n '950': 'oklch(0.293 0.066 243.157)',\n },\n slate: {\n '50': 'oklch(0.984 0.003 247.858)',\n '100': 'oklch(0.968 0.007 247.896)',\n '200': 'oklch(0.929 0.013 255.508)',\n '300': 'oklch(0.869 0.022 252.894)',\n '400': 'oklch(0.704 0.04 256.788)',\n '500': 'oklch(0.554 0.046 257.417)',\n '600': 'oklch(0.446 0.043 257.281)',\n '700': 'oklch(0.372 0.044 257.287)',\n '800': 'oklch(0.279 0.041 260.031)',\n '900': 'oklch(0.208 0.042 265.755)',\n '950': 'oklch(0.129 0.042 264.695)',\n },\n stone: {\n '50': 'oklch(0.985 0.001 106.423)',\n '100': 'oklch(0.97 0.001 106.424)',\n '200': 'oklch(0.923 0.003 48.717)',\n '300': 'oklch(0.869 0.005 56.366)',\n '400': 'oklch(0.709 0.01 56.259)',\n '500': 'oklch(0.553 0.013 58.071)',\n '600': 'oklch(0.444 0.011 73.639)',\n '700': 'oklch(0.374 0.01 67.558)',\n '800': 'oklch(0.268 0.007 34.298)',\n '900': 'oklch(0.216 0.006 56.043)',\n '950': 'oklch(0.147 0.004 49.25)',\n },\n teal: {\n '50': 'oklch(0.984 0.014 180.72)',\n '100': 'oklch(0.953 0.051 180.801)',\n '200': 'oklch(0.91 0.096 180.426)',\n '300': 'oklch(0.855 0.138 181.071)',\n '400': 'oklch(0.777 0.152 181.912)',\n '500': 'oklch(0.704 0.14 182.503)',\n '600': 'oklch(0.6 0.118 184.704)',\n '700': 'oklch(0.511 0.096 186.391)',\n '800': 'oklch(0.437 0.078 188.216)',\n '900': 'oklch(0.386 0.063 188.416)',\n '950': 'oklch(0.277 0.046 192.524)',\n },\n transparent: 'transparent',\n violet: {\n '50': 'oklch(0.969 0.016 293.756)',\n '100': 'oklch(0.943 0.029 294.588)',\n '200': 'oklch(0.894 0.057 293.283)',\n '300': 'oklch(0.811 0.111 293.571)',\n '400': 'oklch(0.702 0.183 293.541)',\n '500': 'oklch(0.606 0.25 292.717)',\n '600': 'oklch(0.541 0.281 293.009)',\n '700': 'oklch(0.491 0.27 292.581)',\n '800': 'oklch(0.432 0.232 292.759)',\n '900': 'oklch(0.38 0.189 293.745)',\n '950': 'oklch(0.283 0.141 291.089)',\n },\n white: '#fff',\n yellow: {\n '50': 'oklch(0.987 0.026 102.212)',\n '100': 'oklch(0.973 0.071 103.193)',\n '200': 'oklch(0.945 0.129 101.54)',\n '300': 'oklch(0.905 0.182 98.111)',\n '400': 'oklch(0.852 0.199 91.936)',\n '500': 'oklch(0.795 0.184 86.047)',\n '600': 'oklch(0.681 0.162 75.834)',\n '700': 'oklch(0.554 0.135 66.442)',\n '800': 'oklch(0.476 0.114 61.907)',\n '900': 'oklch(0.421 0.095 57.708)',\n '950': 'oklch(0.286 0.066 53.813)',\n },\n zinc: {\n '50': 'oklch(0.985 0 0)',\n '100': 'oklch(0.967 0.001 286.375)',\n '200': 'oklch(0.92 0.004 286.32)',\n '300': 'oklch(0.871 0.006 286.286)',\n '400': 'oklch(0.705 0.015 286.067)',\n '500': 'oklch(0.552 0.016 285.938)',\n '600': 'oklch(0.442 0.017 285.786)',\n '700': 'oklch(0.37 0.013 285.805)',\n '800': 'oklch(0.274 0.006 286.033)',\n '900': 'oklch(0.21 0.006 285.885)',\n '950': 'oklch(0.141 0.005 285.823)',\n },\n}\n\n// prettier-ignore\n/* eslint-disable perfectionist/sort-objects */\nexport const defaultColors = {\n text: {\n 'text-red': { css: { 'color': `light-dark(${tailwindColors.red[600]}, ${tailwindColors.red[400]})`, }, label: 'Red' },\n 'text-orange': { css: { 'color': `light-dark(${tailwindColors.orange[600]}, ${tailwindColors.orange[400]})`, }, label: 'Orange' },\n 'text-yellow': { css: { 'color': `light-dark(${tailwindColors.yellow[700]}, ${tailwindColors.yellow[300]})`, }, label: 'Yellow' },\n 'text-green': { css: { 'color': `light-dark(${tailwindColors.green[700]}, ${tailwindColors.green[400]})`, }, label: 'Green' },\n 'text-blue': { css: { 'color': `light-dark(${tailwindColors.blue[600]}, ${tailwindColors.blue[400]})`, }, label: 'Blue' },\n 'text-purple': { css: { 'color': `light-dark(${tailwindColors.purple[600]}, ${tailwindColors.purple[400]})`, }, label: 'Purple' },\n 'text-pink': { css: { 'color': `light-dark(${tailwindColors.pink[600]}, ${tailwindColors.pink[400]})`, }, label: 'Pink' },\n } satisfies StateValues,\n background: {\n 'bg-red': { css: { 'background-color': `light-dark(${tailwindColors.red[400]}, ${tailwindColors.red[600]})`, }, label: 'Red' },\n 'bg-orange': { css: { 'background-color': `light-dark(${tailwindColors.orange[400]}, ${tailwindColors.orange[600]})`, }, label: 'Orange' },\n 'bg-yellow': { css: { 'background-color': `light-dark(${tailwindColors.yellow[300]}, ${tailwindColors.yellow[700]})`, }, label: 'Yellow' },\n 'bg-green': { css: { 'background-color': `light-dark(${tailwindColors.green[400]}, ${tailwindColors.green[700]})`, }, label: 'Green' },\n 'bg-blue': { css: { 'background-color': `light-dark(${tailwindColors.blue[400]}, ${tailwindColors.blue[600]})`, }, label: 'Blue' },\n 'bg-purple': { css: { 'background-color': `light-dark(${tailwindColors.purple[400]}, ${tailwindColors.purple[600]})`, }, label: 'Purple' },\n 'bg-pink': { css: { 'background-color': `light-dark(${tailwindColors.pink[400]}, ${tailwindColors.pink[600]})`, }, label: 'Pink' },\n } satisfies StateValues\n }\n"],"mappings":"AAEA,MAAMA,cAAA,GAAiB;EACrBC,KAAA,EAAO;IACL,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;EACT;EACAC,KAAA,EAAO;EACPC,IAAA,EAAM;IACJ,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;EACT;EACAC,OAAA,EAAS;EACTC,IAAA,EAAM;IACJ,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;EACT;EACAC,OAAA,EAAS;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;EACT;EACAC,OAAA,EAAS;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;EACT;EACAC,IAAA,EAAM;IACJ,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;EACT;EACAC,KAAA,EAAO;IACL,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;EACT;EACAC,MAAA,EAAQ;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;EACT;EACAC,OAAA,EAAS;EACTC,IAAA,EAAM;IACJ,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;EACT;EACAC,OAAA,EAAS;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;EACT;EACAC,MAAA,EAAQ;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;EACT;EACAC,IAAA,EAAM;IACJ,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;EACT;EACAC,MAAA,EAAQ;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;EACT;EACAC,GAAA,EAAK;IACH,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;EACT;EACAC,IAAA,EAAM;IACJ,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAA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Aec,MAAM,CAAC,IAAI;MAAK;MAAGiB,KAAA,EAAO;IAAS;IACzI,aAAa;MAAED,GAAA,EAAK;QAAE,oBAAoB,cAAc9B,cAAA,CAAe0B,MAAM,CAAC,IAAI,KAAK1B,cAAA,CAAe0B,MAAM,CAAC,IAAI;MAAK;MAAGK,KAAA,EAAO;IAAS;IACzI,YAAY;MAAED,GAAA,EAAK;QAAE,oBAAoB,cAAc9B,cAAA,CAAeS,KAAK,CAAC,IAAI,KAAKT,cAAA,CAAeS,KAAK,CAAC,IAAI;MAAK;MAAGsB,KAAA,EAAO;IAAQ;IACrI,WAAW;MAAED,GAAA,EAAK;QAAE,oBAAoB,cAAc9B,cAAA,CAAeG,IAAI,CAAC,IAAI,KAAKH,cAAA,CAAeG,IAAI,CAAC,IAAI;MAAK;MAAG4B,KAAA,EAAO;IAAO;IACjI,aAAa;MAAED,GAAA,EAAK;QAAE,oBAAoB,cAAc9B,cAAA,CAAegB,MAAM,CAAC,IAAI,KAAKhB,cAAA,CAAegB,MAAM,CAAC,IAAI;MAAK;MAAGe,KAAA,EAAO;IAAS;IACzI,WAAW;MAAED,GAAA,EAAK;QAAE,oBAAoB,cAAc9B,cAAA,CAAee,IAAI,CAAC,IAAI,KAAKf,cAAA,CAAee,IAAI,CAAC,IAAI;MAAK;MAAGgB,KAAA,EAAO;IAAO;EACnI;AACF","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import type { TextStateFeatureProps } from './feature.server.js';
2
+ export declare const TextStateFeatureClient: import("../typesClient.js").FeatureProviderProviderClient<TextStateFeatureProps, TextStateFeatureProps>;
3
+ //# sourceMappingURL=feature.client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature.client.d.ts","sourceRoot":"","sources":["../../../src/features/textState/feature.client.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAiDhE,eAAO,MAAM,sBAAsB,yGAgBjC,CAAA"}
@@ -0,0 +1,69 @@
1
+ 'use client';
2
+
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ import { TextStateIcon } from '../../lexical/ui/icons/TextState/index.js';
5
+ import { createClientFeature } from '../../utilities/createClientFeature.js';
6
+ import { registerTextStates, setTextState, StatePlugin } from './textState.js';
7
+ const toolbarGroups = props => {
8
+ const items = [];
9
+ for (const stateKey in props.state) {
10
+ const key = props.state[stateKey];
11
+ for (const stateValue in key) {
12
+ const meta = key[stateValue];
13
+ items.push({
14
+ ChildComponent: () => /*#__PURE__*/_jsx(TextStateIcon, {
15
+ css: meta.css
16
+ }),
17
+ key: stateValue,
18
+ label: meta.label,
19
+ onSelect: ({
20
+ editor
21
+ }) => {
22
+ setTextState(editor, stateKey, stateValue);
23
+ }
24
+ });
25
+ }
26
+ }
27
+ const clearStyle = [{
28
+ ChildComponent: () => /*#__PURE__*/_jsx(TextStateIcon, {}),
29
+ key: `clear-style`,
30
+ label: 'Default style',
31
+ onSelect: ({
32
+ editor
33
+ }) => {
34
+ for (const stateKey in props.state) {
35
+ setTextState(editor, stateKey, undefined);
36
+ }
37
+ },
38
+ order: 1
39
+ }];
40
+ return [{
41
+ type: 'dropdown',
42
+ ChildComponent: () => /*#__PURE__*/_jsx(TextStateIcon, {
43
+ css: {
44
+ color: 'var(--theme-elevation-600)'
45
+ }
46
+ }),
47
+ items: [...clearStyle, ...items],
48
+ key: 'textState',
49
+ order: 30
50
+ }];
51
+ };
52
+ export const TextStateFeatureClient = createClientFeature(({
53
+ props
54
+ }) => {
55
+ registerTextStates(props.state);
56
+ return {
57
+ plugins: [{
58
+ Component: StatePlugin,
59
+ position: 'normal'
60
+ }],
61
+ toolbarFixed: {
62
+ groups: toolbarGroups(props)
63
+ },
64
+ toolbarInline: {
65
+ groups: toolbarGroups(props)
66
+ }
67
+ };
68
+ });
69
+ //# sourceMappingURL=feature.client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature.client.js","names":["TextStateIcon","createClientFeature","registerTextStates","setTextState","StatePlugin","toolbarGroups","props","items","stateKey","state","key","stateValue","meta","push","ChildComponent","_jsx","css","label","onSelect","editor","clearStyle","undefined","order","type","color","TextStateFeatureClient","plugins","Component","position","toolbarFixed","groups","toolbarInline"],"sources":["../../../src/features/textState/feature.client.tsx"],"sourcesContent":["'use client'\n\nimport type { ToolbarDropdownGroup, ToolbarGroup } from '../toolbars/types.js'\nimport type { TextStateFeatureProps } from './feature.server.js'\n\nimport { TextStateIcon } from '../../lexical/ui/icons/TextState/index.js'\nimport { createClientFeature } from '../../utilities/createClientFeature.js'\nimport { registerTextStates, setTextState, StatePlugin } from './textState.js'\n\nconst toolbarGroups = (props: TextStateFeatureProps): ToolbarGroup[] => {\n const items: ToolbarDropdownGroup['items'] = []\n\n for (const stateKey in props.state) {\n const key = props.state[stateKey]!\n for (const stateValue in key) {\n const meta = key[stateValue]!\n items.push({\n ChildComponent: () => <TextStateIcon css={meta.css} />,\n key: stateValue,\n label: meta.label,\n onSelect: ({ editor }) => {\n setTextState(editor, stateKey, stateValue)\n },\n })\n }\n }\n\n const clearStyle: ToolbarDropdownGroup['items'] = [\n {\n ChildComponent: () => <TextStateIcon />,\n key: `clear-style`,\n label: 'Default style',\n onSelect: ({ editor }) => {\n for (const stateKey in props.state) {\n setTextState(editor, stateKey, undefined)\n }\n },\n order: 1,\n },\n ]\n\n return [\n {\n type: 'dropdown',\n ChildComponent: () => <TextStateIcon css={{ color: 'var(--theme-elevation-600)' }} />,\n items: [...clearStyle, ...items],\n key: 'textState',\n order: 30,\n },\n ]\n}\n\nexport const TextStateFeatureClient = createClientFeature<TextStateFeatureProps>(({ props }) => {\n registerTextStates(props.state)\n return {\n plugins: [\n {\n Component: StatePlugin,\n position: 'normal',\n },\n ],\n toolbarFixed: {\n groups: toolbarGroups(props),\n },\n toolbarInline: {\n groups: toolbarGroups(props),\n },\n }\n})\n"],"mappings":"AAAA;;;AAKA,SAASA,aAAa,QAAQ;AAC9B,SAASC,mBAAmB,QAAQ;AACpC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MG,sBAAA,GAAyBxB,mBAAA,CAA2C,CAAC;EAAEK;AAAK,CAAE;EACzFJ,kBAAA,CAAmBI,KAAA,CAAMG,KAAK;EAC9B,OAAO;IACLiB,OAAA,EAAS,CACP;MACEC,SAAA,EAAWvB,WAAA;MACXwB,QAAA,EAAU;IACZ,EACD;IACDC,YAAA,EAAc;MACZC,MAAA,EAAQzB,aAAA,CAAcC,KAAA;IACxB;IACAyB,aAAA,EAAe;MACbD,MAAA,EAAQzB,aAAA,CAAcC,KAAA;IACxB;EACF;AACF","ignoreList":[]}
@@ -0,0 +1,60 @@
1
+ import type { PropertiesHyphenFallback } from 'csstype';
2
+ import type { Prettify } from 'ts-essentials';
3
+ export type StyleObject = Prettify<{
4
+ [K in keyof PropertiesHyphenFallback]?: Extract<PropertiesHyphenFallback[K], string> | undefined;
5
+ }>;
6
+ export type StateValues = {
7
+ [stateValue: string]: {
8
+ css: StyleObject;
9
+ label: string;
10
+ };
11
+ };
12
+ export type TextStateFeatureProps = {
13
+ /**
14
+ * The keys of the top-level object (stateKeys) represent the attributes that the textNode can have (e.g., color).
15
+ * The values of the top-level object (stateValues) represent the values that the attribute can have (e.g., red, blue, etc.).
16
+ * Within the stateValue, you can define inline styles and labels.
17
+ *
18
+ * @note Because this is a common use case, we provide a defaultColors object with colors that
19
+ * look good in both dark and light mode, which you can use or adapt to your liking.
20
+ *
21
+ *
22
+ *
23
+ * @example
24
+ * import { defaultColors } from '@payloadcms/richtext-lexical'
25
+ *
26
+ * state: {
27
+ * color: {
28
+ * ...defaultColors.background,
29
+ * ...defaultColors.text,
30
+ * // fancy gradients!
31
+ * galaxy: { label: 'Galaxy', css: { background: 'linear-gradient(to right, #0000ff, #ff0000)', color: 'white' } },
32
+ * sunset: { label: 'Sunset', css: { background: 'linear-gradient(to top, #ff5f6d, #6a3093)' } },
33
+ * },
34
+ * // You can have both colored and underlined text at the same time.
35
+ * // If you don't want that, you should group them within the same key.
36
+ * // (just like I did with defaultColors and my fancy gradients)
37
+ * underline: {
38
+ * 'solid': { label: 'Solid', css: { 'text-decoration': 'underline', 'text-underline-offset': '4px' } },
39
+ * // You'll probably want to use the CSS light-dark() utility.
40
+ * 'yellow-dashed': { label: 'Yellow Dashed', css: { 'text-decoration': 'underline dashed', 'text-decoration-color': 'light-dark(#EAB308,yellow)', 'text-underline-offset': '4px' } },
41
+ * },
42
+ * }
43
+ *
44
+ */
45
+ state: {
46
+ [stateKey: string]: StateValues;
47
+ };
48
+ };
49
+ /**
50
+ * Allows you to store key-value attributes within TextNodes and define inline styles for each combination.
51
+ * Inline styles are not part of the editorState, reducing the JSON size and allowing you to easily migrate or adapt styles later.
52
+ *
53
+ * This feature can be used, among other things, to add colors to text.
54
+ *
55
+ * For more information and examples, see the JSdocs for the "state" property that this feature receives as a parameter.
56
+ *
57
+ * @experimental There may be breaking changes to this API
58
+ */
59
+ export declare const TextStateFeature: import("../typesServer.js").FeatureProviderProviderServer<TextStateFeatureProps, TextStateFeatureProps, TextStateFeatureProps>;
60
+ //# sourceMappingURL=feature.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../src/features/textState/feature.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAK7C,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;KAChC,CAAC,IAAI,MAAM,wBAAwB,CAAC,CAAC,EAClC,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,GAG5C,SAAS;CACd,CAAC,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG;IAAE,CAAC,UAAU,EAAE,MAAM,GAAG;QAAE,GAAG,EAAE,WAAW,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAA;AAEvF,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,KAAK,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE,CAAA;CAC3C,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,gIAc3B,CAAA"}
@@ -0,0 +1,25 @@
1
+ import { createServerFeature } from '../../utilities/createServerFeature.js';
2
+ /**
3
+ * Allows you to store key-value attributes within TextNodes and define inline styles for each combination.
4
+ * Inline styles are not part of the editorState, reducing the JSON size and allowing you to easily migrate or adapt styles later.
5
+ *
6
+ * This feature can be used, among other things, to add colors to text.
7
+ *
8
+ * For more information and examples, see the JSdocs for the "state" property that this feature receives as a parameter.
9
+ *
10
+ * @experimental There may be breaking changes to this API
11
+ */
12
+ export const TextStateFeature = createServerFeature({
13
+ feature: ({
14
+ props
15
+ }) => {
16
+ return {
17
+ ClientFeature: '@payloadcms/richtext-lexical/client#TextStateFeatureClient',
18
+ clientFeatureProps: {
19
+ state: props.state
20
+ }
21
+ };
22
+ },
23
+ key: 'textState'
24
+ });
25
+ //# sourceMappingURL=feature.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature.server.js","names":["createServerFeature","TextStateFeature","feature","props","ClientFeature","clientFeatureProps","state","key"],"sources":["../../../src/features/textState/feature.server.ts"],"sourcesContent":["import type { PropertiesHyphenFallback } from 'csstype'\nimport type { Prettify } from 'ts-essentials'\n\nimport { createServerFeature } from '../../utilities/createServerFeature.js'\n\n// extracted from https://github.com/facebook/lexical/pull/7294\nexport type StyleObject = Prettify<{\n [K in keyof PropertiesHyphenFallback]?:\n | Extract<PropertiesHyphenFallback[K], string>\n // This is simplified to not deal with arrays or numbers.\n // This is an example after all!\n | undefined\n}>\n\nexport type StateValues = { [stateValue: string]: { css: StyleObject; label: string } }\n\nexport type TextStateFeatureProps = {\n /**\n * The keys of the top-level object (stateKeys) represent the attributes that the textNode can have (e.g., color).\n * The values of the top-level object (stateValues) represent the values that the attribute can have (e.g., red, blue, etc.).\n * Within the stateValue, you can define inline styles and labels.\n *\n * @note Because this is a common use case, we provide a defaultColors object with colors that\n * look good in both dark and light mode, which you can use or adapt to your liking.\n *\n *\n *\n * @example\n * import { defaultColors } from '@payloadcms/richtext-lexical'\n *\n * state: {\n * color: {\n * ...defaultColors.background,\n * ...defaultColors.text,\n * // fancy gradients!\n * galaxy: { label: 'Galaxy', css: { background: 'linear-gradient(to right, #0000ff, #ff0000)', color: 'white' } },\n * sunset: { label: 'Sunset', css: { background: 'linear-gradient(to top, #ff5f6d, #6a3093)' } },\n * },\n * // You can have both colored and underlined text at the same time.\n * // If you don't want that, you should group them within the same key.\n * // (just like I did with defaultColors and my fancy gradients)\n * underline: {\n * 'solid': { label: 'Solid', css: { 'text-decoration': 'underline', 'text-underline-offset': '4px' } },\n * // You'll probably want to use the CSS light-dark() utility.\n * 'yellow-dashed': { label: 'Yellow Dashed', css: { 'text-decoration': 'underline dashed', 'text-decoration-color': 'light-dark(#EAB308,yellow)', 'text-underline-offset': '4px' } },\n * },\n * }\n *\n */\n state: { [stateKey: string]: StateValues }\n}\n\n/**\n * Allows you to store key-value attributes within TextNodes and define inline styles for each combination.\n * Inline styles are not part of the editorState, reducing the JSON size and allowing you to easily migrate or adapt styles later.\n *\n * This feature can be used, among other things, to add colors to text.\n *\n * For more information and examples, see the JSdocs for the \"state\" property that this feature receives as a parameter.\n *\n * @experimental There may be breaking changes to this API\n */\nexport const TextStateFeature = createServerFeature<\n TextStateFeatureProps,\n TextStateFeatureProps,\n TextStateFeatureProps\n>({\n feature: ({ props }) => {\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#TextStateFeatureClient',\n clientFeatureProps: {\n state: props.state,\n },\n }\n },\n key: 'textState',\n})\n"],"mappings":"AAGA,SAASA,mBAAmB,QAAQ;AAiDpC;;;;;;;;;;AAUA,OAAO,MAAMC,gBAAA,GAAmBD,mBAAA,CAI9B;EACAE,OAAA,EAASA,CAAC;IAAEC;EAAK,CAAE;IACjB,OAAO;MACLC,aAAA,EAAe;MACfC,kBAAA,EAAoB;QAClBC,KAAA,EAAOH,KAAA,CAAMG;MACf;IACF;EACF;EACAC,GAAA,EAAK;AACP","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import type { LexicalEditor } from 'lexical';
2
+ import { type TextStateFeatureProps } from './feature.server.js';
3
+ export declare function registerTextStates(state: TextStateFeatureProps['state']): void;
4
+ export declare function setTextState(editor: LexicalEditor, stateKey: string, value: string | undefined): void;
5
+ export declare function StatePlugin(): null;
6
+ //# sourceMappingURL=textState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textState.d.ts","sourceRoot":"","sources":["../../../src/features/textState/textState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,SAAS,CAAA;AAOzD,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAUlF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,qBAAqB,CAAC,OAAO,CAAC,QASvE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,QAU9F;AAED,wBAAgB,WAAW,SAuC1B"}
@@ -0,0 +1,67 @@
1
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
2
+ import { $forEachSelectedTextNode } from '@lexical/selection';
3
+ import { $getNodeByKey, $getState, $setState, createState, TextNode } from 'lexical';
4
+ import { useEffect } from 'react';
5
+ const stateMap = new Map();
6
+ export function registerTextStates(state) {
7
+ for (const stateKey in state) {
8
+ const stateValues = state[stateKey];
9
+ const stateConfig = createState(stateKey, {
10
+ parse: value => typeof value === 'string' && Object.keys(stateValues).includes(value) ? value : undefined
11
+ });
12
+ stateMap.set(stateKey, {
13
+ stateConfig,
14
+ stateValues
15
+ });
16
+ }
17
+ }
18
+ export function setTextState(editor, stateKey, value) {
19
+ editor.update(() => {
20
+ $forEachSelectedTextNode(textNode => {
21
+ const stateMapEntry = stateMap.get(stateKey);
22
+ if (!stateMapEntry) {
23
+ throw new Error(`State config for ${stateKey} not found`);
24
+ }
25
+ $setState(textNode, stateMapEntry.stateConfig, value);
26
+ });
27
+ });
28
+ }
29
+ export function StatePlugin() {
30
+ const [editor] = useLexicalComposerContext();
31
+ useEffect(() => {
32
+ return editor.registerMutationListener(TextNode, mutatedNodes => {
33
+ editor.getEditorState().read(() => {
34
+ for (const [nodeKey, mutation] of mutatedNodes) {
35
+ if (mutation === 'destroyed') {
36
+ continue;
37
+ }
38
+ const node = $getNodeByKey(nodeKey);
39
+ const dom = editor.getElementByKey(nodeKey);
40
+ if (!node || !dom) {
41
+ continue;
42
+ }
43
+ // stateKey could be color for example
44
+ stateMap.forEach((stateEntry, _stateKey) => {
45
+ // stateValue could be bg-red for example
46
+ const stateValue = $getState(node, stateEntry.stateConfig);
47
+ if (!stateValue) {
48
+ delete dom.dataset[_stateKey];
49
+ dom.style.cssText = '';
50
+ return;
51
+ }
52
+ dom.dataset[_stateKey] = stateValue;
53
+ const css = stateEntry.stateValues[stateValue]?.css;
54
+ if (!css) {
55
+ return;
56
+ }
57
+ Object.entries(css).forEach(([key, value]) => {
58
+ dom.style.setProperty(key, value);
59
+ });
60
+ });
61
+ }
62
+ });
63
+ });
64
+ }, [editor]);
65
+ return null;
66
+ }
67
+ //# sourceMappingURL=textState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textState.js","names":["useLexicalComposerContext","$forEachSelectedTextNode","$getNodeByKey","$getState","$setState","createState","TextNode","useEffect","stateMap","Map","registerTextStates","state","stateKey","stateValues","stateConfig","parse","value","Object","keys","includes","undefined","set","setTextState","editor","update","textNode","stateMapEntry","get","Error","StatePlugin","registerMutationListener","mutatedNodes","getEditorState","read","nodeKey","mutation","node","dom","getElementByKey","forEach","stateEntry","_stateKey","stateValue","dataset","style","cssText","css","entries","key","setProperty"],"sources":["../../../src/features/textState/textState.ts"],"sourcesContent":["import type { LexicalEditor, StateConfig } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $forEachSelectedTextNode } from '@lexical/selection'\nimport { $getNodeByKey, $getState, $setState, createState, TextNode } from 'lexical'\nimport { useEffect } from 'react'\n\nimport { type StateValues, type TextStateFeatureProps } from './feature.server.js'\n\nconst stateMap = new Map<\n string,\n {\n stateConfig: StateConfig<string, string | undefined>\n stateValues: StateValues\n }\n>()\n\nexport function registerTextStates(state: TextStateFeatureProps['state']) {\n for (const stateKey in state) {\n const stateValues = state[stateKey]!\n const stateConfig = createState(stateKey, {\n parse: (value) =>\n typeof value === 'string' && Object.keys(stateValues).includes(value) ? value : undefined,\n })\n stateMap.set(stateKey, { stateConfig, stateValues })\n }\n}\n\nexport function setTextState(editor: LexicalEditor, stateKey: string, value: string | undefined) {\n editor.update(() => {\n $forEachSelectedTextNode((textNode) => {\n const stateMapEntry = stateMap.get(stateKey)\n if (!stateMapEntry) {\n throw new Error(`State config for ${stateKey} not found`)\n }\n $setState(textNode, stateMapEntry.stateConfig, value)\n })\n })\n}\n\nexport function StatePlugin() {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n return editor.registerMutationListener(TextNode, (mutatedNodes) => {\n editor.getEditorState().read(() => {\n for (const [nodeKey, mutation] of mutatedNodes) {\n if (mutation === 'destroyed') {\n continue\n }\n const node = $getNodeByKey(nodeKey)\n const dom = editor.getElementByKey(nodeKey)\n if (!node || !dom) {\n continue\n }\n // stateKey could be color for example\n stateMap.forEach((stateEntry, _stateKey) => {\n // stateValue could be bg-red for example\n const stateValue = $getState(node, stateEntry.stateConfig)\n if (!stateValue) {\n delete dom.dataset[_stateKey]\n dom.style.cssText = ''\n return\n }\n dom.dataset[_stateKey] = stateValue\n const css = stateEntry.stateValues[stateValue]?.css\n if (!css) {\n return\n }\n Object.entries(css).forEach(([key, value]) => {\n dom.style.setProperty(key, value)\n })\n })\n }\n })\n })\n }, [editor])\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