@haklex/rich-compose 0.22.1 → 0.24.0

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.
@@ -2687,6 +2687,7 @@
2687
2687
  }
2688
2688
  }
2689
2689
  .gxfui12 {
2690
+ display: flow-root;
2690
2691
  font-family: var(--rc-font-family);
2691
2692
  font-size: var(--rc-font-size-base);
2692
2693
  line-height: var(--rc-line-height);
@@ -3458,6 +3459,48 @@
3458
3459
  .gxfui1x > :last-child {
3459
3460
  margin-bottom: 0;
3460
3461
  }
3462
+ figure.rich-image {
3463
+ width: var(--rich-image-display-width, auto);
3464
+ max-width: 100%;
3465
+ margin-inline: auto;
3466
+ }
3467
+ figure.rich-image[data-layout="align-left"] {
3468
+ margin-left: 0;
3469
+ margin-right: auto;
3470
+ text-align: left;
3471
+ }
3472
+ figure.rich-image[data-layout="align-right"] {
3473
+ margin-left: auto;
3474
+ margin-right: 0;
3475
+ text-align: right;
3476
+ }
3477
+ figure.rich-image[data-layout="float-left"] {
3478
+ float: left;
3479
+ width: var(--rich-image-display-width, 50%);
3480
+ margin: 0.25rem 1.5rem 1rem 0;
3481
+ }
3482
+ figure.rich-image[data-layout="float-right"] {
3483
+ float: right;
3484
+ width: var(--rich-image-display-width, 50%);
3485
+ margin: 0.25rem 0 1rem 1.5rem;
3486
+ }
3487
+ .rich-image-wrapper[data-layout="float-left"] {
3488
+ float: left;
3489
+ width: 50%;
3490
+ max-width: 100%;
3491
+ margin: 0.25rem 1.5rem 1rem 0;
3492
+ }
3493
+ .rich-image-wrapper[data-layout="float-right"] {
3494
+ float: right;
3495
+ width: 50%;
3496
+ max-width: 100%;
3497
+ margin: 0.25rem 0 1rem 1.5rem;
3498
+ }
3499
+ .rich-image-wrapper[data-layout^="float"] figure.rich-image {
3500
+ float: none;
3501
+ width: auto;
3502
+ margin: 0;
3503
+ }
3461
3504
  @supports (animation-timeline: view()) {
3462
3505
  .gxfui1b {
3463
3506
  --rc-hl-highlighted: 0;
@@ -3465,6 +3508,18 @@
3465
3508
  animation-timeline: view();
3466
3509
  animation-range: entry 100% cover 10%;
3467
3510
  }
3511
+ }
3512
+ @media (max-width: 640px) {
3513
+ figure.rich-image[data-layout^="float"] {
3514
+ float: none;
3515
+ width: auto;
3516
+ margin: 1.25rem auto;
3517
+ }
3518
+ .rich-image-wrapper[data-layout^="float"] {
3519
+ float: none;
3520
+ width: 100% !important;
3521
+ margin: 0;
3522
+ }
3468
3523
  }._1pkof4r0 {
3469
3524
  margin: var(--rc-space-md) 0;
3470
3525
  border: none;
@@ -4586,6 +4641,7 @@
4586
4641
  overflow: hidden;
4587
4642
  border: 1px solid color-mix(in srgb, var(--rc-border) 60%, transparent);
4588
4643
  background: var(--rc-code-bg);
4644
+ font-family: var(--rc-font-family-sans);
4589
4645
  font-size: var(--rc-font-size-md);
4590
4646
  }
4591
4647
  ._1v9rg4b1 {
@@ -5312,6 +5368,7 @@
5312
5368
  justify-content: space-between;
5313
5369
  padding: var(--rc-space-sm) var(--rc-space-md);
5314
5370
  border-bottom: 1px solid var(--rc-border);
5371
+ font-family: var(--rc-font-family-sans);
5315
5372
  font-size: var(--rc-font-size-md);
5316
5373
  color: var(--rc-text-secondary);
5317
5374
  user-select: none;
@@ -5363,6 +5420,7 @@
5363
5420
  justify-content: space-between;
5364
5421
  padding: var(--rc-space-sm) var(--rc-space-md);
5365
5422
  border-bottom: 1px solid var(--rc-border);
5423
+ font-family: var(--rc-font-family-sans);
5366
5424
  font-size: var(--rc-font-size-md);
5367
5425
  color: var(--rc-text-secondary);
5368
5426
  user-select: none;
@@ -5503,6 +5561,7 @@
5503
5561
  display: flex;
5504
5562
  align-items: center;
5505
5563
  justify-content: center;
5564
+ font-family: var(--rc-font-family-sans);
5506
5565
  padding: 0.75rem 1rem;
5507
5566
  margin: 1rem 0;
5508
5567
  border-radius: 0.5rem;
@@ -5808,7 +5867,7 @@
5808
5867
  border-bottom: 1px solid var(--rc-hr-border);
5809
5868
  padding: var(--rc-space-lg) 0;
5810
5869
  margin: var(--rc-space-lg) 0;
5811
- font-family: inherit;
5870
+ font-family: var(--rc-font-family-sans);
5812
5871
  }
5813
5872
  ._1cvhw6k1 {
5814
5873
  font-size: 0.7rem;
@@ -5948,6 +6007,7 @@
5948
6007
  display: flex;
5949
6008
  align-items: center;
5950
6009
  gap: 8px;
6010
+ font-family: var(--rc-font-family-sans);
5951
6011
  font-weight: 600;
5952
6012
  text-transform: uppercase;
5953
6013
  letter-spacing: 0.02em;
@@ -6026,6 +6086,7 @@
6026
6086
  display: flex;
6027
6087
  align-items: center;
6028
6088
  gap: var(--rc-space-sm);
6089
+ font-family: var(--rc-font-family-sans);
6029
6090
  font-weight: 600;
6030
6091
  margin-bottom: var(--rc-space-xs);
6031
6092
  font-size: var(--rc-font-size-md);
@@ -6264,7 +6325,7 @@
6264
6325
  border: 1px solid color-mix(in srgb, rgb(var(--_1pymbyu0)) 25%, transparent);
6265
6326
  border-radius: 12px;
6266
6327
  background-color: color-mix(in srgb, rgb(var(--_1pymbyu0)) 12%, transparent);
6267
- font-family: var(--rc-font-family);
6328
+ font-family: var(--rc-font-family-sans);
6268
6329
  font-size: var(--rc-font-size-md);
6269
6330
  transition: border-color 0.15s ease, background-color 0.15s ease;
6270
6331
  }
@@ -6454,7 +6515,7 @@
6454
6515
  border: 1px solid color-mix(in srgb, rgb(var(--_1kngc4r0)) 25%, transparent);
6455
6516
  border-radius: 12px;
6456
6517
  background-color: color-mix(in srgb, rgb(var(--_1kngc4r0)) 8%, transparent);
6457
- font-family: var(--rc-font-family);
6518
+ font-family: var(--rc-font-family-sans);
6458
6519
  font-size: var(--rc-font-size-md);
6459
6520
  margin: 8px 0;
6460
6521
  }
