oasis-editor 0.0.103 → 0.0.105

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.
@@ -2444,7 +2444,7 @@ function OasisBrandMark(props) {
2444
2444
  return _el$;
2445
2445
  })();
2446
2446
  }
2447
- var _tmpl$$R = /* @__PURE__ */ template(`<div class=oasis-editor-import-progress-label>`), _tmpl$2$A = /* @__PURE__ */ template(`<div role=status aria-live=polite><div class=oasis-editor-import-card><div class=oasis-editor-import-title></div><div class=oasis-editor-import-progress-track><div>`), _tmpl$3$o = /* @__PURE__ */ template(`<span class=oasis-editor-import-done-icon>Done`);
2447
+ var _tmpl$$R = /* @__PURE__ */ template(`<div class=oasis-editor-import-progress-label>`), _tmpl$2$A = /* @__PURE__ */ template(`<div role=status aria-live=polite><div class=oasis-editor-import-card><div class=oasis-editor-import-title></div><div class=oasis-editor-import-progress-track><div>`), _tmpl$3$p = /* @__PURE__ */ template(`<span class=oasis-editor-import-done-icon>Done`);
2448
2448
  function OasisEditorLoading(props) {
2449
2449
  const t = useI18n();
2450
2450
  const variant = () => props.variant ?? "overlay";
@@ -2468,7 +2468,7 @@ function OasisEditorLoading(props) {
2468
2468
  var _el$6 = _tmpl$$R();
2469
2469
  insert(_el$6, (() => {
2470
2470
  var _c$ = memo(() => !!isDone());
2471
- return () => _c$() ? _tmpl$3$o() : `${pct()}%`;
2471
+ return () => _c$() ? _tmpl$3$p() : `${pct()}%`;
2472
2472
  })());
2473
2473
  return _el$6;
2474
2474
  }
@@ -2519,7 +2519,7 @@ function OasisEditorAppLazy(props = {}) {
2519
2519
  onCleanup(() => {
2520
2520
  cancelled = true;
2521
2521
  });
2522
- import("./OasisEditorApp-CLzJ9zyp.js").then((m) => {
2522
+ import("./OasisEditorApp-CwVZxG1m.js").then((m) => {
2523
2523
  cancelled = true;
2524
2524
  setProgress(1);
2525
2525
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -4982,7 +4982,7 @@ function mount(target, props = {}) {
4982
4982
  unmount: () => client.dispose()
4983
4983
  });
4984
4984
  }
4985
- var _tmpl$$Q = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg width=24 height=24 viewBox="0 0 24 24"fill=none aria-hidden=true><text x=2 y=18 font-family="'Segoe UI', Arial, sans-serif"font-size=14 font-weight=700 fill=currentColor>ab</text><text x=15.5 y=11 font-family="'Segoe UI', Arial, sans-serif"font-size=10 font-weight=700 fill=#c00000>1`), _tmpl$2$z = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg width=24 height=24 viewBox="0 0 24 24"aria-hidden=true><g fill=currentColor><path d="M3.375 4.875 L7.125 8.625 L3.375 12.375 L2.25 11.25 L4.875 8.625 L2.25 6 Z"></path><rect x=10.125 y=6 width=9 height=1.6875 rx=0.25></rect><rect x=5.625 y=10.875 width=13.5 height=1.6875 rx=0.25></rect><rect x=5.625 y=15.75 width=13.5 height=1.6875 rx=0.25>`), _tmpl$3$n = /* @__PURE__ */ template(`<i>`);
4985
+ var _tmpl$$Q = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg width=24 height=24 viewBox="0 0 24 24"fill=none aria-hidden=true><text x=2 y=18 font-family="'Segoe UI', Arial, sans-serif"font-size=14 font-weight=700 fill=currentColor>ab</text><text x=15.5 y=11 font-family="'Segoe UI', Arial, sans-serif"font-size=10 font-weight=700 fill=#c00000>1`), _tmpl$2$z = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg width=24 height=24 viewBox="0 0 24 24"aria-hidden=true><g fill=currentColor><path d="M3.375 4.875 L7.125 8.625 L3.375 12.375 L2.25 11.25 L4.875 8.625 L2.25 6 Z"></path><rect x=10.125 y=6 width=9 height=1.6875 rx=0.25></rect><rect x=5.625 y=10.875 width=13.5 height=1.6875 rx=0.25></rect><rect x=5.625 y=15.75 width=13.5 height=1.6875 rx=0.25>`), _tmpl$3$o = /* @__PURE__ */ template(`<i>`);
4986
4986
  const FootnoteIcon = () => _tmpl$$Q();
4987
4987
  const SpecialIndentFirstLineIcon = () => _tmpl$2$z();
4988
4988
  const CUSTOM_ICONS = {
@@ -4999,7 +4999,7 @@ function ToolIcon(props) {
4999
4999
  },
5000
5000
  get fallback() {
5001
5001
  return (() => {
5002
- var _el$3 = _tmpl$3$n();
5002
+ var _el$3 = _tmpl$3$o();
5003
5003
  createRenderEffect(() => setAttribute(_el$3, "data-lucide", props.name));
5004
5004
  return _el$3;
5005
5005
  })();
@@ -5007,7 +5007,7 @@ function ToolIcon(props) {
5007
5007
  children: (render2) => render2()()
5008
5008
  });
5009
5009
  }
5010
- var _tmpl$$P = /* @__PURE__ */ template(`<div class=oasis-menubar role=menubar>`), _tmpl$2$y = /* @__PURE__ */ template(`<div class=oasis-menubar-dropdown role=menu>`), _tmpl$3$m = /* @__PURE__ */ template(`<div class=oasis-menubar-menu><div class=oasis-menubar-button role=menuitem aria-haspopup=true>`), _tmpl$4$h = /* @__PURE__ */ template(`<div class=oasis-menubar-separator role=separator>`), _tmpl$5$e = /* @__PURE__ */ template(`<span class=oasis-menubar-item-icon aria-hidden=true>`), _tmpl$6$7 = /* @__PURE__ */ template(`<span class=oasis-menubar-shortcut>`), _tmpl$7$3 = /* @__PURE__ */ template(`<i class=oasis-menubar-submenu-icon data-lucide=chevron-right>`), _tmpl$8$2 = /* @__PURE__ */ template(`<div class=oasis-menubar-submenu role=menu>`), _tmpl$9$1 = /* @__PURE__ */ template(`<div class=oasis-menubar-item role=menuitem><span class=oasis-menubar-item-main><span>`);
5010
+ var _tmpl$$P = /* @__PURE__ */ template(`<div class=oasis-menubar role=menubar>`), _tmpl$2$y = /* @__PURE__ */ template(`<div class=oasis-menubar-dropdown role=menu>`), _tmpl$3$n = /* @__PURE__ */ template(`<div class=oasis-menubar-menu><div class=oasis-menubar-button role=menuitem aria-haspopup=true>`), _tmpl$4$i = /* @__PURE__ */ template(`<div class=oasis-menubar-separator role=separator>`), _tmpl$5$f = /* @__PURE__ */ template(`<span class=oasis-menubar-item-icon aria-hidden=true>`), _tmpl$6$8 = /* @__PURE__ */ template(`<span class=oasis-menubar-shortcut>`), _tmpl$7$3 = /* @__PURE__ */ template(`<i class=oasis-menubar-submenu-icon data-lucide=chevron-right>`), _tmpl$8$2 = /* @__PURE__ */ template(`<div class=oasis-menubar-submenu role=menu>`), _tmpl$9$1 = /* @__PURE__ */ template(`<div class=oasis-menubar-item role=menuitem><span class=oasis-menubar-item-main><span>`);
5011
5011
  function Menubar(props) {
5012
5012
  const t = useI18n();
5013
5013
  const [activeMenu, setActiveMenu] = createSignal(null);
@@ -5081,7 +5081,7 @@ function Menubar(props) {
5081
5081
  return topLevelItems();
5082
5082
  },
5083
5083
  children: (topLevel) => (() => {
5084
- var _el$2 = _tmpl$3$m(), _el$3 = _el$2.firstChild;
5084
+ var _el$2 = _tmpl$3$n(), _el$3 = _el$2.firstChild;
5085
5085
  _el$2.addEventListener("mouseenter", () => {
5086
5086
  if (activeMenu() && activeMenu() !== topLevel.id) {
5087
5087
  setActiveMenu(topLevel.id);
@@ -5141,7 +5141,7 @@ function MenuNode(props) {
5141
5141
  } = props;
5142
5142
  const isSeparator = (_a = node.item) == null ? void 0 : _a.separator;
5143
5143
  if (isSeparator) {
5144
- return _tmpl$4$h();
5144
+ return _tmpl$4$i();
5145
5145
  }
5146
5146
  const hasChildren = node.children.length > 0;
5147
5147
  const [showSub, setShowSub] = createSignal(false);
@@ -5176,7 +5176,7 @@ function MenuNode(props) {
5176
5176
  return icon();
5177
5177
  },
5178
5178
  get children() {
5179
- var _el$8 = _tmpl$5$e();
5179
+ var _el$8 = _tmpl$5$f();
5180
5180
  insert(_el$8, createComponent(ToolIcon, {
5181
5181
  get name() {
5182
5182
  return icon();
@@ -5192,7 +5192,7 @@ function MenuNode(props) {
5192
5192
  return (_a2 = node.item) == null ? void 0 : _a2.shortcut;
5193
5193
  },
5194
5194
  get children() {
5195
- var _el$0 = _tmpl$6$7();
5195
+ var _el$0 = _tmpl$6$8();
5196
5196
  insert(_el$0, () => node.item.shortcut);
5197
5197
  return _el$0;
5198
5198
  }
@@ -13089,6 +13089,50 @@ function getTableCellContentWidthForParagraph(document2, paragraphId, activeSect
13089
13089
  cellWidth - horizontalChrome
13090
13090
  );
13091
13091
  }
13092
+ const cache = /* @__PURE__ */ new WeakMap();
13093
+ function getOrCreateStylesBucket(byStyles, styles) {
13094
+ let bucket = byStyles.get(styles);
13095
+ if (!bucket) {
13096
+ bucket = /* @__PURE__ */ new Map();
13097
+ byStyles.set(styles, bucket);
13098
+ }
13099
+ return bucket;
13100
+ }
13101
+ function resolveCachedTableCellParagraph(source, formatting, styles) {
13102
+ var _a;
13103
+ const inherited = resolveTableParagraphInheritance(
13104
+ formatting == null ? void 0 : formatting.paragraphStyle,
13105
+ (_a = source.style) == null ? void 0 : _a.styleId,
13106
+ styles
13107
+ );
13108
+ const signature = JSON.stringify([
13109
+ inherited ?? null,
13110
+ (formatting == null ? void 0 : formatting.textStyle) ?? null
13111
+ ]);
13112
+ let perParagraph = cache.get(source);
13113
+ if (!perParagraph) {
13114
+ perParagraph = { noStyles: /* @__PURE__ */ new Map(), byStyles: /* @__PURE__ */ new WeakMap() };
13115
+ cache.set(source, perParagraph);
13116
+ }
13117
+ const bucket = styles ? getOrCreateStylesBucket(perParagraph.byStyles, styles) : perParagraph.noStyles;
13118
+ const cached = bucket.get(signature);
13119
+ if (cached) {
13120
+ return cached;
13121
+ }
13122
+ const resolved = {
13123
+ ...source,
13124
+ style: {
13125
+ ...inherited,
13126
+ ...source.style
13127
+ },
13128
+ runs: source.runs.map((run) => ({
13129
+ ...run,
13130
+ styles: { ...formatting == null ? void 0 : formatting.textStyle, ...run.styles }
13131
+ }))
13132
+ };
13133
+ bucket.set(signature, resolved);
13134
+ return resolved;
13135
+ }
13092
13136
  const DEFAULT_FONT_SIZE$1 = 14.6667;
13093
13137
  const DEFAULT_LINE_HEIGHT = 1.15;
13094
13138
  const DEFAULT_TABLE_CELL_HORIZONTAL_PADDING_PX = 14.4;
@@ -13222,24 +13266,9 @@ function estimateTableRowHeight(row, styles, measurer, defaultTabStop, contentWi
13222
13266
  const cell = {
13223
13267
  ...sourceCell,
13224
13268
  style: (formatting == null ? void 0 : formatting.cellStyle) ?? sourceCell.style,
13225
- blocks: sourceCell.blocks.map((paragraph) => {
13226
- var _a3;
13227
- return {
13228
- ...paragraph,
13229
- style: {
13230
- ...resolveTableParagraphInheritance(
13231
- formatting == null ? void 0 : formatting.paragraphStyle,
13232
- (_a3 = paragraph.style) == null ? void 0 : _a3.styleId,
13233
- styles
13234
- ),
13235
- ...paragraph.style
13236
- },
13237
- runs: paragraph.runs.map((run) => ({
13238
- ...run,
13239
- styles: { ...formatting == null ? void 0 : formatting.textStyle, ...run.styles }
13240
- }))
13241
- };
13242
- })
13269
+ blocks: sourceCell.blocks.map(
13270
+ (paragraph) => resolveCachedTableCellParagraph(paragraph, formatting, styles)
13271
+ )
13243
13272
  };
13244
13273
  if (cell.vMerge === "continue") return 0;
13245
13274
  let columnWidthPx;
@@ -15656,24 +15685,13 @@ function buildCanvasTableLayout(options) {
15656
15685
  const cell = {
15657
15686
  ...sourceCell,
15658
15687
  style: formatting.cellStyle,
15659
- blocks: sourceCell.blocks.map((paragraph) => {
15660
- var _a2;
15661
- return {
15662
- ...paragraph,
15663
- style: {
15664
- ...resolveTableParagraphInheritance(
15665
- formatting.paragraphStyle,
15666
- (_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
15667
- state.document.styles
15668
- ),
15669
- ...paragraph.style
15670
- },
15671
- runs: paragraph.runs.map((run) => ({
15672
- ...run,
15673
- styles: { ...formatting.textStyle, ...run.styles }
15674
- }))
15675
- };
15676
- })
15688
+ blocks: sourceCell.blocks.map(
15689
+ (paragraph) => resolveCachedTableCellParagraph(
15690
+ paragraph,
15691
+ formatting,
15692
+ state.document.styles
15693
+ )
15694
+ )
15677
15695
  };
15678
15696
  const effectiveRow = formatting.rowStyle;
15679
15697
  const rowSpan = Math.max(1, cell.rowSpan ?? 1);
@@ -16772,7 +16790,7 @@ function getCaretRectFromSnapshot(snapshot, position2, paragraphOffset) {
16772
16790
  );
16773
16791
  return rectFromBox(slot.left, slot.top, 1, slot.height || line.height);
16774
16792
  }
16775
- var _tmpl$$N = /* @__PURE__ */ template(`<span class=oasis-outline-title>`), _tmpl$2$x = /* @__PURE__ */ template(`<div class=oasis-outline-list>`), _tmpl$3$l = /* @__PURE__ */ template(`<div class=oasis-outline-panel><div class=oasis-outline-header><button class=oasis-outline-toggle><i>`), _tmpl$4$g = /* @__PURE__ */ template(`<div class=oasis-outline-empty>`), _tmpl$5$d = /* @__PURE__ */ template(`<div class=oasis-outline-item>`);
16793
+ var _tmpl$$N = /* @__PURE__ */ template(`<span class=oasis-outline-title>`), _tmpl$2$x = /* @__PURE__ */ template(`<div class=oasis-outline-list>`), _tmpl$3$m = /* @__PURE__ */ template(`<div class=oasis-outline-panel><div class=oasis-outline-header><button class=oasis-outline-toggle><i>`), _tmpl$4$h = /* @__PURE__ */ template(`<div class=oasis-outline-empty>`), _tmpl$5$e = /* @__PURE__ */ template(`<div class=oasis-outline-item>`);
16776
16794
  function OutlinePanel(props) {
16777
16795
  const t = useI18n();
16778
16796
  const [collapsed, setCollapsed] = createSignal(props.defaultCollapsed ?? false);
@@ -16841,7 +16859,7 @@ function OutlinePanel(props) {
16841
16859
  }
16842
16860
  });
16843
16861
  return (() => {
16844
- var _el$ = _tmpl$3$l(), _el$2 = _el$.firstChild, _el$4 = _el$2.firstChild, _el$5 = _el$4.firstChild;
16862
+ var _el$ = _tmpl$3$m(), _el$2 = _el$.firstChild, _el$4 = _el$2.firstChild, _el$5 = _el$4.firstChild;
16845
16863
  insert(_el$2, createComponent(Show, {
16846
16864
  get when() {
16847
16865
  return !collapsed();
@@ -16865,7 +16883,7 @@ function OutlinePanel(props) {
16865
16883
  },
16866
16884
  get fallback() {
16867
16885
  return (() => {
16868
- var _el$7 = _tmpl$4$g();
16886
+ var _el$7 = _tmpl$4$h();
16869
16887
  insert(_el$7, () => t("outline.empty"));
16870
16888
  return _el$7;
16871
16889
  })();
@@ -16876,7 +16894,7 @@ function OutlinePanel(props) {
16876
16894
  return items();
16877
16895
  },
16878
16896
  children: (item) => (() => {
16879
- var _el$8 = _tmpl$5$d();
16897
+ var _el$8 = _tmpl$5$e();
16880
16898
  _el$8.$$click = () => props.onNavigate(item.anchor);
16881
16899
  insert(_el$8, () => item.text);
16882
16900
  createRenderEffect((_p$) => {
@@ -17340,7 +17358,7 @@ function Popover(props) {
17340
17358
  }
17341
17359
  })];
17342
17360
  }
17343
- var _tmpl$$J = /* @__PURE__ */ template(`<div>`), _tmpl$2$u = /* @__PURE__ */ template(`<div class=oasis-editor-toolbar-dropdown>`), _tmpl$3$k = /* @__PURE__ */ template(`<i>`), _tmpl$4$f = /* @__PURE__ */ template(`<span class=oasis-editor-tool-button-label>`), _tmpl$5$c = /* @__PURE__ */ template(`<i data-lucide=chevron-down class=oasis-editor-dropdown-chevron>`), _tmpl$6$6 = /* @__PURE__ */ template(`<button type=button class="oasis-editor-tool-button oasis-editor-tool-button-dropdown"aria-haspopup=menu>`);
17361
+ var _tmpl$$J = /* @__PURE__ */ template(`<div>`), _tmpl$2$u = /* @__PURE__ */ template(`<div class=oasis-editor-toolbar-dropdown>`), _tmpl$3$l = /* @__PURE__ */ template(`<i>`), _tmpl$4$g = /* @__PURE__ */ template(`<span class=oasis-editor-tool-button-label>`), _tmpl$5$d = /* @__PURE__ */ template(`<i data-lucide=chevron-down class=oasis-editor-dropdown-chevron>`), _tmpl$6$7 = /* @__PURE__ */ template(`<button type=button class="oasis-editor-tool-button oasis-editor-tool-button-dropdown"aria-haspopup=menu>`);
17344
17362
  function Menu(props) {
17345
17363
  const [open, setOpen] = createSignal(false);
17346
17364
  const ariaLabel = () => props.tooltip || props.label || "";
@@ -17360,7 +17378,7 @@ function Menu(props) {
17360
17378
  },
17361
17379
  onPanelMouseLeave: void 0,
17362
17380
  trigger: (api) => (() => {
17363
- var _el$3 = _tmpl$6$6();
17381
+ var _el$3 = _tmpl$6$7();
17364
17382
  _el$3.$$click = () => api.toggle();
17365
17383
  use((el) => api.ref(el), _el$3);
17366
17384
  insert(_el$3, createComponent(Show, {
@@ -17368,7 +17386,7 @@ function Menu(props) {
17368
17386
  return props.icon;
17369
17387
  },
17370
17388
  get children() {
17371
- var _el$4 = _tmpl$3$k();
17389
+ var _el$4 = _tmpl$3$l();
17372
17390
  createRenderEffect(() => setAttribute(_el$4, "data-lucide", props.icon));
17373
17391
  return _el$4;
17374
17392
  }
@@ -17378,7 +17396,7 @@ function Menu(props) {
17378
17396
  return props.label;
17379
17397
  },
17380
17398
  get children() {
17381
- var _el$5 = _tmpl$4$f();
17399
+ var _el$5 = _tmpl$4$g();
17382
17400
  insert(_el$5, () => props.label);
17383
17401
  return _el$5;
17384
17402
  }
@@ -17388,7 +17406,7 @@ function Menu(props) {
17388
17406
  return !props.hideChevron;
17389
17407
  },
17390
17408
  get children() {
17391
- return _tmpl$5$c();
17409
+ return _tmpl$5$d();
17392
17410
  }
17393
17411
  }), null);
17394
17412
  createRenderEffect((_p$) => {
@@ -17536,7 +17554,7 @@ function SplitButton(props) {
17536
17554
  });
17537
17555
  }
17538
17556
  delegateEvents(["click"]);
17539
- var _tmpl$$F = /* @__PURE__ */ template(`<i data-lucide=type>`), _tmpl$2$t = /* @__PURE__ */ template(`<button type=button class=oasis-editor-color-menu-action role=menuitem><span class=oasis-editor-color-menu-action-swatch></span><span>`), _tmpl$3$j = /* @__PURE__ */ template(`<div class=oasis-editor-color-menu-section><div class=oasis-editor-color-menu-heading></div><div class=oasis-editor-color-theme-grid>`), _tmpl$4$e = /* @__PURE__ */ template(`<div class=oasis-editor-color-menu-section><div class=oasis-editor-color-menu-heading></div><div class=oasis-editor-color-standard-grid>`), _tmpl$5$b = /* @__PURE__ */ template(`<button type=button class=oasis-editor-color-menu-action role=menuitem><span class="oasis-editor-color-menu-action-swatch oasis-editor-color-menu-more-swatch"></span><span>`), _tmpl$6$5 = /* @__PURE__ */ template(`<input type=color class=oasis-editor-color-custom-input>`), _tmpl$7$2 = /* @__PURE__ */ template(`<span class=oasis-editor-color-split-icon><i></i><span class=oasis-editor-color-split-indicator>`), _tmpl$8$1 = /* @__PURE__ */ template(`<i data-lucide=slash>`), _tmpl$9 = /* @__PURE__ */ template(`<div class=oasis-editor-color-theme-column>`), _tmpl$0 = /* @__PURE__ */ template(`<button type=button class=oasis-editor-color-swatch>`);
17557
+ var _tmpl$$F = /* @__PURE__ */ template(`<i data-lucide=type>`), _tmpl$2$t = /* @__PURE__ */ template(`<button type=button class=oasis-editor-color-menu-action role=menuitem><span class=oasis-editor-color-menu-action-swatch></span><span>`), _tmpl$3$k = /* @__PURE__ */ template(`<div class=oasis-editor-color-menu-section><div class=oasis-editor-color-menu-heading></div><div class=oasis-editor-color-theme-grid>`), _tmpl$4$f = /* @__PURE__ */ template(`<div class=oasis-editor-color-menu-section><div class=oasis-editor-color-menu-heading></div><div class=oasis-editor-color-standard-grid>`), _tmpl$5$c = /* @__PURE__ */ template(`<button type=button class=oasis-editor-color-menu-action role=menuitem><span class="oasis-editor-color-menu-action-swatch oasis-editor-color-menu-more-swatch"></span><span>`), _tmpl$6$6 = /* @__PURE__ */ template(`<input type=color class=oasis-editor-color-custom-input>`), _tmpl$7$2 = /* @__PURE__ */ template(`<span class=oasis-editor-color-split-icon><i></i><span class=oasis-editor-color-split-indicator>`), _tmpl$8$1 = /* @__PURE__ */ template(`<i data-lucide=slash>`), _tmpl$9 = /* @__PURE__ */ template(`<div class=oasis-editor-color-theme-column>`), _tmpl$0 = /* @__PURE__ */ template(`<button type=button class=oasis-editor-color-swatch>`);
17540
17558
  const normalizeColor = (value) => (value == null ? void 0 : value.trim().toLowerCase()) ?? "";
17541
17559
  function ColorPicker(props) {
17542
17560
  const [isOpen, setIsOpen] = createSignal(false);
@@ -17619,7 +17637,7 @@ function ColorPicker(props) {
17619
17637
  return _el$;
17620
17638
  }
17621
17639
  }), (() => {
17622
- var _el$5 = _tmpl$3$j(), _el$6 = _el$5.firstChild, _el$7 = _el$6.nextSibling;
17640
+ var _el$5 = _tmpl$3$k(), _el$6 = _el$5.firstChild, _el$7 = _el$6.nextSibling;
17623
17641
  insert(_el$6, () => props.themeColorsLabel);
17624
17642
  insert(_el$7, createComponent(For, {
17625
17643
  get each() {
@@ -17659,7 +17677,7 @@ function ColorPicker(props) {
17659
17677
  }));
17660
17678
  return _el$5;
17661
17679
  })(), (() => {
17662
- var _el$8 = _tmpl$4$e(), _el$9 = _el$8.firstChild, _el$0 = _el$9.nextSibling;
17680
+ var _el$8 = _tmpl$4$f(), _el$9 = _el$8.firstChild, _el$0 = _el$9.nextSibling;
17663
17681
  insert(_el$9, () => props.standardColorsLabel);
17664
17682
  insert(_el$0, createComponent(For, {
17665
17683
  get each() {
@@ -17696,13 +17714,13 @@ function ColorPicker(props) {
17696
17714
  },
17697
17715
  get children() {
17698
17716
  return [(() => {
17699
- var _el$1 = _tmpl$5$b(), _el$10 = _el$1.firstChild, _el$11 = _el$10.nextSibling;
17717
+ var _el$1 = _tmpl$5$c(), _el$10 = _el$1.firstChild, _el$11 = _el$10.nextSibling;
17700
17718
  _el$1.$$click = () => customColorInputRef == null ? void 0 : customColorInputRef.click();
17701
17719
  insert(_el$11, () => props.moreColorsLabel);
17702
17720
  createRenderEffect(() => setAttribute(_el$1, "data-testid", `${props.testId}-more-colors`));
17703
17721
  return _el$1;
17704
17722
  })(), (() => {
17705
- var _el$12 = _tmpl$6$5();
17723
+ var _el$12 = _tmpl$6$6();
17706
17724
  _el$12.$$input = (event) => applyColor(event.currentTarget.value);
17707
17725
  var _ref$ = customColorInputRef;
17708
17726
  typeof _ref$ === "function" ? use(_ref$, _el$12) : customColorInputRef = _el$12;
@@ -17724,7 +17742,7 @@ function ColorPicker(props) {
17724
17742
  });
17725
17743
  }
17726
17744
  delegateEvents(["click", "input"]);
17727
- var _tmpl$$E = /* @__PURE__ */ template(`<div class=oasis-editor-table-grid-picker-status>`), _tmpl$2$s = /* @__PURE__ */ template(`<div class=oasis-editor-table-grid-picker-grid>`), _tmpl$3$i = /* @__PURE__ */ template(`<div class=oasis-editor-toolbar-dropdown>`), _tmpl$4$d = /* @__PURE__ */ template(`<button type=button class=oasis-editor-tool-button><i>`), _tmpl$5$a = /* @__PURE__ */ template(`<button type=button class=oasis-editor-table-grid-picker-cell>`);
17745
+ var _tmpl$$E = /* @__PURE__ */ template(`<div class=oasis-editor-table-grid-picker-status>`), _tmpl$2$s = /* @__PURE__ */ template(`<div class=oasis-editor-table-grid-picker-grid>`), _tmpl$3$j = /* @__PURE__ */ template(`<div class=oasis-editor-toolbar-dropdown>`), _tmpl$4$e = /* @__PURE__ */ template(`<button type=button class=oasis-editor-tool-button><i>`), _tmpl$5$b = /* @__PURE__ */ template(`<button type=button class=oasis-editor-table-grid-picker-cell>`);
17728
17746
  function GridPicker(props) {
17729
17747
  const t = useI18n();
17730
17748
  const [isOpen, setIsOpen] = createSignal(false);
@@ -17799,7 +17817,7 @@ function GridPicker(props) {
17799
17817
  return h.row === 0 || h.col === 0 ? t("toolbar.table") : `${h.row} × ${h.col}`;
17800
17818
  };
17801
17819
  return (() => {
17802
- var _el$ = _tmpl$3$i();
17820
+ var _el$ = _tmpl$3$j();
17803
17821
  insert(_el$, createComponent(Popover, {
17804
17822
  get open() {
17805
17823
  return isOpen();
@@ -17811,7 +17829,7 @@ function GridPicker(props) {
17811
17829
  col: 0
17812
17830
  }),
17813
17831
  trigger: (api) => (() => {
17814
- var _el$4 = _tmpl$4$d(), _el$5 = _el$4.firstChild;
17832
+ var _el$4 = _tmpl$4$e(), _el$5 = _el$4.firstChild;
17815
17833
  _el$4.$$click = () => api.toggle();
17816
17834
  use((el) => api.ref(el), _el$4);
17817
17835
  createRenderEffect((_p$) => {
@@ -17847,7 +17865,7 @@ function GridPicker(props) {
17847
17865
  return cols();
17848
17866
  },
17849
17867
  children: (c) => (() => {
17850
- var _el$6 = _tmpl$5$a();
17868
+ var _el$6 = _tmpl$5$b();
17851
17869
  _el$6.$$click = () => selectGridSize(r, c);
17852
17870
  _el$6.$$mousedown = (event) => event.preventDefault();
17853
17871
  _el$6.addEventListener("mouseenter", () => setHover({
@@ -17937,7 +17955,7 @@ const DEFAULT_PALETTE = {
17937
17955
  standardColors: STANDARD_COLORS,
17938
17956
  allowCustom: true
17939
17957
  };
17940
- var _tmpl$$D = /* @__PURE__ */ template(`<button type=button class=oasis-editor-style-gallery-card role=option><span>`), _tmpl$2$r = /* @__PURE__ */ template(`<div class=oasis-editor-style-gallery-grid>`), _tmpl$3$h = /* @__PURE__ */ template(`<div class=oasis-editor-style-gallery><div class=oasis-editor-style-gallery-ribbon><div class=oasis-editor-style-gallery-strip role=listbox></div><button type=button class=oasis-editor-style-gallery-expand aria-haspopup=listbox><i data-lucide=chevron-down>`), _tmpl$4$c = /* @__PURE__ */ template(`<option>`);
17958
+ var _tmpl$$D = /* @__PURE__ */ template(`<button type=button class=oasis-editor-style-gallery-card role=option><span>`), _tmpl$2$r = /* @__PURE__ */ template(`<div class=oasis-editor-style-gallery-grid>`), _tmpl$3$i = /* @__PURE__ */ template(`<div class=oasis-editor-style-gallery><div class=oasis-editor-style-gallery-ribbon><div class=oasis-editor-style-gallery-strip role=listbox></div><button type=button class=oasis-editor-style-gallery-expand aria-haspopup=listbox><i data-lucide=chevron-down>`), _tmpl$4$d = /* @__PURE__ */ template(`<option>`);
17941
17959
  function getQuickStyles(styles) {
17942
17960
  const applicable = styles.filter((style2) => style2.type !== "table" && (!style2.semiHidden || style2.unhideWhenUsed && style2.isUsed));
17943
17961
  const hasQuickStyles = applicable.some((style2) => style2.qFormat === true);
@@ -18048,7 +18066,7 @@ function StyleGallery(props) {
18048
18066
  panelRole: "listbox",
18049
18067
  panelTestId,
18050
18068
  trigger: (popover) => (() => {
18051
- var _el$4 = _tmpl$3$h(), _el$5 = _el$4.firstChild, _el$6 = _el$5.firstChild, _el$7 = _el$6.nextSibling;
18069
+ var _el$4 = _tmpl$3$i(), _el$5 = _el$4.firstChild, _el$6 = _el$5.firstChild, _el$7 = _el$6.nextSibling;
18052
18070
  var _ref$ = popover.ref;
18053
18071
  typeof _ref$ === "function" ? use(_ref$, _el$4) : popover.ref = _el$4;
18054
18072
  insert(_el$4, createComponent(Select, {
@@ -18072,7 +18090,7 @@ function StyleGallery(props) {
18072
18090
  return styles();
18073
18091
  },
18074
18092
  children: (style2) => (() => {
18075
- var _el$8 = _tmpl$4$c();
18093
+ var _el$8 = _tmpl$4$d();
18076
18094
  insert(_el$8, () => style2.name);
18077
18095
  createRenderEffect(() => _el$8.value = style2.id);
18078
18096
  return _el$8;
@@ -18105,7 +18123,7 @@ function StyleGallery(props) {
18105
18123
  });
18106
18124
  }
18107
18125
  delegateEvents(["click", "keydown"]);
18108
- var _tmpl$$C = /* @__PURE__ */ template(`<option value>`), _tmpl$2$q = /* @__PURE__ */ template(`<option>`), _tmpl$3$g = /* @__PURE__ */ template(`<div class=oasis-editor-toolbar-item style=align-items:center>`);
18126
+ var _tmpl$$C = /* @__PURE__ */ template(`<option value>`), _tmpl$2$q = /* @__PURE__ */ template(`<option>`), _tmpl$3$h = /* @__PURE__ */ template(`<div class=oasis-editor-toolbar-item style=align-items:center>`);
18109
18127
  function renderMenuContent(content, api) {
18110
18128
  if (content.kind === "custom") {
18111
18129
  return content.render(api);
@@ -18434,7 +18452,7 @@ function ToolbarItemRenderer(props) {
18434
18452
  const binding = bindItem(props.item, props.api);
18435
18453
  const component = () => resolveRenderer(props.item.type);
18436
18454
  return (() => {
18437
- var _el$3 = _tmpl$3$g();
18455
+ var _el$3 = _tmpl$3$h();
18438
18456
  insert(_el$3, createComponent(Show, {
18439
18457
  get when() {
18440
18458
  return component();
@@ -18546,6 +18564,70 @@ const RIBBON_GROUP_ORDER = {
18546
18564
  general: 10
18547
18565
  }
18548
18566
  };
18567
+ const DEFAULT_RESIZE_STATES = [
18568
+ "full",
18569
+ "compact",
18570
+ "collapsed"
18571
+ ];
18572
+ const DEFAULT_GROUP_RESIZE_POLICY = {
18573
+ states: DEFAULT_RESIZE_STATES,
18574
+ priority: 50,
18575
+ compactMinWidth: 96,
18576
+ collapsedMinWidth: 68,
18577
+ collapsedIcon: "ellipsis",
18578
+ compactLabels: "show"
18579
+ };
18580
+ const STYLE_GALLERY_CARD_WIDTH = 106;
18581
+ const STYLE_GALLERY_EXPAND_WIDTH = 24;
18582
+ const STYLE_GALLERY_BORDER_WIDTH = 2;
18583
+ const RIBBON_GROUP_RESIZE_DEFAULTS = {
18584
+ home: {
18585
+ styles: {
18586
+ priority: 10,
18587
+ states: ["full", "compact", "collapsed"],
18588
+ compactMinWidth: 132,
18589
+ collapsedIcon: "palette"
18590
+ },
18591
+ paragraph: {
18592
+ priority: 15,
18593
+ states: ["full", "collapsed"],
18594
+ collapsedMinWidth: 74,
18595
+ collapsedIcon: "pilcrow"
18596
+ },
18597
+ clipboard: {
18598
+ priority: 20,
18599
+ states: ["full", "collapsed"],
18600
+ collapsedIcon: "clipboard"
18601
+ },
18602
+ font: {
18603
+ priority: 30,
18604
+ states: ["full", "collapsed"],
18605
+ collapsedMinWidth: 74,
18606
+ collapsedIcon: "type"
18607
+ }
18608
+ },
18609
+ insert: {
18610
+ illustrations: { priority: 25, collapsedIcon: "image" },
18611
+ tables: { priority: 30, collapsedIcon: "table" },
18612
+ links: { priority: 35, collapsedIcon: "link" },
18613
+ accessibility: { priority: 20, collapsedIcon: "file-text" },
18614
+ footnotes: { priority: 15, collapsedIcon: "footnote" }
18615
+ },
18616
+ layout: {
18617
+ paragraph: { priority: 30, compactMinWidth: 112, collapsedIcon: "ruler" },
18618
+ table: { priority: 20, collapsedIcon: "table" },
18619
+ section: { priority: 40, compactMinWidth: 148, collapsedIcon: "layout" }
18620
+ },
18621
+ file: {
18622
+ document: { priority: 10, collapsedIcon: "file" }
18623
+ },
18624
+ references: {
18625
+ footnotes: { priority: 10, collapsedIcon: "footnote" }
18626
+ },
18627
+ plugins: {
18628
+ general: { priority: 50, collapsedIcon: "plug" }
18629
+ }
18630
+ };
18549
18631
  function normalizeRibbonTab(tab) {
18550
18632
  return tab ?? DEFAULT_RIBBON_TAB;
18551
18633
  }
@@ -18558,6 +18640,30 @@ function normalizeRibbonRow(row) {
18558
18640
  function isLargeRibbonItem(item) {
18559
18641
  return "ribbonSize" in item && item.ribbonSize === "large";
18560
18642
  }
18643
+ function normalizeResizeStates(states) {
18644
+ const source = (states == null ? void 0 : states.length) ? states : DEFAULT_RESIZE_STATES;
18645
+ const unique = source.filter(
18646
+ (state, index) => source.indexOf(state) === index
18647
+ );
18648
+ return unique.includes("full") ? unique : ["full", ...unique];
18649
+ }
18650
+ function mergeRibbonGroupResizePolicy(tab, group, itemPolicy) {
18651
+ var _a;
18652
+ const tabDefaults = ((_a = RIBBON_GROUP_RESIZE_DEFAULTS[tab]) == null ? void 0 : _a[group]) ?? {};
18653
+ const merged = {
18654
+ ...DEFAULT_GROUP_RESIZE_POLICY,
18655
+ ...tabDefaults,
18656
+ ...itemPolicy
18657
+ };
18658
+ return {
18659
+ states: normalizeResizeStates(merged.states),
18660
+ priority: merged.priority ?? DEFAULT_GROUP_RESIZE_POLICY.priority,
18661
+ compactMinWidth: merged.compactMinWidth ?? DEFAULT_GROUP_RESIZE_POLICY.compactMinWidth,
18662
+ collapsedMinWidth: merged.collapsedMinWidth ?? DEFAULT_GROUP_RESIZE_POLICY.collapsedMinWidth,
18663
+ collapsedIcon: merged.collapsedIcon ?? DEFAULT_GROUP_RESIZE_POLICY.collapsedIcon,
18664
+ compactLabels: merged.compactLabels ?? DEFAULT_GROUP_RESIZE_POLICY.compactLabels
18665
+ };
18666
+ }
18561
18667
  function ribbonGroupLabel(group, t) {
18562
18668
  const key = GROUP_LABEL_KEYS[group];
18563
18669
  return key ? t(key) : group;
@@ -18566,6 +18672,7 @@ function buildRibbonGroups(items, tab, t) {
18566
18672
  const groups = /* @__PURE__ */ new Map();
18567
18673
  const tabGroupOrder = RIBBON_GROUP_ORDER[tab] ?? {};
18568
18674
  items.forEach((item, index) => {
18675
+ var _a;
18569
18676
  if (normalizeRibbonTab(item.tab) !== tab) {
18570
18677
  return;
18571
18678
  }
@@ -18579,11 +18686,27 @@ function buildRibbonGroups(items, tab, t) {
18579
18686
  label: ribbonGroupLabel(groupId, t),
18580
18687
  largeItems: [],
18581
18688
  rows: { 1: [], 2: [] },
18582
- order: groupOrder
18689
+ order: groupOrder,
18690
+ resizePolicy: mergeRibbonGroupResizePolicy(
18691
+ tab,
18692
+ groupId,
18693
+ item.ribbonGroupResize
18694
+ )
18583
18695
  };
18584
18696
  groups.set(groupId, group);
18585
18697
  }
18586
18698
  group.order = Math.min(group.order, groupOrder);
18699
+ group.resizePolicy = {
18700
+ ...group.resizePolicy,
18701
+ ...Object.fromEntries(
18702
+ Object.entries(item.ribbonGroupResize ?? {}).filter(
18703
+ ([, value]) => value !== void 0
18704
+ )
18705
+ ),
18706
+ states: normalizeResizeStates(
18707
+ ((_a = item.ribbonGroupResize) == null ? void 0 : _a.states) ?? group.resizePolicy.states
18708
+ )
18709
+ };
18587
18710
  if (isLargeRibbonItem(item)) {
18588
18711
  group.largeItems.push(item);
18589
18712
  } else {
@@ -18592,6 +18715,154 @@ function buildRibbonGroups(items, tab, t) {
18592
18715
  });
18593
18716
  return Array.from(groups.values()).sort((a, b) => a.order - b.order);
18594
18717
  }
18718
+ function estimatedRibbonGroupWidths(group) {
18719
+ const normalCount = group.rows[1].length + group.rows[2].length;
18720
+ const largeCount = group.largeItems.length;
18721
+ const full = Math.max(
18722
+ group.resizePolicy.collapsedMinWidth,
18723
+ largeCount * 72 + Math.max(group.rows[1].length, group.rows[2].length) * 30
18724
+ );
18725
+ return {
18726
+ full,
18727
+ compact: Math.max(
18728
+ group.resizePolicy.compactMinWidth,
18729
+ Math.ceil(full * (largeCount > 0 || normalCount > 6 ? 0.72 : 0.84))
18730
+ ),
18731
+ collapsed: group.resizePolicy.collapsedMinWidth
18732
+ };
18733
+ }
18734
+ function widthForState(state, widths) {
18735
+ return widths[state];
18736
+ }
18737
+ function widthForResolvedState(group, state, widths, allocatedWidths) {
18738
+ return state === "compact" ? allocatedWidths.get(group.id) ?? widths.compact : widthForState(state, widths);
18739
+ }
18740
+ function snapCompactWidthToWholeItems(group, desiredWidth, minWidth, maxWidth) {
18741
+ if (group.id !== "styles") {
18742
+ return Math.min(maxWidth, Math.max(minWidth, desiredWidth));
18743
+ }
18744
+ const chromeWidth = STYLE_GALLERY_EXPAND_WIDTH + STYLE_GALLERY_BORDER_WIDTH;
18745
+ if (maxWidth < STYLE_GALLERY_CARD_WIDTH + chromeWidth) {
18746
+ return Math.min(maxWidth, Math.max(minWidth, desiredWidth));
18747
+ }
18748
+ const cardSlots = Math.max(
18749
+ 1,
18750
+ Math.floor((desiredWidth - chromeWidth) / STYLE_GALLERY_CARD_WIDTH)
18751
+ );
18752
+ const snapped = cardSlots * STYLE_GALLERY_CARD_WIDTH + chromeWidth;
18753
+ return Math.min(maxWidth, Math.max(minWidth, snapped));
18754
+ }
18755
+ function resolveResponsiveRibbonGroups(groups, availableWidth, measurements = {}) {
18756
+ const states = /* @__PURE__ */ new Map();
18757
+ const widths = /* @__PURE__ */ new Map();
18758
+ const allocatedWidths = /* @__PURE__ */ new Map();
18759
+ for (const group of groups) {
18760
+ const estimated = estimatedRibbonGroupWidths(group);
18761
+ const measured = measurements[group.id] ?? {};
18762
+ const full = Math.max(
18763
+ estimated.full,
18764
+ Math.ceil(measured.full ?? estimated.full)
18765
+ );
18766
+ widths.set(group.id, {
18767
+ full,
18768
+ compact: Math.min(
18769
+ full,
18770
+ Math.max(
18771
+ group.resizePolicy.compactMinWidth,
18772
+ Math.ceil(measured.compact ?? estimated.compact)
18773
+ )
18774
+ ),
18775
+ collapsed: Math.min(
18776
+ full,
18777
+ Math.max(
18778
+ group.resizePolicy.collapsedMinWidth,
18779
+ Math.ceil(measured.collapsed ?? estimated.collapsed)
18780
+ )
18781
+ )
18782
+ });
18783
+ states.set(group.id, "full");
18784
+ }
18785
+ if (availableWidth !== null && Number.isFinite(availableWidth)) {
18786
+ let currentWidth = groups.reduce(
18787
+ (sum, group) => sum + widthForState("full", widths.get(group.id)),
18788
+ 0
18789
+ );
18790
+ const targetWidth = Math.max(0, availableWidth);
18791
+ while (currentWidth > targetWidth) {
18792
+ const candidates = groups.map((group) => {
18793
+ const groupStates = group.resizePolicy.states;
18794
+ const currentState = states.get(group.id) ?? "full";
18795
+ const currentIndex = groupStates.indexOf(currentState);
18796
+ const nextState = currentIndex >= 0 ? groupStates[currentIndex + 1] : void 0;
18797
+ if (!nextState) return null;
18798
+ const groupWidths2 = widths.get(group.id);
18799
+ const currentWidth2 = widthForResolvedState(
18800
+ group,
18801
+ currentState,
18802
+ groupWidths2,
18803
+ allocatedWidths
18804
+ );
18805
+ const saving = currentWidth2 - widthForState(nextState, groupWidths2);
18806
+ return saving > 0 ? { group, nextState, saving, currentState, currentIndex } : null;
18807
+ }).filter(
18808
+ (candidate) => Boolean(candidate)
18809
+ ).sort(
18810
+ (a, b) => a.currentIndex - b.currentIndex || b.group.order - a.group.order || a.group.resizePolicy.priority - b.group.resizePolicy.priority || b.saving - a.saving
18811
+ );
18812
+ const next = candidates[0];
18813
+ if (!next) break;
18814
+ const groupWidths = widths.get(next.group.id);
18815
+ const currentStateWidth = widthForResolvedState(
18816
+ next.group,
18817
+ next.currentState,
18818
+ groupWidths,
18819
+ allocatedWidths
18820
+ );
18821
+ const deficit = currentWidth - targetWidth;
18822
+ const nextStateWidth = next.nextState === "compact" ? snapCompactWidthToWholeItems(
18823
+ next.group,
18824
+ currentStateWidth - deficit,
18825
+ groupWidths.compact,
18826
+ groupWidths.full
18827
+ ) : widthForState(next.nextState, groupWidths);
18828
+ const actualSaving = currentStateWidth - nextStateWidth;
18829
+ states.set(next.group.id, next.nextState);
18830
+ if (next.nextState === "compact") {
18831
+ allocatedWidths.set(next.group.id, nextStateWidth);
18832
+ } else {
18833
+ allocatedWidths.delete(next.group.id);
18834
+ }
18835
+ currentWidth -= actualSaving;
18836
+ }
18837
+ let slack = targetWidth - currentWidth;
18838
+ if (slack > 0) {
18839
+ for (const group of groups.filter((candidate) => states.get(candidate.id) === "compact").sort(
18840
+ (a, b) => b.order - a.order || a.resizePolicy.priority - b.resizePolicy.priority
18841
+ )) {
18842
+ const groupWidths = widths.get(group.id);
18843
+ const compactWidth = groupWidths.compact;
18844
+ const maxExtra = groupWidths.full - compactWidth;
18845
+ if (maxExtra <= 0) continue;
18846
+ const allocated = snapCompactWidthToWholeItems(
18847
+ group,
18848
+ compactWidth + slack,
18849
+ compactWidth,
18850
+ groupWidths.full
18851
+ );
18852
+ const consumed = allocated - compactWidth;
18853
+ if (consumed <= 0) continue;
18854
+ allocatedWidths.set(group.id, allocated);
18855
+ slack -= consumed;
18856
+ if (slack <= 0) break;
18857
+ }
18858
+ }
18859
+ }
18860
+ return groups.map((group) => ({
18861
+ ...group,
18862
+ resizeState: states.get(group.id) ?? "full",
18863
+ allocatedWidth: allocatedWidths.get(group.id)
18864
+ }));
18865
+ }
18595
18866
  var _tmpl$$B = /* @__PURE__ */ template(`<div class=oasis-editor-ribbon-tabs role=tablist>`), _tmpl$2$p = /* @__PURE__ */ template(`<button type=button class=oasis-editor-ribbon-tab role=tab>`);
18596
18867
  function RibbonTabs(props) {
18597
18868
  const tabs = buildRibbonTabDefinitions(useI18n());
@@ -18665,67 +18936,183 @@ function RibbonRow(props) {
18665
18936
  return _el$;
18666
18937
  })();
18667
18938
  }
18668
- var _tmpl$$z = /* @__PURE__ */ template(`<div class=oasis-editor-ribbon-large-items>`), _tmpl$2$o = /* @__PURE__ */ template(`<section class=oasis-editor-ribbon-group><div class=oasis-editor-ribbon-group-rows><div class=oasis-editor-ribbon-normal-rows></div></div><div class=oasis-editor-ribbon-group-label>`);
18939
+ var _tmpl$$z = /* @__PURE__ */ template(`<div class=oasis-editor-ribbon-large-items>`), _tmpl$2$o = /* @__PURE__ */ template(`<div class=oasis-editor-ribbon-group-rows><div class=oasis-editor-ribbon-normal-rows>`), _tmpl$3$g = /* @__PURE__ */ template(`<div class=oasis-editor-ribbon-group-label>`), _tmpl$4$c = /* @__PURE__ */ template(`<section class=oasis-editor-ribbon-group>`), _tmpl$5$a = /* @__PURE__ */ template(`<div class=oasis-editor-ribbon-collapsed-items>`), _tmpl$6$5 = /* @__PURE__ */ template(`<div class=oasis-editor-ribbon-group-rows>`);
18940
+ function groupItems(group) {
18941
+ return [...group.largeItems, ...group.rows[1], ...group.rows[2]];
18942
+ }
18943
+ function groupStyle(group) {
18944
+ return group.resizeState === "compact" && group.allocatedWidth ? {
18945
+ "--oasis-ribbon-group-compact-width": `${group.allocatedWidth}px`
18946
+ } : {};
18947
+ }
18669
18948
  function RibbonGroup(props) {
18670
18949
  return (() => {
18671
- var _el$ = _tmpl$2$o(), _el$2 = _el$.firstChild, _el$4 = _el$2.firstChild, _el$5 = _el$2.nextSibling;
18672
- insert(_el$2, createComponent(Show, {
18950
+ var _el$ = _tmpl$4$c();
18951
+ insert(_el$, createComponent(Show, {
18673
18952
  get when() {
18674
- return props.group.largeItems.length > 0;
18953
+ return props.group.resizeState !== "collapsed";
18954
+ },
18955
+ get fallback() {
18956
+ return [(() => {
18957
+ var _el$6 = _tmpl$6$5();
18958
+ insert(_el$6, createComponent(Menu, {
18959
+ get icon() {
18960
+ return props.group.resizePolicy.collapsedIcon;
18961
+ },
18962
+ get label() {
18963
+ return props.group.label;
18964
+ },
18965
+ get tooltip() {
18966
+ return props.group.label;
18967
+ },
18968
+ get testId() {
18969
+ return `editor-ribbon-group-${props.group.id}`;
18970
+ },
18971
+ ribbonSize: "large",
18972
+ panelClass: "oasis-editor-ribbon-collapsed-menu",
18973
+ get children() {
18974
+ var _el$7 = _tmpl$5$a();
18975
+ insert(_el$7, createComponent(For, {
18976
+ get each() {
18977
+ return groupItems(props.group);
18978
+ },
18979
+ children: (item) => createComponent(ToolbarItemRenderer, {
18980
+ item,
18981
+ get api() {
18982
+ return props.api;
18983
+ }
18984
+ })
18985
+ }));
18986
+ return _el$7;
18987
+ }
18988
+ }));
18989
+ return _el$6;
18990
+ })(), (() => {
18991
+ var _el$8 = _tmpl$3$g();
18992
+ insert(_el$8, () => props.group.label);
18993
+ return _el$8;
18994
+ })()];
18675
18995
  },
18676
18996
  get children() {
18677
- var _el$3 = _tmpl$$z();
18678
- insert(_el$3, createComponent(For, {
18679
- get each() {
18680
- return props.group.largeItems;
18681
- },
18682
- children: (item) => createComponent(ToolbarItemRenderer, {
18683
- item,
18997
+ return [(() => {
18998
+ var _el$2 = _tmpl$2$o(), _el$4 = _el$2.firstChild;
18999
+ insert(_el$2, createComponent(Show, {
19000
+ get when() {
19001
+ return props.group.largeItems.length > 0;
19002
+ },
19003
+ get children() {
19004
+ var _el$3 = _tmpl$$z();
19005
+ insert(_el$3, createComponent(For, {
19006
+ get each() {
19007
+ return props.group.largeItems;
19008
+ },
19009
+ children: (item) => createComponent(ToolbarItemRenderer, {
19010
+ item,
19011
+ get api() {
19012
+ return props.api;
19013
+ }
19014
+ })
19015
+ }));
19016
+ return _el$3;
19017
+ }
19018
+ }), _el$4);
19019
+ insert(_el$4, createComponent(RibbonRow, {
19020
+ get items() {
19021
+ return props.group.rows[1];
19022
+ },
18684
19023
  get api() {
18685
19024
  return props.api;
18686
19025
  }
18687
- })
18688
- }));
18689
- return _el$3;
18690
- }
18691
- }), _el$4);
18692
- insert(_el$4, createComponent(RibbonRow, {
18693
- get items() {
18694
- return props.group.rows[1];
18695
- },
18696
- get api() {
18697
- return props.api;
18698
- }
18699
- }), null);
18700
- insert(_el$4, createComponent(RibbonRow, {
18701
- get items() {
18702
- return props.group.rows[2];
18703
- },
18704
- get api() {
18705
- return props.api;
19026
+ }), null);
19027
+ insert(_el$4, createComponent(RibbonRow, {
19028
+ get items() {
19029
+ return props.group.rows[2];
19030
+ },
19031
+ get api() {
19032
+ return props.api;
19033
+ }
19034
+ }), null);
19035
+ return _el$2;
19036
+ })(), (() => {
19037
+ var _el$5 = _tmpl$3$g();
19038
+ insert(_el$5, () => props.group.label);
19039
+ return _el$5;
19040
+ })()];
18706
19041
  }
18707
- }), null);
18708
- insert(_el$5, () => props.group.label);
19042
+ }));
18709
19043
  createRenderEffect((_p$) => {
18710
- var _v$ = props.group.id, _v$2 = props.group.label;
18711
- _v$ !== _p$.e && setAttribute(_el$, "data-ribbon-group", _p$.e = _v$);
18712
- _v$2 !== _p$.t && setAttribute(_el$, "aria-label", _p$.t = _v$2);
19044
+ var _v$ = !!(props.group.resizeState === "compact"), _v$2 = !!(props.group.resizeState === "collapsed"), _v$3 = !!(props.group.resizeState === "compact" && props.group.resizePolicy.compactLabels === "hide"), _v$4 = props.group.id, _v$5 = props.group.resizeState, _v$6 = props.group.label, _v$7 = groupStyle(props.group);
19045
+ _v$ !== _p$.e && _el$.classList.toggle("oasis-editor-ribbon-group-compact", _p$.e = _v$);
19046
+ _v$2 !== _p$.t && _el$.classList.toggle("oasis-editor-ribbon-group-collapsed", _p$.t = _v$2);
19047
+ _v$3 !== _p$.a && _el$.classList.toggle("oasis-editor-ribbon-group-compact-hide-labels", _p$.a = _v$3);
19048
+ _v$4 !== _p$.o && setAttribute(_el$, "data-ribbon-group", _p$.o = _v$4);
19049
+ _v$5 !== _p$.i && setAttribute(_el$, "data-ribbon-state", _p$.i = _v$5);
19050
+ _v$6 !== _p$.n && setAttribute(_el$, "aria-label", _p$.n = _v$6);
19051
+ _p$.s = style(_el$, _v$7, _p$.s);
18713
19052
  return _p$;
18714
19053
  }, {
18715
19054
  e: void 0,
18716
- t: void 0
19055
+ t: void 0,
19056
+ a: void 0,
19057
+ o: void 0,
19058
+ i: void 0,
19059
+ n: void 0,
19060
+ s: void 0
18717
19061
  });
18718
19062
  return _el$;
18719
19063
  })();
18720
19064
  }
18721
19065
  var _tmpl$$y = /* @__PURE__ */ template(`<div class=oasis-editor-ribbon-panel role=tabpanel data-testid=editor-ribbon-panel>`);
18722
19066
  function RibbonPanel(props) {
18723
- const groups = () => buildRibbonGroups(props.items(), props.activeTab(), props.api.t);
19067
+ const [availableWidth, setAvailableWidth] = createSignal(null);
19068
+ const [measurements, setMeasurements] = createSignal({});
19069
+ let panelRef;
19070
+ const groups = createMemo(() => buildRibbonGroups(props.items(), props.activeTab(), props.api.t));
19071
+ const resolvedGroups = createMemo(() => resolveResponsiveRibbonGroups(groups(), availableWidth(), measurements()));
19072
+ const measureGroups = () => {
19073
+ var _a;
19074
+ const panel = panelRef;
19075
+ if (!panel) return;
19076
+ const panelBox = panel.getBoundingClientRect();
19077
+ const nextMeasurements = {
19078
+ ...measurements()
19079
+ };
19080
+ for (const el of Array.from(panel.querySelectorAll("[data-ribbon-group]"))) {
19081
+ const id = el.dataset.ribbonGroup;
19082
+ if (!id || el.dataset.ribbonState !== "full") continue;
19083
+ const width = Math.ceil(el.getBoundingClientRect().width);
19084
+ if (width > 0) {
19085
+ nextMeasurements[id] = {
19086
+ ...nextMeasurements[id],
19087
+ full: Math.max(((_a = nextMeasurements[id]) == null ? void 0 : _a.full) ?? 0, width)
19088
+ };
19089
+ }
19090
+ }
19091
+ setMeasurements(nextMeasurements);
19092
+ setAvailableWidth(Math.floor(panelBox.width));
19093
+ };
19094
+ onMount(() => {
19095
+ const panel = panelRef;
19096
+ if (!panel) return;
19097
+ const observer2 = new ResizeObserver(() => {
19098
+ requestAnimationFrame(measureGroups);
19099
+ });
19100
+ observer2.observe(panel);
19101
+ requestAnimationFrame(measureGroups);
19102
+ onCleanup(() => observer2.disconnect());
19103
+ });
19104
+ createEffect(() => {
19105
+ props.activeTab();
19106
+ props.items();
19107
+ requestAnimationFrame(measureGroups);
19108
+ });
18724
19109
  return (() => {
18725
19110
  var _el$ = _tmpl$$y();
19111
+ var _ref$ = panelRef;
19112
+ typeof _ref$ === "function" ? use(_ref$, _el$) : panelRef = _el$;
18726
19113
  insert(_el$, createComponent(For, {
18727
19114
  get each() {
18728
- return groups();
19115
+ return resolvedGroups();
18729
19116
  },
18730
19117
  children: (group) => createComponent(RibbonGroup, {
18731
19118
  group,