2018-05-09 12:01:36 +05:30
|
|
|
import $ from 'jquery';
|
2018-03-17 18:26:18 +05:30
|
|
|
import IssuableTemplateSelector from './issuable_template_selector';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
export default class IssuableTemplateSelectors {
|
2019-12-21 20:55:43 +05:30
|
|
|
constructor({ $dropdowns, editor, warnTemplateOverride } = {}) {
|
2018-03-17 18:26:18 +05:30
|
|
|
this.$dropdowns = $dropdowns || $('.js-issuable-selector');
|
|
|
|
this.editor = editor || this.initEditor();
|
2016-09-13 17:45:13 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
this.$dropdowns.each((i, dropdown) => {
|
|
|
|
const $dropdown = $(dropdown);
|
2022-01-26 12:08:38 +05:30
|
|
|
|
|
|
|
// eslint-disable-next-line no-new
|
2018-03-17 18:26:18 +05:30
|
|
|
new IssuableTemplateSelector({
|
|
|
|
pattern: /(\.md)/,
|
|
|
|
data: $dropdown.data('data'),
|
|
|
|
wrapper: $dropdown.closest('.js-issuable-selector-wrap'),
|
|
|
|
dropdown: $dropdown,
|
|
|
|
editor: this.editor,
|
2019-12-21 20:55:43 +05:30
|
|
|
warnTemplateOverride,
|
2016-09-13 17:45:13 +05:30
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
2016-09-13 17:45:13 +05:30
|
|
|
}
|
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
// eslint-disable-next-line class-methods-use-this
|
2018-03-17 18:26:18 +05:30
|
|
|
initEditor() {
|
|
|
|
const editor = $('.markdown-area');
|
|
|
|
// Proxy ace-editor's .setValue to jQuery's .val
|
|
|
|
editor.setValue = editor.val;
|
|
|
|
editor.getValue = editor.val;
|
|
|
|
return editor;
|
|
|
|
}
|
|
|
|
}
|