@univerjs/ui 0.12.3 → 0.12.4

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 (64) hide show
  1. package/lib/cjs/facade.js +1 -1
  2. package/lib/cjs/index.js +9 -9
  3. package/lib/cjs/locale/ca-ES.js +1 -1
  4. package/lib/cjs/locale/en-US.js +1 -1
  5. package/lib/cjs/locale/es-ES.js +1 -1
  6. package/lib/cjs/locale/fa-IR.js +1 -1
  7. package/lib/cjs/locale/fr-FR.js +1 -1
  8. package/lib/cjs/locale/ja-JP.js +1 -1
  9. package/lib/cjs/locale/ko-KR.js +1 -1
  10. package/lib/cjs/locale/ru-RU.js +1 -1
  11. package/lib/cjs/locale/vi-VN.js +1 -1
  12. package/lib/cjs/locale/zh-CN.js +1 -1
  13. package/lib/cjs/locale/zh-TW.js +1 -1
  14. package/lib/es/facade.js +44 -35
  15. package/lib/es/index.js +3065 -2936
  16. package/lib/es/locale/ca-ES.js +14 -16
  17. package/lib/es/locale/en-US.js +14 -16
  18. package/lib/es/locale/es-ES.js +14 -16
  19. package/lib/es/locale/fa-IR.js +16 -18
  20. package/lib/es/locale/fr-FR.js +14 -16
  21. package/lib/es/locale/ja-JP.js +16 -18
  22. package/lib/es/locale/ko-KR.js +16 -18
  23. package/lib/es/locale/ru-RU.js +16 -18
  24. package/lib/es/locale/vi-VN.js +14 -16
  25. package/lib/es/locale/zh-CN.js +14 -16
  26. package/lib/es/locale/zh-TW.js +14 -16
  27. package/lib/facade.js +44 -35
  28. package/lib/index.css +1 -1
  29. package/lib/index.js +3065 -2936
  30. package/lib/locale/ca-ES.js +14 -16
  31. package/lib/locale/en-US.js +14 -16
  32. package/lib/locale/es-ES.js +14 -16
  33. package/lib/locale/fa-IR.js +16 -18
  34. package/lib/locale/fr-FR.js +14 -16
  35. package/lib/locale/ja-JP.js +16 -18
  36. package/lib/locale/ko-KR.js +16 -18
  37. package/lib/locale/ru-RU.js +16 -18
  38. package/lib/locale/vi-VN.js +14 -16
  39. package/lib/locale/zh-CN.js +14 -16
  40. package/lib/locale/zh-TW.js +14 -16
  41. package/lib/types/components/font-family/FontFamilyItem.d.ts +19 -2
  42. package/lib/types/components/font-family/index.d.ts +0 -1
  43. package/lib/types/components/font-family/interface.d.ts +0 -6
  44. package/lib/types/controllers/config.schema.d.ts +5 -0
  45. package/lib/types/controllers/ui/ui.controller.d.ts +8 -15
  46. package/lib/types/facade/f-univer.d.ts +22 -1
  47. package/lib/types/index.d.ts +2 -1
  48. package/lib/types/locale/en-US.d.ts +14 -16
  49. package/lib/types/services/dom/canvas-dom-layer.service.d.ts +1 -0
  50. package/lib/types/services/font.service.d.ts +91 -0
  51. package/lib/umd/facade.js +1 -1
  52. package/lib/umd/index.js +9 -9
  53. package/lib/umd/locale/ca-ES.js +1 -1
  54. package/lib/umd/locale/en-US.js +1 -1
  55. package/lib/umd/locale/es-ES.js +1 -1
  56. package/lib/umd/locale/fa-IR.js +1 -1
  57. package/lib/umd/locale/fr-FR.js +1 -1
  58. package/lib/umd/locale/ja-JP.js +1 -1
  59. package/lib/umd/locale/ko-KR.js +1 -1
  60. package/lib/umd/locale/ru-RU.js +1 -1
  61. package/lib/umd/locale/vi-VN.js +1 -1
  62. package/lib/umd/locale/zh-CN.js +1 -1
  63. package/lib/umd/locale/zh-TW.js +1 -1
  64. package/package.json +8 -8