@@ -7723,8 +7784,35 @@
7723
7784
  }
7724
7785
  }
7725
7786
  .yvdzu0 {
7726
- margin: 1.25rem 0;
7787
+ margin: 1.25rem auto;
7727
7788
  text-align: center;
7789
+ width: var(--rich-image-display-width, auto);
7790
+ max-width: 100%;
7791
+ }
7792
+ .yvdzu0[data-layout="align-left"] {
7793
+ margin-left: 0;
7794
+ margin-right: auto;
7795
+ text-align: left;
7796
+ }
7797
+ .yvdzu0[data-layout="align-right"] {
7798
+ margin-left: auto;
7799
+ margin-right: 0;
7800
+ text-align: right;
7801
+ }
7802
+ .yvdzu0[data-layout="float-left"] {
7803
+ float: left;
7804
+ width: var(--rich-image-display-width, 50%);
7805
+ margin: 0.25rem 1.5rem 1rem 0;
7806
+ }
7807
+ .yvdzu0[data-layout="float-right"] {
7808
+ float: right;
7809
+ width: var(--rich-image-display-width, 50%);
7810
+ margin: 0.25rem 0 1rem 1.5rem;
7811
+ }
7812
+ .rich-image-wrapper[data-layout^="float"] .yvdzu0 {
7813
+ float: none;
7814
+ width: auto;
7815
+ margin: 0;
7728
7816
  }
