Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with typings for Jodit options #1157

Open
julianpoemp opened this issue Jul 5, 2024 · 0 comments
Open

Issues with typings for Jodit options #1157

julianpoemp opened this issue Jul 5, 2024 · 0 comments

Comments

@julianpoemp
Copy link

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 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant