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

Code before:
      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;
  editor: CKEDITOR.editor;
}

import {Injectable} from '@angular/core';

@Injectable({
  providedIn: 'root',
})
export class CkEditorInitializerService {
  static initialized = true;
  static ckEditorInitializer(
    rteHelperService: RteHelperService,
    htmlEscaperService: HtmlEscaperService,
    pageContextService: PageContextService,
    ngZone: NgZone
  ): void {
    if (rteHelperService === undefined) {
      return;
    }
    ngZone.runOutsideAngular(() => {
      var _RICH_TEXT_COMPONENTS = rteHelperService.getRichTextComponents();
      _RICH_TEXT_COMPONENTS.forEach(function (componentDefn) {
        // The name of the CKEditor widget corresponding to this component.
        var ckName = 'oppia' + componentDefn.id;

        // Check to ensure that a plugin is not registered more than once.
        if (CKEDITOR.plugins.registered[ckName] !== undefined) {
          return;
        }
        var tagName = 'oppia-noninteractive-ckeditor-' + componentDefn.id;
        var customizationArgSpecs = componentDefn.customizationArgSpecs;
        var isInline = rteHelperService.isInlineComponent(componentDefn.id);
        var componentId = componentDefn.id;


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

Code after:
  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>;
  element: CKEDITOR.dom.element;
  id: number;
  initialSnapshot: string;
  isReady: () => boolean;
  setData: (
    key: string,
    value: string | number | boolean | object | undefined
  ) => void;
  editor: CKEDITOR.editor;
}

import {Injectable} from '@angular/core';

@Injectable({
  providedIn: 'root',
})
export class CkEditorInitializerService {
  static initialized = true;
  static ckEditorInitializer(
    rteHelperService: RteHelperService,
    htmlEscaperService: HtmlEscaperService,
    pageContextService: PageContextService,
    ngZone: NgZone
  ): void {
    if (rteHelperService === undefined) {
      return;
    }
    ngZone.runOutsideAngular(() => {
      var _RICH_TEXT_COMPONENTS = rteHelperService.getRichTextComponents();
      _RICH_TEXT_COMPONENTS.forEach(function (componentDefn) {
        // The name of the CKEditor widget corresponding to this component.
        var ckName = 'oppia' + componentDefn.id;

        // Check to ensure that a plugin is not registered more than once.