@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.
Files changed (33) hide show
  1. package/moj/all.jquery.min.js +7 -70
  2. package/moj/all.js +2856 -2865
  3. package/moj/components/add-another/add-another.js +135 -104
  4. package/moj/components/alert/alert.js +482 -247
  5. package/moj/components/alert/alert.spec.helper.js +30 -5
  6. package/moj/components/button-menu/button-menu.js +346 -319
  7. package/moj/components/date-picker/date-picker.js +925 -900
  8. package/moj/components/filter-toggle-button/filter-toggle-button.js +122 -91
  9. package/moj/components/form-validator/form-validator.js +399 -164
  10. package/moj/components/multi-file-upload/multi-file-upload.js +445 -210
  11. package/moj/components/multi-select/multi-select.js +106 -75
  12. package/moj/components/password-reveal/password-reveal.js +64 -33
  13. package/moj/components/rich-text-editor/rich-text-editor.js +186 -153
  14. package/moj/components/search-toggle/search-toggle.js +77 -46
  15. package/moj/components/sortable-table/sortable-table.js +167 -146
  16. package/moj/helpers/_links.scss +1 -1
  17. package/moj/helpers.js +218 -180
  18. package/moj/moj-frontend.min.js +7 -70
  19. package/moj/version.js +28 -1
  20. package/package.json +1 -1
  21. package/moj/all.spec.js +0 -24
  22. package/moj/components/add-another/add-another.spec.js +0 -165
  23. package/moj/components/alert/alert.spec.js +0 -229
  24. package/moj/components/button-menu/button-menu.spec.js +0 -360
  25. package/moj/components/date-picker/date-picker.spec.js +0 -1178
  26. package/moj/components/filter-toggle-button/filter-toggle-button.spec.js +0 -302
  27. package/moj/components/multi-file-upload/multi-file-upload.spec.js +0 -510
  28. package/moj/components/multi-select/multi-select.spec.js +0 -128
  29. package/moj/components/password-reveal/password-reveal.spec.js +0 -57
  30. package/moj/components/search-toggle/search-toggle.spec.js +0 -129
  31. package/moj/components/sortable-table/sortable-table.spec.js +0 -362
  32. package/moj/helpers.spec.js +0 -235
  33. package/moj/namespace.js +0 -2