@@ -44,22 +44,20 @@ declare const locale: {
44
44
  more: string;
45
45
  };
46
46
  fontFamily: {
47
- TimesNewRoman: string;
48
- Arial: string;
49
- Tahoma: string;
50
- Verdana: string;
51
- MicrosoftYaHei: string;
52
- SimSun: string;
53
- SimHei: string;
54
- Kaiti: string;
55
- FangSong: string;
56
- NSimSun: string;
57
- STXinwei: string;
58
- STXingkai: string;
59
- STLiti: string;
60
- HanaleiFill: string;
61
- Anton: string;
62
- Pacifico: string;
47
+ 'not-supported': string;
48
+ arial: string;
49
+ 'times-new-roman': string;
50
+ tahoma: string;
51
+ verdana: string;
52
+ 'microsoft-yahei': string;
53
+ simsun: string;
54
+ simhei: string;
55
+ kaiti: string;
56
+ fangsong: string;
57
+ nsimsun: string;
58
+ stxinwei: string;
59
+ stxingkai: string;
60
+ stliti: string;
63
61
  };
64
62
  'shortcut-panel': {
65
63
  title: string;
@@ -13,6 +13,7 @@ export interface IFloatDomLayout extends IPosition {
13
13
  export interface IFloatDom {
14
14
  position$: Observable<IFloatDomLayout>;
15
15
  id: string;
16
+ domId?: string;
16
17
  componentKey: string | React.ComponentType;
17
18
  onPointerMove: (evt: PointerEvent | MouseEvent) => void;
18
19
  onPointerDown: (evt: PointerEvent | MouseEvent) => void;
@@ -0,0 +1,91 @@
1
+ import { IDisposable, IConfigService } from '@univerjs/core';
2
+ import { BehaviorSubject } from 'rxjs';
3
+ export declare const IFontService: import('@wendellhu/redi').IdentifierDecorator<IFontService>;
4
+ /**
5
+ * Font configuration interface
6
+ */
7
+ export interface IFontConfig {
8
+ /**
9
+ * Unique identifier, usually also the preferred value for CSS font-family
10
+ * @example 'Microsoft YaHei'
11
+ */
12
+ value: string;
13
+ /**
14
+ * Translation key for i18n
15
+ * @example 'font.microsoft_yahei'
16
+ */
17
+ label: string;
18
+ /**
19
+ * Font category for UI grouping (optional)
20
+ */
21
+ category?: 'sans-serif' | 'serif' | 'monospace' | 'display' | 'handwriting';
22
+ /**
23
+ * Mark whether the font is user-added
24
+ * (Used to distinguish built-in fonts to prevent accidental deletion of core fonts)
25
+ */
26
+ isCustom?: boolean;
27
+ }
28
+ export interface IFontService {
29
+ /**
30
+ * The data stream of the font list
31
+ * UI components should subscribe to this stream to render dropdown lists
32
+ * When the list changes (add, delete, update), a new value is automatically emitted
33
+ */
34
+ readonly fonts$: BehaviorSubject<IFontConfig[]>;
35
+ /**
36
+ * Get a snapshot of the current font list (synchronously)
37
+ * Suitable for scenarios where subscribing to the stream is not needed,
38
+ * or when obtaining the current state during logic processing
39
+ */
40
+ getFonts(): IFontConfig[];
41
+ /**
42
+ * Get a single font configuration by value
43
+ */
44
+ getFontByValue(value: string): IFontConfig | undefined;
45
+ /**
46
+ * Check if the current browser environment supports the font
47
+ * (Based on document.fonts.check or Canvas fallback)
48
+ */
49
+ isFontSupported(fontValue: string): boolean;
50
+ /**
51
+ * Add a new font
52
+ * @throws Error if the font value already exists
53
+ */
54
+ addFont(font: IFontConfig): void;
55
+ /**
56
+ * Update an existing font configuration
57
+ * Supports partial updates (e.g., only updating stack or label)
58
+ * @param value The unique identifier of the font to update
59
+ * @param updates The fields to update
60
+ */
61
+ updateFont(value: string, updates: Partial<Omit<IFontConfig, 'value'>>): void;
62
+ /**
63
+ * Remove a font
64
+ * @param value The identifier of the font to remove
65
+ * @returns boolean Whether the removal was successful (e.g., built-in fonts may not be allowed to be removed)
66
+ */
67
+ removeFont(value: string): boolean;
68
+ /**
69
+ * Reset to the default built-in font list
70
+ * (Used for the "Restore Defaults" feature)
71
+ */
72
+ resetToDefaults(): void;
73
+ }
74
+ export declare class FontService implements IFontService, IDisposable {
75
+ protected readonly _configService: IConfigService;
76
+ readonly fonts$: BehaviorSubject<IFontConfig[]>;
77
+ constructor(_configService: IConfigService);
78
+ dispose(): void;
79
+ getFonts(): IFontConfig[];
80
+ getFontByValue(value: string): IFontConfig | undefined;
81
+ /**
82
+ * Check if the current browser environment supports the font
83
+ * @param fontValue
84
+ * @returns boolean Whether the font is supported
85
+ */
86
+ isFontSupported(fontValue: string): boolean;
87
+ addFont(font: IFontConfig): void;
88
+ updateFont(value: string, updates: Partial<Omit<IFontConfig, 'value'>>): void;
89
+ removeFont(value: string): boolean;
90
+ resetToDefaults(): void;
91
+ }
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(s,d){typeof exports=="object"&&typeof module<"u"?d(require("@univerjs/core/facade"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["@univerjs/core/facade","@univerjs/engine-render","@univerjs/ui","@univerjs/core"],d):(s=typeof globalThis<"u"?globalThis:s||self,d(s.UniverCoreFacade,s.UniverEngineRender,s.UniverUi,s.UniverCore))})(this,(function(s,d,r,c){"use strict";var E=Object.defineProperty;var F=(s,d,r)=>d in s?E(s,d,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[d]=r;var u=(s,d,r)=>F(s,typeof d!="symbol"?d+"":d,r);var v;var f=Object.getOwnPropertyDescriptor,I=(a,e,t,n)=>{for(var i=n>1?void 0:n?f(e,t):e,o=a.length-1,h;o>=0;o--)(h=a[o])&&(i=h(i)||i);return i},m=(a,e)=>(t,n)=>e(t,n,a);class b extends s.FBase{appendTo(e){const t=typeof e=="string"?e.split("|"):e,n=t.length,i={};let o=i;const h=this.__getSchema();t.forEach((l,P)=>{P===n-1?o[l]=h:o[l]={},o=o[l]}),this._menuManagerService.mergeMenu(i)}}let g=(v=class extends b{constructor(e,t,n,i){super();u(this,"_commandToRegister",new Map);u(this,"_buildingSchema");this._item=e,this._injector=t,this._commandService=n,this._menuManagerService=i;const o=typeof e.action=="string"?e.action:c.generateRandomId(12);o!==e.action&&this._commandToRegister.set(o,e.action),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:r.MenuItemType.BUTTON,icon:e.icon,title:e.title,tooltip:e.tooltip,commandId:o})},typeof e.order<"u"&&(this._buildingSchema.order=e.order)}__getSchema(){return this._commandToRegister.forEach((e,t)=>{this._commandService.hasCommand(t)||this._commandService.registerCommand({id:t,type:c.CommandType.COMMAND,handler:e})}),{[this._item.id]:this._buildingSchema}}},u(v,"RibbonStartGroup",r.RibbonStartGroup),u(v,"RibbonPosition",r.RibbonPosition),u(v,"MenuManagerPosition",r.MenuManagerPosition),v);g=I([m(1,c.Inject(c.Injector)),m(2,c.ICommandService),m(3,r.IMenuManagerService)],g);let p=class extends b{constructor(e,t,n){super();u(this,"_menuByGroups",[]);u(this,"_submenus",[]);u(this,"_buildingSchema");this._item=e,this._injector=t,this._menuManagerService=n,this._buildingSchema={menuItemFactory:()=>({id:e.id,type:r.MenuItemType.SUBITEMS,icon:e.icon,title:e.title,tooltip:e.tooltip})},typeof e.order<"u"&&(this._buildingSchema.order=e.order)}addSubmenu(e){return this._submenus.push(e),this}addSeparator(){return this._menuByGroups.push(this._submenus),this._submenus=[],this}__getSchema(){const e={};return this.addSeparator(),this._menuByGroups.forEach((t,n)=>{const i={};t.forEach(o=>{Object.assign(i,o.__getSchema())}),e[`${this._item.id}-group-${n}`]=i}),{[this._item.id]:Object.assign(this._buildingSchema,e)}}};p=I([m(1,c.Inject(c.Injector)),m(2,r.IMenuManagerService)],p);var C=Object.getOwnPropertyDescriptor,j=(a,e,t,n)=>{for(var i=n>1?void 0:n?C(e,t):e,o=a.length-1,h;o>=0;o--)(h=a[o])&&(i=h(i)||i);return i},S=(a,e)=>(t,n)=>e(t,n,a);let _=class extends s.FBase{constructor(e,t,n,i){super();u(this,"_forceDisableDisposable",null);this._injector=e,this._renderManagerService=t,this._univerInstanceService=n,this._shortcutService=i}enableShortcut(){var e;return(e=this._forceDisableDisposable)==null||e.dispose(),this._forceDisableDisposable=null,this}disableShortcut(){return this._forceDisableDisposable||(this._forceDisableDisposable=this._shortcutService.forceDisable()),this}triggerShortcut(e){const t=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=this._renderManagerService.getRenderById(t.getUnitId());return n?(n.engine.getCanvasElement().dispatchEvent(e),this._shortcutService.dispatch(e)):void 0}dispatchShortcutEvent(e){return this._shortcutService.dispatch(e)}};_=j([S(0,c.Inject(c.Injector)),S(1,c.Inject(d.IRenderManagerService)),S(2,c.IUniverInstanceService),S(3,r.IShortcutService)],_);class M extends s.FUniver{getURL(){return new URL(window.location.href)}getShortcut(){return this._injector.createInstance(_)}copy(){return this._commandService.executeCommand(r.CopyCommand.id)}paste(){return this._commandService.executeCommand(r.PasteCommand.id)}createMenu(e){return this._injector.createInstance(g,e)}createSubmenu(e){return this._injector.createInstance(p,e)}openSiderbar(e){return this._injector.get(r.ISidebarService).open(e)}openSidebar(e){return this.openSiderbar(e)}openDialog(e){const n=this._injector.get(r.IDialogService).open({...e,onClose:()=>{n.dispose()}});return n}getComponentManager(){return this._injector.get(r.ComponentManager)}showMessage(e){return this._injector.get(r.IMessageService).show(e),this}setUIVisible(e,t){return this._injector.get(r.IUIPartsService).setUIVisible(e,t),this}isUIVisible(e){return this._injector.get(r.IUIPartsService).isUIVisible(e)}registerUIPart(e,t){return this._injector.get(r.IUIPartsService).registerComponent(e,()=>r.connectInjector(t,this._injector))}registerComponent(e,t,n){const i=this._injector.get(r.ComponentManager);return this.disposeWithMe(i.register(e,t,n))}setCurrent(e){if(!this._injector.get(d.IRenderManagerService).getRenderById(e))throw new Error("Unit not found");this._univerInstanceService.setCurrentUnitForType(e)}}s.FUniver.extend(M);class U extends s.FHooks{onBeforeCopy(e){return this._injector.get(c.ICommandService).beforeCommandExecuted(n=>{n.id===r.CopyCommand.id&&e()})}onCopy(e){return this._injector.get(c.ICommandService).onCommandExecuted(n=>{n.id===r.CopyCommand.id&&e()})}onBeforePaste(e){return this._injector.get(c.ICommandService).beforeCommandExecuted(n=>{n.id===r.PasteCommand.id&&e()})}onPaste(e){return this._injector.get(c.ICommandService).onCommandExecuted(n=>{(n.id===r.PasteCommand.id||n.id===r.SheetPasteShortKeyCommandName)&&e()})}}s.FHooks.extend(U);class y extends s.FEnum{get BuiltInUIPart(){return r.BuiltInUIPart}get KeyCode(){return r.KeyCode}}s.FEnum.extend(y)}));
1
+ (function(s,d){typeof exports=="object"&&typeof module<"u"?d(require("@univerjs/core/facade"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["@univerjs/core/facade","@univerjs/engine-render","@univerjs/ui","@univerjs/core"],d):(s=typeof globalThis<"u"?globalThis:s||self,d(s.UniverCoreFacade,s.UniverEngineRender,s.UniverUi,s.UniverCore))})(this,(function(s,d,r,c){"use strict";var F=Object.defineProperty;var E=(s,d,r)=>d in s?F(s,d,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[d]=r;var u=(s,d,r)=>E(s,typeof d!="symbol"?d+"":d,r);var v;var f=Object.getOwnPropertyDescriptor,I=(a,e,t,n)=>{for(var i=n>1?void 0:n?f(e,t):e,o=a.length-1,h;o>=0;o--)(h=a[o])&&(i=h(i)||i);return i},m=(a,e)=>(t,n)=>e(t,n,a);class b extends s.FBase{appendTo(e){const t=typeof e=="string"?e.split("|"):e,n=t.length,i={};let o=i;const h=this.__getSchema();t.forEach((l,P)=>{P===n-1?o[l]=h:o[l]={},o=o[l]}),this._menuManagerService.mergeMenu(i)}}let g=(v=class extends b{constructor(e,t,n,i){super();u(this,"_commandToRegister",new Map);u(this,"_buildingSchema");this._item=e,this._injector=t,this._commandService=n,this._menuManagerService=i;const o=typeof e.action=="string"?e.action:c.generateRandomId(12);o!==e.action&&this._commandToRegister.set(o,e.action),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:r.MenuItemType.BUTTON,icon:e.icon,title:e.title,tooltip:e.tooltip,commandId:o})},typeof e.order<"u"&&(this._buildingSchema.order=e.order)}__getSchema(){return this._commandToRegister.forEach((e,t)=>{this._commandService.hasCommand(t)||this._commandService.registerCommand({id:t,type:c.CommandType.COMMAND,handler:e})}),{[this._item.id]:this._buildingSchema}}},u(v,"RibbonStartGroup",r.RibbonStartGroup),u(v,"RibbonPosition",r.RibbonPosition),u(v,"MenuManagerPosition",r.MenuManagerPosition),v);g=I([m(1,c.Inject(c.Injector)),m(2,c.ICommandService),m(3,r.IMenuManagerService)],g);let p=class extends b{constructor(e,t,n){super();u(this,"_menuByGroups",[]);u(this,"_submenus",[]);u(this,"_buildingSchema");this._item=e,this._injector=t,this._menuManagerService=n,this._buildingSchema={menuItemFactory:()=>({id:e.id,type:r.MenuItemType.SUBITEMS,icon:e.icon,title:e.title,tooltip:e.tooltip})},typeof e.order<"u"&&(this._buildingSchema.order=e.order)}addSubmenu(e){return this._submenus.push(e),this}addSeparator(){return this._menuByGroups.push(this._submenus),this._submenus=[],this}__getSchema(){const e={};return this.addSeparator(),this._menuByGroups.forEach((t,n)=>{const i={};t.forEach(o=>{Object.assign(i,o.__getSchema())}),e[`${this._item.id}-group-${n}`]=i}),{[this._item.id]:Object.assign(this._buildingSchema,e)}}};p=I([m(1,c.Inject(c.Injector)),m(2,r.IMenuManagerService)],p);var C=Object.getOwnPropertyDescriptor,j=(a,e,t,n)=>{for(var i=n>1?void 0:n?C(e,t):e,o=a.length-1,h;o>=0;o--)(h=a[o])&&(i=h(i)||i);return i},S=(a,e)=>(t,n)=>e(t,n,a);let _=class extends s.FBase{constructor(e,t,n,i){super();u(this,"_forceDisableDisposable",null);this._injector=e,this._renderManagerService=t,this._univerInstanceService=n,this._shortcutService=i}enableShortcut(){var e;return(e=this._forceDisableDisposable)==null||e.dispose(),this._forceDisableDisposable=null,this}disableShortcut(){return this._forceDisableDisposable||(this._forceDisableDisposable=this._shortcutService.forceDisable()),this}triggerShortcut(e){const t=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=this._renderManagerService.getRenderById(t.getUnitId());return n?(n.engine.getCanvasElement().dispatchEvent(e),this._shortcutService.dispatch(e)):void 0}dispatchShortcutEvent(e){return this._shortcutService.dispatch(e)}};_=j([S(0,c.Inject(c.Injector)),S(1,c.Inject(d.IRenderManagerService)),S(2,c.IUniverInstanceService),S(3,r.IShortcutService)],_);class M extends s.FUniver{getURL(){return new URL(window.location.href)}getShortcut(){return this._injector.createInstance(_)}copy(){return this._commandService.executeCommand(r.CopyCommand.id)}paste(){return this._commandService.executeCommand(r.PasteCommand.id)}createMenu(e){return this._injector.createInstance(g,e)}createSubmenu(e){return this._injector.createInstance(p,e)}openSiderbar(e){return this._injector.get(r.ISidebarService).open(e)}openSidebar(e){return this.openSiderbar(e)}openDialog(e){const n=this._injector.get(r.IDialogService).open({...e,onClose:()=>{n.dispose()}});return n}getComponentManager(){return this._injector.get(r.ComponentManager)}showMessage(e){return this._injector.get(r.IMessageService).show(e),this}setUIVisible(e,t){return this._injector.get(r.IUIPartsService).setUIVisible(e,t),this}isUIVisible(e){return this._injector.get(r.IUIPartsService).isUIVisible(e)}registerUIPart(e,t){return this._injector.get(r.IUIPartsService).registerComponent(e,()=>r.connectInjector(t,this._injector))}registerComponent(e,t,n){const i=this._injector.get(r.ComponentManager);return this.disposeWithMe(i.register(e,t,n))}setCurrent(e){if(!this._injector.get(d.IRenderManagerService).getRenderById(e))throw new Error("Unit not found");this._univerInstanceService.setCurrentUnitForType(e)}addFonts(e){const t=this._injector.get(r.IFontService);e.forEach(n=>{t.addFont({...n,isCustom:!0})})}}s.FUniver.extend(M);class U extends s.FHooks{onBeforeCopy(e){return this._injector.get(c.ICommandService).beforeCommandExecuted(n=>{n.id===r.CopyCommand.id&&e()})}onCopy(e){return this._injector.get(c.ICommandService).onCommandExecuted(n=>{n.id===r.CopyCommand.id&&e()})}onBeforePaste(e){return this._injector.get(c.ICommandService).beforeCommandExecuted(n=>{n.id===r.PasteCommand.id&&e()})}onPaste(e){return this._injector.get(c.ICommandService).onCommandExecuted(n=>{(n.id===r.PasteCommand.id||n.id===r.SheetPasteShortKeyCommandName)&&e()})}}s.FHooks.extend(U);class y extends s.FEnum{get BuiltInUIPart(){return r.BuiltInUIPart}get KeyCode(){return r.KeyCode}}s.FEnum.extend(y)}));