qms-angular 1.1.41 → 1.1.43

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. package/bundles/qms-angular.umd.js +1569 -441
  2. package/bundles/qms-angular.umd.js.map +1 -1
  3. package/esm2015/lib/common/enum/data-type.enum.js +2 -1
  4. package/esm2015/lib/common/enum/process-classification.enum.js +6 -0
  5. package/esm2015/lib/common/qms-icon.const.js +116 -111
  6. package/esm2015/lib/common/themes.const.js +2 -2
  7. package/esm2015/lib/components/app-icon/icon-registry.service.js +5 -2
  8. package/esm2015/lib/components/related/common/video.const.js +3 -1
  9. package/esm2015/lib/components/related/content/related-content.component.js +2 -2
  10. package/esm2015/lib/components/related/list-other-related/list-related.component.js +5 -2
  11. package/esm2015/lib/components/related/model/popup-data.model.js +3 -1
  12. package/esm2015/lib/components/related/model/related-data.model.js +1 -1
  13. package/esm2015/lib/components/related/popup/related-popup.component.js +48 -32
  14. package/esm2015/lib/components/related/related.module.js +3 -2
  15. package/esm2015/lib/components/related/risk/analysis/analysis.component.js +2 -2
  16. package/esm2015/lib/components/select-access-dialog/select-access-dialog.component.js +24 -4
  17. package/esm2015/lib/components/select-department-tree/select-department-tree.component.js +5 -4
  18. package/esm2015/lib/components/select-one/select-one.component.js +2 -2
  19. package/esm2015/lib/components/select-process-document/select-process-document.component.js +15 -11
  20. package/esm2015/lib/components/tree/model/tree-config.model.js +1 -1
  21. package/esm2015/lib/components/tree/tree.component.js +12 -4
  22. package/esm2015/lib/components/treeNew/model/tree-node.model.js +1 -1
  23. package/esm2015/lib/components/treeNew/model/tree.model.js +1 -1
  24. package/esm2015/lib/components/treeNew/tree.component.js +8 -4
  25. package/esm2015/lib/components/treeNew/tree.function.js +8 -4
  26. package/esm2015/lib/model/en.js +86 -2
  27. package/esm2015/lib/model/no.js +87 -3
  28. package/esm2015/lib/model/sv.js +437 -0
  29. package/esm2015/lib/qms-ckeditor-components/common/functions/common.function.js +15 -14
  30. package/esm2015/lib/qms-ckeditor-components/common/functions/resource.function.js +207 -0
  31. package/esm2015/lib/qms-ckeditor-components/common/models/qms-ckeditor-data.model.js +1 -1
  32. package/esm2015/lib/qms-ckeditor-components/common/models/qms-ckeditor-url.model.js +1 -1
  33. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.js +262 -29
  34. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-link/qms-ckeditor-link.component.js +102 -36
  35. package/esm2015/lib/qms-ckeditor-components/models/qms-ckeditor-imagemap.model.js +1 -1
  36. package/esm2015/lib/qms-ckeditor-components/models/qms-ckeditor-video.model.js +16 -0
  37. package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.component.js +39 -118
  38. package/esm2015/lib/qms-ckeditor-components/services/qms-ckeditor-bpmn.service.js +10 -3
  39. package/esm2015/lib/qms-ckeditor-components/services/qms-ckeditor-tree.service.js +7 -3
  40. package/esm2015/lib/services/translation-registry.service.js +7 -5
  41. package/fesm2015/qms-angular.js +1603 -503
  42. package/fesm2015/qms-angular.js.map +1 -1
  43. package/lib/common/enum/data-type.enum.d.ts +2 -1
  44. package/lib/common/enum/process-classification.enum.d.ts +4 -0
  45. package/lib/common/qms-icon.const.d.ts +1 -0
  46. package/lib/components/app-icon/icon-registry.service.d.ts +1 -0
  47. package/lib/components/related/common/video.const.d.ts +2 -0
  48. package/lib/components/related/content/related-content.component.d.ts +1 -1
  49. package/lib/components/related/list-other-related/list-related.component.d.ts +2 -2
  50. package/lib/components/related/model/popup-data.model.d.ts +3 -0
  51. package/lib/components/related/model/related-data.model.d.ts +1 -0
  52. package/lib/components/related/popup/related-popup.component.d.ts +7 -3
  53. package/lib/components/select-access-dialog/select-access-dialog.component.d.ts +3 -2
  54. package/lib/components/select-one/select-one.component.d.ts +1 -1
  55. package/lib/components/select-process-document/select-process-document.component.d.ts +5 -6
  56. package/lib/components/tree/model/tree-config.model.d.ts +1 -1
  57. package/lib/components/tree/tree.component.d.ts +1 -1
  58. package/lib/components/treeNew/model/tree-node.model.d.ts +1 -0
  59. package/lib/components/treeNew/model/tree.model.d.ts +1 -0
  60. package/lib/components/treeNew/tree.component.d.ts +5 -2
  61. package/lib/model/en.d.ts +84 -0
  62. package/lib/model/no.d.ts +84 -0
  63. package/lib/model/sv.d.ts +436 -0
  64. package/lib/qms-ckeditor-components/common/functions/common.function.d.ts +29 -10
  65. package/lib/qms-ckeditor-components/common/functions/resource.function.d.ts +194 -0
  66. package/lib/qms-ckeditor-components/common/models/qms-ckeditor-data.model.d.ts +3 -0
  67. package/lib/qms-ckeditor-components/common/models/qms-ckeditor-url.model.d.ts +2 -0
  68. package/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.d.ts +13 -2
  69. package/lib/qms-ckeditor-components/components/qms-ckeditor-link/qms-ckeditor-link.component.d.ts +1 -0
  70. package/lib/qms-ckeditor-components/models/qms-ckeditor-imagemap.model.d.ts +1 -0
  71. package/lib/qms-ckeditor-components/models/qms-ckeditor-video.model.d.ts +10 -0
  72. package/lib/qms-ckeditor-components/qms-ckeditor.component.d.ts +1 -2
  73. package/lib/qms-ckeditor-components/services/qms-ckeditor-tree.service.d.ts +2 -1
  74. package/lib/services/translation-registry.service.d.ts +1 -0
  75. package/package.json +1 -1
  76. package/qms-angular.metadata.json +1 -1
  77. package/src/assets/jointjs/scss/bpmn.scss +914 -906
  78. package/src/assets/qms-ckeditor-plugin/build/ckeditor.js +1 -1
  79. package/src/assets/qms-ckeditor-plugin/build/ckeditor.js.map +1 -1
  80. package/src/assets/qms-ckeditor-plugin/build/translations/no.js +1 -1
  81. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/findandreplaceui.js +223 -223
  82. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/lang/translations/no.po +21 -0
  83. package/src/assets/qms-ckeditor-plugin/src/plugins/fullscreen/qmsCKEditorFullscreenPlugin.js +52 -50
  84. package/src/assets/qms-ckeditor-plugin/src/plugins/heading/headingui.js +115 -115
  85. package/src/assets/qms-ckeditor-plugin/src/plugins/heading/utils.js +42 -42
  86. package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkcommand.js +1 -1
  87. package/src/assets/qms-ckeditor-plugin/src/plugins/media/mediaembedediting.js +281 -283
  88. package/src/assets/qms-ckeditor-plugin/src/plugins/media/theme/mediaembed.css +30 -30
  89. package/src/assets/qms-ckeditor-plugin/src/plugins/media/theme/mediaembedediting.css +57 -57
  90. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/snippet.css +3877 -3876
  91. package/src/assets/qms-ckeditor-plugin/src/plugins/video/theme/video.css +17 -17
  92. package/src/assets/qms-ckeditor-plugin/src/plugins/video/theme/videoresize.css +33 -32
  93. package/src/assets/qms-ckeditor-plugin/src/plugins/video/video/videoediting.js +81 -75
  94. package/src/assets/qms-ckeditor-plugin/src/plugins/video/videoresize/resizevideocommand.js +35 -35
  95. package/src/assets/qms-ckeditor-plugin/src/plugins/video/videoresize/videoresizeediting.js +104 -92
  96. package/src/assets/qms-ckeditor-plugin/src/plugins/video/videoupload/browsevideodialogcommand.js +69 -25
  97. package/src/assets/qms-ckeditor-plugin/src/plugins/video/videoupload/uploadvideocommand.js +21 -21
  98. package/src/lib/components/related/popup/related-popup.component.scss +374 -350
  99. package/esm2015/lib/components/related/common/data-type.enum.js +0 -14
  100. package/esm2015/lib/components/select-one/common/data-type.enum.js +0 -14
  101. package/lib/components/related/common/data-type.enum.d.ts +0 -12
  102. package/lib/components/select-one/common/data-type.enum.d.ts +0 -12