7729
7817
  .yvdzu2 {
7730
7818
  display: block;
@@ -8014,6 +8102,136 @@
8014
8102
  gap: 0.4rem;
8015
8103
  color: var(--rc-text-secondary);
8016
8104
  font-size: var(--rc-font-size-xs);
8105
+ }
8106
+ .yvdzuy {
8107
+ position: absolute;
8108
+ top: 50%;
8109
+ transform: translateY(-50%);
8110
+ width: 6px;
8111
+ height: 36px;
8112
+ max-height: 50%;
8113
+ border-radius: 9999px;
8114
+ background: rgba(255, 255, 255, 0.92);
8115
+ border: 1px solid rgba(0, 0, 0, 0.18);
8116
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
8117
+ cursor: ew-resize;
8118
+ touch-action: none;
8119
+ opacity: 0;
8120
+ transition: opacity 0.15s ease;
8121
+ z-index: 10;
8122
+ }
8123
+ .yvdzuz {
8124
+ left: 6px;
8125
+ }
8126
+ .yvdzu10 {
8127
+ right: 6px;
8128
+ }
8129
+ .yvdzu11 {
8130
+ opacity: 1;
8131
+ }
8132
+ .yvdzu12 {
8133
+ display: flex;
8134
+ align-items: center;
8135
+ gap: 4px;
8136
+ padding: 4px;
8137
+ font-family: var(--rc-font-family);
8138
+ z-index: 30;
8139
+ }
8140
+ .yvdzu12.yvdzu12 {
8141
+ width: fit-content;
8142
+ }
8143
+ .yvdzu13 {
8144
+ position: relative;
8145
+ display: flex;
8146
+ align-items: center;
8147
+ width: 132px;
8148
+ height: 24px;
8149
+ }
8150
+ .yvdzu14 {
8151
+ appearance: none;
8152
+ width: 100%;
8153
+ height: 24px;
8154
+ margin: 0;
8155
+ background: transparent;
8156
+ cursor: pointer;
8157
+ }
8158
+ .yvdzu14::-webkit-slider-runnable-track {
8159
+ height: 3px;
8160
+ border-radius: 9999px;
8161
+ background: linear-gradient(to right, var(--rc-text-secondary) var(--fill), var(--rc-fill) var(--fill));
8162
+ }
8163
+ .yvdzu14::-webkit-slider-thumb {
8164
+ appearance: none;
8165
+ width: 12px;
8166
+ height: 12px;
8167
+ border-radius: 50%;
8168
+ background-color: var(--rc-bg);
8169
+ border: 1px solid var(--rc-border);
8170
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
8171
+ cursor: ew-resize;
8172
+ margin-top: -4.5px;
8173
+ }
8174
+ .yvdzu14::-moz-range-track {
8175
+ height: 3px;
8176
+ border-radius: 9999px;
8177
+ background: linear-gradient(to right, var(--rc-text-secondary) var(--fill), var(--rc-fill) var(--fill));
8178
+ }
8179
+ .yvdzu14::-moz-range-thumb {
8180
+ appearance: none;
8181
+ width: 12px;
8182
+ height: 12px;
8183
+ border-radius: 50%;
8184
+ background-color: var(--rc-bg);
8185
+ border: 1px solid var(--rc-border);
8186
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
8187
+ cursor: ew-resize;
8188
+ }
8189
+ .yvdzu15 {
8190
+ position: absolute;
8191
+ top: 50%;
8192
+ width: 3px;
8193
+ height: 3px;
8194
+ border-radius: 50%;
8195
+ background-color: var(--rc-bg);
8196
+ transform: translate(-50%, -50%);
8197
+ pointer-events: none;
8198
+ }
8199
+ .yvdzu16 {
8200
+ min-width: 34px;
8201
+ text-align: right;
8202
+ font-size: var(--rc-font-size-xs);
8203
+ font-variant-numeric: tabular-nums;
8204
+ color: var(--rc-text-secondary);
8205
+ }
8206
+ .yvdzu17 {
8207
+ display: inline-flex;
8208
+ align-items: center;
8209
+ justify-content: center;
8210
+ height: 26px;
8211
+ padding: 0 8px;
8212
+ border-radius: 6px;
8213
+ border: none;
8214
+ background: transparent;
8215
+ color: var(--rc-text-secondary);
8216
+ font-size: var(--rc-font-size-xs);
8217
+ font-weight: 500;
8218
+ cursor: pointer;
8219
+ transition: background-color 0.15s ease, color 0.15s ease;
8220
+ }
8221
+ .yvdzu17:hover {
8222
+ color: var(--rc-text);
8223
+ background-color: var(--rc-fill-secondary);
8224
+ }
8225
+ .yvdzu18 {
8226
+ color: var(--rc-text);
8227
+ background-color: var(--rc-fill-secondary);
8228
+ }
8229
+ @media (max-width: 640px) {
8230
+ .yvdzu0[data-layout="float-left"], .yvdzu0[data-layout="float-right"] {
8231
+ float: none;
8232
+ width: auto;
8233
+ margin: 1.25rem auto;
8234
+ }
8017
8235
  }@keyframes vwn881f {
8018
8236
  0%, 100% {
8019
8237
  opacity: 1;
@@ -8681,6 +8899,7 @@
8681
8899
  animation: _1fjmgdr3 0.5s ease forwards;
8682
8900
  }
8683
8901
  ._1fjmgdr5 {
8902
+ font-family: var(--rc-font-family-sans);
8684
8903
  position: absolute;
8685
8904
  left: 2rem;
8686
8905
  right: 2rem;
@@ -65855,7 +65855,7 @@
65855
65855
  }));
