deepseek-1.x-dev/js/ckeditor5_plugins/insert_prompts/src/insert_prompts-view.js

js/ckeditor5_plugins/insert_prompts/src/insert_prompts-view.js
import { View, LabeledFieldView, Template, createLabeledInputText, ButtonView, submitHandler} from 'ckeditor5/src/ui';
import { IconCheck, IconCancel } from '@ckeditor/ckeditor5-icons';

/**
 * A class rendering the information required from user input.
 *
 * @extends module:ui/view~View
 *
 * @internal
 */
export default class InsertBlocView extends View {

  /**
   * @inheritdoc
   */
  constructor(editor) {
    const locale = editor.locale;
    super(locale);
    this.classInputView = this._createInput(editor.t('Ask me'), 'text');
    let collection = [
      this.classInputView,
    ];
    // Create the save and cancel buttons.
    this.saveButtonView = this._createButton(
      editor.t('Save'), IconCheck, 'ck-button-save'
    );
    this.saveButtonView.type = 'submit';
    collection.push(this.saveButtonView);
    this.cancelButtonView = this._createButton(
      editor.t('Cancel'), IconCancel, 'ck-button-cancel'
    );
    // Delegate ButtonView#execute to FormView#cancel.
    this.cancelButtonView.delegate('execute').to(this, 'cancel');
    collection.push(this.cancelButtonView);
    this.childViews = this.createCollection(collection);
    this.setTemplate({
      tag: 'form',
      attributes: {
        class: ['ck', 'ck-responsive-form', 'ck-insert-prompt'],
        tabindex: '-1'
      },
      children: this.childViews
    });
  }

  /**
   * @inheritdoc
   */
  render() {
    super.render();
    // Submit the form when the user clicked the save button or pressed enter the input.
    submitHandler({
      view: this
    });
  }

  /**
   * @inheritdoc
   */
  focus() {
    this.childViews.first.focus();
  }

  // Create a generic input field.
  _createInput(label, type = 'text') {
    const labeledInput = new LabeledFieldView(this.locale, createLabeledInputText);
    if (type != 'hidden') {
      labeledInput.label = Drupal.t(label);
    }
    if (type != 'text') {
      labeledInput.fieldView.inputMode = type;
      let tmp = labeledInput.fieldView.template;
      tmp.attributes.type = type;
      labeledInput.fieldView.setTemplate(new Template(tmp));
    }
    return labeledInput;
  }

  // Create a generic button.
  _createButton(label, icon, className) {
    const button = new ButtonView();

    button.set({
      label: label,
      icon: icon,
      tooltip: true,
      class: className,
    });

    return button;
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc