qms-angular 1.0.73 → 1.0.77

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 (78) hide show
  1. package/bundles/qms-angular.umd.js +317 -351
  2. package/bundles/qms-angular.umd.js.map +1 -1
  3. package/esm2015/lib/components/button/button.js +1 -1
  4. package/esm2015/lib/components/comment/comment.js +2 -2
  5. package/esm2015/lib/components/qms-navigation-drawer/qms-navigation-drawer.component.js +12 -8
  6. package/esm2015/lib/components/qms-navigation-drawer/qms-navigation-drawer.module.js +4 -2
  7. package/esm2015/lib/components/qms-paginator/qms-paginator.component.js +5 -3
  8. package/esm2015/lib/components/qms-stepper/qms-stepper.component.js +1 -1
  9. package/esm2015/lib/components/related/popup/related-popup.component.js +11 -11
  10. package/esm2015/lib/components/select-include-children/select-include-children.component.js +2 -2
  11. package/esm2015/lib/components/select-one/select-one.component.js +2 -2
  12. package/esm2015/lib/components/select-process-document/select-process-document.component.js +64 -143
  13. package/esm2015/lib/components/side-sheet/directives/drawer-content.directive.js +20 -0
  14. package/esm2015/lib/components/side-sheet/directives/drawer-header-action.directive.js +20 -0
  15. package/esm2015/lib/components/side-sheet/directives/drawer-header.directive.js +20 -0
  16. package/esm2015/lib/components/side-sheet/directives/drawer.directive.js +20 -0
  17. package/esm2015/lib/components/side-sheet/index.js +2 -0
  18. package/esm2015/lib/components/side-sheet/public-api.js +6 -0
  19. package/esm2015/lib/components/side-sheet/side-sheet.module.js +28 -0
  20. package/esm2015/lib/directives/table/table-row.directive.js +50 -0
  21. package/esm2015/lib/directives/table/table.directive.js +18 -61
  22. package/esm2015/lib/qms-angular.module.js +5 -18
  23. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.js +1 -1
  24. package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.component.js +1 -1
  25. package/esm2015/public-api.js +4 -5
  26. package/fesm2015/qms-angular.js +263 -317
  27. package/fesm2015/qms-angular.js.map +1 -1
  28. package/lib/components/button/button.d.ts +1 -1
  29. package/lib/components/qms-navigation-drawer/qms-navigation-drawer.component.d.ts +2 -2
  30. package/lib/components/select-process-document/select-process-document.component.d.ts +3 -0
  31. package/lib/{directives/side-sheet → components/side-sheet/directives}/drawer-content.directive.d.ts +0 -0
  32. package/lib/{directives/side-sheet → components/side-sheet/directives}/drawer-header-action.directive.d.ts +0 -0
  33. package/lib/{directives/side-sheet → components/side-sheet/directives}/drawer-header.directive.d.ts +0 -0
  34. package/lib/{directives/side-sheet → components/side-sheet/directives}/drawer.directive.d.ts +0 -0
  35. package/lib/components/side-sheet/index.d.ts +1 -0
  36. package/lib/components/side-sheet/public-api.d.ts +5 -0
  37. package/lib/components/side-sheet/side-sheet.module.d.ts +2 -0
  38. package/lib/directives/table/table-row.directive.d.ts +13 -0
  39. package/lib/directives/table/table.directive.d.ts +2 -11
  40. package/package.json +1 -1
  41. package/public-api.d.ts +2 -4
  42. package/qms-angular.metadata.json +1 -1
  43. package/src/assets/jointjs/scss/rappid.scss +1 -1
  44. package/src/assets/qms-ckeditor-plugin/build/ckeditor.js +1 -1
  45. package/src/assets/qms-ckeditor-plugin/build/ckeditor.js.map +1 -1
  46. package/src/assets/qms-ckeditor-plugin/build/translations/de.js +1 -1
  47. package/src/assets/qms-ckeditor-plugin/build/translations/gl.js +1 -1
  48. package/src/assets/qms-ckeditor-plugin/build/translations/hu.js +1 -1
  49. package/src/assets/qms-ckeditor-plugin/build/translations/it.js +1 -1
  50. package/src/assets/qms-ckeditor-plugin/build/translations/ru.js +1 -1
  51. package/src/assets/qms-ckeditor-plugin/build/translations/zh.js +1 -1
  52. package/src/assets/qms-ckeditor-plugin/src/ckeditor.js +3 -1
  53. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/lang/contexts.json +3 -0
  54. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/lang/translations/de.po +21 -0
  55. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/lang/translations/en.po +21 -0
  56. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/lang/translations/gl.po +21 -0
  57. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/lang/translations/hu.po +21 -0
  58. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/lang/translations/it.po +21 -0
  59. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/lang/translations/ru.po +21 -0
  60. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/lang/translations/zh.po +21 -0
  61. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/src/index.js +10 -0
  62. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/src/sourceediting.js +386 -0
  63. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/src/utils/formathtml.js +142 -0
  64. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/theme/icons/source-editing.svg +1 -0
  65. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/theme/sourceediting.css +48 -0
  66. package/src/assets/qms-ckeditor-plugin/src/plugins/fullscreen/qmsCKEditorFullscreenPlugin.js +1 -5
  67. package/src/lib/components/qms-navigation-drawer/qms-navigation-drawer.component.scss +53 -26
  68. package/src/lib/components/qms-paginator/qms-paginator.component.scss +40 -3
  69. package/src/lib/components/qms-stepper/qms-stepper.component.scss +2 -1
  70. package/src/lib/components/select-process-document/select-process-document.component.scss +2 -2
  71. package/src/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.scss +0 -1
  72. package/src/lib/qms-ckeditor-components/qms-ckeditor.component.scss +11 -11
  73. package/src/themes/core/_side-sheet.scss +2 -2
  74. package/src/themes/core/_table.scss +176 -37
  75. package/esm2015/lib/directives/side-sheet/drawer-content.directive.js +0 -20
  76. package/esm2015/lib/directives/side-sheet/drawer-header-action.directive.js +0 -20
  77. package/esm2015/lib/directives/side-sheet/drawer-header.directive.js +0 -20
  78. package/esm2015/lib/directives/side-sheet/drawer.directive.js +0 -20
