@widgetic/editor 4.0.8 → 4.0.10

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.
@@ -250,9 +250,29 @@
250
250
  // Add a variable to store the debounced search function
251
251
  let debouncedSearch: (event: Event) => void;
252
252
 
253
+ let fontPickerReadyAt = 0;
254
+
255
+ function ensureFontPickerPortal() {
256
+ if (!browser) return;
257
+ const portalId = 'widgetic-font-picker-portal';
258
+ if (document.getElementById(portalId)) return;
259
+ const host = document.createElement('div');
260
+ host.id = portalId;
261
+ host.style.position = 'relative';
262
+ host.style.zIndex = '100000000';
263
+ document.body.appendChild(host);
264
+ }
265
+
266
+ // The font popover looks up this node while it is created. onMount is too
267
+ // late: the child portal mounts first and throws if the host is missing,
268
+ // which takes the whole details panel (including chat) down with it.
269
+ ensureFontPickerPortal();
270
+
253
271
  onMount(async () => {
254
272
  try {
255
273
  if (browser) {
274
+ fontPickerReadyAt = Date.now() + 400;
275
+ ensureFontPickerPortal();
256
276
  const coerced = coerceFontValue(value);
257
277
  if (coerced?.weight) {
258
278
  selectedWeight = `${controllerId}-${coerced.weight}`;
@@ -1721,37 +1741,31 @@
1721
1741
  <Popover.Root
1722
1742
  open={$openDropdowns?.has(controllerId)}
1723
1743
  onOpenChange={(isOpen) => {
1724
- if (isOpen !== $openDropdowns?.has(controllerId)) {
1725
- if (!isOpen && resolvedFont?.family && !shouldSkipFont(resolvedFont.family)) {
1726
- fontUtils.addRecentFont({
1727
- family: resolvedFont.family,
1728
- category: normalizeCategory(resolvedFont.category) as FontItem['category'],
1729
- isCustom: fontManagerInstance?.isCustomFont(resolvedFont.family) || false
1730
- });
1731
- } else if (isOpen) {
1732
- activeSearchIndex = -1;
1733
- void tick().then(() => {
1734
- updateFamilyPopoverBox();
1735
- requestAnimationFrame(updateFamilyPopoverBox);
1736
- });
1737
-
1738
- // When opening, ensure we have fonts ready
1739
- if (filteredFonts.length === 0 && allFonts.length > 0) {
1740
- // If we have allFonts but no filtered fonts, update them
1741
- updateFilteredFonts();
1742
- }
1743
-
1744
- // Use a small timeout to ensure the DOM has updated before setting up the observer
1745
- // This prevents the initial delay when opening the popover
1746
- setTimeout(() => {
1747
- if (fontListContainer) {
1748
- setupFontObserver();
1749
- }
1750
- }, 50);
1751
-
1752
- toggleDropdown(controllerId);
1744
+ if (isOpen && Date.now() < fontPickerReadyAt) return;
1745
+ const wasOpen = !!$openDropdowns?.has(controllerId);
1746
+ if (isOpen === wasOpen) return;
1747
+ if (!isOpen && resolvedFont?.family && !shouldSkipFont(resolvedFont.family)) {
1748
+ fontUtils.addRecentFont({
1749
+ family: resolvedFont.family,
1750
+ category: normalizeCategory(resolvedFont.category) as FontItem['category'],
1751
+ isCustom: fontManagerInstance?.isCustomFont(resolvedFont.family) || false
1752
+ });
1753
+ } else if (isOpen) {
1754
+ activeSearchIndex = -1;
1755
+ void tick().then(() => {
1756
+ updateFamilyPopoverBox();
1757
+ requestAnimationFrame(updateFamilyPopoverBox);
1758
+ });
1759
+ if (filteredFonts.length === 0 && allFonts.length > 0) {
1760
+ updateFilteredFonts();
1753
1761
  }
1762
+ setTimeout(() => {
1763
+ if (fontListContainer) {
1764
+ setupFontObserver();
1765
+ }
1766
+ }, 50);
1754
1767
  }
1768
+ toggleDropdown(controllerId);
1755
1769
  }}
1756
1770
  >
1757
1771
  <Popover.Trigger tabindex={-1} class="w-full h-full flex items-center border-0 bg-transparent hover:bg-transparent focus:bg-transparent pl-3 pr-[16px] group"
@@ -1776,6 +1790,7 @@
1776
1790
  collisionPadding={12}
1777
1791
  side={familyPopoverSide}
1778
1792
  sideOffset={4}
1793
+ portalProps={{ to: '#widgetic-font-picker-portal' }}
1779
1794
  class="font-input-popover !p-0 widgetic-colors widgetic-radius rounded-medium modal-shadow border border-grey2"
1780
1795
  style={familyPopoverStyle}
1781
1796
  >
@@ -1969,6 +1984,7 @@
1969
1984
  <Popover.Root
1970
1985
  open={$openDropdowns?.has('weight-' + controllerId)}
1971
1986
  onOpenChange={(isOpen) => {
1987
+ if (isOpen && Date.now() < fontPickerReadyAt) return;
1972
1988
  if (isOpen !== $openDropdowns?.has('weight-' + controllerId)) {
1973
1989
  toggleDropdown('weight-' + controllerId);
1974
1990
  }
@@ -1980,7 +1996,7 @@
1980
1996
  </span>
1981
1997
  <IconCaretDownFilled class="w-5 h-5 shrink-0 text-grey5 group-hover:text-grey7" />
1982
1998
  </Popover.Trigger>
1983
- <Popover.Content class="p-0 w-[150px]">
1999
+ <Popover.Content class="font-input-popover p-0 w-[150px]" portalProps={{ to: '#widgetic-font-picker-portal' }}>
1984
2000
  <Command.Root>
1985
2001
  <Command.List>
1986
2002
  <Command.Group>
@@ -2091,7 +2107,7 @@
2091
2107
 
2092
2108
  /* Clamp to the viewport so the Fonts header and list stay on screen */
2093
2109
  :global(.font-input-popover) {
2094
- z-index: 50;
2110
+ z-index: 100000000 !important;
2095
2111
  will-change: transform;
2096
2112
  transform: translateZ(0);
2097
2113
  backface-visibility: hidden;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export type { ContentSchemaItemView, ContentSchemaPropertyView, ContentSchemaView, DesignSchemaComponentView, DesignSchemaGroupView, DesignSchemaPropertyView, DesignSchemaView, } from './schemaViews.js';
2
2
  export { default as PropsEditor } from './components/editors/PropsEditor.svelte';
3
+ export { default as FontInputController } from './components/ic/FontInputController.svelte';
3
4
  export { default as WidgetPreview } from './components/WidgetPreview.svelte';
4
5
  export { setFileBrowserUploadConfig } from '@widgetic/file-browser';
5
6
  export { setGoogleFontsApiKey, getGoogleFontsKey } from './config';
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  // EDITORS
3
3
  // Props Editor
4
4
  export { default as PropsEditor } from './components/editors/PropsEditor.svelte';
5
+ export { default as FontInputController } from './components/ic/FontInputController.svelte';
5
6
  export { default as WidgetPreview } from './components/WidgetPreview.svelte';
6
7
  export { setFileBrowserUploadConfig } from '@widgetic/file-browser';
7
8
  export { setGoogleFontsApiKey, getGoogleFontsKey } from './config';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widgetic/editor",
3
- "version": "4.0.8",
3
+ "version": "4.0.10",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",