@alitons/ckeditor5 0.0.23 → 0.0.24

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@alitons/ckeditor5",
3
3
  "author": "Aliton Silva",
4
4
  "description": "Ckeditor 5 Personalizado adicionados campos para atender as demandas da SEAD/AC",
5
- "version": "0.0.23",
5
+ "version": "0.0.24",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
7
7
  "private": false,
8
8
  "main": "./build/ckeditor.js",
package/sample/script.js CHANGED
@@ -14,23 +14,17 @@ watchdog.setCreator( ( element, config ) => {
14
14
  watchdog.create( document.querySelector( '.editor' ), {
15
15
  toolbar: {
16
16
  autoTextoOptions: {
17
- options: [
18
- {
19
- autotexto: 'teste 1',
20
- titulo: 'Primeiro teste'
21
- }
22
- ],
23
17
  ajax: {
24
- url: '/api/teste',
18
+ url: "https://compras.test/api/autotexto",
25
19
  method: 'GET',
26
20
  data: {
27
- usuario: 'usuario',
21
+ tipo: 'autotexto',
28
22
  },
29
23
  results: {
30
24
  autotexto: 'autotexto',
31
25
  titulo: 'titulo'
32
26
  }
33
- }
27
+ },
34
28
  },
35
29
  documentoModeloOptions: {
36
30
  categoria: {
@@ -189,6 +189,45 @@ export default class NumberedDivList extends Plugin {
189
189
  }, { priority: 'high' } );
190
190
  });
191
191
 
192
+ // ação para observar se um numList foi adicionado
193
+ editor.model.document.on('change:data', () => {
194
+ const model = editor.model;
195
+ const root = model.document.getRoot();
196
+ if(root) {
197
+ checkChildrenIsList(root, 0);
198
+ }
199
+ });
200
+
201
+ function checkChildrenIsList(contents: any, nivel: number) {
202
+ for ( const child of contents.getChildren() ) {
203
+ if ( child?.is('element', 'numList') ) {
204
+ const parent = child?.parent;
205
+ if(parent?.is('element', 'numList') && !parent?.parent.is('element', '$root')) {
206
+ let vazio = true;
207
+ for ( const subChild of parent.getChildren() ) {
208
+ if ( subChild?.is('element', 'numItem') ) {
209
+ vazio = false;
210
+ break;
211
+ }
212
+ }
213
+ if(vazio) {
214
+ editor.model.change( (writer: any) => {
215
+ const itens = [];
216
+ for ( const item of child.getChildren() ) {
217
+ itens.push(item);
218
+ }
219
+ for ( const item of itens ) {
220
+ writer.move( writer.createRangeOn( item ), writer.createPositionAt( parent, 'end' ) );
221
+ }
222
+ writer.remove( child );
223
+ });
224
+ }
225
+ }
226
+
227
+ checkChildrenIsList(child, nivel + 1);
228
+ }
229
+ }
230
+ }
192
231
 
193
232
  const viewDoc = editor.editing.view.document;
194
233