Repository: oppia/oppia
File: core/templates/components/ck-editor-helpers/ck-editor-4-widgets.initializer.ts (TypeScript)

Code before:
 */

import {NgZone} from '@angular/core';
import {PageContextService} from 'services/page-context.service';
import {HtmlEscaperService} from 'services/html-escaper.service';

export interface RteComponentSpecs {
  backendId: string;
  customizationArgSpecs: {
    name: string;
    value: string;
    default_value: string;
    default_value_obtainable_from_highlight: boolean;
  }[];
  id: string;
  iconDataUrl: string;
  isComplex: boolean;
  isBlockElement: boolean;
  requiresFs: boolean;
  requiresInternet?: boolean;
  tooltip: string;
}

export interface RteHelperService {
  createCustomizationArgDictFromAttrs: (
    attrs: Record<string, unknown>
  ) => Record<string, string>;
  getRichTextComponents: () => RteComponentSpecs[];
  isInlineComponent: (arg0: string) => boolean;
  openCustomizationModal: (
    componentIsNewlyCreated: boolean,
    componentId: string,
    customizationArgSpecs: {
      name: string;
      default_value: unknown;
      default_value_obtainable_from_highlight: boolean;
    }[],
    attrsCustomizationArgsDict: Record<string, unknown>,
    onSubmitCallback: (customizationArgsDict: Record<string, unknown>) => void,
    onDismissCallback: (widgetShouldBeRemoved: boolean) => void
  ) => void;
}

interface WidgetDefinition {
  wrapper: CKEDITOR.dom.element;
  data: Record<string, unknown>;
  element: CKEDITOR.dom.element;
  id: number;
  initialSnapshot: unknown;
  isReady: () => boolean;
  setData: (key: string, value: unknown) => void;

Review comment (suggestion):
We need to determine the exact type of this, using unknown or undefined is not the optimal solution.

Code after:
 */

import {NgZone} from '@angular/core';
import {PageContextService} from 'services/page-context.service';
import {HtmlEscaperService} from 'services/html-escaper.service';
import {CustomizationArgsForRteType} from 'services/rte-helper-modal.component';

export interface CustomizationArgSpec {
  name: string;
  default_value: string | number | boolean | object;
  default_value_obtainable_from_highlight: boolean;
}

export interface RteComponentSpecs {
  backendId: string;
  customizationArgSpecs: {
    name: string;
    value: string;
    default_value: string;
    default_value_obtainable_from_highlight: boolean;
  }[];
  id: string;
  iconDataUrl: string;
  isComplex: boolean;
  isBlockElement: boolean;
  requiresFs: boolean;
  requiresInternet?: boolean;
  tooltip: string;
}

export interface RteHelperService {
  createCustomizationArgDictFromAttrs: (
    attrs: Record<string, string>
  ) => Record<string, string>;
  getRichTextComponents: () => RteComponentSpecs[];
  isInlineComponent: (arg0: string) => boolean;
  openCustomizationModal: (
    componentIsNewlyCreated: boolean,
    componentId: string,
    customizationArgSpecs: CustomizationArgSpec[],
    attrsCustomizationArgsDict: Partial<CustomizationArgsForRteType>,
    onSubmitCallback: (
      customizationArgsDict: Partial<CustomizationArgsForRteType>
    ) => void,
    onDismissCallback: (widgetShouldBeRemoved: boolean) => void
  ) => void;
}

interface WidgetDefinition {
  wrapper: CKEDITOR.dom.element;
  data: Record<string, string | number | boolean | object>;