@alitons/ckeditor5 0.0.2
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/LICENSE.md +49 -0
- package/README.md +262 -0
- package/build/ckeditor.d.ts +70 -0
- package/build/ckeditor.js +17 -0
- package/build/ckeditor.js.map +1 -0
- package/build/plugins/autotexto.d.ts +7 -0
- package/build/plugins/modelo.d.ts +15 -0
- package/build/plugins/salvarcomo.d.ts +5 -0
- package/build/plugins/sei.d.ts +6 -0
- package/build/translations/af.js +1 -0
- package/build/translations/ar.js +1 -0
- package/build/translations/ast.js +1 -0
- package/build/translations/az.js +1 -0
- package/build/translations/bg.js +1 -0
- package/build/translations/bn.js +1 -0
- package/build/translations/bs.js +1 -0
- package/build/translations/ca.js +1 -0
- package/build/translations/cs.js +1 -0
- package/build/translations/da.js +1 -0
- package/build/translations/de-ch.js +1 -0
- package/build/translations/de.js +1 -0
- package/build/translations/el.js +1 -0
- package/build/translations/en-au.js +1 -0
- package/build/translations/en-gb.js +1 -0
- package/build/translations/en.js +1 -0
- package/build/translations/eo.js +1 -0
- package/build/translations/es-co.js +1 -0
- package/build/translations/es.js +1 -0
- package/build/translations/et.js +1 -0
- package/build/translations/eu.js +1 -0
- package/build/translations/fa.js +1 -0
- package/build/translations/fi.js +1 -0
- package/build/translations/fr.js +1 -0
- package/build/translations/gl.js +1 -0
- package/build/translations/gu.js +1 -0
- package/build/translations/he.js +1 -0
- package/build/translations/hi.js +1 -0
- package/build/translations/hr.js +1 -0
- package/build/translations/hu.js +1 -0
- package/build/translations/id.js +1 -0
- package/build/translations/it.js +1 -0
- package/build/translations/ja.js +1 -0
- package/build/translations/jv.js +1 -0
- package/build/translations/kk.js +1 -0
- package/build/translations/km.js +1 -0
- package/build/translations/kn.js +1 -0
- package/build/translations/ko.js +1 -0
- package/build/translations/ku.js +1 -0
- package/build/translations/lt.js +1 -0
- package/build/translations/lv.js +1 -0
- package/build/translations/ms.js +1 -0
- package/build/translations/nb.js +1 -0
- package/build/translations/ne.js +1 -0
- package/build/translations/nl.js +1 -0
- package/build/translations/no.js +1 -0
- package/build/translations/oc.js +1 -0
- package/build/translations/pl.js +1 -0
- package/build/translations/pt.js +1 -0
- package/build/translations/ro.js +1 -0
- package/build/translations/ru.js +1 -0
- package/build/translations/si.js +1 -0
- package/build/translations/sk.js +1 -0
- package/build/translations/sl.js +1 -0
- package/build/translations/sq.js +1 -0
- package/build/translations/sr-latn.js +1 -0
- package/build/translations/sr.js +1 -0
- package/build/translations/sv.js +1 -0
- package/build/translations/th.js +1 -0
- package/build/translations/tk.js +1 -0
- package/build/translations/tr.js +1 -0
- package/build/translations/tt.js +1 -0
- package/build/translations/ug.js +1 -0
- package/build/translations/uk.js +1 -0
- package/build/translations/ur.js +1 -0
- package/build/translations/uz.js +1 -0
- package/build/translations/vi.js +1 -0
- package/build/translations/zh-cn.js +1 -0
- package/build/translations/zh.js +1 -0
- package/package.json +76 -0
- package/sample/index.html +34 -0
- package/sample/script.js +120 -0
- package/sample/styles.css +510 -0
- package/src/ckeditor.js +210 -0
- package/src/ckeditor.js.map +1 -0
- package/src/ckeditor.ts +255 -0
- package/src/plugins/autotexto.ts +159 -0
- package/src/plugins/modelo.ts +251 -0
- package/src/plugins/salvarcomo.ts +163 -0
- package/src/plugins/sei.ts +184 -0
- package/tsconfig.json +20 -0
- package/tsconfig.types.json +9 -0
- package/webpack.config.js +96 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
3
|
+
import { createDropdown } from '@ckeditor/ckeditor5-ui';
|
|
4
|
+
import { HtmlDataProcessor } from '@ckeditor/ckeditor5-engine';
|
|
5
|
+
import Swal from 'sweetalert2'
|
|
6
|
+
import axios from 'axios'
|
|
7
|
+
import $ from "jquery";
|
|
8
|
+
|
|
9
|
+
export default class SalvarComo extends Plugin {
|
|
10
|
+
options = [] as any
|
|
11
|
+
init() {
|
|
12
|
+
const editor = this.editor;
|
|
13
|
+
//GERAR UM NÚMERO ÚNICO ALEATÓRIO
|
|
14
|
+
const uid = Math.random() * (5 - 5) + 5;
|
|
15
|
+
|
|
16
|
+
editor.ui.componentFactory.add( 'salvarcomo', () => {
|
|
17
|
+
|
|
18
|
+
const dropdown = createDropdown( editor.locale );
|
|
19
|
+
|
|
20
|
+
// Configure dropdown's button properties:
|
|
21
|
+
dropdown.buttonView.set( {
|
|
22
|
+
label: 'Salvar como',
|
|
23
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M48 96V416c0 8.8 7.2 16 16 16H384c8.8 0 16-7.2 16-16V170.5c0-4.2-1.7-8.3-4.7-11.3l33.9-33.9c12 12 18.7 28.3 18.7 45.3V416c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V96C0 60.7 28.7 32 64 32H309.5c17 0 33.3 6.7 45.3 18.7l74.5 74.5-33.9 33.9L320.8 84.7c-.3-.3-.5-.5-.8-.8V184c0 13.3-10.7 24-24 24H104c-13.3 0-24-10.7-24-24V80H64c-8.8 0-16 7.2-16 16zm80-16v80H272V80H128zm32 240a64 64 0 1 1 128 0 64 64 0 1 1 -128 0z"/></svg>`,
|
|
24
|
+
withText: true,
|
|
25
|
+
tooltip: false
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
dropdown.render();
|
|
29
|
+
|
|
30
|
+
//VERIFICA SE O EDITOR ESTÁ DESATIVADO
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
if(editor.isReadOnly) dropdown.isEnabled = false
|
|
33
|
+
}, 500)
|
|
34
|
+
|
|
35
|
+
// DESABILITA O BOTÃO QUANDO O EDITOR ESTIVER DESABILITADO OU NÃO ESTIVER ATIVO
|
|
36
|
+
editor.model.document.on('change:data', () => {
|
|
37
|
+
if(editor.isReadOnly) dropdown.isEnabled = false
|
|
38
|
+
else dropdown.isEnabled = true
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const toolbar = editor.config.get('toolbar') as any;
|
|
42
|
+
|
|
43
|
+
if(!toolbar!.salvarComoOptions || toolbar!.salvarComoOptions === undefined || [null, undefined, ''].includes(toolbar!.salvarComoOptions?.url) || [null, undefined, ''].includes(toolbar!.salvarComoOptions?.options)) {
|
|
44
|
+
dropdown.isEnabled = false
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const input = document.createElement( 'div' );
|
|
48
|
+
input.innerHTML = `<div class="ck ck-reset ck-dropdown__panel ck-dropdown__panel_se ck-dropdown__panel-visible" tabindex="-1">
|
|
49
|
+
<form class="ck ck-find-and-replace-form" tabindex="-1">
|
|
50
|
+
<div class="ck ck-form__header">
|
|
51
|
+
<h2 class="ck ck-form__header__label">Salvar como</h2>
|
|
52
|
+
</div>
|
|
53
|
+
<fieldset class="ck ck-find-and-replace-form__find" style="padding-bottom: 0px;">
|
|
54
|
+
<div class="ck ck-labeled-field-view ck-labeled-field-view_empty" style="width:100%">
|
|
55
|
+
<div class="ck ck-labeled-field-view__input-wrapper">
|
|
56
|
+
<select class="ck ck-input ck-input-text_empty ck-input-text" id="input-salvarcomo-tipo-${uid}">
|
|
57
|
+
${
|
|
58
|
+
toolbar!.salvarComoOptions?.options?.map((option: any) => {
|
|
59
|
+
return `<option value="${option.value}">${option.label}</option>`
|
|
60
|
+
}).join('')
|
|
61
|
+
}
|
|
62
|
+
</select>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
<div class="ck ck-labeled-field-view ck-labeled-field-view_empty" style="width:100%">
|
|
66
|
+
<div class="ck ck-labeled-field-view__input-wrapper">
|
|
67
|
+
<input class="ck ck-input ck-input-text_empty ck-input-text" id="input-salvarcomo-nome-${uid}" type="text" placeholder="Digite o nome do documento">
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
<button class="ck ck-button ck-button-find ck-button-action ck-off ck-button_with-text" type="button" tabindex="-1" data-cke-tooltip-position="s" id="button-salvarcomo-${uid}">
|
|
71
|
+
<span class="ck ck-button__label">Salvar</span>
|
|
72
|
+
</button>
|
|
73
|
+
</fieldset>
|
|
74
|
+
<fieldset class="ck ck-find-and-replace-form__find" style="padding-top: 0px;">
|
|
75
|
+
<div class="ck ck-labeled-field-view ck-labeled-field-view_empty" style="width:100%">
|
|
76
|
+
<div class="ck ck-labeled-field-view__status ck-labeled-field-view__status_error" id="error-salvarcomo-${uid}" role="alert"></div>
|
|
77
|
+
</div>
|
|
78
|
+
</fieldset>
|
|
79
|
+
</form>
|
|
80
|
+
</div>`;
|
|
81
|
+
dropdown.panelView.element.appendChild( input );
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
$('body').on('change', `input, select`, function() {
|
|
85
|
+
$(`#error-salvarcomo-${uid}`).html('')
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
$('body').on('click', `#button-salvarcomo-${uid}`, async function() {
|
|
89
|
+
if($(this).hasClass('ck-disabled')) return
|
|
90
|
+
|
|
91
|
+
$(this).addClass('ck-disabled')
|
|
92
|
+
|
|
93
|
+
let parametros = {
|
|
94
|
+
tipo: $(`#input-salvarcomo-tipo-${uid}`).val(),
|
|
95
|
+
titulo: $(`#input-salvarcomo-nome-${uid}`).val(),
|
|
96
|
+
conteudo: editor.getData()
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if(toolbar!.salvarComoOptions?.parametros) {
|
|
100
|
+
for(let p in toolbar!.salvarComoOptions?.parametros) {
|
|
101
|
+
parametros[p] = toolbar!.salvarComoOptions?.parametros[p]
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//FAZ UMA REQUISIÇÃO AJAX PARA SALVAR O DOCUMENTO
|
|
106
|
+
const result = await axios({
|
|
107
|
+
method: toolbar!.salvarComoOptions?.method ?? 'post',
|
|
108
|
+
url: toolbar!.salvarComoOptions?.url,
|
|
109
|
+
timeout: 5000,
|
|
110
|
+
responseType: 'json',
|
|
111
|
+
params: parametros
|
|
112
|
+
}).then((response) => {
|
|
113
|
+
return response
|
|
114
|
+
}).catch((error) => {
|
|
115
|
+
return error.response
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
$(this).removeClass('ck-disabled')
|
|
119
|
+
|
|
120
|
+
// DEFINE AS MENSAGENS DE ERRO
|
|
121
|
+
let msgRetorno = {
|
|
122
|
+
'200': 'Documento salvo com sucesso',
|
|
123
|
+
'400': 'Requisição inválida',
|
|
124
|
+
'401': 'Você não tem permissão para acessar este recurso',
|
|
125
|
+
'403': 'Você não tem permissão para acessar este recurso',
|
|
126
|
+
'404': 'Não foi possível salvar o documento',
|
|
127
|
+
'500': 'Erro interno do servidor',
|
|
128
|
+
'502': 'Gateway inválido',
|
|
129
|
+
'503': 'Serviço indisponível',
|
|
130
|
+
'504': 'Gateway Time-out'
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
//ADICIONA A CLASSE DE ERRO NO CAMPO DE BUSCA
|
|
134
|
+
if(toolbar!.salvarComoOptions?.mensagens) {
|
|
135
|
+
for(let e in toolbar!.salvarComoOptions?.mensagens) {
|
|
136
|
+
msgRetorno[e] = toolbar!.salvarComoOptions?.erros[e]
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//CASO NÃO ENCONTRE NENHUM RESULTADO
|
|
141
|
+
if(result.status != 201) {
|
|
142
|
+
$(`#input-salvarcomo-${uid}`).addClass('ck-error')
|
|
143
|
+
$(`#error-salvarcomo-${uid}`).html(result?.data?.message ?? msgRetorno[result.status] ?? msgRetorno['404'])
|
|
144
|
+
return
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
$(`#input-salvarcomo-tipo-${uid}`).val($(`#input-salvarcomo-tipo-${uid}`).find('option').eq(0).val() ?? ''),
|
|
148
|
+
$(`#input-salvarcomo-nome-${uid}`).val($(`#input-salvarcomo-nome-${uid} options`).eq(0).val()),
|
|
149
|
+
|
|
150
|
+
Swal.fire({
|
|
151
|
+
title: 'Sucesso',
|
|
152
|
+
text: msgRetorno['200'],
|
|
153
|
+
icon: 'success',
|
|
154
|
+
showCancelButton: false,
|
|
155
|
+
showConfirmButton: false,
|
|
156
|
+
timer: 1500
|
|
157
|
+
})
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
return dropdown;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
3
|
+
import { createDropdown } from '@ckeditor/ckeditor5-ui';
|
|
4
|
+
import { HtmlDataProcessor } from '@ckeditor/ckeditor5-engine';
|
|
5
|
+
import axios from 'axios'
|
|
6
|
+
import $ from "jquery";
|
|
7
|
+
|
|
8
|
+
class ImportarSei extends Plugin {
|
|
9
|
+
options = [] as any
|
|
10
|
+
init() {
|
|
11
|
+
const editor = this.editor;
|
|
12
|
+
//GERAR UM NÚMERO ÚNICO ALEATÓRIO
|
|
13
|
+
const uid = Math.random().toString(36).substring(7);
|
|
14
|
+
|
|
15
|
+
editor.ui.componentFactory.add( 'importarsei', () => {
|
|
16
|
+
|
|
17
|
+
const dropdown = createDropdown( editor.locale );
|
|
18
|
+
|
|
19
|
+
// Configure dropdown's button properties:
|
|
20
|
+
dropdown.buttonView.set( {
|
|
21
|
+
label: 'Importar do SEI',
|
|
22
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="400px" height="400px" version="1.1" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
|
|
23
|
+
viewBox="0 0 400 400"
|
|
24
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
25
|
+
xmlns:xodm="http://www.corel.com/coreldraw/odm/2003">
|
|
26
|
+
<defs>
|
|
27
|
+
<style type="text/css">
|
|
28
|
+
<![CDATA[
|
|
29
|
+
.fil0 {fill:#0492C6}
|
|
30
|
+
.fil1 {fill:#9FB947}
|
|
31
|
+
]]>
|
|
32
|
+
</style>
|
|
33
|
+
</defs>
|
|
34
|
+
<g id="Layer_x0020_1">
|
|
35
|
+
<metadata id="CorelCorpID_0Corel-Layer"/>
|
|
36
|
+
<g id="_1420878160">
|
|
37
|
+
<g>
|
|
38
|
+
<path class="fil0" d="M229.58 211.03l-52.57 0.22c-6.46,-0.36 -4.14,1.11 -4.86,-3.58 -0.78,-5.14 7.25,-34.4 28.2,-34.4 10.41,0 17.6,1.46 24.65,13.1 2.9,4.8 7.24,18.7 4.58,24.66zm-101.09 19.48c0,76.19 59.14,99.77 124.69,80.84 12.05,-3.48 9.66,-2.91 9.8,-5.92 0.38,-7.98 -4.7,-20.36 -5.38,-28.63 -14.71,1.22 -51.7,15.7 -72.8,-3.94 -9.4,-8.74 -12.46,-16.12 -12.46,-28.95l95 0c4.24,0 3.52,-2.91 4.12,-6.84 7.83,-50.79 -23.83,-109.89 -84.49,-94.3 -2.66,0.68 -4.99,1.5 -7.25,2.53l-4.27 2.05c-19.93,8.97 -33.36,26.24 -40.71,46.78 -2.99,8.38 -6.25,25.44 -6.25,36.38z"/>
|
|
39
|
+
<path class="fil0" d="M87.08 270.71c0,20.22 -30.65,17.96 -45.45,12.56 -6.17,-2.26 -10.21,-4.97 -16.67,-6.47 -2.76,11.85 -7.3,21.44 -7.3,32.88 15.86,7.61 52.97,13.4 73.81,8.05 44.91,-11.55 51.45,-73.47 11.86,-94.94 -18.66,-10.12 -40.61,-15.53 -40.61,-31.25 0,-17.06 24.54,-16.33 38.46,-11.67 5.23,1.75 7.78,4.22 13.91,4.36 0.66,-7.83 7.31,-22.86 7.31,-31.67 -6.31,-1.47 -6.37,-2.81 -15.58,-4.9 -25.7,-5.83 -52.16,-5.92 -71.2,13.12 -10.26,10.26 -18.19,27.67 -13.87,47.37 8.64,39.38 65.33,36.8 65.33,62.56z"/>
|
|
40
|
+
<polygon class="fil1" points="336.76,250 381.83,250 381.83,80.7 336.76,80.7 "/>
|
|
41
|
+
<path class="fil0" d="M280.74 251.22l0 59.68c0,2.81 0.84,3.65 3.65,3.65l41.41 0 0 -169.29 -43.85 0c0,36.65 -1.21,69.27 -1.21,105.96z"/>
|
|
42
|
+
<path class="fil0" d="M333.11 287.76c0,34.66 45.47,34.56 48.47,3.37 1.2,-12.6 -9.08,-26.51 -25.33,-26.51 -12.1,0 -23.14,10.83 -23.14,23.14z"/>
|
|
43
|
+
<path class="fil1" d="M279.52 103.85c0,38.42 47.5,31.28 47.5,4.87 0,-40.3 -47.5,-32.18 -47.5,-4.87z"/>
|
|
44
|
+
</g>
|
|
45
|
+
</g>
|
|
46
|
+
</g>
|
|
47
|
+
</svg>`,
|
|
48
|
+
withText: false,
|
|
49
|
+
tooltip: true
|
|
50
|
+
} );
|
|
51
|
+
|
|
52
|
+
dropdown.render();
|
|
53
|
+
|
|
54
|
+
//VERIFICA SE O EDITOR ESTÁ DESATIVADO
|
|
55
|
+
setTimeout(() => {
|
|
56
|
+
if(editor.isReadOnly) dropdown.isEnabled = false
|
|
57
|
+
}, 500)
|
|
58
|
+
|
|
59
|
+
// DESABILITA O BOTÃO QUANDO O EDITOR ESTIVER DESABILITADO OU NÃO ESTIVER ATIVO
|
|
60
|
+
editor.model.document.on('change:data', () => {
|
|
61
|
+
if(editor.isReadOnly) dropdown.isEnabled = false
|
|
62
|
+
else dropdown.isEnabled = true
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const toolbar = editor.config.get('toolbar') as any;
|
|
66
|
+
|
|
67
|
+
if(!toolbar!.seiOptions || toolbar!.seiOptions === undefined || [null, undefined, ''].includes(toolbar!.seiOptions?.url)) {
|
|
68
|
+
dropdown.isEnabled = false
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// CRIAR O ELEMENTO IGUAL AO ELEMENTO DE BUSCA
|
|
72
|
+
const input = document.createElement( 'div' );
|
|
73
|
+
input.innerHTML = `<div class="ck ck-reset ck-dropdown__panel ck-dropdown__panel_se ck-dropdown__panel-visible" tabindex="-1" style="left: initial;right: 0;">
|
|
74
|
+
<form class="ck ck-find-and-replace-form" tabindex="-1">
|
|
75
|
+
<div class="ck ck-form__header">
|
|
76
|
+
<h2 class="ck ck-form__header__label">Importar documento do SEI</h2>
|
|
77
|
+
</div>
|
|
78
|
+
<fieldset class="ck ck-find-and-replace-form__find">
|
|
79
|
+
<div class="ck ck-labeled-field-view ck-labeled-field-view_empty">
|
|
80
|
+
<div class="ck ck-labeled-field-view__input-wrapper">
|
|
81
|
+
<input class="ck ck-input ck-input-text_empty ck-input-text" id="search-input-sei-${uid}" type="text" placeholder="Digite o número do documento SEI">
|
|
82
|
+
</div>
|
|
83
|
+
<div class="ck ck-labeled-field-view__status ck-labeled-field-view__status_error" id="search-error-sei-${uid}" role="alert"></div>
|
|
84
|
+
</div>
|
|
85
|
+
<button class="ck ck-button ck-button-find ck-button-action ck-off ck-button_with-text" type="button" tabindex="-1" data-cke-tooltip-position="s" id="search-button-sei-${uid}">
|
|
86
|
+
<span class="ck ck-button__label">Pesquisar</span>
|
|
87
|
+
</button>
|
|
88
|
+
</fieldset>
|
|
89
|
+
<fieldset class="ck ck-find-and-replace-form__replace" id="search-actions-sei-${uid}" style="display: none">
|
|
90
|
+
<div class="ck ck-labeled-field-view ck-disabled ck-labeled-field-view_empty" style="background: #e9ecef; border: 1px solid #ced4da; padding: 5px; height: 200px; overflow: auto; text-align: initial;">
|
|
91
|
+
<div class="ck" id="search-result-sei-${uid}"></div>
|
|
92
|
+
</div>
|
|
93
|
+
<button class="ck ck-button ck-button-save ck-off ck-button_with-text" type="button" tabindex="-1" id="search-add-sei-${uid}">
|
|
94
|
+
<svg class="ck ck-icon ck-reset_all-excluded ck-icon_inherit-color ck-button__icon" viewBox="0 0 20 20"><path d="M6.972 16.615a.997.997 0 0 1-.744-.292l-4.596-4.596a1 1 0 1 1 1.414-1.414l3.926 3.926 9.937-9.937a1 1 0 0 1 1.414 1.415L7.717 16.323a.997.997 0 0 1-.745.292z"></path></svg>
|
|
95
|
+
<span class="ck ck-button__label">Importar</span>
|
|
96
|
+
</button>
|
|
97
|
+
</fieldset>
|
|
98
|
+
</form>
|
|
99
|
+
</div>`;
|
|
100
|
+
dropdown.panelView.element.appendChild( input );
|
|
101
|
+
|
|
102
|
+
$('body').on('click', `#search-button-sei-${uid}`, async function() {
|
|
103
|
+
if($(this).hasClass('ck-disabled')) return
|
|
104
|
+
|
|
105
|
+
$(this).addClass('ck-disabled')
|
|
106
|
+
|
|
107
|
+
//FAZ UMA REQUISIÇÃO AJAX PARA PROCURAR O PROCESSO
|
|
108
|
+
const result = await axios({
|
|
109
|
+
method: toolbar!.seiOptions?.method ?? 'get',
|
|
110
|
+
url: toolbar!.seiOptions?.url,
|
|
111
|
+
timeout: 5000,
|
|
112
|
+
responseType: 'json',
|
|
113
|
+
params: {
|
|
114
|
+
search: $(`#search-input-sei-${uid}`).val()
|
|
115
|
+
}
|
|
116
|
+
}).then((response) => {
|
|
117
|
+
return response
|
|
118
|
+
}).catch((error) => {
|
|
119
|
+
return error.response
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
$(this).removeClass('ck-disabled')
|
|
123
|
+
|
|
124
|
+
// DEFINE AS MENSAGENS DE ERRO
|
|
125
|
+
let msgErros = {
|
|
126
|
+
'400': 'Requisição inválida',
|
|
127
|
+
'401': 'Você não tem permissão para acessar este recurso',
|
|
128
|
+
'403': 'Você não tem permissão para acessar este recurso',
|
|
129
|
+
'404': 'Nenhum documento encontrado',
|
|
130
|
+
'500': 'Erro interno do servidor',
|
|
131
|
+
'502': 'Gateway inválido',
|
|
132
|
+
'503': 'Serviço indisponível',
|
|
133
|
+
'504': 'Gateway Time-out'
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
//ADICIONA A CLASSE DE ERRO NO CAMPO DE BUSCA
|
|
137
|
+
if(toolbar!.seiOptions?.erros) {
|
|
138
|
+
for(let e in toolbar!.seiOptions?.erros) {
|
|
139
|
+
msgErros[e] = toolbar!.seiOptions?.erros[e]
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//CASO NÃO ENCONTRE NENHUM RESULTADO
|
|
144
|
+
if(result.status != 200) {
|
|
145
|
+
$(`#search-input-sei-${uid}`).addClass('ck-error')
|
|
146
|
+
$(`#search-error-sei-${uid}`).html(msgErros[result.status] ?? msgErros['404'])
|
|
147
|
+
return
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
$(`#search-actions-sei-${uid}`).show()
|
|
151
|
+
|
|
152
|
+
//CASO ENCONTRE RESULTADO
|
|
153
|
+
$(`#search-result-sei-${uid}`).html(toolbar!.seiOptions?.resultData ? eval('result.data.' + toolbar!.seiOptions?.resultData) : result.data)
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
$('body').on('keyup', `.ck-error`, function() {
|
|
157
|
+
$(this).removeClass('ck-error')
|
|
158
|
+
$(`#search-error-sei-${uid}`).html('')
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
$('body').on('click', `#search-add-sei-${uid}`, async function() {
|
|
162
|
+
const conteudo = $(`#search-result-sei-${uid}`).html()
|
|
163
|
+
const viewDocument = editor.editing.view.document;
|
|
164
|
+
const htmlDP = new HtmlDataProcessor( viewDocument );
|
|
165
|
+
const viewFragment = htmlDP.toView( conteudo );
|
|
166
|
+
const modelFragment = editor.data.toModel( viewFragment ) as any;
|
|
167
|
+
|
|
168
|
+
editor.model.change(writer => {
|
|
169
|
+
writer.remove(writer.createRangeIn(editor.model.document.getRoot()));
|
|
170
|
+
editor.model.insertContent(modelFragment);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// LIMPA O CAMPO DE BUSCA
|
|
174
|
+
$(`#search-input-sei-${uid}`).val('')
|
|
175
|
+
$(`#search-actions-sei-${uid}`).hide()
|
|
176
|
+
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
return dropdown;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export default ImportarSei;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": [
|
|
4
|
+
"DOM",
|
|
5
|
+
"DOM.Iterable"
|
|
6
|
+
],
|
|
7
|
+
"noImplicitAny": true,
|
|
8
|
+
"noImplicitOverride": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"module": "es6",
|
|
11
|
+
"target": "es2019",
|
|
12
|
+
"sourceMap": true,
|
|
13
|
+
"allowJs": true,
|
|
14
|
+
"moduleResolution": "node",
|
|
15
|
+
"skipLibCheck": true
|
|
16
|
+
},
|
|
17
|
+
"include": [
|
|
18
|
+
"./src"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2014-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
/* eslint-env node */
|
|
9
|
+
|
|
10
|
+
const path = require( 'path' );
|
|
11
|
+
const webpack = require( 'webpack' );
|
|
12
|
+
const { bundler, styles } = require( '@ckeditor/ckeditor5-dev-utils' );
|
|
13
|
+
const { CKEditorTranslationsPlugin } = require( '@ckeditor/ckeditor5-dev-translations' );
|
|
14
|
+
const TerserWebpackPlugin = require( 'terser-webpack-plugin' );
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
devtool: 'source-map',
|
|
18
|
+
performance: { hints: false },
|
|
19
|
+
|
|
20
|
+
entry: path.resolve( __dirname, 'src', 'ckeditor.ts' ),
|
|
21
|
+
|
|
22
|
+
output: {
|
|
23
|
+
// The name under which the editor will be exported.
|
|
24
|
+
library: 'CKSource',
|
|
25
|
+
|
|
26
|
+
path: path.resolve( __dirname, 'build' ),
|
|
27
|
+
filename: 'ckeditor.js',
|
|
28
|
+
libraryTarget: 'umd',
|
|
29
|
+
libraryExport: 'default'
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
optimization: {
|
|
33
|
+
minimizer: [
|
|
34
|
+
new TerserWebpackPlugin( {
|
|
35
|
+
sourceMap: true,
|
|
36
|
+
terserOptions: {
|
|
37
|
+
output: {
|
|
38
|
+
// Preserve CKEditor 5 license comments.
|
|
39
|
+
comments: /^!/
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
extractComments: false
|
|
43
|
+
} )
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
plugins: [
|
|
48
|
+
new CKEditorTranslationsPlugin( {
|
|
49
|
+
// UI language. Language codes follow the https://en.wikipedia.org/wiki/ISO_639-1 format.
|
|
50
|
+
// When changing the built-in language, remember to also change it in the editor's configuration (src/ckeditor.ts).
|
|
51
|
+
language: 'pt-br',
|
|
52
|
+
additionalLanguages: 'all'
|
|
53
|
+
} ),
|
|
54
|
+
new webpack.BannerPlugin( {
|
|
55
|
+
banner: bundler.getLicenseBanner(),
|
|
56
|
+
raw: true
|
|
57
|
+
} )
|
|
58
|
+
],
|
|
59
|
+
|
|
60
|
+
resolve: {
|
|
61
|
+
extensions: [ '.ts', '.js', '.json' ]
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
module: {
|
|
65
|
+
rules: [ {
|
|
66
|
+
test: /\.svg$/,
|
|
67
|
+
use: [ 'raw-loader' ]
|
|
68
|
+
}, {
|
|
69
|
+
test: /\.ts$/,
|
|
70
|
+
use: 'ts-loader'
|
|
71
|
+
}, {
|
|
72
|
+
test: /\.css$/,
|
|
73
|
+
use: [ {
|
|
74
|
+
loader: 'style-loader',
|
|
75
|
+
options: {
|
|
76
|
+
injectType: 'singletonStyleTag',
|
|
77
|
+
attributes: {
|
|
78
|
+
'data-cke': true
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
loader: 'css-loader'
|
|
83
|
+
}, {
|
|
84
|
+
loader: 'postcss-loader',
|
|
85
|
+
options: {
|
|
86
|
+
postcssOptions: styles.getPostCssConfig( {
|
|
87
|
+
themeImporter: {
|
|
88
|
+
themePath: require.resolve( '@ckeditor/ckeditor5-theme-lark' )
|
|
89
|
+
},
|
|
90
|
+
minify: true
|
|
91
|
+
} )
|
|
92
|
+
}
|
|
93
|
+
} ]
|
|
94
|
+
} ]
|
|
95
|
+
}
|
|
96
|
+
};
|