@@ -1,283 +1,281 @@
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 media-embed/mediaembedediting
8
- */
9
-
10
- import { Plugin } from 'ckeditor5/src/core';
11
-
12
- import { modelToViewUrlAttributeConverter } from './converters';
13
- import MediaEmbedCommand from './mediaembedcommand';
14
- import MediaRegistry from './mediaregistry';
15
- import { toMediaWidget, createMediaFigureElement } from './utils';
16
-
17
- import './theme/mediaembedediting.css';
18
-
19
- /**
20
- * The media embed editing feature.
21
- *
22
- * @extends module:core/plugin~Plugin
23
- */
24
- export default class MediaEmbedEditing extends Plugin {
25
- /**
26
- * @inheritDoc
27
- */
28
- static get pluginName() {
29
- return 'MediaEmbedEditing';
30
- }
31
-
32
- /**
33
- * @inheritDoc
34
- */
35
- constructor( editor ) {
36
- super( editor );
37
-
38
- editor.config.define( 'mediaEmbed', {
39
- elementName: 'oembed',
40
- providers: [
41
- {
42
- name: 'dailymotion',
43
- url: /^dailymotion\.com\/video\/(\w+)/,
44
- html: match => {
45
- const id = match[ 1 ];
46
-
47
- return (
48
- '<div style="position: relative; padding-bottom: 100%; height: 0; ">' +
49
- `<iframe src="https://www.dailymotion.com/embed/video/${ id }" ` +
50
- 'style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" ' +
51
- 'frameborder="0" width="480" height="270" allowfullscreen allow="autoplay">' +
52
- '</iframe>' +
53
- '</div>'
54
- );
55
- }
56
- },
57
-
58
- {
59
- name: 'spotify',
60
- url: [
61
- /^open\.spotify\.com\/(artist\/\w+)/,
62
- /^open\.spotify\.com\/(album\/\w+)/,
63
- /^open\.spotify\.com\/(track\/\w+)/
64
- ],
65
- html: match => {
66
- const id = match[ 1 ];
67
-
68
- return (
69
- '<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 126%;">' +
70
- `<iframe src="https://open.spotify.com/embed/${ id }" ` +
71
- 'style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" ' +
72
- 'frameborder="0" allowtransparency="true" allow="encrypted-media">' +
73
- '</iframe>' +
74
- '</div>'
75
- );
76
- }
77
- },
78
-
79
- {
80
- name: 'youtube',
81
- url: [
82
- /^(?:m\.)?youtube\.com\/watch\?v=([\w-]+)/,
83
- /^(?:m\.)?youtube\.com\/v\/([\w-]+)/,
84
- /^youtube\.com\/embed\/([\w-]+)/,
85
- /^youtu\.be\/([\w-]+)/
86
- ],
87
- html: match => {
88
- const id = match[ 1 ];
89
-
90
- return (
91
- '<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 56.2493%;">' +
92
- `<iframe src="https://www.youtube.com/embed/${ id }" ` +
93
- 'style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" ' +
94
- 'frameborder="0" allow="autoplay; encrypted-media" allowfullscreen>' +
95
- '</iframe>' +
96
- '</div>'
97
- );
98
- }
99
- },
100
-
101
- {
102
- name: 'vimeo',
103
- url: [
104
- /^vimeo\.com\/(\d+)/,
105
- /^vimeo\.com\/[^/]+\/[^/]+\/video\/(\d+)/,
106
- /^vimeo\.com\/album\/[^/]+\/video\/(\d+)/,
107
- /^vimeo\.com\/channels\/[^/]+\/(\d+)/,
108
- /^vimeo\.com\/groups\/[^/]+\/videos\/(\d+)/,
109
- /^vimeo\.com\/ondemand\/[^/]+\/(\d+)/,
110
- /^player\.vimeo\.com\/video\/(\d+)/
111
- ],
112
- html: match => {
113
- const id = match[ 1 ];
114
-
115
- return (
116
- '<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 56.2493%;">' +
117
- `<iframe src="https://player.vimeo.com/video/${ id }" ` +
118
- 'style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" ' +
119
- 'frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen>' +
120
- '</iframe>' +
121
- '</div>'
122
- );
123
- }
124
- },
125
-
126
- {
127
- name: 'instagram',
128
- url: /^instagram\.com\/p\/(\w+)/
129
- },
130
- {
131
- name: 'twitter',
132
- url: /^twitter\.com/
133
- },
134
- {
135
- name: 'googleMaps',
136
- url: /^google\.com\/maps/
137
- },
138
- {
139
- name: 'flickr',
140
- url: /^flickr\.com/
141
- },
142
- {
143
- name: 'facebook',
144
- url: /^facebook\.com/
145
- }
146
- ]
147
- } );
148
-
149
- /**
150
- * The media registry managing the media providers in the editor.
151
- *
152
- * @member {module:media-embed/mediaregistry~MediaRegistry} #registry
153
- */
154
- this.registry = new MediaRegistry( editor.locale, editor.config.get( 'mediaEmbed' ) );
155
- }
156
-
157
- /**
158
- * @inheritDoc
159
- */
160
- init() {
161
- const editor = this.editor;
162
- const schema = editor.model.schema;
163
- const t = editor.t;
164
- const conversion = editor.conversion;
165
- const renderMediaPreview = editor.config.get( 'mediaEmbed.previewsInData' );
166
- const elementName = editor.config.get( 'mediaEmbed.elementName' );
167
-
168
- const registry = this.registry;
169
-
170
- editor.commands.add( 'mediaEmbed', new MediaEmbedCommand( editor ) );
171
-
172
- // Configure the schema.
173
- schema.register( 'media', {
174
- isObject: true,
175
- isBlock: true,
176
- allowWhere: '$block',
177
- allowAttributes: [ 'url' ]
178
- } );
179
-
180
- // Model -> Data
181
- conversion.for( 'dataDowncast' ).elementToElement( {
182
- model: 'media',
183
- view: ( modelElement, { writer } ) => {
184
- const url = modelElement.getAttribute( 'url' );
185
-
186
- return createMediaFigureElement( writer, registry, url, {
187
- elementName,
188
- renderMediaPreview: url && renderMediaPreview
189
- } );
190
- }
191
- } );
192
-
193
- // Model -> Data (url -> data-oembed-url)
194
- conversion.for( 'dataDowncast' ).add(
195
- modelToViewUrlAttributeConverter( registry, {
196
- elementName,
197
- renderMediaPreview
198
- } ) );
199
-
200
- // Model -> View (element)
201
- conversion.for( 'editingDowncast' ).elementToElement( {
202
- model: 'media',
203
- view: ( modelElement, { writer } ) => {
204
- const url = modelElement.getAttribute( 'url' );
205
- const figure = createMediaFigureElement( writer, registry, url, {
206
- elementName,
207
- renderForEditingView: true
208
- } );
209
-
210
- return toMediaWidget( figure, writer, t( 'media widget' ) );
211
- }
212
- } );
213
-
214
- // Model -> View (url -> data-oembed-url)
215
- conversion.for( 'editingDowncast' ).add(
216
- modelToViewUrlAttributeConverter( registry, {
217
- elementName,
218
- renderForEditingView: true
219
- } ) );
220
-
221
- // View -> Model (data-oembed-url -> url)
222
- conversion.for( 'upcast' )
223
- // Upcast semantic media.
224
- .elementToElement( {
225
- view: element => [ 'oembed', elementName ].includes( element.name ) && element.getAttribute( 'url' ) ?
226
- { name: true } :
227
- null,
228
- model: ( viewMedia, { writer } ) => {
229
- const url = viewMedia.getAttribute( 'url' );
230
-
231
- if ( registry.hasMedia( url ) ) {
232
- return writer.createElement( 'media', { url } );
233
- }
234
- }
235
- } )
236
- // Upcast non-semantic media.
237
- .elementToElement( {
238
- view: {
239
- name: 'div',
240
- attributes: {
241
- 'data-oembed-url': true
242
- }
243
- },
244
- model: ( viewMedia, { writer } ) => {
245
- const url = viewMedia.getAttribute( 'data-oembed-url' );
246
-
247
- if ( registry.hasMedia( url ) ) {
248
- return writer.createElement( 'media', { url } );
249
- }
250
- }
251
- } )
252
- // Upcast for iframe from ck4-editor.
253
- .elementToElement( {
254
- view: {
255
- name: 'iframe',
256
- attributes: {
257
- 'data-src': true
258
- }
259
- },
260
- model: ( viewMedia, { writer } ) => {
261
- const url = viewMedia.getAttribute( 'data-src' );
262
- if ( registry.hasMedia( url ) ) {
263
- return writer.createElement( 'media', { url } );
264
- }
265
- }
266
- } )
267
- // for video upload from ck4
268
- .elementToElement( {
269
- view: {
270
- name: 'video',
271
- attributes: {
272
- 'poster': true
273
- }
274
- },
275
- model: ( viewMedia, { writer } ) => {
276
- const url = viewMedia.getAttribute( 'poster' );
277
- if ( registry.hasMedia( url ) ) {
278
- return writer.createElement( 'media', { url } );
279
- }
280
- }
281
- } );
282
- }
283
- }
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 media-embed/mediaembedediting
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+
12
+ import { modelToViewUrlAttributeConverter } from './converters';
13
+ import MediaEmbedCommand from './mediaembedcommand';
14
+ import MediaRegistry from './mediaregistry';
15
+ import { toMediaWidget, createMediaFigureElement } from './utils';
16
+
17
+ import './theme/mediaembedediting.css';
18
+
19
+ /**
20
+ * The media embed editing feature.
21
+ *
22
+ * @extends module:core/plugin~Plugin
23
+ */
24
+ export default class MediaEmbedEditing extends Plugin {
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ static get pluginName() {
29
+ return 'MediaEmbedEditing';
30
+ }
31
+
32
+ /**
33
+ * @inheritDoc
34
+ */
35
+ constructor( editor ) {
36
+ super( editor );
37
+
38
+ editor.config.define( 'mediaEmbed', {
39
+ elementName: 'oembed',
40
+ providers: [
41
+ {
42
+ name: 'dailymotion',
43
+ url: /^dailymotion\.com\/video\/(\w+)/,
44
+ html: match => {
45
+ const id = match[ 1 ];
46
+
47
+ return (
48
+ '<div style="position: relative; padding-bottom: 100%; height: 0; ">' +
49
+ `<iframe src="https://www.dailymotion.com/embed/video/${ id }" ` +
50
+ 'style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" ' +
51
+ 'frameborder="0" width="480" height="270" allowfullscreen allow="autoplay">' +
52
+ '</iframe>' +
53
+ '</div>'
54
+ );
55
+ }
56
+ },
57
+
58
+ {
59
+ name: 'spotify',
60
+ url: [
61
+ /^open\.spotify\.com\/(artist\/\w+)/,
62
+ /^open\.spotify\.com\/(album\/\w+)/,
63
+ /^open\.spotify\.com\/(track\/\w+)/
64
+ ],
65
+ html: match => {
66
+ const id = match[ 1 ];
67
+
68
+ return (
69
+ '<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 126%;">' +
70
+ `<iframe src="https://open.spotify.com/embed/${ id }" ` +
71
+ 'style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" ' +
72
+ 'frameborder="0" allowtransparency="true" allow="encrypted-media">' +
73
+ '</iframe>' +
74
+ '</div>'
75
+ );
76
+ }
77
+ },
78
+
79
+ {
80
+ name: 'youtube',
81
+ url: [
82
+ /^(?:m\.)?youtube\.com\/watch\?v=([\w-]+)/,
83
+ /^(?:m\.)?youtube\.com\/v\/([\w-]+)/,
84
+ /^youtube\.com\/embed\/([\w-]+)/,
85
+ /^youtu\.be\/([\w-]+)/
86
+ ],
87
+ html: match => {
88
+ const id = match[ 1 ];
89
+
90
+ return (
91
+ '<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 56.2493%;">' +
92
+ `<iframe src="https://www.youtube.com/embed/${ id }" ` +
93
+ 'style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" ' +
94
+ 'frameborder="0" allow="autoplay; encrypted-media" allowfullscreen>' +
95
+ '</iframe>' +
96
+ '</div>'
97
+ );
98
+ }
99
+ },
100
+
101
+ {
102
+ name: 'vimeo',
103
+ url: [
104
+ /^vimeo\.com\/(\d+)/,
105
+ /^vimeo\.com\/[^/]+\/[^/]+\/video\/(\d+)/,
106
+ /^vimeo\.com\/album\/[^/]+\/video\/(\d+)/,
107
+ /^vimeo\.com\/channels\/[^/]+\/(\d+)/,
108
+ /^vimeo\.com\/groups\/[^/]+\/videos\/(\d+)/,
109
+ /^vimeo\.com\/ondemand\/[^/]+\/(\d+)/,
110
+ /^player\.vimeo\.com\/video\/(\d+)/
111
+ ],
112
+ html: match => {
113
+ const id = match[ 1 ];
114
+
115
+ return (
116
+ '<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 56.2493%;">' +
117
+ `<iframe src="https://player.vimeo.com/video/${ id }" ` +
118
+ 'style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" ' +
119
+ 'frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen>' +
120
+ '</iframe>' +
121
+ '</div>'
122
+ );
123
+ }
124
+ },
125
+
126
+ {
127
+ name: 'instagram',
128
+ url: /^instagram\.com\/p\/(\w+)/
129
+ },
130
+ {
131
+ name: 'twitter',
132
+ url: /^twitter\.com/
133
+ },
134
+ {
135
+ name: 'googleMaps',
136
+ url: /^google\.com\/maps/
137
+ },
138
+ {
139
+ name: 'flickr',
140
+ url: /^flickr\.com/
141
+ },
142
+ {
143
+ name: 'facebook',
144
+ url: /^facebook\.com/
145
+ }
146
+ ]
147
+ } );
148
+
149
+ /**
150
+ * The media registry managing the media providers in the editor.
151
+ *
152
+ * @member {module:media-embed/mediaregistry~MediaRegistry} #registry
153
+ */
154
+ this.registry = new MediaRegistry( editor.locale, editor.config.get( 'mediaEmbed' ) );
155
+ }
156
+
157
+ /**
158
+ * @inheritDoc
159
+ */
160
+ init() {
161
+ const editor = this.editor;
162
+ const schema = editor.model.schema;
163
+ const t = editor.t;
164
+ const conversion = editor.conversion;
165
+ const renderMediaPreview = editor.config.get( 'mediaEmbed.previewsInData' );
166
+ const elementName = editor.config.get( 'mediaEmbed.elementName' );
167
+
168
+ const registry = this.registry;
169
+
170
+ editor.commands.add( 'mediaEmbed', new MediaEmbedCommand( editor ) );
171
+ // Configure the schema.
172
+ schema.register( 'media', {
173
+ isObject: true,
174
+ isBlock: true,
175
+ allowWhere: '$block',
176
+ allowAttributes: [ 'url' ]
177
+ } );
178
+
179
+ // Model -> Data
180
+ conversion.for( 'dataDowncast' ).elementToElement( {
181
+ model: 'media',
182
+ view: ( modelElement, { writer } ) => {
183
+ const url = modelElement.getAttribute( 'url' );
184
+ return createMediaFigureElement( writer, registry, url, {
185
+ elementName,
186
+ renderMediaPreview: url && renderMediaPreview
187
+ } );
188
+ }
189
+ } );
190
+
191
+ // Model -> Data (url -> data-oembed-url)
192
+ conversion.for( 'dataDowncast' ).add(
193
+ modelToViewUrlAttributeConverter( registry, {
194
+ elementName,
195
+ renderMediaPreview
196
+ } ) );
197
+
198
+ // Model -> View (element)
199
+ conversion.for( 'editingDowncast' ).elementToElement( {
200
+ model: 'media',
201
+ view: ( modelElement, { writer } ) => {
202
+ const url = modelElement.getAttribute( 'url' );
203
+ const figure = createMediaFigureElement( writer, registry, url, {
204
+ elementName,
205
+ renderForEditingView: true
206
+ } );
207
+
208
+ return toMediaWidget( figure, writer, t( 'media widget' ) );
209
+ }
210
+ } );
211
+
212
+ // Model -> View (url -> data-oembed-url)
213
+ conversion.for( 'editingDowncast' ).add(
214
+ modelToViewUrlAttributeConverter( registry, {
215
+ elementName,
216
+ renderForEditingView: true
217
+ } ) );
218
+
219
+ // View -> Model (data-oembed-url -> url)
220
+ conversion.for( 'upcast' )
221
+ // Upcast semantic media.
222
+ .elementToElement( {
223
+ view: element => [ 'oembed', elementName ].includes( element.name ) && element.getAttribute( 'url' ) ?
224
+ { name: true } :
225
+ null,
226
+ model: ( viewMedia, { writer } ) => {
227
+ const url = viewMedia.getAttribute( 'url' );
228
+
229
+ if ( registry.hasMedia( url ) ) {
230
+ return writer.createElement( 'media', { url } );
231
+ }
232
+ }
233
+ } )
234
+ // Upcast non-semantic media.
235
+ .elementToElement( {
236
+ view: {
237
+ name: 'div',
238
+ attributes: {
239
+ 'data-oembed-url': true
240
+ }
241
+ },
242
+ model: ( viewMedia, { writer } ) => {
243
+ const url = viewMedia.getAttribute( 'data-oembed-url' );
244
+
245
+ if ( registry.hasMedia( url ) ) {
246
+ return writer.createElement( 'media', { url } );
247
+ }
248
+ }
249
+ } )
250
+ // Upcast for iframe from ck4-editor.
251
+ .elementToElement( {
252
+ view: {
253
+ name: 'iframe',
254
+ attributes: {
255
+ 'data-src': true
256
+ }
257
+ },
258
+ model: ( viewMedia, { writer } ) => {
259
+ const url = viewMedia.getAttribute( 'data-src' );
260
+ if ( registry.hasMedia( url ) ) {
261
+ return writer.createElement( 'media', { url } );
262
+ }
263
+ }
264
+ } )
265
+ // for video upload from ck4
266
+ // .elementToElement( {
267
+ // view: {
268
+ // name: 'video',
269
+ // attributes: {
270
+ // 'poster': true
271
+ // }
272
+ // },
273
+ // model: ( viewMedia, { writer } ) => {
274
+ // const url = viewMedia.getAttribute( 'poster' );
275
+ // if ( registry.hasMedia( url ) ) {
276
+ // return writer.createElement( 'media', { url } );
277
+ // }
278
+ // }
279
+ // } );
280
+ }
281
+ }
@@ -1,30 +1,30 @@
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
- /* .ck-content .media {
7
- clear: both;
8
- margin: 1em 0;
9
- display: table;
10
- min-width: 15em;
11
- text-align: center;
12
- } */
13
-
14
- .ck-content .media {
15
- display: table;
16
- clear: both;
17
- text-align: center;
18
- margin: 1em auto;
19
-
20
- & media {
21
- display: block;
22
- margin: 0 auto;
23
- max-width: 100%;
24
- min-width: 50px;
25
- }
26
- }
27
-
28
- .ck.ck-editor__editable .media > figcaption.ck-placeholder::before {
29
- position: static;
30
- }
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
+ /* .ck-content .media {
7
+ clear: both;
8
+ margin: 1em 0;
9
+ display: table;
10
+ min-width: 15em;
11
+ text-align: center;
12
+ } */
13
+
14
+ .ck-content .media {
15
+ display: table;
16
+ clear: both;
17
+ text-align: center;
18
+ margin: 1em auto;
19
+ width: 640px;
20
+ & media {
21
+ display: block;
22
+ margin: 0 auto;
23
+ max-width: 100%;
24
+ min-width: 50px;
25
+ }
26
+ }
27
+
28
+ .ck.ck-editor__editable .media > figcaption.ck-placeholder::before {
29
+ position: static;
30
+ }