@@ -1,75 +1,106 @@
1
- MOJFrontend.MultiSelect = function (options) {
2
- this.container = $(options.container)
3
-
4
- if (this.container.data('moj-multi-select-initialised')) {
5
- return
6
- }
7
-
8
- this.container.data('moj-multi-select-initialised', true)
9
-
10
- const idPrefix = options.id_prefix
11
- let allId = 'checkboxes-all'
12
- if (typeof idPrefix !== 'undefined') {
13
- allId = `${idPrefix}checkboxes-all`
14
- }
15
-
16
- this.toggle = $(this.getToggleHtml(allId))
17
- this.toggleButton = this.toggle.find('input')
18
- this.toggleButton.on('click', $.proxy(this, 'onButtonClick'))
19
- this.container.append(this.toggle)
20
- this.checkboxes = $(options.checkboxes)
21
- this.checkboxes.on('click', $.proxy(this, 'onCheckboxClick'))
22
- this.checked = options.checked || false
23
- }
24
-
25
- MOJFrontend.MultiSelect.prototype.getToggleHtml = function (allId) {
26
- let html = ''
27
- html +=
28
- '<div class="govuk-checkboxes__item govuk-checkboxes--small moj-multi-select__checkbox">'
29
- html += ` <input type="checkbox" class="govuk-checkboxes__input" id="${allId}">`
30
- html += ` <label class="govuk-label govuk-checkboxes__label moj-multi-select__toggle-label" for="${allId}">`
31
- html += ' <span class="govuk-visually-hidden">Select all</span>'
32
- html += ' </label>'
33
- html += '</div>'
34
- return html
35
- }
36
-
37
- MOJFrontend.MultiSelect.prototype.onButtonClick = function (e) {
38
- if (this.checked) {
39
- this.uncheckAll()
40
- this.toggleButton[0].checked = false
41
- } else {
42
- this.checkAll()
43
- this.toggleButton[0].checked = true
44
- }
45
- }
46
-
47
- MOJFrontend.MultiSelect.prototype.checkAll = function () {
48
- this.checkboxes.each(
49
- $.proxy(function (index, el) {
50
- el.checked = true
51
- }, this)
52
- )
53
- this.checked = true
54
- }
55
-
56
- MOJFrontend.MultiSelect.prototype.uncheckAll = function () {
57
- this.checkboxes.each(
58
- $.proxy(function (index, el) {
59
- el.checked = false
60
- }, this)
61
- )
62
- this.checked = false
63
- }
64
-
65
- MOJFrontend.MultiSelect.prototype.onCheckboxClick = function (e) {
66
- if (!e.target.checked) {
67
- this.toggleButton[0].checked = false
68
- this.checked = false
69
- } else {
70
- if (this.checkboxes.filter(':checked').length === this.checkboxes.length) {
71
- this.toggleButton[0].checked = true
72
- this.checked = true
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
- MOJFrontend.PasswordReveal = function (element) {
2
- this.el = element
3
- const $el = $(this.el)
4
-
5
- if ($el.data('moj-password-reveal-initialised')) {
6
- return
7
- }
8
-
9
- $el.data('moj-password-reveal-initialised', true)
10
- $el.attr('spellcheck', 'false')
11
-
12
- $el.wrap('<div class="moj-password-reveal"></div>')
13
- this.container = $(this.el).parent()
14
- this.createButton()
15
- }
16
-
17
- MOJFrontend.PasswordReveal.prototype.createButton = function () {
18
- this.button = $(
19
- '<button type="button" class="govuk-button govuk-button--secondary moj-password-reveal__button">Show <span class="govuk-visually-hidden">password</span></button>'
20
- )
21
- this.container.append(this.button)
22
- this.button.on('click', $.proxy(this, 'onButtonClick'))
23
- }
24
-
25
- MOJFrontend.PasswordReveal.prototype.onButtonClick = function () {
26
- if (this.el.type === 'password') {
27
- this.el.type = 'text'
28
- this.button.html('Hide <span class="govuk-visually-hidden">password</span>')
29
- } else {
30
- this.el.type = 'password'
31
- this.button.html('Show <span class="govuk-visually-hidden">password</span>')
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
- if ('contentEditable' in document.documentElement) {
2
- MOJFrontend.RichTextEditor = function (options) {
3
- this.options = options
4
- this.options.toolbar = this.options.toolbar || {
5
- bold: false,
6
- italic: false,
7
- underline: false,
8
- bullets: true,
9
- numbers: true
10
- }
11
- this.textarea = this.options.textarea
12
- this.container = $(this.textarea).parent()
13
-
14
- if (this.container.data('moj-rich-text-editor-initialised')) {
15
- return
16
- }
17
-
18
- this.container.data('moj-rich-text-editor-initialised', true)
19
-
20
- this.createToolbar()
21
- this.hideDefault()
22
- this.configureToolbar()
23
- this.keys = {
24
- left: 37,
25
- right: 39,
26
- up: 38,
27
- down: 40
28
- }
29
- this.container.on(
30
- 'click',
31
- '.moj-rich-text-editor__toolbar-button',
32
- $.proxy(this, 'onButtonClick')
33
- )
34
- this.container
35
- .find('.moj-rich-text-editor__content')
36
- .on('input', $.proxy(this, 'onEditorInput'))
37
- this.container.find('label').on('click', $.proxy(this, 'onLabelClick'))
38
- this.toolbar.on('keydown', $.proxy(this, 'onToolbarKeydown'))
39
- }
40
-
41
- MOJFrontend.RichTextEditor.prototype.onToolbarKeydown = function (e) {
42
- let focusableButton
43
- switch (e.keyCode) {
44
- case this.keys.right:
45
- case this.keys.down: {
46
- focusableButton = this.toolbar.find('button[tabindex=0]')
47
- const nextButton = focusableButton.next('button')
48
- if (nextButton[0]) {
49
- nextButton.focus()
50
- focusableButton.attr('tabindex', '-1')
51
- nextButton.attr('tabindex', '0')
52
- }
53
- break
54
- }
55
- case this.keys.left:
56
- case this.keys.up: {
57
- focusableButton = this.toolbar.find('button[tabindex=0]')
58
- const previousButton = focusableButton.prev('button')
59
- if (previousButton[0]) {
60
- previousButton.focus()
61
- focusableButton.attr('tabindex', '-1')
62
- previousButton.attr('tabindex', '0')
63
- }
64
- break
65
- }
66
- }
67
- }
68
-
69
- MOJFrontend.RichTextEditor.prototype.getToolbarHtml = function () {
70
- let html = ''
71
-
72
- html += '<div class="moj-rich-text-editor__toolbar" role="toolbar">'
73
-
74
- if (this.options.toolbar.bold) {
75
- html +=
76
- '<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>'
77
- }
78
-
79
- if (this.options.toolbar.italic) {
80
- html +=
81
- '<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>'
82
- }
83
-
84
- if (this.options.toolbar.underline) {
85
- html +=
86
- '<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>'
87
- }
88
-
89
- if (this.options.toolbar.bullets) {
90
- html +=
91
- '<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>'
92
- }
93
-
94
- if (this.options.toolbar.numbers) {
95
- html +=
96
- '<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>'
97
- }
98
-
99
- html += '</div>'
100
- return html
101
- }
102
-
103
- MOJFrontend.RichTextEditor.prototype.getEnhancedHtml = function (val) {
104
- return `${this.getToolbarHtml()}<div class="govuk-textarea moj-rich-text-editor__content" contenteditable="true" spellcheck="false"></div>`
105
- }
106
-
107
- MOJFrontend.RichTextEditor.prototype.hideDefault = function () {
108
- this.textarea = this.container.find('textarea')
109
- this.textarea.addClass('govuk-visually-hidden')
110
- this.textarea.attr('aria-hidden', true)
111
- this.textarea.attr('tabindex', '-1')
112
- }
113
-
114
- MOJFrontend.RichTextEditor.prototype.createToolbar = function () {
115
- this.toolbar = document.createElement('div')
116
- this.toolbar.className = 'moj-rich-text-editor'
117
- this.toolbar.innerHTML = this.getEnhancedHtml()
118
- this.container.append(this.toolbar)
119
- this.toolbar = this.container.find('.moj-rich-text-editor__toolbar')
120
- this.container
121
- .find('.moj-rich-text-editor__content')
122
- .html(this.textarea.val())
123
- }
124
-
125
- MOJFrontend.RichTextEditor.prototype.configureToolbar = function () {
126
- this.buttons = this.container.find('.moj-rich-text-editor__toolbar-button')
127
- this.buttons.prop('tabindex', '-1')
128
- const firstTab = this.buttons.first()
129
- firstTab.prop('tabindex', '0')
130
- }
131
-
132
- MOJFrontend.RichTextEditor.prototype.onButtonClick = function (e) {
133
- document.execCommand($(e.currentTarget).data('command'), false, null)
134
- }
135
-
136
- MOJFrontend.RichTextEditor.prototype.getContent = function () {
137
- return this.container.find('.moj-rich-text-editor__content').html()
138
- }
139
-
140
- MOJFrontend.RichTextEditor.prototype.onEditorInput = function (e) {
141
- this.updateTextarea()
142
- }
143
-
144
- MOJFrontend.RichTextEditor.prototype.updateTextarea = function () {
145
- document.execCommand('defaultParagraphSeparator', false, 'p')
146
- this.textarea.val(this.getContent())
147
- }
148
-
149
- MOJFrontend.RichTextEditor.prototype.onLabelClick = function (e) {
150
- e.preventDefault()
151
- this.container.find('.moj-rich-text-editor__content').focus()
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
+ }));