jodit icon indicating copy to clipboard operation
jodit copied to clipboard

Issues with typings for Jodit options

Open julianpoemp opened this issue 7 months ago • 0 comments

Jodit 4.2.27

  1. At the moment Jodit.make(element, options) doesn't declare the type for options. There should be a type definition instead of just "object".

/**
 * Factory for creating Jodit instance
 */
static make(element: HTMLElement | string, options?: object): Jodit;

  1. So I was using Config from "types/config.d.ts" in order to allow type safety and code suggestions in my project. I found out that the Config class from "types/config.d.ts" is out of sync with the IViewOptions interface (see comments I made):
interface IViewOptions extends ILanguageOptions, IToolbarOptions {
  /**
   * Use cache for heavy methods
   */
  cache?: boolean; // mandatory in types/config.d.ts
  getIcon?: (name: string, clearName: string) => CanUndef<string>; // missing
  headerButtons?: string | Array<IControlType | string | ButtonsGroup>; // missing
  basePath?: string;
  theme?: string; // mandatory in types/config.d.ts
  defaultTimeout?: number; // mandatory in types/config.d.ts
  disabled?: boolean; // mandatory in types/config.d.ts
  readonly?: boolean; // mandatory in types/config.d.ts
  iframe?: boolean; // mandatory in types/config.d.ts
  namespace?: string; // mandatory in types/config.d.ts
  activeButtonsInReadOnly?: string[]; // mandatory in types/config.d.ts
  allowTabNavigation?: boolean; // mandatory in types/config.d.ts
  zIndex?: number | string; // mandatory in types/config.d.ts
  fullsize?: boolean; // missing
  globalFullSize?: boolean; // missing
  controls?: Controls; // mandatory in types/config.d.ts
  createAttributes?: IDictionary<Attributes | NodeFunction>; // mandatory in types/config.d.ts
  events?: IDictionary<(...args: any[]) => any>; // mandatory in types/config.d.ts
  shadowRoot?: Nullable<ShadowRoot>;
  ownerWindow?: Window; // mandatory in types/config.d.ts
  language?: string; // mandatory in types/config.d.ts
}

interface ILanguageOptions {
  language?: string; // mandatory in types/config.d.ts
  debugLanguage?: boolean; // mandatory in types/config.d.ts
  i18n?: IDictionary<IDictionary<string>> | false; // mandatory in types/config.d.ts
}

interface IToolbarOptions {
  toolbar?: boolean | string | HTMLElement; // mandatory in types/config.d.ts
  readonly theme?: string; // mandatory in types/config.d.ts
  readonly toolbarButtonSize?: IUIButtonState['size']; // mandatory in types/config.d.ts
  readonly textIcons?: boolean | ((key: string) => boolean); // mandatory in types/config.d.ts
  readonly extraButtons?: Buttons; // mandatory in types/config.d.ts
  readonly removeButtons?: string[]; // mandatory in types/config.d.ts
  readonly extraIcons?: IDictionary<string>; // mandatory in types/config.d.ts
  readonly buttons?: ButtonsOption; // mandatory in types/config.d.ts
  readonly showTooltip?: boolean; // mandatory in types/config.d.ts
  readonly showTooltipDelay?: number; // mandatory in types/config.d.ts
  readonly useNativeTooltip?: boolean; // mandatory in types/config.d.ts
  readonly direction?: string; // mandatory in types/config.d.ts
}

I assume that the Config class is the class that typescript devs should use for defining the type of options? At the moment the Config class does not represent the optional and mandatory options that are handled by Jodit. Can you please update this class? If done that would help TS devs a lot and I could change the type definition in ngx-jodit 😄

julianpoemp avatar Jul 05 '24 16:07 julianpoemp