@univerjs/ui 0.14.0 → 0.15.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.
@@ -1,2 +1,2 @@
1
1
  import { IFontFamilyProps } from './interface';
2
- export declare const FontFamily: (props: IFontFamilyProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const FontFamily: ({ id, value, disabled$ }: IFontFamilyProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,9 @@
1
+ import { Observable } from 'rxjs';
1
2
  import { ICustomComponentProps } from '../../services/menu/menu';
2
3
  export interface IFontFamilyProps extends ICustomComponentProps<string> {
4
+ id: string;
3
5
  value: string;
6
+ disabled$?: Observable<boolean>;
4
7
  }
5
8
  export declare const FONT_FAMILY_COMPONENT = "UI_FONT_FAMILY_COMPONENT";
6
9
  export declare const FONT_FAMILY_ITEM_COMPONENT = "UI_FONT_FAMILY_ITEM_COMPONENT";
@@ -1,5 +1,4 @@
1
1
  import { DependencyOverride } from '@univerjs/core';
2
- import { IFontConfig } from '../services/font.service';
3
2
  import { MenuConfig } from '../services/menu/menu';
4
3
  import { IWorkbenchOptions } from './ui/ui.controller';
5
4
  export declare const UI_PLUGIN_CONFIG_KEY = "ui.config";
@@ -9,10 +8,6 @@ export interface IUniverUIConfig extends IWorkbenchOptions {
9
8
  disableAutoFocus?: true;
10
9
  override?: DependencyOverride;
11
10
  menu?: MenuConfig;
12
- /**
13
- * Custom font family list to be added to the font service.
14
- */
15
- customFontFamily?: IFontConfig[];
16
11
  popupRootId?: string;
17
12
  /**
18
13
  * The fallback avatar for user.
@@ -17,7 +17,10 @@ export interface IWorkbenchOptions {
17
17
  /**
18
18
  * Custom font family list to be added to the font service.
19
19
  */
20
- customFontFamily?: IFontConfig[];
20
+ customFontFamily?: IFontConfig[] | {
21
+ override?: boolean;
22
+ list: IFontConfig[];
23
+ };
21
24
  /**
22
25
  * If Univer should make the footer bar visible.
23
26
  */
@@ -19,11 +19,6 @@ export interface IFontConfig {
19
19
  * Font category for UI grouping (optional)
20
20
  */
21
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
22
  }
28
23
  export interface IFontService {
29
24
  /**
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 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)}));
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)})}}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)}));