@@ -0,0 +1,386 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /**
7
+ * @module source-editing/sourceediting
8
+ */
9
+
10
+ /* global console */
11
+
12
+ import { Plugin, PendingActions } from 'ckeditor5/src/core';
13
+ import { ButtonView } from 'ckeditor5/src/ui';
14
+ import { createElement, ElementReplacer } from 'ckeditor5/src/utils';
15
+ import { formatHtml } from './utils/formathtml';
16
+
17
+ import '../theme/sourceediting.css';
18
+
19
+ import sourceEditingIcon from '../theme/icons/source-editing.svg';
20
+
21
+ const COMMAND_FORCE_DISABLE_ID = 'SourceEditingMode';
22
+
23
+ /**
24
+ * The source editing feature.
25
+ *
26
+ * It provides the possibility to view and edit the source of the document.
27
+ *
28
+ * For a detailed overview, check the {@glink features/source-editing source editing feature documentation} and the
29
+ * {@glink api/source-editing package page}.
30
+ *
31
+ * @extends module:core/plugin~Plugin
32
+ */
33
+ export default class SourceEditing extends Plugin {
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ static get pluginName() {
38
+ return 'SourceEditing';
39
+ }
40
+
41
+ /**
42
+ * @inheritDoc
43
+ */
44
+ static get requires() {
45
+ return [ PendingActions ];
46
+ }
47
+
48
+ /**
49
+ * @inheritDoc
50
+ */
51
+ constructor( editor ) {
52
+ super( editor );
53
+
54
+ /**
55
+ * Flag indicating whether the document source mode is active.
56
+ *
57
+ * @observable
58
+ * @member {Boolean}
59
+ */
60
+ this.set( 'isSourceEditingMode', false );
61
+
62
+ /**
63
+ * The element replacer instance used to replace the editing roots with the wrapper elements containing the document source.
64
+ *
65
+ * @private
66
+ * @member {module:utils/elementreplacer~ElementReplacer}
67
+ */
68
+ this._elementReplacer = new ElementReplacer();
69
+
70
+ /**
71
+ * Maps all root names to wrapper elements containing the document source.
72
+ *
73
+ * @private
74
+ * @member {Map.<String,HTMLElement>}
75
+ */
76
+ this._replacedRoots = new Map();
77
+
78
+ /**
79
+ * Maps all root names to their document data.
80
+ *
81
+ * @private
82
+ * @member {Map.<String,String>}
83
+ */
84
+ this._dataFromRoots = new Map();
85
+ }
86
+
87
+ /**
88
+ * @inheritDoc
89
+ */
90
+ init() {
91
+ const editor = this.editor;
92
+ const t = editor.t;
93
+
94
+ editor.ui.componentFactory.add( 'sourceEditing', locale => {
95
+ const buttonView = new ButtonView( locale );
96
+
97
+ buttonView.set( {
98
+ label: t( 'Source' ),
99
+ icon: sourceEditingIcon,
100
+ tooltip: true,
101
+ withText: true,
102
+ class: 'ck-source-editing-button'
103
+ } );
104
+
105
+ buttonView.bind( 'isOn' ).to( this, 'isSourceEditingMode' );
106
+
107
+ // The button should be disabled if one of the following conditions is met:
108
+ buttonView.bind( 'isEnabled' ).to(
109
+ this, 'isEnabled',
110
+ editor, 'isReadOnly',
111
+ editor.plugins.get( PendingActions ), 'hasAny',
112
+ ( isEnabled, isEditorReadOnly, hasAnyPendingActions ) => {
113
+ // (1) The plugin itself is disabled.
114
+ if ( !isEnabled ) {
115
+ return false;
116
+ }
117
+
118
+ // (2) The editor is in read-only mode.
119
+ if ( isEditorReadOnly ) {
120
+ return false;
121
+ }
122
+
123
+ // (3) Any pending action is scheduled. It may change the model, so modifying the document source should be prevented
124
+ // until the model is finally set.
125
+ if ( hasAnyPendingActions ) {
126
+ return false;
127
+ }
128
+
129
+ return true;
130
+ }
131
+ );
132
+
133
+ this.listenTo( buttonView, 'execute', () => {
134
+ this.isSourceEditingMode = !this.isSourceEditingMode;
135
+ } );
136
+
137
+ return buttonView;
138
+ } );
139
+
140
+ // Currently, the plugin handles the source editing mode by itself only for the classic editor. To use this plugin with other
141
+ // integrations, listen to the `change:isSourceEditingMode` event and act accordingly.
142
+ if ( this._isAllowedToHandleSourceEditingMode() ) {
143
+ this.on( 'change:isSourceEditingMode', ( evt, name, isSourceEditingMode ) => {
144
+ if ( isSourceEditingMode ) {
145
+ this._showSourceEditing();
146
+ this._disableCommands();
147
+ } else {
148
+ this._hideSourceEditing();
149
+ this._enableCommands();
150
+ }
151
+ } );
152
+
153
+ this.on( 'change:isEnabled', ( evt, name, isEnabled ) => this._handleReadOnlyMode( !isEnabled ) );
154
+
155
+ this.listenTo( editor, 'change:isReadOnly', ( evt, name, isReadOnly ) => this._handleReadOnlyMode( isReadOnly ) );
156
+ }
157
+ }
158
+
159
+ /**
160
+ * @inheritDoc
161
+ */
162
+ afterInit() {
163
+ const editor = this.editor;
164
+
165
+ const collaborationPluginNamesToWarn = [
166
+ 'RealTimeCollaborativeEditing',
167
+ 'CommentsEditing',
168
+ 'TrackChangesEditing',
169
+ 'RevisionHistory'
170
+ ];
171
+
172
+ // Currently, the basic integration with Collaboration Features is to display a warning in the console.
173
+ if ( collaborationPluginNamesToWarn.some( pluginName => editor.plugins.has( pluginName ) ) ) {
174
+ console.warn(
175
+ 'You initialized the editor with the source editing feature and at least one of the collaboration features. ' +
176
+ 'Please be advised that the source editing feature may not work, and be careful when editing document source ' +
177
+ 'that contains markers created by the collaboration features.'
178
+ );
179
+ }
180
+
181
+ // Restricted Editing integration can also lead to problems. Warn the user accordingly.
182
+ if ( editor.plugins.has( 'RestrictedEditingModeEditing' ) ) {
183
+ console.warn(
184
+ 'You initialized the editor with the source editing feature and restricted editing feature. ' +
185
+ 'Please be advised that the source editing feature may not work, and be careful when editing document source ' +
186
+ 'that contains markers created by the restricted editing feature.'
187
+ );
188
+ }
189
+ }
190
+
191
+ /**
192
+ * Creates source editing wrappers that replace each editing root. Each wrapper contains the document source from the corresponding
193
+ * root.
194
+ *
195
+ * The wrapper element contains a textarea and it solves the problem, that the textarea element cannot auto expand its height based on
196
+ * the content it contains. The solution is to make the textarea more like a plain div element, which expands in height as much as it
197
+ * needs to, in order to display the whole document source without scrolling. The wrapper element is a parent for the textarea and for
198
+ * the pseudo-element `::after`, that replicates the look, content, and position of the textarea. The pseudo-element replica is hidden,
199
+ * but it is styled to be an identical visual copy of the textarea with the same content. Then, the wrapper is a grid container and both
200
+ * of its children (the textarea and the `::after` pseudo-element) are positioned within a CSS grid to occupy the same grid cell. The
201
+ * content in the pseudo-element `::after` is set in CSS and it stretches the grid to the appropriate size based on the textarea value.
202
+ * Since both children occupy the same grid cell, both have always the same height.
203
+ *
204
+ * @private
205
+ */
206
+ _showSourceEditing() {
207
+ const editor = this.editor;
208
+ const editingView = editor.editing.view;
209
+ const model = editor.model;
210
+
211
+ model.change( writer => {
212
+ writer.setSelection( null );
213
+ writer.removeSelectionAttribute( model.document.selection.getAttributeKeys() );
214
+ } );
215
+
216
+ // It is not needed to iterate through all editing roots, as currently the plugin supports only the Classic Editor with a single
217
+ // main root, but this code may help understand and use this feature in external integrations.
218
+ for ( const [ rootName, domRootElement ] of editingView.domRoots ) {
219
+ const data = formatSource( editor.data.get( { rootName } ) );
220
+
221
+ const domSourceEditingElementTextarea = createElement( domRootElement.ownerDocument, 'textarea', { rows: '1' } );
222
+
223
+ const domSourceEditingElementWrapper = createElement( domRootElement.ownerDocument, 'div', {
224
+ class: 'ck-source-editing-area',
225
+ 'data-value': data
226
+ }, [ domSourceEditingElementTextarea ] );
227
+
228
+ domSourceEditingElementTextarea.value = data;
229
+
230
+ // Setting a value to textarea moves the input cursor to the end. We want the selection at the beginning.
231
+ domSourceEditingElementTextarea.setSelectionRange( 0, 0 );
232
+
233
+ // Bind the textarea's value to the wrapper's `data-value` property. Each change of the textarea's value updates the
234
+ // wrapper's `data-value` property.
235
+ domSourceEditingElementTextarea.addEventListener( 'input', () => {
236
+ domSourceEditingElementWrapper.dataset.value = domSourceEditingElementTextarea.value;
237
+ } );
238
+
239
+ editingView.change( writer => {
240
+ const viewRoot = editingView.document.getRoot( rootName );
241
+
242
+ writer.addClass( 'ck-hidden', viewRoot );
243
+ } );
244
+
245
+ this._replacedRoots.set( rootName, domSourceEditingElementWrapper );
246
+
247
+ this._elementReplacer.replace( domRootElement, domSourceEditingElementWrapper );
248
+
249
+ this._dataFromRoots.set( rootName, data );
250
+ }
251
+
252
+ this._focusSourceEditing();
253
+ }
254
+
255
+ /**
256
+ * Restores all hidden editing roots and sets the source data in them.
257
+ *
258
+ * @private
259
+ */
260
+ _hideSourceEditing() {
261
+ const editor = this.editor;
262
+ const editingView = editor.editing.view;
263
+
264
+ const data = {};
265
+
266
+ for ( const [ rootName, domSourceEditingElementWrapper ] of this._replacedRoots ) {
267
+ const oldData = this._dataFromRoots.get( rootName );
268
+ const newData = domSourceEditingElementWrapper.dataset.value;
269
+
270
+ // Do not set the data unless some changes have been made in the meantime.
271
+ // This prevents empty undo steps after switching to the normal editor.
272
+ if ( oldData !== newData ) {
273
+ data[ rootName ] = newData;
274
+ }
275
+
276
+ editingView.change( writer => {
277
+ const viewRoot = editingView.document.getRoot( rootName );
278
+
279
+ writer.removeClass( 'ck-hidden', viewRoot );
280
+ } );
281
+ }
282
+
283
+ this._elementReplacer.restore();
284
+
285
+ this._replacedRoots.clear();
286
+
287
+ this._dataFromRoots.clear();
288
+
289
+ if ( Object.keys( data ).length ) {
290
+ editor.data.set( data, { batchType: 'default' } );
291
+ }
292
+
293
+ editor.editing.view.focus();
294
+ }
295
+
296
+ /**
297
+ * Focuses the textarea containing document source from the first editing root.
298
+ *
299
+ * @private
300
+ */
301
+ _focusSourceEditing() {
302
+ const [ domSourceEditingElementWrapper ] = this._replacedRoots.values();
303
+
304
+ const textarea = domSourceEditingElementWrapper.querySelector( 'textarea' );
305
+
306
+ textarea.focus();
307
+ }
308
+
309
+ /**
310
+ * Disables all commands.
311
+ *
312
+ * @private
313
+ */
314
+ _disableCommands() {
315
+ const editor = this.editor;
316
+
317
+ for ( const command of editor.commands.commands() ) {
318
+ command.forceDisabled( COMMAND_FORCE_DISABLE_ID );
319
+ }
320
+ }
321
+
322
+ /**
323
+ * Clears forced disable for all commands, that was previously set through {@link #_disableCommands}.
324
+ *
325
+ * @private
326
+ */
327
+ _enableCommands() {
328
+ const editor = this.editor;
329
+
330
+ for ( const command of editor.commands.commands() ) {
331
+ command.clearForceDisabled( COMMAND_FORCE_DISABLE_ID );
332
+ }
333
+ }
334
+
335
+ /**
336
+ * Adds or removes the `readonly` attribute from the textarea from all roots, if document source mode is active.
337
+ *
338
+ * @param {Boolean} isReadOnly Indicates whether all textarea elements should be read-only.
339
+ */
340
+ _handleReadOnlyMode( isReadOnly ) {
341
+ if ( !this.isSourceEditingMode ) {
342
+ return;
343
+ }
344
+
345
+ for ( const [ , domSourceEditingElementWrapper ] of this._replacedRoots ) {
346
+ domSourceEditingElementWrapper.querySelector( 'textarea' ).readOnly = isReadOnly;
347
+ }
348
+ }
349
+
350
+ /**
351
+ * Checks, if the plugin is allowed to handle the source editing mode by itself. Currently, the source editing mode is supported only
352
+ * for the {@link module:editor-classic/classiceditor~ClassicEditor classic editor}.
353
+ *
354
+ * @private
355
+ * @returns {Boolean}
356
+ */
357
+ _isAllowedToHandleSourceEditingMode() {
358
+ const editor = this.editor;
359
+ const editable = editor.ui.view.editable;
360
+
361
+ // Checks, if the editor's editable belongs to the editor's DOM tree.
362
+ return editable && !editable._hasExternalElement;
363
+ }
364
+ }
365
+
366
+ // Formats the content for a better readability.
367
+ //
368
+ // For a non-HTML source the unchanged input string is returned.
369
+ //
370
+ // @param {String} input Input string to check.
371
+ // @returns {Boolean}
372
+ function formatSource( input ) {
373
+ if ( !isHtml( input ) ) {
374
+ return input;
375
+ }
376
+
377
+ return formatHtml( input );
378
+ }
379
+
380
+ // Checks, if the document source is HTML. It is sufficient to just check the first character from the document data.
381
+ //
382
+ // @param {String} input Input string to check.
383
+ // @returns {Boolean}
384
+ function isHtml( input ) {
385
+ return input.startsWith( '<' );
386
+ }
@@ -0,0 +1,142 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /**
7
+ * @module source-editing/utils/formathtml
8
+ */
9
+
10
+ /**
11
+ * A simple (and naive) HTML code formatter that returns a formatted HTML markup that can be easily
12
+ * parsed by human eyes. It beautifies the HTML code by adding new lines between elements that behave like block elements
13
+ * (https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
14
+ * and a few more like `tr`, `td`, and similar ones) and inserting indents for nested content.
15
+ *
16
+ * WARNING: This function works only on a text that does not contain any indentations or new lines.
17
+ * Calling this function on the already formatted text will damage the formatting.
18
+ *
19
+ * @param {String} input An HTML string to format.
20
+ * @returns {String}
21
+ */
22
+ export function formatHtml( input ) {
23
+ // A list of block-like elements around which the new lines should be inserted, and within which
24
+ // the indentation of their children should be increased.
25
+ // The list is partially based on https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements that contains
26
+ // a full list of HTML block-level elements.
27
+ // A void element is an element that cannot have any child - https://html.spec.whatwg.org/multipage/syntax.html#void-elements.
28
+ const elementsToFormat = [
29
+ { name: 'address', isVoid: false },
30
+ { name: 'article', isVoid: false },
31
+ { name: 'aside', isVoid: false },
32
+ { name: 'blockquote', isVoid: false },
33
+ { name: 'br', isVoid: true },
34
+ { name: 'details', isVoid: false },
35
+ { name: 'dialog', isVoid: false },
36
+ { name: 'dd', isVoid: false },
37
+ { name: 'div', isVoid: false },
38
+ { name: 'dl', isVoid: false },
39
+ { name: 'dt', isVoid: false },
40
+ { name: 'fieldset', isVoid: false },
41
+ { name: 'figcaption', isVoid: false },
42
+ { name: 'figure', isVoid: false },
43
+ { name: 'footer', isVoid: false },
44
+ { name: 'form', isVoid: false },
45
+ { name: 'h1', isVoid: false },
46
+ { name: 'h2', isVoid: false },
47
+ { name: 'h3', isVoid: false },
48
+ { name: 'h4', isVoid: false },
49
+ { name: 'h5', isVoid: false },
50
+ { name: 'h6', isVoid: false },
51
+ { name: 'header', isVoid: false },
52
+ { name: 'hgroup', isVoid: false },
53
+ { name: 'hr', isVoid: true },
54
+ { name: 'input', isVoid: true },
55
+ { name: 'li', isVoid: false },
56
+ { name: 'main', isVoid: false },
57
+ { name: 'nav', isVoid: false },
58
+ { name: 'ol', isVoid: false },
59
+ { name: 'p', isVoid: false },
60
+ { name: 'pre', isVoid: false },
61
+ { name: 'section', isVoid: false },
62
+ { name: 'table', isVoid: false },
63
+ { name: 'tbody', isVoid: false },
64
+ { name: 'td', isVoid: false },
65
+ { name: 'textarea', isVoid: false },
66
+ { name: 'th', isVoid: false },
67
+ { name: 'thead', isVoid: false },
68
+ { name: 'tr', isVoid: false },
69
+ { name: 'ul', isVoid: false }
70
+ ];
71
+
72
+ const elementNamesToFormat = elementsToFormat.map( element => element.name ).join( '|' );
73
+
74
+ // It is not the fastest way to format the HTML markup but the performance should be good enough.
75
+ const lines = input
76
+ // Add new line before and after `<tag>` and `</tag>`.
77
+ // It may separate individual elements with two new lines, but this will be fixed below.
78
+ .replace( new RegExp( `</?(${ elementNamesToFormat })( .*?)?>`, 'g' ), '\n$&\n' )
79
+ // Divide input string into lines, which start with either an opening tag, a closing tag, or just a text.
80
+ .split( '\n' );
81
+
82
+ let indentCount = 0;
83
+
84
+ return lines
85
+ .filter( line => line.length )
86
+ .map( line => {
87
+ if ( isNonVoidOpeningTag( line, elementsToFormat ) ) {
88
+ return indentLine( line, indentCount++ );
89
+ }
90
+
91
+ if ( isClosingTag( line, elementsToFormat ) ) {
92
+ return indentLine( line, --indentCount );
93
+ }
94
+
95
+ return indentLine( line, indentCount );
96
+ } )
97
+ .join( '\n' );
98
+ }
99
+
100
+ // Checks, if an argument is an opening tag of a non-void element to be formatted.
101
+ //
102
+ // @param {String} line String to check.
103
+ // @param {Array} elementsToFormat Elements to be formatted.
104
+ // @param {String} elementsToFormat.name Element name.
105
+ // @param {Boolean} elementsToFormat.isVoid Flag indicating whether element is a void one.
106
+ // @returns {Boolean}
107
+ function isNonVoidOpeningTag( line, elementsToFormat ) {
108
+ return elementsToFormat.some( element => {
109
+ if ( element.isVoid ) {
110
+ return false;
111
+ }
112
+
113
+ if ( !new RegExp( `<${ element.name }( .*?)?>` ).test( line ) ) {
114
+ return false;
115
+ }
116
+
117
+ return true;
118
+ } );
119
+ }
120
+
121
+ // Checks, if an argument is a closing tag.
122
+ //
123
+ // @param {String} line String to check.
124
+ // @param {Array} elementsToFormat Elements to be formatted.
125
+ // @param {String} elementsToFormat.name Element name.
126
+ // @param {Boolean} elementsToFormat.isVoid Flag indicating whether element is a void one.
127
+ // @returns {Boolean}
128
+ function isClosingTag( line, elementsToFormat ) {
129
+ return elementsToFormat.some( element => {
130
+ return new RegExp( `</${ element.name }>` ).test( line );
131
+ } );
132
+ }
133
+
134
+ // Indents a line by a specified number of characters.
135
+ //
136
+ // @param {String} line Line to indent.
137
+ // @param {Number} indentCount Number of characters to use for indentation.
138
+ // @param {String} [indentChar] Indentation character(s). 4 spaces by default.
139
+ // @returns {String}
140
+ function indentLine( line, indentCount, indentChar = ' ' ) {
141
+ return `${ indentChar.repeat( indentCount ) }${ line }`;
142
+ }
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m12.5 0 5 4.5v15.003h-16V0h11zM3 1.5v3.25l-1.497 1-.003 8 1.5 1v3.254L7.685 18l-.001 1.504H17.5V8.002L16 9.428l-.004-4.22-4.222-3.692L3 1.5z"/><path d="M4.06 6.64a.75.75 0 0 1 .958 1.15l-.085.07L2.29 9.75l2.646 1.89c.302.216.4.62.232.951l-.058.095a.75.75 0 0 1-.951.232l-.095-.058-3.5-2.5V9.14l3.496-2.5zm4.194 6.22a.75.75 0 0 1-.958-1.149l.085-.07 2.643-1.89-2.646-1.89a.75.75 0 0 1-.232-.952l.058-.095a.75.75 0 0 1 .95-.232l.096.058 3.5 2.5v1.22l-3.496 2.5zm7.644-.836 2.122 2.122-5.825 5.809-2.125-.005.003-2.116zm2.539-1.847 1.414 1.414a.5.5 0 0 1 0 .707l-1.06 1.06-2.122-2.12 1.061-1.061a.5.5 0 0 1 .707 0z"/></svg>
@@ -0,0 +1,48 @@
1
+ /*
2
+ * Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ @import "@ckeditor/ckeditor5-theme-lark/theme/mixins/_rounded.css";
7
+ @import "@ckeditor/ckeditor5-theme-lark/theme/mixins/_focus.css";
8
+ @import "@ckeditor/ckeditor5-theme-lark/theme/mixins/_shadow.css";
9
+
10
+ .ck-source-editing-area {
11
+ display: inline-grid;
12
+ width: 100%;
13
+ font-family: monospace;
14
+ }
15
+
16
+ .ck-source-editing-area::after,
17
+ .ck-source-editing-area textarea {
18
+ grid-area: 1/1;
19
+ padding: var(--ck-spacing-large);
20
+ margin: 0;
21
+ border: 1px solid transparent;
22
+ line-height: var(--ck-line-height-base);
23
+ font-size: var(--ck-font-size-normal);
24
+ white-space: pre-wrap;
25
+ }
26
+
27
+ .ck-source-editing-area::after {
28
+ content: attr(data-value) " ";
29
+ visibility: hidden;
30
+ }
31
+
32
+ .ck-source-editing-area textarea {
33
+ resize: none;
34
+ outline: none;
35
+ overflow: hidden;
36
+
37
+ border-color: var(--ck-color-base-border);
38
+
39
+ @mixin ck-rounded-corners {
40
+ border-top-left-radius: 0;
41
+ border-top-right-radius: 0;
42
+ }
43
+
44
+ &:not([readonly]):focus {
45
+ @mixin ck-focus-ring;
46
+ @mixin ck-box-shadow var(--ck-inner-shadow);
47
+ }
48
+ }
@@ -8,10 +8,6 @@ import * as constant from '../common/qmsCKEditorConstant';
8
8
  export default class QMSCKEditorFullscreenPlugin extends Plugin {
9
9
  init() {
10
10
  const editor = this.editor;
11
- editor.editing.view.change( writer => {
12
- // writer.setStyle( 'height', 'calc(100vh - 180px)', editor.editing.view.document.getRoot() );
13
- } );
14
-
15
11
  editor.ui.componentFactory.add('qmsFullscreen', locale => {
16
12
  const view = new ButtonView(locale);
17
13
 
@@ -21,7 +17,7 @@ export default class QMSCKEditorFullscreenPlugin extends Plugin {
21
17
  tooltip: true
22
18
  });
23
19
  const fullscreenClass = this.editor.config.get('fullScreenConfig.class') || 'qmsckeditor__fullscreen';
24
-
20
+
25
21
  view.on('execute', () => {
26
22
  const ck = window.document.getElementById('qmsckeditor');
27
23
  const isFullscreen = ck && ck.classList.contains(fullscreenClass);