@ministryofjustice/frontend 3.4.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/moj/all.jquery.min.js +7 -70
- package/moj/all.js +2856 -2865
- package/moj/components/add-another/add-another.js +135 -104
- package/moj/components/alert/alert.js +482 -247
- package/moj/components/alert/alert.spec.helper.js +30 -5
- package/moj/components/button-menu/button-menu.js +346 -319
- package/moj/components/date-picker/date-picker.js +925 -900
- package/moj/components/filter-toggle-button/filter-toggle-button.js +122 -91
- package/moj/components/form-validator/form-validator.js +399 -164
- package/moj/components/multi-file-upload/multi-file-upload.js +445 -210
- package/moj/components/multi-select/multi-select.js +106 -75
- package/moj/components/password-reveal/password-reveal.js +64 -33
- package/moj/components/rich-text-editor/rich-text-editor.js +186 -153
- package/moj/components/search-toggle/search-toggle.js +77 -46
- package/moj/components/sortable-table/sortable-table.js +167 -146
- package/moj/helpers/_links.scss +1 -1
- package/moj/helpers.js +218 -180
- package/moj/moj-frontend.min.js +7 -70
- package/moj/version.js +28 -1
- package/package.json +1 -1
- package/moj/all.spec.js +0 -24
- package/moj/components/add-another/add-another.spec.js +0 -165
- package/moj/components/alert/alert.spec.js +0 -229
- package/moj/components/button-menu/button-menu.spec.js +0 -360
- package/moj/components/date-picker/date-picker.spec.js +0 -1178
- package/moj/components/filter-toggle-button/filter-toggle-button.spec.js +0 -302
- package/moj/components/multi-file-upload/multi-file-upload.spec.js +0 -510
- package/moj/components/multi-select/multi-select.spec.js +0 -128
- package/moj/components/password-reveal/password-reveal.spec.js +0 -57
- package/moj/components/search-toggle/search-toggle.spec.js +0 -129
- package/moj/components/sortable-table/sortable-table.spec.js +0 -362
- package/moj/helpers.spec.js +0 -235
- package/moj/namespace.js +0 -2
|
@@ -1,75 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.MOJFrontend = factory());
|
|
5
|
+
})(this, (function () { 'use strict';
|
|
6
|
+
|
|
7
|
+
function getDefaultExportFromCjs (x) {
|
|
8
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
var _global_window_jQuery = window.jQuery;
|
|
12
|
+
|
|
13
|
+
var multiSelect$1;
|
|
14
|
+
var hasRequiredMultiSelect;
|
|
15
|
+
|
|
16
|
+
function requireMultiSelect () {
|
|
17
|
+
if (hasRequiredMultiSelect) return multiSelect$1;
|
|
18
|
+
hasRequiredMultiSelect = 1;
|
|
19
|
+
const $ = _global_window_jQuery;
|
|
20
|
+
|
|
21
|
+
function MultiSelect(options) {
|
|
22
|
+
this.container = $(options.container);
|
|
23
|
+
|
|
24
|
+
if (this.container.data('moj-multi-select-initialised')) {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
this.container.data('moj-multi-select-initialised', true);
|
|
29
|
+
|
|
30
|
+
const idPrefix = options.id_prefix;
|
|
31
|
+
let allId = 'checkboxes-all';
|
|
32
|
+
if (typeof idPrefix !== 'undefined') {
|
|
33
|
+
allId = `${idPrefix}checkboxes-all`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
this.toggle = $(this.getToggleHtml(allId));
|
|
37
|
+
this.toggleButton = this.toggle.find('input');
|
|
38
|
+
this.toggleButton.on('click', $.proxy(this, 'onButtonClick'));
|
|
39
|
+
this.container.append(this.toggle);
|
|
40
|
+
this.checkboxes = $(options.checkboxes);
|
|
41
|
+
this.checkboxes.on('click', $.proxy(this, 'onCheckboxClick'));
|
|
42
|
+
this.checked = options.checked || false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
MultiSelect.prototype.getToggleHtml = function (allId) {
|
|
46
|
+
let html = '';
|
|
47
|
+
html +=
|
|
48
|
+
'<div class="govuk-checkboxes__item govuk-checkboxes--small moj-multi-select__checkbox">';
|
|
49
|
+
html += ` <input type="checkbox" class="govuk-checkboxes__input" id="${allId}">`;
|
|
50
|
+
html += ` <label class="govuk-label govuk-checkboxes__label moj-multi-select__toggle-label" for="${allId}">`;
|
|
51
|
+
html += ' <span class="govuk-visually-hidden">Select all</span>';
|
|
52
|
+
html += ' </label>';
|
|
53
|
+
html += '</div>';
|
|
54
|
+
return html
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
MultiSelect.prototype.onButtonClick = function (e) {
|
|
58
|
+
if (this.checked) {
|
|
59
|
+
this.uncheckAll();
|
|
60
|
+
this.toggleButton[0].checked = false;
|
|
61
|
+
} else {
|
|
62
|
+
this.checkAll();
|
|
63
|
+
this.toggleButton[0].checked = true;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
MultiSelect.prototype.checkAll = function () {
|
|
68
|
+
this.checkboxes.each(
|
|
69
|
+
$.proxy(function (index, el) {
|
|
70
|
+
el.checked = true;
|
|
71
|
+
}, this)
|
|
72
|
+
);
|
|
73
|
+
this.checked = true;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
MultiSelect.prototype.uncheckAll = function () {
|
|
77
|
+
this.checkboxes.each(
|
|
78
|
+
$.proxy(function (index, el) {
|
|
79
|
+
el.checked = false;
|
|
80
|
+
}, this)
|
|
81
|
+
);
|
|
82
|
+
this.checked = false;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
MultiSelect.prototype.onCheckboxClick = function (e) {
|
|
86
|
+
if (!e.target.checked) {
|
|
87
|
+
this.toggleButton[0].checked = false;
|
|
88
|
+
this.checked = false;
|
|
89
|
+
} else {
|
|
90
|
+
if (this.checkboxes.filter(':checked').length === this.checkboxes.length) {
|
|
91
|
+
this.toggleButton[0].checked = true;
|
|
92
|
+
this.checked = true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
multiSelect$1 = { MultiSelect };
|
|
98
|
+
return multiSelect$1;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
var multiSelectExports = requireMultiSelect();
|
|
102
|
+
var multiSelect = /*@__PURE__*/getDefaultExportFromCjs(multiSelectExports);
|
|
103
|
+
|
|
104
|
+
return multiSelect;
|
|
105
|
+
|
|
106
|
+
}));
|
|
@@ -1,33 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.MOJFrontend = factory());
|
|
5
|
+
})(this, (function () { 'use strict';
|
|
6
|
+
|
|
7
|
+
function getDefaultExportFromCjs (x) {
|
|
8
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
var _global_window_jQuery = window.jQuery;
|
|
12
|
+
|
|
13
|
+
var passwordReveal$1;
|
|
14
|
+
var hasRequiredPasswordReveal;
|
|
15
|
+
|
|
16
|
+
function requirePasswordReveal () {
|
|
17
|
+
if (hasRequiredPasswordReveal) return passwordReveal$1;
|
|
18
|
+
hasRequiredPasswordReveal = 1;
|
|
19
|
+
const $ = _global_window_jQuery;
|
|
20
|
+
|
|
21
|
+
function PasswordReveal(element) {
|
|
22
|
+
this.el = element;
|
|
23
|
+
const $el = $(this.el);
|
|
24
|
+
|
|
25
|
+
if ($el.data('moj-password-reveal-initialised')) {
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
$el.data('moj-password-reveal-initialised', true);
|
|
30
|
+
$el.attr('spellcheck', 'false');
|
|
31
|
+
|
|
32
|
+
$el.wrap('<div class="moj-password-reveal"></div>');
|
|
33
|
+
this.container = $(this.el).parent();
|
|
34
|
+
this.createButton();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
PasswordReveal.prototype.createButton = function () {
|
|
38
|
+
this.button = $(
|
|
39
|
+
'<button type="button" class="govuk-button govuk-button--secondary moj-password-reveal__button">Show <span class="govuk-visually-hidden">password</span></button>'
|
|
40
|
+
);
|
|
41
|
+
this.container.append(this.button);
|
|
42
|
+
this.button.on('click', $.proxy(this, 'onButtonClick'));
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
PasswordReveal.prototype.onButtonClick = function () {
|
|
46
|
+
if (this.el.type === 'password') {
|
|
47
|
+
this.el.type = 'text';
|
|
48
|
+
this.button.html('Hide <span class="govuk-visually-hidden">password</span>');
|
|
49
|
+
} else {
|
|
50
|
+
this.el.type = 'password';
|
|
51
|
+
this.button.html('Show <span class="govuk-visually-hidden">password</span>');
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
passwordReveal$1 = { PasswordReveal };
|
|
56
|
+
return passwordReveal$1;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
var passwordRevealExports = requirePasswordReveal();
|
|
60
|
+
var passwordReveal = /*@__PURE__*/getDefaultExportFromCjs(passwordRevealExports);
|
|
61
|
+
|
|
62
|
+
return passwordReveal;
|
|
63
|
+
|
|
64
|
+
}));
|
|
@@ -1,153 +1,186 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.MOJFrontend = factory());
|
|
5
|
+
})(this, (function () { 'use strict';
|
|
6
|
+
|
|
7
|
+
function getDefaultExportFromCjs (x) {
|
|
8
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
var _global_window_jQuery = window.jQuery;
|
|
12
|
+
|
|
13
|
+
var richTextEditor$1;
|
|
14
|
+
var hasRequiredRichTextEditor;
|
|
15
|
+
|
|
16
|
+
function requireRichTextEditor () {
|
|
17
|
+
if (hasRequiredRichTextEditor) return richTextEditor$1;
|
|
18
|
+
hasRequiredRichTextEditor = 1;
|
|
19
|
+
const $ = _global_window_jQuery;
|
|
20
|
+
|
|
21
|
+
function RichTextEditor(options) {
|
|
22
|
+
if (!('contentEditable' in document.documentElement)) {
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
this.options = options;
|
|
27
|
+
this.options.toolbar = this.options.toolbar || {
|
|
28
|
+
bold: false,
|
|
29
|
+
italic: false,
|
|
30
|
+
underline: false,
|
|
31
|
+
bullets: true,
|
|
32
|
+
numbers: true
|
|
33
|
+
};
|
|
34
|
+
this.textarea = this.options.textarea;
|
|
35
|
+
this.container = $(this.textarea).parent();
|
|
36
|
+
|
|
37
|
+
if (this.container.data('moj-rich-text-editor-initialised')) {
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
this.container.data('moj-rich-text-editor-initialised', true);
|
|
42
|
+
|
|
43
|
+
this.createToolbar();
|
|
44
|
+
this.hideDefault();
|
|
45
|
+
this.configureToolbar();
|
|
46
|
+
this.keys = {
|
|
47
|
+
left: 37,
|
|
48
|
+
right: 39,
|
|
49
|
+
up: 38,
|
|
50
|
+
down: 40
|
|
51
|
+
};
|
|
52
|
+
this.container.on(
|
|
53
|
+
'click',
|
|
54
|
+
'.moj-rich-text-editor__toolbar-button',
|
|
55
|
+
$.proxy(this, 'onButtonClick')
|
|
56
|
+
);
|
|
57
|
+
this.container
|
|
58
|
+
.find('.moj-rich-text-editor__content')
|
|
59
|
+
.on('input', $.proxy(this, 'onEditorInput'));
|
|
60
|
+
this.container.find('label').on('click', $.proxy(this, 'onLabelClick'));
|
|
61
|
+
this.toolbar.on('keydown', $.proxy(this, 'onToolbarKeydown'));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
RichTextEditor.prototype.onToolbarKeydown = function (e) {
|
|
65
|
+
let focusableButton;
|
|
66
|
+
switch (e.keyCode) {
|
|
67
|
+
case this.keys.right:
|
|
68
|
+
case this.keys.down: {
|
|
69
|
+
focusableButton = this.toolbar.find('button[tabindex=0]');
|
|
70
|
+
const nextButton = focusableButton.next('button');
|
|
71
|
+
if (nextButton[0]) {
|
|
72
|
+
nextButton.focus();
|
|
73
|
+
focusableButton.attr('tabindex', '-1');
|
|
74
|
+
nextButton.attr('tabindex', '0');
|
|
75
|
+
}
|
|
76
|
+
break
|
|
77
|
+
}
|
|
78
|
+
case this.keys.left:
|
|
79
|
+
case this.keys.up: {
|
|
80
|
+
focusableButton = this.toolbar.find('button[tabindex=0]');
|
|
81
|
+
const previousButton = focusableButton.prev('button');
|
|
82
|
+
if (previousButton[0]) {
|
|
83
|
+
previousButton.focus();
|
|
84
|
+
focusableButton.attr('tabindex', '-1');
|
|
85
|
+
previousButton.attr('tabindex', '0');
|
|
86
|
+
}
|
|
87
|
+
break
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
RichTextEditor.prototype.getToolbarHtml = function () {
|
|
93
|
+
let html = '';
|
|
94
|
+
|
|
95
|
+
html += '<div class="moj-rich-text-editor__toolbar" role="toolbar">';
|
|
96
|
+
|
|
97
|
+
if (this.options.toolbar.bold) {
|
|
98
|
+
html +=
|
|
99
|
+
'<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--bold" type="button" data-command="bold"><span class="govuk-visually-hidden">Bold</span></button>';
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (this.options.toolbar.italic) {
|
|
103
|
+
html +=
|
|
104
|
+
'<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--italic" type="button" data-command="italic"><span class="govuk-visually-hidden">Italic</span></button>';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (this.options.toolbar.underline) {
|
|
108
|
+
html +=
|
|
109
|
+
'<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--underline" type="button" data-command="underline"><span class="govuk-visually-hidden">Underline</span></button>';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (this.options.toolbar.bullets) {
|
|
113
|
+
html +=
|
|
114
|
+
'<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--unordered-list" type="button" data-command="insertUnorderedList"><span class="govuk-visually-hidden">Unordered list</span></button>';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (this.options.toolbar.numbers) {
|
|
118
|
+
html +=
|
|
119
|
+
'<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--ordered-list" type="button" data-command="insertOrderedList"><span class="govuk-visually-hidden">Ordered list</span></button>';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
html += '</div>';
|
|
123
|
+
return html
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
RichTextEditor.prototype.getEnhancedHtml = function (val) {
|
|
127
|
+
return `${this.getToolbarHtml()}<div class="govuk-textarea moj-rich-text-editor__content" contenteditable="true" spellcheck="false"></div>`
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
RichTextEditor.prototype.hideDefault = function () {
|
|
131
|
+
this.textarea = this.container.find('textarea');
|
|
132
|
+
this.textarea.addClass('govuk-visually-hidden');
|
|
133
|
+
this.textarea.attr('aria-hidden', true);
|
|
134
|
+
this.textarea.attr('tabindex', '-1');
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
RichTextEditor.prototype.createToolbar = function () {
|
|
138
|
+
this.toolbar = document.createElement('div');
|
|
139
|
+
this.toolbar.className = 'moj-rich-text-editor';
|
|
140
|
+
this.toolbar.innerHTML = this.getEnhancedHtml();
|
|
141
|
+
this.container.append(this.toolbar);
|
|
142
|
+
this.toolbar = this.container.find('.moj-rich-text-editor__toolbar');
|
|
143
|
+
this.container
|
|
144
|
+
.find('.moj-rich-text-editor__content')
|
|
145
|
+
.html(this.textarea.val());
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
RichTextEditor.prototype.configureToolbar = function () {
|
|
149
|
+
this.buttons = this.container.find('.moj-rich-text-editor__toolbar-button');
|
|
150
|
+
this.buttons.prop('tabindex', '-1');
|
|
151
|
+
const firstTab = this.buttons.first();
|
|
152
|
+
firstTab.prop('tabindex', '0');
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
RichTextEditor.prototype.onButtonClick = function (e) {
|
|
156
|
+
document.execCommand($(e.currentTarget).data('command'), false, null);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
RichTextEditor.prototype.getContent = function () {
|
|
160
|
+
return this.container.find('.moj-rich-text-editor__content').html()
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
RichTextEditor.prototype.onEditorInput = function (e) {
|
|
164
|
+
this.updateTextarea();
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
RichTextEditor.prototype.updateTextarea = function () {
|
|
168
|
+
document.execCommand('defaultParagraphSeparator', false, 'p');
|
|
169
|
+
this.textarea.val(this.getContent());
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
RichTextEditor.prototype.onLabelClick = function (e) {
|
|
173
|
+
e.preventDefault();
|
|
174
|
+
this.container.find('.moj-rich-text-editor__content').focus();
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
richTextEditor$1 = { RichTextEditor };
|
|
178
|
+
return richTextEditor$1;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
var richTextEditorExports = requireRichTextEditor();
|
|
182
|
+
var richTextEditor = /*@__PURE__*/getDefaultExportFromCjs(richTextEditorExports);
|
|
183
|
+
|
|
184
|
+
return richTextEditor;
|
|
185
|
+
|
|
186
|
+
}));
|