65856
65856
  //#endregion
65857
65857
  //#region ../rich-editor/src/components/renderers/ImageRenderer.tsx
65858
- function ImageRenderer$1({ src, altText, width, height, caption, thumbhash, accent }) {
65858
+ function ImageRenderer$1({ src, altText, width, height, caption, thumbhash, accent, displayWidth, layout }) {
65859
65859
  const [loaded, setLoaded] = (0, import_react$167.useState)(false);
65860
65860
  const [zoomed, setZoomed] = (0, import_react$167.useState)(false);
65861
65861
  const handleLoad = (0, import_react$167.useCallback)(() => setLoaded(true), []);
@@ -65894,6 +65894,8 @@
65894
65894
  } : { maxWidth: "100%" };
65895
65895
  return /* @__PURE__ */ (0, import_jsx_runtime$215.jsxs)("figure", {
65896
65896
  className: "rich-image",
65897
+ "data-layout": layout,
65898
+ style: displayWidth ? { "--rich-image-display-width": `${displayWidth}%` } : void 0,
65897
65899
  children: [
65898
65900
  /* @__PURE__ */ (0, import_jsx_runtime$215.jsx)("div", {
65899
65901
  "aria-label": loaded ? `Zoom image: ${altText}` : void 0,
@@ -65967,10 +65969,23 @@
65967
65969
  if (/^(?:rgb|hsl)a?\([^)]+\)$/i.test(trimmed)) return trimmed;
65968
65970
  if (/^[a-z]{3,20}$/i.test(trimmed)) return trimmed;
65969
65971
  }
65972
+ function sanitizeImageDisplayWidth(value) {
65973
+ if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
65974
+ return Math.round(Math.min(100, Math.max(10, value)));
65975
+ }
65976
+ function sanitizeImageLayout(value) {
65977
+ return IMAGE_LAYOUTS.includes(value) ? value : void 0;
65978
+ }
65979
+ function applyLayoutToDOM(dom, layout, displayWidth) {
65980
+ if (layout) dom.dataset.layout = layout;
65981
+ else delete dom.dataset.layout;
65982
+ const isFloat = layout === "float-left" || layout === "float-right";
65983
+ dom.style.width = isFloat && displayWidth !== void 0 ? `${displayWidth}%` : "";
65984
+ }
65970
65985
  function $createImageNode(payload) {
65971
65986
  return new ImageNode(payload);
65972
65987
  }
65973
- var import_react$166, ImageNode;
65988
+ var import_react$166, IMAGE_LAYOUTS, ImageNode;
65974
65989
  var init_ImageNode = __esmMin((() => {
65975
65990
  init_Lexical_prod();
65976
65991
  init_lucide_react();
@@ -65980,6 +65995,12 @@
65980
65995
  init_image_upload_command();
65981
65996
  init_renderer_keys();
65982
65997
  init_defineProperty();
65998
+ IMAGE_LAYOUTS = [
65999
+ "align-left",
66000
+ "align-right",
66001
+ "float-left",
66002
+ "float-right"
66003
+ ];
65983
66004
  ImageNode = class ImageNode extends yo$2 {
65984
66005
  static getType() {
65985
66006
  return "image";
@@ -65992,7 +66013,9 @@
65992
66013
  height: node.__height,
65993
66014
  caption: node.__caption,
65994
66015
  thumbhash: node.__thumbhash,
65995
- accent: node.__accent
66016
+ accent: node.__accent,
66017
+ displayWidth: node.__displayWidth,
66018
+ layout: node.__layout
65996
66019
  }, node.__key);
65997
66020
  }
65998
66021
  constructor(payload, key) {
@@ -66004,6 +66027,8 @@
66004
66027
  _defineProperty$2(this, "__caption", void 0);
66005
66028
  _defineProperty$2(this, "__thumbhash", void 0);
66006
66029
  _defineProperty$2(this, "__accent", void 0);
66030
+ _defineProperty$2(this, "__displayWidth", void 0);
66031
+ _defineProperty$2(this, "__layout", void 0);
66007
66032
  this.__src = sanitizeImageSrc(payload.src);
66008
66033
  this.__altText = payload.altText;
66009
66034
  this.__width = payload.width;
@@ -66011,13 +66036,17 @@
66011
66036
  this.__caption = payload.caption;
66012
66037
  this.__thumbhash = payload.thumbhash;
66013
66038
  this.__accent = sanitizeColor(payload.accent);
66039
+ this.__displayWidth = sanitizeImageDisplayWidth(payload.displayWidth);
66040
+ this.__layout = sanitizeImageLayout(payload.layout);
66014
66041
  }
66015
66042
  createDOM(_config) {
66016
66043
  const div = document.createElement("div");
66017
66044
  div.className = "rich-image-wrapper";
66045
+ applyLayoutToDOM(div, this.__layout, this.__displayWidth);
66018
66046
  return div;
66019
66047
  }
66020
- updateDOM() {
66048
+ updateDOM(prevNode, dom) {
66049
+ if (prevNode.__layout !== this.__layout || prevNode.__displayWidth !== this.__displayWidth) applyLayoutToDOM(dom, this.__layout, this.__displayWidth);
66021
66050
  return false;
66022
66051
  }
66023
66052
  isInline() {
@@ -66031,7 +66060,9 @@
66031
66060
  height: serializedNode.height,
66032
66061
  caption: serializedNode.caption,
66033
66062
  thumbhash: serializedNode.thumbhash,
66034
- accent: serializedNode.accent
66063
+ accent: serializedNode.accent,
66064
+ displayWidth: serializedNode.displayWidth,
66065
+ layout: serializedNode.layout
66035
66066
  });
66036
66067
  }
66037
66068
  exportJSON() {
@@ -66045,6 +66076,8 @@
66045
66076
  caption: this.__caption,
66046
66077
  thumbhash: this.__thumbhash,
66047
66078
  accent: this.__accent,
66079
+ displayWidth: this.__displayWidth,
66080
+ layout: this.__layout,
66048
66081
  version: 1
66049
66082
  };
66050
66083
  }
@@ -66073,6 +66106,14 @@
66073
66106
  const writable = this.getWritable();
66074
66107
  writable.__accent = sanitizeColor(accent);
66075
66108
  }
66109
+ setDisplayWidth(width) {
66110
+ const writable = this.getWritable();
66111
+ writable.__displayWidth = sanitizeImageDisplayWidth(width);
66112
+ }
66113
+ setLayout(layout) {
66114
+ const writable = this.getWritable();
66115
+ writable.__layout = sanitizeImageLayout(layout);
66116
+ }
66076
66117
  getSrc() {
66077
66118
  return this.__src;
66078
66119
  }
@@ -66094,6 +66135,12 @@
66094
66135
  getAccent() {
66095
66136
  return this.__accent;
66096
66137
  }
66138
+ getDisplayWidth() {
66139
+ return this.__displayWidth;
66140
+ }
66141
+ getLayout() {
66142
+ return this.__layout;
66143
+ }
66097
66144
  decorate(_editor, _config) {
66098
66145
  return createRendererDecoration(IMAGE_NODE_KEY, ImageRenderer$1, {
66099
66146
  src: this.__src,
@@ -66102,7 +66149,9 @@
66102
66149
  height: this.__height,
66103
66150
  caption: this.__caption,
66104
66151
  thumbhash: this.__thumbhash,
66105
- accent: this.__accent
66152
+ accent: this.__accent,
66153
+ displayWidth: this.__displayWidth,
66154
+ layout: this.__layout
66106
66155
  });
66107
66156
  }
66108
66157
  };
@@ -478022,7 +478071,8 @@ TTD mermaid definition render errror: ${M.message}`, "color: yellow"), le("ai",
478022
478071
  editInput: "rr-image-edit-input",
478023
478072
  replaceUploadArea: "rr-image-replace-upload-area",
478024
478073
  replacePreview: "rr-image-replace-preview",
478025
- panelHint: "rr-image-panel-hint"
478074
+ panelHint: "rr-image-panel-hint",
478075
+ resizeHandle: "rr-image-resize-handle"
478026
478076
  };
478027
478077
  var root$1 = "yvdzu0";
478028
478078
  var image$1 = "yvdzu2";
@@ -478047,7 +478097,7 @@ TTD mermaid definition render errror: ${M.message}`, "color: yellow"), le("ai",
478047
478097
  if (!altText) return void 0;
478048
478098
  if (altText.startsWith("!") || altText.startsWith("¡")) return altText.slice(1);
478049
478099
  }
478050
- function ImageRenderer({ src, altText, width, height, caption: caption$1, thumbhash, accent, onActivate, ref }) {
478100
+ function ImageRenderer({ src, altText, width, height, caption: caption$1, thumbhash, accent, displayWidth, layout, onActivate, ref }) {
478051
478101
  const [state, setState] = (0, import_react$186.useState)("loading");
478052
478102
  const imgRef = (0, import_react$186.useRef)(null);
478053
478103
  const captionText = (0, import_react$186.useMemo)(() => getCaptionText(altText, caption$1), [altText, caption$1]);
@@ -478070,9 +478120,12 @@ TTD mermaid definition render errror: ${M.message}`, "color: yellow"), le("ai",
478070
478120
  e.preventDefault();
478071
478121
  activate();
478072
478122
  };
478123
+ const figureStyle = displayWidth ? { "--rich-image-display-width": `${displayWidth}%` } : void 0;
478073
478124
  return /* @__PURE__ */ (0, import_jsx_runtime$232.jsxs)("figure", {
478074
478125
  className: `${root$1} ${semanticClassNames$4.root}`,
478126
+ "data-layout": layout,
478075
478127
  ref,
478128
+ style: figureStyle,
478076
478129
  children: [/* @__PURE__ */ (0, import_jsx_runtime$232.jsxs)("div", {
478077
478130
  "aria-label": interactive ? `Open image: ${altText || "image"}` : void 0,
478078
478131
  className: `${frame} ${interactive ? "" : frameStatic} ${semanticClassNames$4.frame} ${imageState[state]} ${frameStateSemanticClass[state]}`.trim(),