<commit_before>import { WebDirective } from './../../types';
import { WebApplication } from '@/ui_models/application';
import { SNComponent, SNItem, ComponentArea } from '@standardnotes/snjs';
import { isDesktopApplication } from '@/utils';
import template from '%/directives/editor-menu.pug';
import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl';

interface EditorMenuScope {
  callback: (component: SNComponent) => void;
  selectedEditorUuid: string;
  currentItem: SNItem;
  application: WebApplication;
}

class EditorMenuCtrl extends PureViewCtrl implements EditorMenuScope {
  callback!: () => (component: SNComponent) => void;
  selectedEditorUuid!: string;
  currentItem!: SNItem;
  application!: WebApplication;

  /* @ngInject */
  constructor($timeout: ng.ITimeoutService) {
    super($timeout);
    this.state = {
      isDesktop: isDesktopApplication(),
    };
  }

  public isEditorSelected(editor: SNComponent) {
    if (!this.selectedEditorUuid) {
      return false;
    }
    return this.selectedEditorUuid === editor.uuid;
  }

  public isEditorDefault(editor: SNComponent) {
    return this.state.defaultEditor?.uuid === editor.uuid;
  }

  $onInit() {
    super.$onInit();
    const editors = this.application
      .componentManager!.componentsForArea(ComponentArea.Editor)
      .sort((a, b) => {
        return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
      });
    const defaultEditor = editors.filter((e) => e.isDefaultEditor())[0];
    this.setState({
      editors: editors,
      defaultEditor: defaultEditor,
    });
  }

  selectComponent(component: SNComponent) {
    if (component) {
      if (component.conflictOf) {
        this.application.changeAndSaveItem(component.uuid, (mutator) => {
          mutator.conflictOf = undefined;
        });
      }
    }
    this.$timeout(() => {
      this.callback()(component);
    });
  }

  offlineAvailableForComponent(component: SNComponent) {
    return component.local_url && this.state.isDesktop;
  }
}

export class EditorMenu extends WebDirective {
  constructor() {
    super();
    this.restrict = 'E';
    this.template = template;
    this.controller = EditorMenuCtrl;
    this.controllerAs = 'self';
    this.bindToController = true;
    this.scope = {
      callback: '&',
      selectedEditorUuid: '=',
      currentItem: '=',
      application: '=',
    };
  }
}
<commit_msg>feat: Remove references of default editor<commit_after>import { WebDirective } from './../../types';
import { WebApplication } from '@/ui_models/application';
import { SNComponent, SNItem, ComponentArea } from '@standardnotes/snjs';
import { isDesktopApplication } from '@/utils';
import template from '%/directives/editor-menu.pug';
import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl';

interface EditorMenuScope {
  callback: (component: SNComponent) => void;
  selectedEditorUuid: string;
  currentItem: SNItem;
  application: WebApplication;
}

class EditorMenuCtrl extends PureViewCtrl implements EditorMenuScope {
  callback!: () => (component: SNComponent) => void;
  selectedEditorUuid!: string;
  currentItem!: SNItem;
  application!: WebApplication;

  /* @ngInject */
  constructor($timeout: ng.ITimeoutService) {
    super($timeout);
    this.state = {
      isDesktop: isDesktopApplication(),
    };
  }

  public isEditorSelected(editor: SNComponent) {
    if (!this.selectedEditorUuid) {
      return false;
    }
    return this.selectedEditorUuid === editor.uuid;
  }

  $onInit() {
    super.$onInit();
    const editors = this.application
      .componentManager!.componentsForArea(ComponentArea.Editor)
      .sort((a, b) => {
        return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
      });
    this.setState({
      editors: editors,
    });
  }

  selectComponent(component: SNComponent) {
    if (component) {
      if (component.conflictOf) {
        this.application.changeAndSaveItem(component.uuid, (mutator) => {
          mutator.conflictOf = undefined;
        });
      }
    }
    this.$timeout(() => {
      this.callback()(component);
    });
  }

  offlineAvailableForComponent(component: SNComponent) {
    return component.local_url && this.state.isDesktop;
  }
}

export class EditorMenu extends WebDirective {
  constructor() {
    super();
    this.restrict = 'E';
    this.template = template;
    this.controller = EditorMenuCtrl;
    this.controllerAs = 'self';
    this.bindToController = true;
    this.scope = {
      callback: '&',
      selectedEditorUuid: '=',
      currentItem: '=',
      application: '=',
    };
  }
}

{'fraction_non_alphanumeric': 0.13675027262813522, 'fraction_numerical': 0.0010905125408942203, 'mean_word_length': 3.334593572778828, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2270329', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1360, 'n_words': 269}