@widgetic/editor 4.0.8 → 4.0.9

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,24 @@
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
+
253
266
  onMount(async () => {
254
267
  try {
255
268
  if (browser) {
269
+ fontPickerReadyAt = Date.now() + 400;
270
+ ensureFontPickerPortal();
256
271
  const coerced = coerceFontValue(value);
257
272
  if (coerced?.weight) {
258
273
  selectedWeight = `${controllerId}-${coerced.weight}`;
@@ -1721,37 +1736,31 @@
1721
1736
  <Popover.Root
1722
1737
  open={$openDropdowns?.has(controllerId)}
1723
1738
  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);
1739
+ if (isOpen && Date.now() < fontPickerReadyAt) return;
1740
+ const wasOpen = !!$openDropdowns?.has(controllerId);
1741
+ if (isOpen === wasOpen) return;
1742
+ if (!isOpen && resolvedFont?.family && !shouldSkipFont(resolvedFont.family)) {
1743
+ fontUtils.addRecentFont({
1744
+ family: resolvedFont.family,
1745
+ category: normalizeCategory(resolvedFont.category) as FontItem['category'],
1746
+ isCustom: fontManagerInstance?.isCustomFont(resolvedFont.family) || false
1747
+ });
1748
+ } else if (isOpen) {
1749
+ activeSearchIndex = -1;
1750
+ void tick().then(() => {
1751
+ updateFamilyPopoverBox();
1752
+ requestAnimationFrame(updateFamilyPopoverBox);
1753
+ });
1754
+ if (filteredFonts.length === 0 && allFonts.length > 0) {
1755
+ updateFilteredFonts();
1753
1756
  }
1757
+ setTimeout(() => {
1758
+ if (fontListContainer) {
1759
+ setupFontObserver();
1760
+ }
1761
+ }, 50);
1754
1762
  }
1763
+ toggleDropdown(controllerId);
1755
1764
  }}
1756
1765
  >
1757
1766
  <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 +1785,7 @@
1776
1785
  collisionPadding={12}
1777
1786
  side={familyPopoverSide}
1778
1787
  sideOffset={4}
1788
+ portalProps={{ to: '#widgetic-font-picker-portal' }}
1779
1789
  class="font-input-popover !p-0 widgetic-colors widgetic-radius rounded-medium modal-shadow border border-grey2"
1780
1790
  style={familyPopoverStyle}
1781
1791
  >
@@ -1969,6 +1979,7 @@
1969
1979
  <Popover.Root
1970
1980
  open={$openDropdowns?.has('weight-' + controllerId)}
1971
1981
  onOpenChange={(isOpen) => {
1982
+ if (isOpen && Date.now() < fontPickerReadyAt) return;
1972
1983
  if (isOpen !== $openDropdowns?.has('weight-' + controllerId)) {
1973
1984
  toggleDropdown('weight-' + controllerId);
1974
1985
  }
@@ -1980,7 +1991,7 @@
1980
1991
  </span>
1981
1992
  <IconCaretDownFilled class="w-5 h-5 shrink-0 text-grey5 group-hover:text-grey7" />
1982
1993
  </Popover.Trigger>
1983
- <Popover.Content class="p-0 w-[150px]">
1994
+ <Popover.Content class="font-input-popover p-0 w-[150px]" portalProps={{ to: '#widgetic-font-picker-portal' }}>
1984
1995
  <Command.Root>
1985
1996
  <Command.List>
1986
1997
  <Command.Group>
@@ -2091,7 +2102,7 @@
2091
2102
 
2092
2103
  /* Clamp to the viewport so the Fonts header and list stay on screen */
2093
2104
  :global(.font-input-popover) {
2094
- z-index: 50;
2105
+ z-index: 100000000 !important;
2095
2106
  will-change: transform;
2096
2107
  transform: translateZ(0);
2097
2108
  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.9",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",