quill-clausula 0.1.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.
- package/README.md +133 -0
- package/dist/actions/action-buttons.d.ts +2 -0
- package/dist/actions/drag-organizer.d.ts +54 -0
- package/dist/actions/floating-bar.d.ts +19 -0
- package/dist/actions/ghost-cut.d.ts +55 -0
- package/dist/actions/move-delta.d.ts +7 -0
- package/dist/assinatura/assinatura-renderer.d.ts +5 -0
- package/dist/assinatura/assinatura-sync.d.ts +12 -0
- package/dist/autofill.d.ts +22 -0
- package/dist/blots/assinatura-embed.d.ts +11 -0
- package/dist/blots/clausula-container.d.ts +4 -0
- package/dist/blots/clausula-item.d.ts +15 -0
- package/dist/blots/objeto-container.d.ts +4 -0
- package/dist/blots/objeto-item.d.ts +12 -0
- package/dist/blots/parte-container.d.ts +4 -0
- package/dist/blots/parte-item.d.ts +13 -0
- package/dist/export/exporter.d.ts +64 -0
- package/dist/formats/agreed.d.ts +9 -0
- package/dist/formats/ghost.d.ts +7 -0
- package/dist/formats/locked.d.ts +2 -0
- package/dist/formats/spacing.d.ts +13 -0
- package/dist/import/markdown-importer.d.ts +37 -0
- package/dist/index.d.ts +32 -0
- package/dist/module.d.ts +112 -0
- package/dist/numbering/counter.d.ts +18 -0
- package/dist/numbering/extenso.d.ts +9 -0
- package/dist/numbering/formatter.d.ts +2 -0
- package/dist/numbering/roman.d.ts +2 -0
- package/dist/partes/partes-counter.d.ts +25 -0
- package/dist/quill-clausula.cjs +25 -0
- package/dist/quill-clausula.css +856 -0
- package/dist/quill-clausula.mjs +1779 -0
- package/dist/toolbar/handler.d.ts +18 -0
- package/dist/types.d.ts +68 -0
- package/package.json +57 -0
|
@@ -0,0 +1,1779 @@
|
|
|
1
|
+
import h from "quill";
|
|
2
|
+
const st = h.import("blots/container");
|
|
3
|
+
class y extends st {
|
|
4
|
+
}
|
|
5
|
+
y.blotName = "clausula-container";
|
|
6
|
+
y.className = "ql-clausula-container";
|
|
7
|
+
y.tagName = "DIV";
|
|
8
|
+
const nt = h.import("blots/block"), k = class k extends nt {
|
|
9
|
+
constructor(t, e) {
|
|
10
|
+
super(t, e), this.actionsNode = null;
|
|
11
|
+
const n = e.ownerDocument.createElement("span");
|
|
12
|
+
n.classList.add("ql-clausula-prefix"), this.attachUI(n);
|
|
13
|
+
}
|
|
14
|
+
static create(t) {
|
|
15
|
+
const e = super.create();
|
|
16
|
+
return e.setAttribute("data-clausula-type", t), e;
|
|
17
|
+
}
|
|
18
|
+
static formats(t) {
|
|
19
|
+
return t.getAttribute("data-clausula-type") || void 0;
|
|
20
|
+
}
|
|
21
|
+
static register() {
|
|
22
|
+
h.register(y, !0);
|
|
23
|
+
}
|
|
24
|
+
format(t, e) {
|
|
25
|
+
t === k.blotName && e ? this.domNode.setAttribute("data-clausula-type", e) : super.format(t, e);
|
|
26
|
+
}
|
|
27
|
+
update(t, e) {
|
|
28
|
+
const n = t.filter((s) => {
|
|
29
|
+
if (!this.actionsNode) return !0;
|
|
30
|
+
if (s.type === "childList") {
|
|
31
|
+
const i = Array.from(s.addedNodes).some(
|
|
32
|
+
(l) => l === this.actionsNode || this.actionsNode && this.actionsNode.contains(l)
|
|
33
|
+
), o = Array.from(s.removedNodes).some(
|
|
34
|
+
(l) => l === this.actionsNode || this.actionsNode && this.actionsNode.contains(l)
|
|
35
|
+
);
|
|
36
|
+
if (i || o) return !1;
|
|
37
|
+
}
|
|
38
|
+
return !(s.target === this.actionsNode || this.actionsNode && this.actionsNode.contains(s.target));
|
|
39
|
+
});
|
|
40
|
+
n.length > 0 && super.update(n, e);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
k.blotName = "clausula", k.tagName = "DIV", k.className = "ql-clausula-item";
|
|
44
|
+
let E = k;
|
|
45
|
+
y.allowedChildren = [E];
|
|
46
|
+
E.requiredContainer = y;
|
|
47
|
+
const rt = h.import("blots/container");
|
|
48
|
+
class v extends rt {
|
|
49
|
+
}
|
|
50
|
+
v.blotName = "parte-container";
|
|
51
|
+
v.className = "ql-parte-container";
|
|
52
|
+
v.tagName = "DIV";
|
|
53
|
+
const it = h.import("blots/block"), x = class x extends it {
|
|
54
|
+
static create(t) {
|
|
55
|
+
const e = super.create();
|
|
56
|
+
return e.setAttribute("data-parte-type", t), e;
|
|
57
|
+
}
|
|
58
|
+
static formats(t) {
|
|
59
|
+
return t.getAttribute("data-parte-type") || void 0;
|
|
60
|
+
}
|
|
61
|
+
static register() {
|
|
62
|
+
h.register(v, !0);
|
|
63
|
+
}
|
|
64
|
+
constructor(t, e) {
|
|
65
|
+
super(t, e);
|
|
66
|
+
const n = e.ownerDocument.createElement("span");
|
|
67
|
+
n.classList.add("ql-parte-prefix"), this.attachUI(n);
|
|
68
|
+
}
|
|
69
|
+
format(t, e) {
|
|
70
|
+
t === x.blotName && e ? this.domNode.setAttribute("data-parte-type", e) : super.format(t, e);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
x.blotName = "parte", x.tagName = "DIV", x.className = "ql-parte-item";
|
|
74
|
+
let T = x;
|
|
75
|
+
v.allowedChildren = [T];
|
|
76
|
+
T.requiredContainer = v;
|
|
77
|
+
const ot = h.import("blots/container");
|
|
78
|
+
class A extends ot {
|
|
79
|
+
}
|
|
80
|
+
A.blotName = "objeto-container";
|
|
81
|
+
A.className = "ql-objeto-container";
|
|
82
|
+
A.tagName = "DIV";
|
|
83
|
+
const at = h.import("blots/block"), q = class q extends at {
|
|
84
|
+
static create(t) {
|
|
85
|
+
const e = super.create();
|
|
86
|
+
return e.setAttribute("data-objeto", "true"), e;
|
|
87
|
+
}
|
|
88
|
+
static formats(t) {
|
|
89
|
+
return t.getAttribute("data-objeto") ? "true" : void 0;
|
|
90
|
+
}
|
|
91
|
+
static register() {
|
|
92
|
+
h.register(A, !0);
|
|
93
|
+
}
|
|
94
|
+
constructor(t, e) {
|
|
95
|
+
super(t, e);
|
|
96
|
+
const n = e.ownerDocument.createElement("span");
|
|
97
|
+
n.classList.add("ql-objeto-prefix"), n.textContent = "OBJETO: ", this.attachUI(n);
|
|
98
|
+
}
|
|
99
|
+
format(t, e) {
|
|
100
|
+
t === q.blotName && e ? this.domNode.setAttribute("data-objeto", "true") : super.format(t, e);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
q.blotName = "objeto", q.tagName = "DIV", q.className = "ql-objeto-item";
|
|
104
|
+
let I = q;
|
|
105
|
+
A.allowedChildren = [I];
|
|
106
|
+
I.requiredContainer = A;
|
|
107
|
+
const lt = h.import("blots/block/embed"), S = class S extends lt {
|
|
108
|
+
static create(t) {
|
|
109
|
+
const e = super.create(), n = typeof t == "string" ? JSON.parse(t) : t || {};
|
|
110
|
+
return e.setAttribute("data-assinatura", JSON.stringify(n)), e.setAttribute("contenteditable", "false"), e;
|
|
111
|
+
}
|
|
112
|
+
static value(t) {
|
|
113
|
+
const e = t.getAttribute("data-assinatura");
|
|
114
|
+
if (!e) return {};
|
|
115
|
+
try {
|
|
116
|
+
return JSON.parse(e);
|
|
117
|
+
} catch {
|
|
118
|
+
return {};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
static formats(t) {
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
S.blotName = "assinatura", S.tagName = "DIV", S.className = "ql-assinatura-block";
|
|
125
|
+
let C = S;
|
|
126
|
+
const { ClassAttributor: ct, Scope: ut } = h.import("parchment"), dt = new ct("locked", "ql-locked", {
|
|
127
|
+
scope: ut.BLOCK,
|
|
128
|
+
whitelist: ["true"]
|
|
129
|
+
}), { Attributor: ht, Scope: ft } = h.import("parchment");
|
|
130
|
+
class gt extends ht {
|
|
131
|
+
constructor(t, e, n) {
|
|
132
|
+
super(t, e, n);
|
|
133
|
+
}
|
|
134
|
+
add(t, e) {
|
|
135
|
+
const n = typeof e == "string" ? JSON.parse(e) : e;
|
|
136
|
+
t.setAttribute("data-agreed", JSON.stringify(n));
|
|
137
|
+
const s = Object.values(n), i = s.length > 0 && s.every(Boolean), o = s.some((l) => l === !1);
|
|
138
|
+
return t.classList.toggle("ql-agreed", i), t.classList.toggle("ql-disagreed", o), !0;
|
|
139
|
+
}
|
|
140
|
+
remove(t) {
|
|
141
|
+
t.removeAttribute("data-agreed"), t.classList.remove("ql-agreed"), t.classList.remove("ql-disagreed");
|
|
142
|
+
}
|
|
143
|
+
value(t) {
|
|
144
|
+
const e = t.getAttribute("data-agreed");
|
|
145
|
+
if (e)
|
|
146
|
+
try {
|
|
147
|
+
return JSON.parse(e);
|
|
148
|
+
} catch {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const pt = new gt("agreed", "data-agreed", {
|
|
154
|
+
scope: ft.BLOCK
|
|
155
|
+
}), { ClassAttributor: mt, Scope: bt } = h.import("parchment"), yt = new mt("ghost", "ql-ghost", {
|
|
156
|
+
scope: bt.INLINE,
|
|
157
|
+
whitelist: ["true"]
|
|
158
|
+
}), { StyleAttributor: M, Scope: j } = h.import("parchment"), vt = ["1", "1.15", "1.5", "2", "2.5", "3"], At = ["0em", "0.5em", "1em", "1.5em", "2em"], kt = new M("lineheight", "line-height", {
|
|
159
|
+
scope: j.BLOCK,
|
|
160
|
+
whitelist: [...vt]
|
|
161
|
+
}), xt = new M("spacing", "margin-bottom", {
|
|
162
|
+
scope: j.BLOCK,
|
|
163
|
+
whitelist: [...At]
|
|
164
|
+
});
|
|
165
|
+
function F(r, t, e, n) {
|
|
166
|
+
const s = [];
|
|
167
|
+
if (e <= r)
|
|
168
|
+
e > 0 && s.push({ retain: e }), s.push(...n), r - e > 0 && s.push({ retain: r - e }), s.push({ delete: t });
|
|
169
|
+
else {
|
|
170
|
+
r > 0 && s.push({ retain: r }), s.push({ delete: t });
|
|
171
|
+
const i = e - (r + t);
|
|
172
|
+
i > 0 && s.push({ retain: i }), s.push(...n);
|
|
173
|
+
}
|
|
174
|
+
return s;
|
|
175
|
+
}
|
|
176
|
+
function qt(r) {
|
|
177
|
+
var s;
|
|
178
|
+
let t = 0, e = -1, n = -1;
|
|
179
|
+
for (const i of r.ops || []) {
|
|
180
|
+
const o = typeof i.insert == "string" ? i.insert.length : i.insert ? 1 : 0;
|
|
181
|
+
(s = i.attributes) != null && s.ghost && (e === -1 && (e = t), n = t + o), t += o;
|
|
182
|
+
}
|
|
183
|
+
return e === -1 ? null : { index: e, length: n - e };
|
|
184
|
+
}
|
|
185
|
+
class Lt {
|
|
186
|
+
constructor(t, e) {
|
|
187
|
+
this.quill = t, this.isRangeLocked = e.isRangeLocked;
|
|
188
|
+
}
|
|
189
|
+
get active() {
|
|
190
|
+
return this.findRange() !== null;
|
|
191
|
+
}
|
|
192
|
+
findRange() {
|
|
193
|
+
return qt(this.quill.getContents());
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Expands a selection to include the trailing newline when it covers the
|
|
197
|
+
* entire text of its line(s), so line formats move together.
|
|
198
|
+
*/
|
|
199
|
+
expandToLineBoundary(t, e) {
|
|
200
|
+
const n = this.quill, [s, i] = n.getLine(t), [o, l] = n.getLine(t + e);
|
|
201
|
+
if (!s || !o) return { index: t, length: e };
|
|
202
|
+
const c = i === 0, a = l === o.length() - 1, u = t + e + 1 < n.getLength();
|
|
203
|
+
return c && a && u ? { index: t, length: e + 1 } : { index: t, length: e };
|
|
204
|
+
}
|
|
205
|
+
/** Handles a `cut` DOM event. Returns true when the event was consumed. */
|
|
206
|
+
handleCut(t) {
|
|
207
|
+
const e = this.quill.getSelection();
|
|
208
|
+
if (!e || e.length === 0) return !1;
|
|
209
|
+
if (t.preventDefault(), this.isRangeLocked(e.index, e.length)) return !0;
|
|
210
|
+
this.cancel();
|
|
211
|
+
const n = this.expandToLineBoundary(e.index, e.length);
|
|
212
|
+
return this.quill.formatText(n.index, n.length, "ghost", "true", "silent"), this.markGhostLines(n.index, n.length), this.quill.setSelection(n.index + n.length, 0, "silent"), !0;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Lines fully covered by the ghost range get a line-level class so their
|
|
216
|
+
* UI labels ("CLÁUSULA SEGUNDA — ", "2.1", "Parágrafo Primeiro.") fade
|
|
217
|
+
* together with the content — the label is presentation DOM, not text,
|
|
218
|
+
* so the inline ghost format alone cannot reach it.
|
|
219
|
+
*/
|
|
220
|
+
markGhostLines(t, e) {
|
|
221
|
+
const n = this.quill.getLines(t, Math.max(e, 1));
|
|
222
|
+
for (const s of n) {
|
|
223
|
+
if (!(s != null && s.domNode)) continue;
|
|
224
|
+
const i = this.quill.getIndex(s), o = i + s.length();
|
|
225
|
+
i >= t && o - 1 <= t + e && s.domNode.classList.add("ql-ghost-line");
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
clearGhostLines() {
|
|
229
|
+
const t = this.quill.root;
|
|
230
|
+
for (const e of t.querySelectorAll(".ql-ghost-line"))
|
|
231
|
+
e.classList.remove("ql-ghost-line");
|
|
232
|
+
}
|
|
233
|
+
/** Handles a `paste` DOM event. Returns true when the event was consumed. */
|
|
234
|
+
handlePaste(t) {
|
|
235
|
+
const e = this.findRange();
|
|
236
|
+
if (!e) return !1;
|
|
237
|
+
t.preventDefault();
|
|
238
|
+
const n = this.expandToLineBoundary(e.index, e.length), s = this.quill.getSelection(!0), i = s ? s.index : n.index;
|
|
239
|
+
if (i > n.index && i < n.index + n.length)
|
|
240
|
+
return this.cancel(), !0;
|
|
241
|
+
if (this.isRangeLocked(i, 0))
|
|
242
|
+
return !0;
|
|
243
|
+
this.clearGhostLines(), this.quill.formatText(e.index, e.length, "ghost", !1, "silent");
|
|
244
|
+
const o = this.quill.getContents(n.index, n.length), l = F(n.index, n.length, i, o.ops);
|
|
245
|
+
this.quill.updateContents({ ops: l }, "user");
|
|
246
|
+
const c = i <= n.index ? i + n.length : i;
|
|
247
|
+
return this.quill.setSelection(c, 0, "silent"), !0;
|
|
248
|
+
}
|
|
249
|
+
/** Cancels an active ghost (Escape). Returns true when one was cleared. */
|
|
250
|
+
cancel() {
|
|
251
|
+
this.clearGhostLines();
|
|
252
|
+
const t = this.findRange();
|
|
253
|
+
return t ? (this.quill.formatText(t.index, t.length, "ghost", !1, "silent"), !0) : !1;
|
|
254
|
+
}
|
|
255
|
+
destroy() {
|
|
256
|
+
this.cancel();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
const Nt = '<svg viewBox="0 0 10 16" width="10" height="16" fill="currentColor"><circle cx="2.5" cy="3" r="1.4"/><circle cx="7.5" cy="3" r="1.4"/><circle cx="2.5" cy="8" r="1.4"/><circle cx="7.5" cy="8" r="1.4"/><circle cx="2.5" cy="13" r="1.4"/><circle cx="7.5" cy="13" r="1.4"/></svg>';
|
|
260
|
+
class Ct {
|
|
261
|
+
constructor(t, e) {
|
|
262
|
+
this.hoveredBlockIndex = -1, this.hoveredParentEl = null, this.hideTimer = null, this.dragging = !1, this.dropBoundary = -1, this.blockRects = [], this.onMouseMove = (s) => this.trackHover(s), this.onMouseLeave = () => {
|
|
263
|
+
this.dragging || this.scheduleHide();
|
|
264
|
+
}, this.onPointerDown = (s) => this.startDrag(s), this.onPointerMove = (s) => this.trackDrag(s), this.onPointerUp = (s) => this.endDrag(s), this.quill = t, this.callbacks = e, this.container = t.container;
|
|
265
|
+
const n = this.container.ownerDocument;
|
|
266
|
+
this.handle = n.createElement("div"), this.handle.className = "ql-clausula-drag-handle", this.handle.setAttribute("contenteditable", "false"), this.handle.setAttribute("title", "Arraste para reordenar a cláusula"), this.handle.innerHTML = Nt, this.container.appendChild(this.handle), this.indicator = n.createElement("div"), this.indicator.className = "ql-clausula-drop-indicator", this.container.appendChild(this.indicator), this.container.addEventListener("mousemove", this.onMouseMove), this.container.addEventListener("mouseleave", this.onMouseLeave), this.handle.addEventListener("pointerdown", this.onPointerDown);
|
|
267
|
+
}
|
|
268
|
+
hideHandle() {
|
|
269
|
+
this.cancelHide(), this.handle.classList.remove("visible"), this.hoveredBlockIndex = -1, this.hoveredParentEl = null;
|
|
270
|
+
}
|
|
271
|
+
/** Hide with a grace period so the mouse can travel to the handle. */
|
|
272
|
+
scheduleHide() {
|
|
273
|
+
this.hideTimer === null && (this.hideTimer = setTimeout(() => {
|
|
274
|
+
this.hideTimer = null, this.hideHandle();
|
|
275
|
+
}, 350));
|
|
276
|
+
}
|
|
277
|
+
cancelHide() {
|
|
278
|
+
this.hideTimer !== null && (clearTimeout(this.hideTimer), this.hideTimer = null);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* While a block is hovered, the strip from the handle to the block's
|
|
282
|
+
* right edge (with vertical slack) counts as "still hovering" — without
|
|
283
|
+
* it the handle vanishes as soon as the mouse leaves the text on its
|
|
284
|
+
* way to grab it.
|
|
285
|
+
*/
|
|
286
|
+
isInReachCorridor(t) {
|
|
287
|
+
if (!this.hoveredParentEl || !this.handle.classList.contains("visible"))
|
|
288
|
+
return !1;
|
|
289
|
+
const e = this.hoveredParentEl.getBoundingClientRect(), n = this.handle.getBoundingClientRect();
|
|
290
|
+
return t.clientY >= Math.min(n.top, e.top) - 10 && t.clientY <= Math.max(n.bottom, e.bottom) + 10 && t.clientX >= n.left - 14 && t.clientX <= e.right;
|
|
291
|
+
}
|
|
292
|
+
trackHover(t) {
|
|
293
|
+
var l, c, a, u;
|
|
294
|
+
if (this.dragging) return;
|
|
295
|
+
if ((c = (l = t.target).closest) != null && c.call(l, ".ql-clausula-drag-handle")) {
|
|
296
|
+
this.cancelHide();
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const e = (u = (a = t.target).closest) == null ? void 0 : u.call(a, ".ql-clausula-item");
|
|
300
|
+
if (!e) {
|
|
301
|
+
this.isInReachCorridor(t) ? this.cancelHide() : this.scheduleHide();
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
const n = this.callbacks.getBlocks(), s = n.findIndex(
|
|
305
|
+
(d) => d.items.some((f) => f.domNode === e)
|
|
306
|
+
);
|
|
307
|
+
if (s === -1) {
|
|
308
|
+
this.scheduleHide();
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
this.cancelHide(), this.hoveredBlockIndex = s, this.hoveredParentEl = n[s].items[0].domNode;
|
|
312
|
+
const i = this.hoveredParentEl.getBoundingClientRect(), o = this.container.getBoundingClientRect();
|
|
313
|
+
this.handle.style.top = `${i.top - o.top + 2}px`, this.handle.style.left = `${Math.max(i.left - o.left - 26, 2)}px`, this.handle.classList.add("visible");
|
|
314
|
+
}
|
|
315
|
+
startDrag(t) {
|
|
316
|
+
if (this.hoveredBlockIndex === -1) return;
|
|
317
|
+
t.preventDefault(), this.dragging = !0, this.dropBoundary = -1;
|
|
318
|
+
try {
|
|
319
|
+
this.handle.setPointerCapture(t.pointerId);
|
|
320
|
+
} catch {
|
|
321
|
+
}
|
|
322
|
+
this.handle.addEventListener("pointermove", this.onPointerMove), this.handle.addEventListener("pointerup", this.onPointerUp), this.container.classList.add("ql-clausula-dragging");
|
|
323
|
+
const e = this.callbacks.getBlocks(), n = this.container.getBoundingClientRect();
|
|
324
|
+
this.blockRects = e.map((s) => {
|
|
325
|
+
const i = s.items[0].domNode.getBoundingClientRect(), o = s.items[s.items.length - 1].domNode.getBoundingClientRect();
|
|
326
|
+
return { top: i.top - n.top, bottom: o.bottom - n.top };
|
|
327
|
+
});
|
|
328
|
+
for (const s of e[this.hoveredBlockIndex].items)
|
|
329
|
+
s.domNode.classList.add("ql-drag-source");
|
|
330
|
+
}
|
|
331
|
+
trackDrag(t) {
|
|
332
|
+
if (!this.dragging) return;
|
|
333
|
+
const e = this.container.getBoundingClientRect(), n = t.clientY - e.top, s = [
|
|
334
|
+
...this.blockRects.map((c) => c.top),
|
|
335
|
+
this.blockRects.length > 0 ? this.blockRects[this.blockRects.length - 1].bottom : 0
|
|
336
|
+
];
|
|
337
|
+
let i = 0, o = 1 / 0;
|
|
338
|
+
s.forEach((c, a) => {
|
|
339
|
+
const u = Math.abs(c - n);
|
|
340
|
+
u < o && (o = u, i = a);
|
|
341
|
+
}), this.dropBoundary = i;
|
|
342
|
+
const l = i === this.hoveredBlockIndex || i === this.hoveredBlockIndex + 1;
|
|
343
|
+
this.indicator.style.top = `${s[i] - 1}px`, this.indicator.classList.toggle("visible", !l);
|
|
344
|
+
}
|
|
345
|
+
endDrag(t) {
|
|
346
|
+
try {
|
|
347
|
+
this.handle.releasePointerCapture(t.pointerId);
|
|
348
|
+
} catch {
|
|
349
|
+
}
|
|
350
|
+
this.handle.removeEventListener("pointermove", this.onPointerMove), this.handle.removeEventListener("pointerup", this.onPointerUp), this.container.classList.remove("ql-clausula-dragging"), this.indicator.classList.remove("visible");
|
|
351
|
+
const e = this.hoveredBlockIndex, n = this.dropBoundary;
|
|
352
|
+
this.dragging = !1;
|
|
353
|
+
for (const i of this.container.querySelectorAll(".ql-drag-source"))
|
|
354
|
+
i.classList.remove("ql-drag-source");
|
|
355
|
+
const s = n === -1 || n === e || n === e + 1;
|
|
356
|
+
e !== -1 && !s && this.callbacks.moveBlock(e, n), this.hideHandle();
|
|
357
|
+
}
|
|
358
|
+
destroy() {
|
|
359
|
+
this.cancelHide(), this.container.removeEventListener("mousemove", this.onMouseMove), this.container.removeEventListener("mouseleave", this.onMouseLeave), this.handle.removeEventListener("pointerdown", this.onPointerDown), this.handle.remove(), this.indicator.remove();
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function St(r) {
|
|
363
|
+
return G(
|
|
364
|
+
r.map(
|
|
365
|
+
(t) => t.domNode.getAttribute("data-clausula-type")
|
|
366
|
+
)
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
function G(r) {
|
|
370
|
+
const t = [];
|
|
371
|
+
let e = -1;
|
|
372
|
+
for (const a of r)
|
|
373
|
+
a === "clausula" && (e++, t.push(0)), a === "paragrafo" && e >= 0 && t[e]++;
|
|
374
|
+
const n = [];
|
|
375
|
+
let s = 0, i = 0, o = 0, l = 0, c = 0;
|
|
376
|
+
for (const a of r)
|
|
377
|
+
switch (a) {
|
|
378
|
+
case "clausula":
|
|
379
|
+
s++, i = 0, o = 0, l = 0, c = 0, n.push({
|
|
380
|
+
type: a,
|
|
381
|
+
index: s,
|
|
382
|
+
parentClausulaIndex: s,
|
|
383
|
+
isUnico: !1
|
|
384
|
+
});
|
|
385
|
+
break;
|
|
386
|
+
case "subclausula":
|
|
387
|
+
i++, l = 0, c = 0, n.push({
|
|
388
|
+
type: a,
|
|
389
|
+
index: i,
|
|
390
|
+
parentClausulaIndex: s,
|
|
391
|
+
isUnico: !1
|
|
392
|
+
});
|
|
393
|
+
break;
|
|
394
|
+
case "paragrafo":
|
|
395
|
+
o++, l = 0, c = 0, n.push({
|
|
396
|
+
type: a,
|
|
397
|
+
index: o,
|
|
398
|
+
parentClausulaIndex: s,
|
|
399
|
+
isUnico: s > 0 && t[s - 1] === 1
|
|
400
|
+
});
|
|
401
|
+
break;
|
|
402
|
+
case "inciso":
|
|
403
|
+
l++, c = 0, n.push({
|
|
404
|
+
type: a,
|
|
405
|
+
index: l,
|
|
406
|
+
parentClausulaIndex: s,
|
|
407
|
+
isUnico: !1
|
|
408
|
+
});
|
|
409
|
+
break;
|
|
410
|
+
case "alinea":
|
|
411
|
+
c++, n.push({
|
|
412
|
+
type: a,
|
|
413
|
+
index: c,
|
|
414
|
+
parentClausulaIndex: s,
|
|
415
|
+
isUnico: !1
|
|
416
|
+
});
|
|
417
|
+
break;
|
|
418
|
+
default:
|
|
419
|
+
n.push({
|
|
420
|
+
type: a || "clausula",
|
|
421
|
+
index: 1,
|
|
422
|
+
parentClausulaIndex: s,
|
|
423
|
+
isUnico: !1
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
return n;
|
|
427
|
+
}
|
|
428
|
+
const Et = [
|
|
429
|
+
"",
|
|
430
|
+
"Primeiro",
|
|
431
|
+
"Segundo",
|
|
432
|
+
"Terceiro",
|
|
433
|
+
"Quarto",
|
|
434
|
+
"Quinto",
|
|
435
|
+
"Sexto",
|
|
436
|
+
"Sétimo",
|
|
437
|
+
"Oitavo",
|
|
438
|
+
"Nono"
|
|
439
|
+
], Tt = [
|
|
440
|
+
"",
|
|
441
|
+
"Primeira",
|
|
442
|
+
"Segunda",
|
|
443
|
+
"Terceira",
|
|
444
|
+
"Quarta",
|
|
445
|
+
"Quinta",
|
|
446
|
+
"Sexta",
|
|
447
|
+
"Sétima",
|
|
448
|
+
"Oitava",
|
|
449
|
+
"Nona"
|
|
450
|
+
], It = [
|
|
451
|
+
"",
|
|
452
|
+
"Décimo",
|
|
453
|
+
"Vigésimo",
|
|
454
|
+
"Trigésimo",
|
|
455
|
+
"Quadragésimo",
|
|
456
|
+
"Quinquagésimo",
|
|
457
|
+
"Sexagésimo",
|
|
458
|
+
"Septuagésimo",
|
|
459
|
+
"Octogésimo",
|
|
460
|
+
"Nonagésimo"
|
|
461
|
+
], wt = [
|
|
462
|
+
"",
|
|
463
|
+
"Décima",
|
|
464
|
+
"Vigésima",
|
|
465
|
+
"Trigésima",
|
|
466
|
+
"Quadragésima",
|
|
467
|
+
"Quinquagésima",
|
|
468
|
+
"Sexagésima",
|
|
469
|
+
"Septuagésima",
|
|
470
|
+
"Octogésima",
|
|
471
|
+
"Nonagésima"
|
|
472
|
+
], Rt = [
|
|
473
|
+
"",
|
|
474
|
+
"Centésimo",
|
|
475
|
+
"Ducentésimo",
|
|
476
|
+
"Trecentésimo",
|
|
477
|
+
"Quadringentésimo",
|
|
478
|
+
"Quingentésimo",
|
|
479
|
+
"Sexcentésimo",
|
|
480
|
+
"Septingentésimo",
|
|
481
|
+
"Octingentésimo",
|
|
482
|
+
"Noningentésimo"
|
|
483
|
+
], $t = [
|
|
484
|
+
"",
|
|
485
|
+
"Centésima",
|
|
486
|
+
"Ducentésima",
|
|
487
|
+
"Trecentésima",
|
|
488
|
+
"Quadringentésima",
|
|
489
|
+
"Quingentésima",
|
|
490
|
+
"Sexcentésima",
|
|
491
|
+
"Septingentésima",
|
|
492
|
+
"Octingentésima",
|
|
493
|
+
"Noningentésima"
|
|
494
|
+
];
|
|
495
|
+
function _(r, t = "feminine") {
|
|
496
|
+
if (r <= 0 || r > 999) return String(r);
|
|
497
|
+
const e = t === "feminine" ? Tt : Et, n = t === "feminine" ? wt : It, s = t === "feminine" ? $t : Rt, i = [], o = Math.floor(r / 100), l = Math.floor(r % 100 / 10), c = r % 10;
|
|
498
|
+
return o > 0 && i.push(s[o]), l > 0 && i.push(n[l]), c > 0 && i.push(e[c]), i.join(" ");
|
|
499
|
+
}
|
|
500
|
+
function V(r, t = "feminine") {
|
|
501
|
+
return _(r, t).toUpperCase();
|
|
502
|
+
}
|
|
503
|
+
const Ot = [
|
|
504
|
+
[1e3, "M"],
|
|
505
|
+
[900, "CM"],
|
|
506
|
+
[500, "D"],
|
|
507
|
+
[400, "CD"],
|
|
508
|
+
[100, "C"],
|
|
509
|
+
[90, "XC"],
|
|
510
|
+
[50, "L"],
|
|
511
|
+
[40, "XL"],
|
|
512
|
+
[10, "X"],
|
|
513
|
+
[9, "IX"],
|
|
514
|
+
[5, "V"],
|
|
515
|
+
[4, "IV"],
|
|
516
|
+
[1, "I"]
|
|
517
|
+
];
|
|
518
|
+
function $(r) {
|
|
519
|
+
if (r <= 0 || r > 3999) return String(r);
|
|
520
|
+
let t = "", e = r;
|
|
521
|
+
for (const [n, s] of Ot)
|
|
522
|
+
for (; e >= n; )
|
|
523
|
+
t += s, e -= n;
|
|
524
|
+
return t;
|
|
525
|
+
}
|
|
526
|
+
function Bt(r) {
|
|
527
|
+
return $(r).toLowerCase();
|
|
528
|
+
}
|
|
529
|
+
function w(r) {
|
|
530
|
+
return r < 10 ? `0${r}` : String(r);
|
|
531
|
+
}
|
|
532
|
+
function _t(r) {
|
|
533
|
+
let t = "", e = r;
|
|
534
|
+
for (; e > 0; )
|
|
535
|
+
e--, t = String.fromCharCode(97 + e % 26) + t, e = Math.floor(e / 26);
|
|
536
|
+
return t;
|
|
537
|
+
}
|
|
538
|
+
function Pt(r, t) {
|
|
539
|
+
switch (t) {
|
|
540
|
+
case "extenso":
|
|
541
|
+
return `CLÁUSULA ${V(r, "feminine")} — `;
|
|
542
|
+
case "numeric":
|
|
543
|
+
return `CLÁUSULA ${r} — `;
|
|
544
|
+
case "numeric-padded":
|
|
545
|
+
return `CLÁUSULA ${w(r)} — `;
|
|
546
|
+
case "ordinal":
|
|
547
|
+
return `CLÁUSULA ${r}ª — `;
|
|
548
|
+
case "abbreviation":
|
|
549
|
+
return `Cl. ${r} — `;
|
|
550
|
+
case "regular":
|
|
551
|
+
return `Cláusula ${r} — `;
|
|
552
|
+
case "regular-padded":
|
|
553
|
+
return `Cláusula ${w(r)} — `;
|
|
554
|
+
default:
|
|
555
|
+
return `CLÁUSULA ${r} — `;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
function Dt(r, t, e) {
|
|
559
|
+
switch (e) {
|
|
560
|
+
case "dotted":
|
|
561
|
+
return `${t}.${r} `;
|
|
562
|
+
case "dotted-padded":
|
|
563
|
+
return `${w(t)}.${w(r)} `;
|
|
564
|
+
case "numeric":
|
|
565
|
+
return `${r}. `;
|
|
566
|
+
case "extenso":
|
|
567
|
+
return `${_(r, "feminine")} `;
|
|
568
|
+
default:
|
|
569
|
+
return `${t}.${r} `;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
function Ut(r, t) {
|
|
573
|
+
if (r.isUnico)
|
|
574
|
+
switch (t) {
|
|
575
|
+
case "extenso":
|
|
576
|
+
return "Parágrafo Único. ";
|
|
577
|
+
case "uppercase":
|
|
578
|
+
return "PARÁGRAFO ÚNICO. ";
|
|
579
|
+
case "numeric":
|
|
580
|
+
return "Parágrafo Único. ";
|
|
581
|
+
case "symbol":
|
|
582
|
+
return "§ Único. ";
|
|
583
|
+
default:
|
|
584
|
+
return "Parágrafo Único. ";
|
|
585
|
+
}
|
|
586
|
+
switch (t) {
|
|
587
|
+
case "extenso":
|
|
588
|
+
return `Parágrafo ${_(r.index, "masculine")}. `;
|
|
589
|
+
case "uppercase":
|
|
590
|
+
return `PARÁGRAFO ${V(r.index, "masculine")}. `;
|
|
591
|
+
case "numeric":
|
|
592
|
+
return `Parágrafo ${r.index}º. `;
|
|
593
|
+
case "symbol":
|
|
594
|
+
return `§${r.index}º. `;
|
|
595
|
+
default:
|
|
596
|
+
return `Parágrafo ${r.index}º. `;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
function Ht(r, t) {
|
|
600
|
+
switch (t) {
|
|
601
|
+
case "roman":
|
|
602
|
+
return `${$(r)} — `;
|
|
603
|
+
case "roman-lower":
|
|
604
|
+
return `${Bt(r)} — `;
|
|
605
|
+
default:
|
|
606
|
+
return `${$(r)} — `;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
function Mt(r, t) {
|
|
610
|
+
const e = _t(r);
|
|
611
|
+
switch (t) {
|
|
612
|
+
case "letter-parenthesis":
|
|
613
|
+
return `${e}) `;
|
|
614
|
+
case "letter":
|
|
615
|
+
return `${e}. `;
|
|
616
|
+
default:
|
|
617
|
+
return `${e}) `;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
function K(r, t) {
|
|
621
|
+
switch (r.type) {
|
|
622
|
+
case "clausula":
|
|
623
|
+
return Pt(r.index, t.clausulaFormat);
|
|
624
|
+
case "subclausula":
|
|
625
|
+
return Dt(
|
|
626
|
+
r.index,
|
|
627
|
+
r.parentClausulaIndex,
|
|
628
|
+
t.subclausulaFormat
|
|
629
|
+
);
|
|
630
|
+
case "paragrafo":
|
|
631
|
+
return Ut(r, t.paragrafoFormat);
|
|
632
|
+
case "inciso":
|
|
633
|
+
return Ht(r.index, t.incisoFormat);
|
|
634
|
+
case "alinea":
|
|
635
|
+
return Mt(r.index, t.alineaFormat);
|
|
636
|
+
default:
|
|
637
|
+
return "";
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
function jt(r) {
|
|
641
|
+
return J(
|
|
642
|
+
r.map(
|
|
643
|
+
(t) => t.domNode.getAttribute("data-parte-type")
|
|
644
|
+
)
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
function J(r) {
|
|
648
|
+
const t = { contratante: 0, contratado: 0 }, e = r.map((i) => i && i in t ? i : "contratante");
|
|
649
|
+
for (const i of e)
|
|
650
|
+
t[i]++;
|
|
651
|
+
const n = { contratante: 0, contratado: 0 }, s = [];
|
|
652
|
+
for (const i of e)
|
|
653
|
+
n[i]++, s.push({
|
|
654
|
+
type: i,
|
|
655
|
+
index: n[i],
|
|
656
|
+
total: t[i]
|
|
657
|
+
});
|
|
658
|
+
return s;
|
|
659
|
+
}
|
|
660
|
+
function Q(r) {
|
|
661
|
+
const t = r.type === "contratante" ? "CONTRATANTE" : "CONTRATADO";
|
|
662
|
+
return r.total <= 1 ? `${t}: ` : `${r.index}º ${t}: `;
|
|
663
|
+
}
|
|
664
|
+
function Ft(r) {
|
|
665
|
+
const t = [];
|
|
666
|
+
for (const e of r) {
|
|
667
|
+
const n = e.domNode, s = n.getAttribute("data-parte-type");
|
|
668
|
+
if (!s) continue;
|
|
669
|
+
const i = n.querySelector(".ql-ui");
|
|
670
|
+
let o = n.textContent || "";
|
|
671
|
+
i && i.textContent && (o = o.replace(i.textContent, "")), o = o.trim();
|
|
672
|
+
const l = o.indexOf(","), c = l >= 0 ? o.substring(0, l).trim() : o.trim();
|
|
673
|
+
c && t.push({ nome: c, role: s });
|
|
674
|
+
}
|
|
675
|
+
return t;
|
|
676
|
+
}
|
|
677
|
+
function z(r, t) {
|
|
678
|
+
const e = [], n = t.local || "[Local]", s = t.dataAssinatura || "[Data]";
|
|
679
|
+
e.push(`<div class="ql-assinatura-header">${n}, ${s}</div>`);
|
|
680
|
+
for (const o of r) {
|
|
681
|
+
const l = o.role === "contratante" ? "CONTRATANTE" : "CONTRATADO";
|
|
682
|
+
e.push(
|
|
683
|
+
`<div class="ql-assinatura-line"><div class="ql-assinatura-rule">____________________________________</div><div class="ql-assinatura-nome">${Gt(o.nome)}</div><div class="ql-assinatura-role">${l}</div></div>`
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
const i = t.testemunhas ?? 2;
|
|
687
|
+
if (i > 0) {
|
|
688
|
+
e.push('<div class="ql-assinatura-testemunhas-header">TESTEMUNHAS:</div>');
|
|
689
|
+
for (let o = 1; o <= i; o++)
|
|
690
|
+
e.push(
|
|
691
|
+
`<div class="ql-assinatura-line"><div class="ql-assinatura-rule">____________________________________</div><div class="ql-assinatura-nome">Testemunha ${o}</div><div class="ql-assinatura-role">Nome / CPF</div></div>`
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
return e.join("");
|
|
695
|
+
}
|
|
696
|
+
function Gt(r) {
|
|
697
|
+
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
698
|
+
}
|
|
699
|
+
function Vt(r) {
|
|
700
|
+
this.quill.format("clausula", r || !1);
|
|
701
|
+
}
|
|
702
|
+
const Kt = "[NOME COMPLETO], [NACIONALIDADE], [ESTADO CIVIL], [PROFISSÃO], inscrito(a) no CPF sob o nº [CPF], RG nº [RG], residente e domiciliado(a) em [ENDEREÇO COMPLETO]";
|
|
703
|
+
function Jt(r) {
|
|
704
|
+
if (!r) {
|
|
705
|
+
this.quill.format("parte", !1);
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
this.quill.format("parte", r);
|
|
709
|
+
const t = this.quill.getSelection();
|
|
710
|
+
if (t) {
|
|
711
|
+
const [e] = this.quill.getLine(t.index);
|
|
712
|
+
if (e) {
|
|
713
|
+
const n = e.domNode.querySelector(".ql-ui");
|
|
714
|
+
let s = e.domNode.textContent || "";
|
|
715
|
+
n && n.textContent && (s = s.replace(n.textContent, "")), s.trim() === "" && this.quill.insertText(t.index, Kt, "user");
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
function Qt(r) {
|
|
720
|
+
this.quill.format("objeto", r || !1);
|
|
721
|
+
}
|
|
722
|
+
function zt() {
|
|
723
|
+
const r = this.quill;
|
|
724
|
+
r.focus();
|
|
725
|
+
const t = r.root.querySelector(".ql-assinatura-block");
|
|
726
|
+
if (t) {
|
|
727
|
+
t.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
const e = r.getLength();
|
|
731
|
+
r.insertEmbed(e - 1, "assinatura", {}, "user"), r.setSelection(e, 0, "silent");
|
|
732
|
+
}
|
|
733
|
+
const Xt = [
|
|
734
|
+
// Sub-cláusula must come before cláusula (longer match first)
|
|
735
|
+
[/^sub[- ]?cl[aá]usula$/i, "subclausula"],
|
|
736
|
+
[/^sub$/i, "subclausula"],
|
|
737
|
+
// Cláusula
|
|
738
|
+
[/^cl[aá]usula$/i, "clausula"],
|
|
739
|
+
[/^cl$/i, "clausula"],
|
|
740
|
+
// Parágrafo
|
|
741
|
+
[/^par[aá]grafo$/i, "paragrafo"],
|
|
742
|
+
[/^par$/i, "paragrafo"],
|
|
743
|
+
[/^§$/, "paragrafo"],
|
|
744
|
+
// Inciso
|
|
745
|
+
[/^inciso$/i, "inciso"],
|
|
746
|
+
[/^inc$/i, "inciso"],
|
|
747
|
+
// Alínea
|
|
748
|
+
[/^al[ií]nea$/i, "alinea"],
|
|
749
|
+
[/^al$/i, "alinea"]
|
|
750
|
+
], Yt = [
|
|
751
|
+
[/^contratante$/i, { format: "parte", value: "contratante" }],
|
|
752
|
+
[/^contratado$/i, { format: "parte", value: "contratado" }],
|
|
753
|
+
[/^objeto$/i, { format: "objeto", value: "true" }]
|
|
754
|
+
], Wt = /^\s*?(cl[aá]usula|sub[- ]?cl[aá]usula|sub|cl|par[aá]grafo|par|§|inciso|inc|al[ií]nea|al|contratante|contratado|objeto)$/i;
|
|
755
|
+
function Zt(r) {
|
|
756
|
+
const t = r.trim();
|
|
757
|
+
for (const [e, n] of Xt)
|
|
758
|
+
if (e.test(t)) return n;
|
|
759
|
+
return null;
|
|
760
|
+
}
|
|
761
|
+
function te(r) {
|
|
762
|
+
const t = r.trim();
|
|
763
|
+
for (const [e, n] of Yt)
|
|
764
|
+
if (e.test(t)) return n;
|
|
765
|
+
return null;
|
|
766
|
+
}
|
|
767
|
+
const b = {
|
|
768
|
+
clausula: 0,
|
|
769
|
+
subclausula: 1,
|
|
770
|
+
paragrafo: 1,
|
|
771
|
+
inciso: 2,
|
|
772
|
+
alinea: 3
|
|
773
|
+
}, N = [
|
|
774
|
+
"clausula",
|
|
775
|
+
"subclausula",
|
|
776
|
+
"paragrafo",
|
|
777
|
+
"inciso",
|
|
778
|
+
"alinea"
|
|
779
|
+
], U = {
|
|
780
|
+
clausulaFormat: "extenso",
|
|
781
|
+
subclausulaFormat: "dotted",
|
|
782
|
+
paragrafoFormat: "extenso",
|
|
783
|
+
incisoFormat: "roman",
|
|
784
|
+
alineaFormat: "letter-parenthesis",
|
|
785
|
+
showActions: !0,
|
|
786
|
+
showFloatingBar: !0,
|
|
787
|
+
showDragHandle: !0
|
|
788
|
+
}, ee = ["bold", "italic", "underline"];
|
|
789
|
+
function se(r) {
|
|
790
|
+
const t = {};
|
|
791
|
+
if (!r) return t;
|
|
792
|
+
for (const e of ee)
|
|
793
|
+
r[e] && (t[e] = !0);
|
|
794
|
+
return t;
|
|
795
|
+
}
|
|
796
|
+
function ne(r) {
|
|
797
|
+
if (typeof r == "string")
|
|
798
|
+
try {
|
|
799
|
+
return JSON.parse(r);
|
|
800
|
+
} catch {
|
|
801
|
+
return {};
|
|
802
|
+
}
|
|
803
|
+
return r || {};
|
|
804
|
+
}
|
|
805
|
+
function X(r, t) {
|
|
806
|
+
const e = [];
|
|
807
|
+
let n = [];
|
|
808
|
+
const s = (a) => {
|
|
809
|
+
const d = {
|
|
810
|
+
kind: "text",
|
|
811
|
+
label: "",
|
|
812
|
+
text: n.map((f) => f.text).join(""),
|
|
813
|
+
segments: n
|
|
814
|
+
};
|
|
815
|
+
(a == null ? void 0 : a.locked) === "true" && (d.locked = !0), a != null && a.agreed && typeof a.agreed == "object" && (d.agreed = a.agreed), typeof (a == null ? void 0 : a.lineheight) == "string" && (d.lineHeight = a.lineheight), typeof (a == null ? void 0 : a.spacing) == "string" && (d.spacingAfter = a.spacing), a != null && a.clausula ? (d.kind = "clausula", d.clausulaType = a.clausula) : a != null && a.parte ? (d.kind = "parte", d.parteType = a.parte) : a != null && a.objeto ? d.kind = "objeto" : a != null && a.table && (d.kind = "table-cell", d.tableRow = String(a.table)), e.push(d), n = [];
|
|
816
|
+
};
|
|
817
|
+
for (const a of r.ops || [])
|
|
818
|
+
if (typeof a.insert == "string") {
|
|
819
|
+
const u = a.insert.split(`
|
|
820
|
+
`);
|
|
821
|
+
u.forEach((d, f) => {
|
|
822
|
+
d && n.push({ text: d, ...se(a.attributes) }), f < u.length - 1 && s(a.attributes);
|
|
823
|
+
});
|
|
824
|
+
} else a.insert && typeof a.insert == "object" && "assinatura" in a.insert && e.push({
|
|
825
|
+
kind: "assinatura",
|
|
826
|
+
label: "",
|
|
827
|
+
text: "",
|
|
828
|
+
segments: [],
|
|
829
|
+
assinatura: ne(a.insert.assinatura)
|
|
830
|
+
});
|
|
831
|
+
n.length > 0 && s();
|
|
832
|
+
const i = e.filter((a) => a.kind === "clausula"), o = G(
|
|
833
|
+
i.map((a) => a.clausulaType || null)
|
|
834
|
+
);
|
|
835
|
+
i.forEach((a, u) => {
|
|
836
|
+
a.label = K(o[u], t);
|
|
837
|
+
});
|
|
838
|
+
const l = e.filter((a) => a.kind === "parte"), c = J(
|
|
839
|
+
l.map((a) => a.parteType || null)
|
|
840
|
+
);
|
|
841
|
+
l.forEach((a, u) => {
|
|
842
|
+
a.label = Q(c[u]);
|
|
843
|
+
});
|
|
844
|
+
for (const a of e)
|
|
845
|
+
a.kind === "objeto" && (a.label = "OBJETO: ");
|
|
846
|
+
return e;
|
|
847
|
+
}
|
|
848
|
+
function Y(r) {
|
|
849
|
+
const t = [];
|
|
850
|
+
let e = [], n;
|
|
851
|
+
for (const s of r)
|
|
852
|
+
s.tableRow !== n && e.length > 0 && (t.push(e), e = []), n = s.tableRow, e.push(s);
|
|
853
|
+
return e.length > 0 && t.push(e), t;
|
|
854
|
+
}
|
|
855
|
+
function W(r) {
|
|
856
|
+
const t = [];
|
|
857
|
+
for (const e of r) {
|
|
858
|
+
if (e.kind !== "parte" || !e.parteType) continue;
|
|
859
|
+
const n = e.text.indexOf(","), s = (n >= 0 ? e.text.slice(0, n) : e.text).trim();
|
|
860
|
+
s && t.push({ nome: s, role: e.parteType });
|
|
861
|
+
}
|
|
862
|
+
return t;
|
|
863
|
+
}
|
|
864
|
+
function Z(r) {
|
|
865
|
+
return r.replace(/([\\`*_])/g, "\\$1");
|
|
866
|
+
}
|
|
867
|
+
function re(r) {
|
|
868
|
+
let t = Z(r.text);
|
|
869
|
+
return r.underline && (t = `[${t}]{.underline}`), r.italic && (t = `*${t}*`), r.bold && (t = `**${t}**`), t;
|
|
870
|
+
}
|
|
871
|
+
function H(r) {
|
|
872
|
+
return r.segments.map(re).join("");
|
|
873
|
+
}
|
|
874
|
+
function ie(r, t) {
|
|
875
|
+
const e = [], n = r.local || "[Local]", s = r.dataAssinatura || "[Data]";
|
|
876
|
+
e.push(`${n}, ${s}`);
|
|
877
|
+
const i = "\\_".repeat(36);
|
|
878
|
+
for (const l of t) {
|
|
879
|
+
const c = l.role === "contratante" ? "CONTRATANTE" : "CONTRATADO";
|
|
880
|
+
e.push(`${i}
|
|
881
|
+
${Z(l.nome)}
|
|
882
|
+
${c}`);
|
|
883
|
+
}
|
|
884
|
+
const o = r.testemunhas ?? 2;
|
|
885
|
+
if (o > 0) {
|
|
886
|
+
e.push("TESTEMUNHAS:");
|
|
887
|
+
for (let l = 1; l <= o; l++)
|
|
888
|
+
e.push(`${i}
|
|
889
|
+
Testemunha ${l}
|
|
890
|
+
Nome / CPF`);
|
|
891
|
+
}
|
|
892
|
+
return e.join(`
|
|
893
|
+
|
|
894
|
+
`);
|
|
895
|
+
}
|
|
896
|
+
function oe(r, t) {
|
|
897
|
+
const e = X(r, t), n = W(e), s = [];
|
|
898
|
+
for (let i = 0; i < e.length; i++) {
|
|
899
|
+
const o = e[i];
|
|
900
|
+
if (o.kind === "table-cell") {
|
|
901
|
+
let c = i;
|
|
902
|
+
for (; c < e.length && e[c].kind === "table-cell"; ) c++;
|
|
903
|
+
const a = Y(e.slice(i, c)), u = (p) => `| ${p.map((m) => H(m).replace(/\|/g, "\\|")).join(" | ")} |`, d = Math.max(...a.map((p) => p.length)), f = `|${" --- |".repeat(d)}`;
|
|
904
|
+
s.push(
|
|
905
|
+
[u(a[0]), f, ...a.slice(1).map(u)].join(`
|
|
906
|
+
`)
|
|
907
|
+
), i = c - 1;
|
|
908
|
+
continue;
|
|
909
|
+
}
|
|
910
|
+
const l = H(o);
|
|
911
|
+
switch (o.kind) {
|
|
912
|
+
case "clausula": {
|
|
913
|
+
o.clausulaType === "clausula" ? s.push(`## ${o.label}${l}`) : o.clausulaType === "alinea" ? s.push(`${o.label.replace(")", "\\)")}${l}`) : o.clausulaType === "inciso" ? s.push(`${o.label}${l}`) : s.push(`**${o.label.trim()}** ${l}`);
|
|
914
|
+
break;
|
|
915
|
+
}
|
|
916
|
+
case "parte":
|
|
917
|
+
case "objeto":
|
|
918
|
+
s.push(`**${o.label.trim()}** ${l}`);
|
|
919
|
+
break;
|
|
920
|
+
case "assinatura":
|
|
921
|
+
s.push(ie(o.assinatura || {}, n));
|
|
922
|
+
break;
|
|
923
|
+
default:
|
|
924
|
+
o.text.trim() && s.push(l);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
return s.join(`
|
|
928
|
+
|
|
929
|
+
`) + `
|
|
930
|
+
`;
|
|
931
|
+
}
|
|
932
|
+
function O(r) {
|
|
933
|
+
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
934
|
+
}
|
|
935
|
+
function tt(r) {
|
|
936
|
+
let t = O(r.text);
|
|
937
|
+
return r.underline && (t = `<u>${t}</u>`), r.italic && (t = `<em>${t}</em>`), r.bold && (t = `<strong>${t}</strong>`), t;
|
|
938
|
+
}
|
|
939
|
+
function ae(r, t) {
|
|
940
|
+
const e = r.segments.map(tt).join(""), n = r.label ? `<span class="qc-label">${O(r.label)}</span>` : "", s = [
|
|
941
|
+
r.lineHeight ? `line-height:${r.lineHeight}` : "",
|
|
942
|
+
r.spacingAfter ? `margin-bottom:${r.spacingAfter}` : ""
|
|
943
|
+
].filter(Boolean).join(";"), i = [
|
|
944
|
+
r.locked ? ' data-locked="true"' : "",
|
|
945
|
+
r.agreed ? ` data-agreed='${O(JSON.stringify(r.agreed))}'` : "",
|
|
946
|
+
s ? ` style="${s}"` : ""
|
|
947
|
+
].join("");
|
|
948
|
+
switch (r.kind) {
|
|
949
|
+
case "clausula":
|
|
950
|
+
return `<p class="qc-clausula qc-${r.clausulaType}"${i}>${n}${e}</p>`;
|
|
951
|
+
case "parte":
|
|
952
|
+
return `<p class="qc-parte" data-parte-type="${r.parteType}"${i}>${n}${e}</p>`;
|
|
953
|
+
case "objeto":
|
|
954
|
+
return `<p class="qc-objeto"${i}>${n}${e}</p>`;
|
|
955
|
+
case "assinatura":
|
|
956
|
+
return `<div class="qc-assinatura ql-assinatura-block">${z(
|
|
957
|
+
t,
|
|
958
|
+
r.assinatura || {}
|
|
959
|
+
)}</div>`;
|
|
960
|
+
default:
|
|
961
|
+
return r.text.trim() ? `<p class="qc-text"${i}>${e}</p>` : "";
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
function le(r, t) {
|
|
965
|
+
const e = X(r, t), n = W(e), s = [];
|
|
966
|
+
for (let i = 0; i < e.length; i++) {
|
|
967
|
+
const o = e[i];
|
|
968
|
+
if (o.kind === "table-cell") {
|
|
969
|
+
let c = i;
|
|
970
|
+
for (; c < e.length && e[c].kind === "table-cell"; ) c++;
|
|
971
|
+
const u = Y(e.slice(i, c)).map(
|
|
972
|
+
(d) => `<tr>${d.map((f) => `<td>${f.segments.map(tt).join("")}</td>`).join("")}</tr>`
|
|
973
|
+
).join(`
|
|
974
|
+
`);
|
|
975
|
+
s.push(`<table class="qc-table"><tbody>
|
|
976
|
+
${u}
|
|
977
|
+
</tbody></table>`), i = c - 1;
|
|
978
|
+
continue;
|
|
979
|
+
}
|
|
980
|
+
const l = ae(o, n);
|
|
981
|
+
l && s.push(l);
|
|
982
|
+
}
|
|
983
|
+
return `<div class="qc-document">
|
|
984
|
+
${s.join(`
|
|
985
|
+
`)}
|
|
986
|
+
</div>`;
|
|
987
|
+
}
|
|
988
|
+
const ce = '<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="7" width="10" height="7" rx="1.5"/><path d="M5 7V5a3 3 0 0 1 6 0v2"/></svg>', ue = '<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="3.5 8.5 6.5 11.5 12.5 4.5"/></svg>', de = '<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="4" x2="12" y2="12"/><line x1="12" y1="4" x2="4" y2="12"/></svg>', he = '<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M2 3h12v8H6l-3 2.5V11H2z"/><circle cx="5.5" cy="7" r="0.5" fill="currentColor" stroke="none"/><circle cx="8" cy="7" r="0.5" fill="currentColor" stroke="none"/><circle cx="10.5" cy="7" r="0.5" fill="currentColor" stroke="none"/></svg>';
|
|
989
|
+
function fe(r) {
|
|
990
|
+
const t = r.createElement("div");
|
|
991
|
+
t.className = "ql-clausula-actions", t.setAttribute("contenteditable", "false");
|
|
992
|
+
const e = r.createElement("button");
|
|
993
|
+
e.className = "ql-clausula-btn ql-clausula-lock", e.setAttribute("tabindex", "-1"), e.setAttribute("type", "button"), e.setAttribute("title", "Lock"), e.innerHTML = ce;
|
|
994
|
+
const n = r.createElement("button");
|
|
995
|
+
n.className = "ql-clausula-btn ql-clausula-agree", n.setAttribute("tabindex", "-1"), n.setAttribute("type", "button"), n.setAttribute("title", "Agree"), n.innerHTML = ue;
|
|
996
|
+
const s = r.createElement("button");
|
|
997
|
+
s.className = "ql-clausula-btn ql-clausula-disagree", s.setAttribute("tabindex", "-1"), s.setAttribute("type", "button"), s.setAttribute("title", "Disagree"), s.innerHTML = de;
|
|
998
|
+
const i = r.createElement("button");
|
|
999
|
+
return i.className = "ql-clausula-btn ql-clausula-conversation", i.setAttribute("tabindex", "-1"), i.setAttribute("type", "button"), i.setAttribute("title", "Conversation"), i.innerHTML = he, t.appendChild(e), t.appendChild(n), t.appendChild(s), t.appendChild(i), t;
|
|
1000
|
+
}
|
|
1001
|
+
function ge(r, t, e, n, s) {
|
|
1002
|
+
const i = r.querySelector(".ql-clausula-lock"), o = r.querySelector(".ql-clausula-agree"), l = r.querySelector(".ql-clausula-disagree");
|
|
1003
|
+
if (!i || !o || !l) return;
|
|
1004
|
+
const c = t.classList.contains("ql-locked-true");
|
|
1005
|
+
if (i.classList.toggle("active", c), o.disabled = c, l.disabled = c, !e) {
|
|
1006
|
+
o.classList.remove("active"), l.classList.remove("active");
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
const a = t.getAttribute("data-clausula-type");
|
|
1010
|
+
if ((a ? b[a] === 0 : !1) && s && s.length > 0) {
|
|
1011
|
+
const d = n || [e], f = s.every((m) => {
|
|
1012
|
+
const L = m.getAttribute("data-agreed");
|
|
1013
|
+
if (!L) return !1;
|
|
1014
|
+
try {
|
|
1015
|
+
const D = JSON.parse(L);
|
|
1016
|
+
return d.every((et) => D[et] === !0);
|
|
1017
|
+
} catch {
|
|
1018
|
+
return !1;
|
|
1019
|
+
}
|
|
1020
|
+
}), p = s.some((m) => {
|
|
1021
|
+
const L = m.getAttribute("data-agreed");
|
|
1022
|
+
if (!L) return !1;
|
|
1023
|
+
try {
|
|
1024
|
+
return JSON.parse(L)[e] === !1;
|
|
1025
|
+
} catch {
|
|
1026
|
+
return !1;
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
1029
|
+
o.classList.toggle("active", f), l.classList.toggle("active", p), t.classList.toggle("ql-agreed", f), t.classList.toggle("ql-disagreed", p);
|
|
1030
|
+
} else {
|
|
1031
|
+
const d = t.getAttribute("data-agreed");
|
|
1032
|
+
let f = !1, p = !1;
|
|
1033
|
+
if (d)
|
|
1034
|
+
try {
|
|
1035
|
+
const m = JSON.parse(d);
|
|
1036
|
+
f = m[e] === !0, p = m[e] === !1;
|
|
1037
|
+
} catch {
|
|
1038
|
+
}
|
|
1039
|
+
o.classList.toggle("active", f), l.classList.toggle("active", p), t.classList.toggle("ql-disagreed", p);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
const pe = '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/></svg>', me = '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 12 9 17 20 6"/></svg>', be = '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>', ye = '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>', ve = '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="5" r="3"/><path d="M12 8v4"/><line x1="5" y1="12" x2="19" y2="12"/><line x1="5" y1="12" x2="5" y2="16"/><line x1="19" y1="12" x2="19" y2="16"/><line x1="12" y1="12" x2="12" y2="20"/><rect x="8" y="20" width="8" height="2" rx="1"/></svg>', Ae = '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" y1="13.51" x2="15.42" y2="17.49"/><line x1="15.41" y1="6.51" x2="8.59" y2="10.49"/></svg>', ke = '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3l4 4-10 10H7v-4L17 3z"/><path d="M2 21h20"/><path d="M14 7l4 4"/></svg>';
|
|
1043
|
+
function xe(r, t) {
|
|
1044
|
+
const e = r.createElement("div");
|
|
1045
|
+
e.className = "ql-clausula-floating-bar", e.setAttribute("contenteditable", "false");
|
|
1046
|
+
const n = [
|
|
1047
|
+
{ className: "ql-floating-undo", title: "Undo / Remake Contract", svg: pe, callback: t.onUndo },
|
|
1048
|
+
{ className: "ql-floating-agree-all", title: "Agree to All", svg: me, callback: t.onAgreeAll },
|
|
1049
|
+
{ className: "ql-floating-disagree-all", title: "Disagree to All", svg: be, callback: t.onDisagreeAll },
|
|
1050
|
+
{ className: "ql-floating-lock-all", title: "Lock All", svg: ye, callback: t.onLockAll },
|
|
1051
|
+
{ className: "ql-floating-judge", title: "AI Judge", svg: ve, callback: t.onJudge },
|
|
1052
|
+
{ className: "ql-floating-share", title: "Share", svg: Ae, callback: t.onShare },
|
|
1053
|
+
{ className: "ql-floating-sign", title: "Sign Contract", svg: ke, callback: t.onSign }
|
|
1054
|
+
];
|
|
1055
|
+
for (const s of n) {
|
|
1056
|
+
const i = r.createElement("button");
|
|
1057
|
+
i.className = `ql-floating-btn ${s.className}`, i.setAttribute("type", "button"), i.setAttribute("title", s.title), i.innerHTML = s.svg, s.callback && i.addEventListener("click", (o) => {
|
|
1058
|
+
o.preventDefault(), s.callback();
|
|
1059
|
+
}), e.appendChild(i);
|
|
1060
|
+
}
|
|
1061
|
+
return e;
|
|
1062
|
+
}
|
|
1063
|
+
function qe(r, t, e) {
|
|
1064
|
+
const n = r.createElement("div");
|
|
1065
|
+
n.className = "ql-clausula-modal-overlay";
|
|
1066
|
+
const s = r.createElement("div");
|
|
1067
|
+
s.className = "ql-clausula-modal";
|
|
1068
|
+
const i = r.createElement("h3");
|
|
1069
|
+
i.className = "ql-clausula-modal-title", i.textContent = "Remake Contract";
|
|
1070
|
+
const o = r.createElement("p");
|
|
1071
|
+
o.className = "ql-clausula-modal-message", o.textContent = "This will undo all agreements, disagreements, and locks on the entire contract. Are you sure you want to proceed?";
|
|
1072
|
+
const l = r.createElement("div");
|
|
1073
|
+
l.className = "ql-clausula-modal-actions";
|
|
1074
|
+
const c = r.createElement("button");
|
|
1075
|
+
c.className = "ql-clausula-modal-btn ql-clausula-modal-cancel", c.setAttribute("type", "button"), c.textContent = "Cancel", c.addEventListener("click", () => {
|
|
1076
|
+
n.remove(), e();
|
|
1077
|
+
});
|
|
1078
|
+
const a = r.createElement("button");
|
|
1079
|
+
return a.className = "ql-clausula-modal-btn ql-clausula-modal-confirm", a.setAttribute("type", "button"), a.textContent = "Confirm", a.addEventListener("click", () => {
|
|
1080
|
+
n.remove(), t();
|
|
1081
|
+
}), l.appendChild(c), l.appendChild(a), s.appendChild(i), s.appendChild(o), s.appendChild(l), n.appendChild(s), n.addEventListener("click", (u) => {
|
|
1082
|
+
u.target === n && (n.remove(), e());
|
|
1083
|
+
}), n;
|
|
1084
|
+
}
|
|
1085
|
+
function Le(r, t) {
|
|
1086
|
+
if (t.length === 0 || r.length === 0) return !1;
|
|
1087
|
+
const e = (s) => {
|
|
1088
|
+
const i = s.getAttribute("data-clausula-type");
|
|
1089
|
+
return i ? b[i] === 0 : !1;
|
|
1090
|
+
}, n = r.filter((s, i) => {
|
|
1091
|
+
if (!e(s)) return !0;
|
|
1092
|
+
const o = r[i + 1];
|
|
1093
|
+
return o === void 0 || e(o);
|
|
1094
|
+
});
|
|
1095
|
+
return n.length === 0 ? !1 : n.every((s) => {
|
|
1096
|
+
const i = s.getAttribute("data-agreed");
|
|
1097
|
+
if (!i) return !1;
|
|
1098
|
+
try {
|
|
1099
|
+
const o = JSON.parse(i);
|
|
1100
|
+
return t.every((l) => o[l] === !0);
|
|
1101
|
+
} catch {
|
|
1102
|
+
return !1;
|
|
1103
|
+
}
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
const Ne = h.import("core/module"), g = h.sources || { USER: "user", SILENT: "silent", API: "api" }, P = class P extends Ne {
|
|
1107
|
+
constructor(t, e) {
|
|
1108
|
+
super(t, e), this.renumberScheduled = !1, this.rafId = null, this.destroyed = !1, this.floatingBar = null, this.ghostCut = null, this.dragOrganizer = null, this.textChangeRenumber = () => this.scheduleRenumber(), this.lockedRevertHandler = (s, i, o) => {
|
|
1109
|
+
var l, c;
|
|
1110
|
+
if (o === g.USER && this.doesDeltaTouchLockedLine(s, i)) {
|
|
1111
|
+
const a = s.invert(i);
|
|
1112
|
+
this.quill.updateContents(a, g.API);
|
|
1113
|
+
const u = (l = this.quill.history) == null ? void 0 : l.stack;
|
|
1114
|
+
(c = u == null ? void 0 : u.undo) != null && c.length && u.undo.pop();
|
|
1115
|
+
}
|
|
1116
|
+
}, this.beforeInputHandler = (s) => {
|
|
1117
|
+
this.isSelectionOnLockedLine() && s.preventDefault();
|
|
1118
|
+
}, this.pasteHandler = (s) => {
|
|
1119
|
+
var i;
|
|
1120
|
+
if (this.isSelectionOnLockedLine()) {
|
|
1121
|
+
s.preventDefault();
|
|
1122
|
+
return;
|
|
1123
|
+
}
|
|
1124
|
+
(i = this.ghostCut) == null || i.handlePaste(s);
|
|
1125
|
+
}, this.cutHandler = (s) => {
|
|
1126
|
+
var i;
|
|
1127
|
+
(i = this.ghostCut) == null || i.handleCut(s);
|
|
1128
|
+
}, this.options = { ...U, ...e };
|
|
1129
|
+
const n = t.getModule("toolbar");
|
|
1130
|
+
n && (n.addHandler("clausula", Vt), n.addHandler("parte", Jt), n.addHandler("objeto", Qt), n.addHandler("assinatura", zt), this.enhanceToolbar(n)), this.addKeyboardBindings(), t.on("text-change", this.textChangeRenumber), this.ghostCut = new Lt(t, {
|
|
1131
|
+
isRangeLocked: (s, i) => this.isRangeLocked(s, i)
|
|
1132
|
+
}), this.addLockedLinePrevention(), this.options.showDragHandle !== !1 && (this.dragOrganizer = new Ct(t, {
|
|
1133
|
+
getBlocks: () => this.getClausulaBlocks(),
|
|
1134
|
+
moveBlock: (s, i) => this.moveClausulaBlock(s, i)
|
|
1135
|
+
})), this.options.showFloatingBar !== !1 && this.initFloatingBar(), this.scheduleRenumber();
|
|
1136
|
+
}
|
|
1137
|
+
static register() {
|
|
1138
|
+
h.register(E, !0), h.register(y, !0), h.register(T, !0), h.register(v, !0), h.register(I, !0), h.register(A, !0), h.register(C, !0), h.register(dt, !0), h.register(pt, !0), h.register(yt, !0), h.register(kt, !0), h.register(xt, !0);
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* Detaches all listeners and overlay DOM. Call when unmounting the editor
|
|
1142
|
+
* (SPAs); the module must not be used afterwards.
|
|
1143
|
+
*/
|
|
1144
|
+
destroy() {
|
|
1145
|
+
var e, n, s;
|
|
1146
|
+
this.destroyed = !0, this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null), this.quill.off("text-change", this.textChangeRenumber), this.quill.off("text-change", this.lockedRevertHandler);
|
|
1147
|
+
const t = this.quill.root;
|
|
1148
|
+
t.removeEventListener("beforeinput", this.beforeInputHandler, !0), t.removeEventListener("paste", this.pasteHandler, !0), t.removeEventListener("cut", this.cutHandler, !0), (e = this.ghostCut) == null || e.destroy(), this.ghostCut = null, (n = this.dragOrganizer) == null || n.destroy(), this.dragOrganizer = null, (s = this.floatingBar) == null || s.remove(), this.floatingBar = null;
|
|
1149
|
+
for (const i of t.querySelectorAll(".ql-clausula-actions"))
|
|
1150
|
+
i.remove();
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Add tooltips and visual enhancements to toolbar controls.
|
|
1154
|
+
*/
|
|
1155
|
+
enhanceToolbar(t) {
|
|
1156
|
+
const e = t.container;
|
|
1157
|
+
if (!e) return;
|
|
1158
|
+
const n = e.querySelector(".ql-clausula");
|
|
1159
|
+
n && n.setAttribute("title", "Tipo de cláusula (ou digite: cl, par, inc, al + Espaço)");
|
|
1160
|
+
const s = e.querySelector(".ql-picker.ql-parte");
|
|
1161
|
+
s && s.setAttribute("title", "Partes do contrato (ou digite: contratante, contratado + Espaço)");
|
|
1162
|
+
const i = e.querySelector(".ql-objeto");
|
|
1163
|
+
i && i.setAttribute("title", "Inserir OBJETO do contrato (ou digite: objeto + Espaço)");
|
|
1164
|
+
const o = e.querySelector(".ql-assinatura");
|
|
1165
|
+
o && o.setAttribute("title", "Inserir bloco de assinaturas");
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Prepend a binding so it fires before Quill's built-in handlers.
|
|
1169
|
+
* Quill's addBinding() uses push(), so built-in Backspace/Enter handlers
|
|
1170
|
+
* consume events before late-registered bindings. We unshift instead.
|
|
1171
|
+
*/
|
|
1172
|
+
prependBinding(t, e, n) {
|
|
1173
|
+
t.bindings[e] = t.bindings[e] || [], t.bindings[e].unshift(n);
|
|
1174
|
+
}
|
|
1175
|
+
removeClausulaFormat() {
|
|
1176
|
+
this.quill.format("clausula", !1, g.USER);
|
|
1177
|
+
}
|
|
1178
|
+
removeParteFormat() {
|
|
1179
|
+
this.quill.format("parte", !1, g.USER);
|
|
1180
|
+
}
|
|
1181
|
+
removeObjetoFormat() {
|
|
1182
|
+
this.quill.format("objeto", !1, g.USER);
|
|
1183
|
+
}
|
|
1184
|
+
addKeyboardBindings() {
|
|
1185
|
+
const t = this.quill.getModule("keyboard"), e = this;
|
|
1186
|
+
this.prependBinding(t, "Enter", {
|
|
1187
|
+
key: "Enter",
|
|
1188
|
+
collapsed: !0,
|
|
1189
|
+
empty: !0,
|
|
1190
|
+
format: ["clausula"],
|
|
1191
|
+
handler() {
|
|
1192
|
+
return e.removeClausulaFormat(), !1;
|
|
1193
|
+
}
|
|
1194
|
+
}), this.prependBinding(t, "Backspace", {
|
|
1195
|
+
key: "Backspace",
|
|
1196
|
+
collapsed: !0,
|
|
1197
|
+
offset: 0,
|
|
1198
|
+
format: ["clausula"],
|
|
1199
|
+
shiftKey: null,
|
|
1200
|
+
metaKey: null,
|
|
1201
|
+
ctrlKey: null,
|
|
1202
|
+
altKey: null,
|
|
1203
|
+
handler() {
|
|
1204
|
+
return e.removeClausulaFormat(), !1;
|
|
1205
|
+
}
|
|
1206
|
+
}), this.prependBinding(t, "Delete", {
|
|
1207
|
+
key: "Delete",
|
|
1208
|
+
collapsed: !0,
|
|
1209
|
+
empty: !0,
|
|
1210
|
+
format: ["clausula"],
|
|
1211
|
+
shiftKey: null,
|
|
1212
|
+
metaKey: null,
|
|
1213
|
+
ctrlKey: null,
|
|
1214
|
+
altKey: null,
|
|
1215
|
+
handler() {
|
|
1216
|
+
return e.removeClausulaFormat(), !1;
|
|
1217
|
+
}
|
|
1218
|
+
}), this.prependBinding(t, "Tab", {
|
|
1219
|
+
key: "Tab",
|
|
1220
|
+
format: ["clausula"],
|
|
1221
|
+
handler(n, s) {
|
|
1222
|
+
if (s.collapsed && s.offset !== 0) return !0;
|
|
1223
|
+
const i = s.format.clausula, o = N.indexOf(i);
|
|
1224
|
+
return o < N.length - 1 && e.quill.format("clausula", N[o + 1], g.USER), !1;
|
|
1225
|
+
}
|
|
1226
|
+
}), this.prependBinding(t, "Tab", {
|
|
1227
|
+
key: "Tab",
|
|
1228
|
+
shiftKey: !0,
|
|
1229
|
+
format: ["clausula"],
|
|
1230
|
+
handler(n, s) {
|
|
1231
|
+
if (s.collapsed && s.offset !== 0) return !0;
|
|
1232
|
+
const i = s.format.clausula, o = N.indexOf(i);
|
|
1233
|
+
return o > 0 ? e.quill.format("clausula", N[o - 1], g.USER) : e.removeClausulaFormat(), !1;
|
|
1234
|
+
}
|
|
1235
|
+
}), this.prependBinding(t, "Enter", {
|
|
1236
|
+
key: "Enter",
|
|
1237
|
+
collapsed: !0,
|
|
1238
|
+
empty: !0,
|
|
1239
|
+
format: ["parte"],
|
|
1240
|
+
handler() {
|
|
1241
|
+
return e.removeParteFormat(), !1;
|
|
1242
|
+
}
|
|
1243
|
+
}), this.prependBinding(t, "Backspace", {
|
|
1244
|
+
key: "Backspace",
|
|
1245
|
+
collapsed: !0,
|
|
1246
|
+
offset: 0,
|
|
1247
|
+
format: ["parte"],
|
|
1248
|
+
shiftKey: null,
|
|
1249
|
+
metaKey: null,
|
|
1250
|
+
ctrlKey: null,
|
|
1251
|
+
altKey: null,
|
|
1252
|
+
handler() {
|
|
1253
|
+
return e.removeParteFormat(), !1;
|
|
1254
|
+
}
|
|
1255
|
+
}), this.prependBinding(t, "Tab", {
|
|
1256
|
+
key: "Tab",
|
|
1257
|
+
format: ["parte"],
|
|
1258
|
+
handler(n, s) {
|
|
1259
|
+
const o = s.format.parte === "contratante" ? "contratado" : "contratante";
|
|
1260
|
+
return e.quill.format("parte", o, g.USER), !1;
|
|
1261
|
+
}
|
|
1262
|
+
}), this.prependBinding(t, "Enter", {
|
|
1263
|
+
key: "Enter",
|
|
1264
|
+
collapsed: !0,
|
|
1265
|
+
empty: !0,
|
|
1266
|
+
format: ["objeto"],
|
|
1267
|
+
handler() {
|
|
1268
|
+
return e.removeObjetoFormat(), !1;
|
|
1269
|
+
}
|
|
1270
|
+
}), this.prependBinding(t, "Backspace", {
|
|
1271
|
+
key: "Backspace",
|
|
1272
|
+
collapsed: !0,
|
|
1273
|
+
offset: 0,
|
|
1274
|
+
format: ["objeto"],
|
|
1275
|
+
shiftKey: null,
|
|
1276
|
+
metaKey: null,
|
|
1277
|
+
ctrlKey: null,
|
|
1278
|
+
altKey: null,
|
|
1279
|
+
handler() {
|
|
1280
|
+
return e.removeObjetoFormat(), !1;
|
|
1281
|
+
}
|
|
1282
|
+
}), this.prependBinding(t, "Escape", {
|
|
1283
|
+
key: "Escape",
|
|
1284
|
+
handler() {
|
|
1285
|
+
return !(e.ghostCut && e.ghostCut.cancel());
|
|
1286
|
+
}
|
|
1287
|
+
}), this.prependBinding(t, " ", {
|
|
1288
|
+
key: " ",
|
|
1289
|
+
shiftKey: null,
|
|
1290
|
+
collapsed: !0,
|
|
1291
|
+
format: {
|
|
1292
|
+
"code-block": !1,
|
|
1293
|
+
blockquote: !1,
|
|
1294
|
+
table: !1,
|
|
1295
|
+
clausula: !1,
|
|
1296
|
+
parte: !1,
|
|
1297
|
+
objeto: !1
|
|
1298
|
+
},
|
|
1299
|
+
prefix: Wt,
|
|
1300
|
+
handler(n, s) {
|
|
1301
|
+
const i = s.prefix, o = Zt(i), l = te(i);
|
|
1302
|
+
if (!o && !l) return !0;
|
|
1303
|
+
const c = o ? "clausula" : l.format, a = o || l.value, { length: u } = i, [d, f] = e.quill.getLine(n.index);
|
|
1304
|
+
if (f > u) return !0;
|
|
1305
|
+
e.quill.insertText(n.index, " ", g.USER), e.quill.history.cutoff();
|
|
1306
|
+
const p = new (e.quill.constructor.import("delta"))().retain(n.index - f).delete(u + 1).retain(d.length() - 2 - f).retain(1, { [c]: a });
|
|
1307
|
+
return e.quill.updateContents(p, g.USER), e.quill.history.cutoff(), e.quill.setSelection(n.index - u, g.SILENT), !1;
|
|
1308
|
+
}
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
addLockedLinePrevention() {
|
|
1312
|
+
const t = this.quill.root;
|
|
1313
|
+
t.addEventListener("beforeinput", this.beforeInputHandler, !0), t.addEventListener("paste", this.pasteHandler, !0), t.addEventListener("cut", this.cutHandler, !0), this.quill.on("text-change", this.lockedRevertHandler);
|
|
1314
|
+
}
|
|
1315
|
+
isRangeLocked(t, e) {
|
|
1316
|
+
return this.quill.getLines(t, Math.max(e, 1)).some(
|
|
1317
|
+
(s) => {
|
|
1318
|
+
var i;
|
|
1319
|
+
return (i = s == null ? void 0 : s.domNode) == null ? void 0 : i.classList.contains("ql-locked-true");
|
|
1320
|
+
}
|
|
1321
|
+
);
|
|
1322
|
+
}
|
|
1323
|
+
isSelectionOnLockedLine() {
|
|
1324
|
+
const t = this.quill.getSelection();
|
|
1325
|
+
return t ? this.isRangeLocked(t.index, t.length) : !1;
|
|
1326
|
+
}
|
|
1327
|
+
/**
|
|
1328
|
+
* Checks the change against the OLD document (via oldDelta attributes),
|
|
1329
|
+
* so it still detects edits that deleted or merged away a locked line.
|
|
1330
|
+
* Line attributes live on the trailing \n of each line in the delta.
|
|
1331
|
+
*/
|
|
1332
|
+
doesDeltaTouchLockedLine(t, e) {
|
|
1333
|
+
var c;
|
|
1334
|
+
const n = [];
|
|
1335
|
+
let s = 0, i = 0;
|
|
1336
|
+
for (const a of e.ops)
|
|
1337
|
+
if (typeof a.insert == "string") {
|
|
1338
|
+
let u = 0, d = a.insert.indexOf(`
|
|
1339
|
+
`);
|
|
1340
|
+
for (; d !== -1; ) {
|
|
1341
|
+
const f = s + d;
|
|
1342
|
+
n.push({
|
|
1343
|
+
start: i,
|
|
1344
|
+
end: f,
|
|
1345
|
+
locked: ((c = a.attributes) == null ? void 0 : c.locked) === "true"
|
|
1346
|
+
}), i = f + 1, u = d + 1, d = a.insert.indexOf(`
|
|
1347
|
+
`, u);
|
|
1348
|
+
}
|
|
1349
|
+
s += a.insert.length;
|
|
1350
|
+
} else a.insert && (s += 1);
|
|
1351
|
+
const o = (a, u) => n.some((d) => d.locked && a <= d.end && u >= d.start);
|
|
1352
|
+
let l = 0;
|
|
1353
|
+
for (const a of t.ops)
|
|
1354
|
+
if (a.retain && !a.attributes)
|
|
1355
|
+
l += a.retain;
|
|
1356
|
+
else if (a.delete) {
|
|
1357
|
+
if (o(l, l + a.delete - 1)) return !0;
|
|
1358
|
+
l += a.delete;
|
|
1359
|
+
} else if (a.retain && a.attributes) {
|
|
1360
|
+
if (o(l, l + a.retain - 1)) return !0;
|
|
1361
|
+
l += a.retain;
|
|
1362
|
+
} else if (a.insert && o(l, l))
|
|
1363
|
+
return !0;
|
|
1364
|
+
return !1;
|
|
1365
|
+
}
|
|
1366
|
+
initFloatingBar() {
|
|
1367
|
+
const t = this.quill.root.ownerDocument, e = this.quill.container;
|
|
1368
|
+
this.floatingBar = xe(t, {
|
|
1369
|
+
onUndo: () => this.handleGlobalUndo(),
|
|
1370
|
+
onAgreeAll: () => this.handleGlobalAgree(),
|
|
1371
|
+
onDisagreeAll: () => this.handleGlobalDisagree(),
|
|
1372
|
+
onLockAll: () => this.handleGlobalLock(),
|
|
1373
|
+
onJudge: () => {
|
|
1374
|
+
var n, s;
|
|
1375
|
+
return (s = (n = this.options).onJudge) == null ? void 0 : s.call(n);
|
|
1376
|
+
},
|
|
1377
|
+
onShare: () => {
|
|
1378
|
+
var n, s;
|
|
1379
|
+
return (s = (n = this.options).onShare) == null ? void 0 : s.call(n);
|
|
1380
|
+
},
|
|
1381
|
+
onSign: () => {
|
|
1382
|
+
var n, s;
|
|
1383
|
+
return (s = (n = this.options).onSign) == null ? void 0 : s.call(n);
|
|
1384
|
+
}
|
|
1385
|
+
}), e.appendChild(this.floatingBar);
|
|
1386
|
+
}
|
|
1387
|
+
getAllItems() {
|
|
1388
|
+
const t = this.quill.scroll.descendants(y), e = [];
|
|
1389
|
+
for (const n of t) {
|
|
1390
|
+
if (!n.children) continue;
|
|
1391
|
+
let s = n.children.head;
|
|
1392
|
+
for (; s; )
|
|
1393
|
+
e.push(s), s = s.next;
|
|
1394
|
+
}
|
|
1395
|
+
return e;
|
|
1396
|
+
}
|
|
1397
|
+
getAllParteItems() {
|
|
1398
|
+
const t = this.quill.scroll.descendants(v), e = [];
|
|
1399
|
+
for (const n of t) {
|
|
1400
|
+
if (!n.children) continue;
|
|
1401
|
+
let s = n.children.head;
|
|
1402
|
+
for (; s; )
|
|
1403
|
+
e.push(s), s = s.next;
|
|
1404
|
+
}
|
|
1405
|
+
return e;
|
|
1406
|
+
}
|
|
1407
|
+
getAllObjetoItems() {
|
|
1408
|
+
const t = this.quill.scroll.descendants(A), e = [];
|
|
1409
|
+
for (const n of t) {
|
|
1410
|
+
if (!n.children) continue;
|
|
1411
|
+
let s = n.children.head;
|
|
1412
|
+
for (; s; )
|
|
1413
|
+
e.push(s), s = s.next;
|
|
1414
|
+
}
|
|
1415
|
+
return e;
|
|
1416
|
+
}
|
|
1417
|
+
handleGlobalUndo() {
|
|
1418
|
+
const t = this.quill.root.ownerDocument;
|
|
1419
|
+
if (t.querySelector(".ql-clausula-modal-overlay")) return;
|
|
1420
|
+
const e = qe(
|
|
1421
|
+
t,
|
|
1422
|
+
() => {
|
|
1423
|
+
const n = this.getAllItems();
|
|
1424
|
+
for (const s of n) {
|
|
1425
|
+
const i = this.quill.getIndex(s);
|
|
1426
|
+
this.quill.formatLine(i, 1, "locked", !1, g.API), this.quill.formatLine(i, 1, "agreed", !1, g.API);
|
|
1427
|
+
}
|
|
1428
|
+
this.scheduleRenumber();
|
|
1429
|
+
},
|
|
1430
|
+
() => {
|
|
1431
|
+
}
|
|
1432
|
+
);
|
|
1433
|
+
t.body.appendChild(e);
|
|
1434
|
+
}
|
|
1435
|
+
handleGlobalAgree() {
|
|
1436
|
+
const t = this.options.currentUser;
|
|
1437
|
+
if (!t) return;
|
|
1438
|
+
const e = this.getAllItems();
|
|
1439
|
+
for (const n of e)
|
|
1440
|
+
n.domNode.classList.contains("ql-locked-true") || this.isParentWithChildren(n, e) || this.setAgreed(n, t, !0);
|
|
1441
|
+
this.scheduleRenumber();
|
|
1442
|
+
}
|
|
1443
|
+
handleGlobalDisagree() {
|
|
1444
|
+
const t = this.options.currentUser;
|
|
1445
|
+
if (!t) return;
|
|
1446
|
+
const e = this.getAllItems();
|
|
1447
|
+
for (const n of e)
|
|
1448
|
+
n.domNode.classList.contains("ql-locked-true") || this.isParentWithChildren(n, e) || this.setAgreed(n, t, !1);
|
|
1449
|
+
this.scheduleRenumber();
|
|
1450
|
+
}
|
|
1451
|
+
handleGlobalLock() {
|
|
1452
|
+
const t = this.getAllItems(), n = t.some(
|
|
1453
|
+
(s) => !s.domNode.classList.contains("ql-locked-true")
|
|
1454
|
+
) ? "true" : !1;
|
|
1455
|
+
for (const s of t) {
|
|
1456
|
+
const i = this.quill.getIndex(s);
|
|
1457
|
+
this.quill.formatLine(i, 1, "locked", n, g.API);
|
|
1458
|
+
}
|
|
1459
|
+
this.scheduleRenumber();
|
|
1460
|
+
}
|
|
1461
|
+
syncFloatingBar() {
|
|
1462
|
+
if (!this.floatingBar) return;
|
|
1463
|
+
const t = this.floatingBar.querySelector(".ql-floating-sign");
|
|
1464
|
+
if (!t) return;
|
|
1465
|
+
const n = this.getAllItems().map((o) => o.domNode), s = this.options.users || (this.options.currentUser ? [this.options.currentUser] : []), i = Le(n, s);
|
|
1466
|
+
t.disabled = !i, t.classList.toggle("ready", i);
|
|
1467
|
+
}
|
|
1468
|
+
scheduleRenumber() {
|
|
1469
|
+
this.renumberScheduled || this.destroyed || (this.renumberScheduled = !0, this.rafId = requestAnimationFrame(() => {
|
|
1470
|
+
this.rafId = null, this.renumberScheduled = !1, !this.destroyed && (this.renumber(), this.renumberPartes(), this.enforceSingletonObjeto(), this.syncAssinatura());
|
|
1471
|
+
}));
|
|
1472
|
+
}
|
|
1473
|
+
/**
|
|
1474
|
+
* Exports the current document as pandoc-friendly Markdown with all
|
|
1475
|
+
* numbering labels materialized (suitable for MD → DOCX pipelines).
|
|
1476
|
+
*/
|
|
1477
|
+
exportMarkdown() {
|
|
1478
|
+
return oe(this.quill.getContents(), this.options);
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* Exports the current document as clean HTML with all numbering labels
|
|
1482
|
+
* materialized (suitable for print/PDF/read-only display).
|
|
1483
|
+
*/
|
|
1484
|
+
exportHTML() {
|
|
1485
|
+
return le(this.quill.getContents(), this.options);
|
|
1486
|
+
}
|
|
1487
|
+
renumber() {
|
|
1488
|
+
const t = this.quill.scroll.descendants(
|
|
1489
|
+
y
|
|
1490
|
+
), e = [];
|
|
1491
|
+
for (const s of t) {
|
|
1492
|
+
if (!s.children) continue;
|
|
1493
|
+
let i = s.children.head;
|
|
1494
|
+
for (; i; )
|
|
1495
|
+
e.push(i), i = i.next;
|
|
1496
|
+
}
|
|
1497
|
+
const n = St(e);
|
|
1498
|
+
e.forEach((s, i) => {
|
|
1499
|
+
const o = n[i];
|
|
1500
|
+
if (!o) return;
|
|
1501
|
+
const l = K(o, this.options), c = s.domNode.querySelector(".ql-ui");
|
|
1502
|
+
c && c.textContent !== l && (c.textContent = l);
|
|
1503
|
+
}), this.options.showActions !== !1 && this.updateActions(e), this.syncFloatingBar();
|
|
1504
|
+
}
|
|
1505
|
+
renumberPartes() {
|
|
1506
|
+
const t = this.getAllParteItems();
|
|
1507
|
+
if (t.length === 0) return;
|
|
1508
|
+
const e = jt(t);
|
|
1509
|
+
t.forEach((n, s) => {
|
|
1510
|
+
const i = e[s];
|
|
1511
|
+
if (!i) return;
|
|
1512
|
+
const o = Q(i), l = n.domNode.querySelector(".ql-ui");
|
|
1513
|
+
l && l.textContent !== o && (l.textContent = o);
|
|
1514
|
+
});
|
|
1515
|
+
}
|
|
1516
|
+
enforceSingletonObjeto() {
|
|
1517
|
+
const t = this.getAllObjetoItems();
|
|
1518
|
+
if (t.length > 1)
|
|
1519
|
+
for (let e = 1; e < t.length; e++) {
|
|
1520
|
+
const n = this.quill.getIndex(t[e]);
|
|
1521
|
+
this.quill.formatLine(n, 1, "objeto", !1, g.API);
|
|
1522
|
+
}
|
|
1523
|
+
this.syncObjetoButton(t.length > 0);
|
|
1524
|
+
}
|
|
1525
|
+
syncObjetoButton(t) {
|
|
1526
|
+
const e = this.quill.getModule("toolbar");
|
|
1527
|
+
if (!e || !e.container) return;
|
|
1528
|
+
const n = e.container.querySelector(".ql-objeto");
|
|
1529
|
+
n && n.classList.toggle("ql-active", t);
|
|
1530
|
+
}
|
|
1531
|
+
syncAssinatura() {
|
|
1532
|
+
const t = this.quill.scroll.descendants(C);
|
|
1533
|
+
if (t.length === 0) return;
|
|
1534
|
+
const e = this.getAllParteItems(), n = Ft(e);
|
|
1535
|
+
for (const s of t) {
|
|
1536
|
+
const i = C.value(s.domNode), o = z(n, i);
|
|
1537
|
+
s.domNode.innerHTML !== o && (s.domNode.innerHTML = o);
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
updateActions(t) {
|
|
1541
|
+
const e = this.quill.root.ownerDocument;
|
|
1542
|
+
for (const n of t) {
|
|
1543
|
+
const s = n.domNode;
|
|
1544
|
+
let i = s.querySelector(".ql-clausula-actions");
|
|
1545
|
+
i || (i = fe(e), s.appendChild(i), n.actionsNode = i, i.addEventListener("mousedown", (a) => {
|
|
1546
|
+
a.preventDefault();
|
|
1547
|
+
const u = a.target.closest(".ql-clausula-btn");
|
|
1548
|
+
if (!u) return;
|
|
1549
|
+
const d = this.getAllItems();
|
|
1550
|
+
d.includes(n) && (u.classList.contains("ql-clausula-lock") ? this.handleLock(n, d) : u.classList.contains("ql-clausula-agree") ? !u.hasAttribute("disabled") && !u.disabled && this.handleAgree(n, d) : u.classList.contains("ql-clausula-disagree") ? !u.hasAttribute("disabled") && !u.disabled && this.handleDisagree(n, d) : u.classList.contains("ql-clausula-conversation") && this.handleConversation(n));
|
|
1551
|
+
}));
|
|
1552
|
+
const o = s.getAttribute("data-clausula-type"), c = (o ? b[o] === 0 : !1) ? this.getChildren(n, t).map((a) => a.domNode) : void 0;
|
|
1553
|
+
ge(
|
|
1554
|
+
i,
|
|
1555
|
+
s,
|
|
1556
|
+
this.options.currentUser,
|
|
1557
|
+
this.options.users,
|
|
1558
|
+
c
|
|
1559
|
+
);
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
handleLock(t, e) {
|
|
1563
|
+
const n = t.domNode, s = n.getAttribute("data-clausula-type"), i = s ? b[s] === 0 : !1, l = n.classList.contains("ql-locked-true") ? !1 : "true", c = this.quill.getIndex(t);
|
|
1564
|
+
if (this.quill.formatLine(c, 1, "locked", l, g.API), i) {
|
|
1565
|
+
const a = this.getChildren(t, e);
|
|
1566
|
+
for (const u of a) {
|
|
1567
|
+
const d = this.quill.getIndex(u);
|
|
1568
|
+
this.quill.formatLine(d, 1, "locked", l, g.API);
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
this.scheduleRenumber();
|
|
1572
|
+
}
|
|
1573
|
+
handleAgree(t, e) {
|
|
1574
|
+
const n = this.options.currentUser;
|
|
1575
|
+
if (!n) return;
|
|
1576
|
+
const i = t.domNode.getAttribute("data-clausula-type"), l = (i ? b[i] === 0 : !1) ? this.getChildren(t, e) : [];
|
|
1577
|
+
if (l.length > 0)
|
|
1578
|
+
for (const c of l)
|
|
1579
|
+
this.setAgreed(c, n, !0);
|
|
1580
|
+
else
|
|
1581
|
+
this.setAgreed(t, n, !0);
|
|
1582
|
+
this.scheduleRenumber();
|
|
1583
|
+
}
|
|
1584
|
+
handleDisagree(t, e) {
|
|
1585
|
+
const n = this.options.currentUser;
|
|
1586
|
+
if (!n) return;
|
|
1587
|
+
const i = t.domNode.getAttribute("data-clausula-type"), l = (i ? b[i] === 0 : !1) ? this.getChildren(t, e) : [];
|
|
1588
|
+
if (l.length > 0)
|
|
1589
|
+
for (const c of l)
|
|
1590
|
+
this.setAgreed(c, n, !1);
|
|
1591
|
+
else
|
|
1592
|
+
this.setAgreed(t, n, !1);
|
|
1593
|
+
this.scheduleRenumber();
|
|
1594
|
+
}
|
|
1595
|
+
handleConversation(t) {
|
|
1596
|
+
var c;
|
|
1597
|
+
const e = this.options.onConversation;
|
|
1598
|
+
if (!e) return;
|
|
1599
|
+
const n = t.domNode, s = n.getAttribute("data-clausula-type"), i = n.querySelector(".ql-ui"), o = ((c = n.textContent) == null ? void 0 : c.replace((i == null ? void 0 : i.textContent) || "", "").trim()) || "", l = {
|
|
1600
|
+
type: s,
|
|
1601
|
+
text: o,
|
|
1602
|
+
domNode: n,
|
|
1603
|
+
currentUser: this.options.currentUser
|
|
1604
|
+
};
|
|
1605
|
+
e(l);
|
|
1606
|
+
}
|
|
1607
|
+
setAgreed(t, e, n) {
|
|
1608
|
+
const i = t.domNode.getAttribute("data-agreed");
|
|
1609
|
+
let o = {};
|
|
1610
|
+
if (i)
|
|
1611
|
+
try {
|
|
1612
|
+
o = JSON.parse(i);
|
|
1613
|
+
} catch {
|
|
1614
|
+
o = {};
|
|
1615
|
+
}
|
|
1616
|
+
o[e] = n;
|
|
1617
|
+
const l = this.quill.getIndex(t), c = Object.keys(o).length > 0 ? o : !1;
|
|
1618
|
+
this.quill.formatLine(l, 1, "agreed", c, g.API);
|
|
1619
|
+
}
|
|
1620
|
+
/**
|
|
1621
|
+
* Groups clausula items into blocks led by a parent cláusula (level 0)
|
|
1622
|
+
* followed by its children. Items before the first parent are not part
|
|
1623
|
+
* of any draggable block.
|
|
1624
|
+
*/
|
|
1625
|
+
getClausulaBlocks() {
|
|
1626
|
+
const t = [];
|
|
1627
|
+
let e = null;
|
|
1628
|
+
for (const n of this.getAllItems()) {
|
|
1629
|
+
const s = n.domNode.getAttribute(
|
|
1630
|
+
"data-clausula-type"
|
|
1631
|
+
);
|
|
1632
|
+
s && b[s] === 0 ? (e = { items: [n] }, t.push(e)) : e && e.items.push(n);
|
|
1633
|
+
}
|
|
1634
|
+
return t;
|
|
1635
|
+
}
|
|
1636
|
+
/**
|
|
1637
|
+
* Moves a whole clause block to another boundary as ONE atomic delta
|
|
1638
|
+
* (single undo). Blocks containing locked lines move with API source so
|
|
1639
|
+
* the reorder is allowed while their content stays protected.
|
|
1640
|
+
*/
|
|
1641
|
+
moveClausulaBlock(t, e) {
|
|
1642
|
+
const n = this.getClausulaBlocks(), s = n[t];
|
|
1643
|
+
if (!s) return;
|
|
1644
|
+
const i = s.items[0], o = s.items[s.items.length - 1], l = this.quill.getIndex(i), c = this.quill.getIndex(o) + o.length() - l;
|
|
1645
|
+
let a;
|
|
1646
|
+
if (e < n.length)
|
|
1647
|
+
a = this.quill.getIndex(n[e].items[0]);
|
|
1648
|
+
else {
|
|
1649
|
+
const p = n[n.length - 1], m = p.items[p.items.length - 1];
|
|
1650
|
+
a = this.quill.getIndex(m) + m.length();
|
|
1651
|
+
}
|
|
1652
|
+
if (a >= l && a <= l + c) return;
|
|
1653
|
+
const u = this.quill.getContents(l, c), d = u.ops.some(
|
|
1654
|
+
(p) => {
|
|
1655
|
+
var m;
|
|
1656
|
+
return ((m = p.attributes) == null ? void 0 : m.locked) === "true";
|
|
1657
|
+
}
|
|
1658
|
+
), f = F(l, c, a, u.ops);
|
|
1659
|
+
this.quill.updateContents(
|
|
1660
|
+
{ ops: f },
|
|
1661
|
+
d ? g.API : g.USER
|
|
1662
|
+
), this.scheduleRenumber();
|
|
1663
|
+
}
|
|
1664
|
+
isParentWithChildren(t, e) {
|
|
1665
|
+
const n = t.domNode.getAttribute("data-clausula-type");
|
|
1666
|
+
return (n ? b[n] === 0 : !1) && this.getChildren(t, e).length > 0;
|
|
1667
|
+
}
|
|
1668
|
+
/**
|
|
1669
|
+
* Get all children after the given clausula (level 0) until the next level-0 item.
|
|
1670
|
+
* Works across container boundaries using the flattened allItems array.
|
|
1671
|
+
*/
|
|
1672
|
+
getChildren(t, e) {
|
|
1673
|
+
const n = e.indexOf(t);
|
|
1674
|
+
if (n === -1) return [];
|
|
1675
|
+
const s = [];
|
|
1676
|
+
for (let i = n + 1; i < e.length; i++) {
|
|
1677
|
+
const l = e[i].domNode.getAttribute("data-clausula-type");
|
|
1678
|
+
if (l && b[l] === 0) break;
|
|
1679
|
+
s.push(e[i]);
|
|
1680
|
+
}
|
|
1681
|
+
return s;
|
|
1682
|
+
}
|
|
1683
|
+
};
|
|
1684
|
+
P.DEFAULTS = { ...U };
|
|
1685
|
+
let B = P;
|
|
1686
|
+
const Ce = /^(?:#{1,6}\s*)?(?:\*\*)?CL[AÁ]USULA\s+[^\s—–:-]+\s*[ª°º]?\s*(?:[—–:-]+\s*)?(?:\*\*)?\s*(.*)$/i, Se = /^(?:\*\*)?(\d+)\.(\d+)(?:\*\*)?[.)]?\s+(.*)$/, Ee = /^(?:\*\*)?§\s*\d*º?\.?(?:\*\*)?\s+(.*)$/, Te = /^(?:\*\*)?PAR[AÁ]GRAFO\s+(?:[ÚU]NICO|PRIMEIRO|SEGUNDO|TERCEIRO|QUARTO|QUINTO|SEXTO|S[ÉE]TIMO|OITAVO|NONO|D[ÉE]CIMO(?:\s+\w+)?|\d+º?)\s*[.:—–-]?(?:\*\*)?\s*(.*)$/i, Ie = /^([IVXLCDM]+|[ivxlcdm]+)\s*[—–-]\s+(.*)$/, we = /^([a-z])\\?\)\s+(.*)$/, Re = /^(?:\*\*)?(CONTRATANTE|CONTRATADO|CONTRATADA)S?\s*:?(?:\*\*)?:?\s*(.*)$/i, $e = /^(?:\*\*)?OBJETO\s*:?(?:\*\*)?:?\s*(.*)$/i, Oe = /^#{1,6}\s+(.*)$/;
|
|
1687
|
+
function Be(r) {
|
|
1688
|
+
let t = r.match(Ce);
|
|
1689
|
+
return t ? { attributes: { clausula: "clausula" }, rest: t[1] } : (t = r.match(Se), t ? { attributes: { clausula: "subclausula" }, rest: t[3] } : (t = r.match(Ee) || r.match(Te), t ? { attributes: { clausula: "paragrafo" }, rest: t[1] } : (t = r.match(Ie), t ? { attributes: { clausula: "inciso" }, rest: t[2] } : (t = r.match(we), t ? { attributes: { clausula: "alinea" }, rest: t[2] } : (t = r.match(Re), t ? { attributes: { parte: t[1].toUpperCase() === "CONTRATANTE" ? "contratante" : "contratado" }, rest: t[2] } : (t = r.match($e), t ? { attributes: { objeto: "true" }, rest: t[1] } : null))))));
|
|
1690
|
+
}
|
|
1691
|
+
function R(r) {
|
|
1692
|
+
const t = [], e = /(\*\*([^*]+)\*\*|\*([^*\s][^*]*)\*|_([^_\s][^_]*)_)/g;
|
|
1693
|
+
let n = 0, s;
|
|
1694
|
+
for (; (s = e.exec(r)) !== null; )
|
|
1695
|
+
s.index > n && t.push({ insert: r.slice(n, s.index) }), s[2] !== void 0 ? t.push({ insert: s[2], attributes: { bold: !0 } }) : t.push({ insert: s[3] ?? s[4], attributes: { italic: !0 } }), n = s.index + s[0].length;
|
|
1696
|
+
return n < r.length && t.push({ insert: r.slice(n) }), t.filter((i) => i.insert.length > 0);
|
|
1697
|
+
}
|
|
1698
|
+
function _e(r) {
|
|
1699
|
+
const t = r.match(/^---\n[\s\S]*?\n---\n?/);
|
|
1700
|
+
return t ? r.slice(t[0].length) : r;
|
|
1701
|
+
}
|
|
1702
|
+
function De(r) {
|
|
1703
|
+
const t = [], e = _e(r).split(`
|
|
1704
|
+
`);
|
|
1705
|
+
for (const n of e) {
|
|
1706
|
+
const s = n.trim();
|
|
1707
|
+
if (!s || /^[-*_]{3,}$/.test(s)) continue;
|
|
1708
|
+
const i = Be(s);
|
|
1709
|
+
if (i) {
|
|
1710
|
+
const l = i.rest.trim();
|
|
1711
|
+
t.push(...R(l)), t.push({ insert: `
|
|
1712
|
+
`, attributes: i.attributes });
|
|
1713
|
+
continue;
|
|
1714
|
+
}
|
|
1715
|
+
const o = s.match(Oe);
|
|
1716
|
+
if (o) {
|
|
1717
|
+
const l = R(o[1].trim());
|
|
1718
|
+
for (const c of l)
|
|
1719
|
+
c.attributes = { ...c.attributes, bold: !0 };
|
|
1720
|
+
t.push(...l), t.push({ insert: `
|
|
1721
|
+
` });
|
|
1722
|
+
continue;
|
|
1723
|
+
}
|
|
1724
|
+
t.push(...R(s)), t.push({ insert: `
|
|
1725
|
+
` });
|
|
1726
|
+
}
|
|
1727
|
+
return t.length === 0 && t.push({ insert: `
|
|
1728
|
+
` }), { ops: t };
|
|
1729
|
+
}
|
|
1730
|
+
function Ue() {
|
|
1731
|
+
h.register("modules/clausula", B);
|
|
1732
|
+
}
|
|
1733
|
+
export {
|
|
1734
|
+
Wt as AUTOFILL_PREFIX,
|
|
1735
|
+
pt as AgreedAttribute,
|
|
1736
|
+
C as AssinaturaEmbed,
|
|
1737
|
+
y as ClausulaContainer,
|
|
1738
|
+
E as ClausulaItem,
|
|
1739
|
+
B as ClausulaModule,
|
|
1740
|
+
Ct as DragOrganizer,
|
|
1741
|
+
yt as GhostAttribute,
|
|
1742
|
+
Lt as GhostCut,
|
|
1743
|
+
vt as LINE_HEIGHTS,
|
|
1744
|
+
kt as LineHeightAttribute,
|
|
1745
|
+
dt as LockedAttribute,
|
|
1746
|
+
A as ObjetoContainer,
|
|
1747
|
+
I as ObjetoItem,
|
|
1748
|
+
At as PARAGRAPH_SPACINGS,
|
|
1749
|
+
xt as ParagraphSpacingAttribute,
|
|
1750
|
+
v as ParteContainer,
|
|
1751
|
+
T as ParteItem,
|
|
1752
|
+
F as buildMoveOps,
|
|
1753
|
+
St as computeIndices,
|
|
1754
|
+
G as computeIndicesFromTypes,
|
|
1755
|
+
jt as computeParteIndices,
|
|
1756
|
+
J as computeParteIndicesFromTypes,
|
|
1757
|
+
fe as createActionButtons,
|
|
1758
|
+
xe as createFloatingBar,
|
|
1759
|
+
qe as createUndoModal,
|
|
1760
|
+
le as exportHTML,
|
|
1761
|
+
oe as exportMarkdown,
|
|
1762
|
+
Ft as extractSignatureLines,
|
|
1763
|
+
qt as findGhostRange,
|
|
1764
|
+
K as formatLabel,
|
|
1765
|
+
Q as formatParteLabel,
|
|
1766
|
+
De as importMarkdown,
|
|
1767
|
+
Le as isContractFullyAgreed,
|
|
1768
|
+
te as matchExtraTrigger,
|
|
1769
|
+
Zt as matchTrigger,
|
|
1770
|
+
X as parseDeltaToLines,
|
|
1771
|
+
R as parseInline,
|
|
1772
|
+
Ue as register,
|
|
1773
|
+
z as renderAssinatura,
|
|
1774
|
+
ge as syncButtonState,
|
|
1775
|
+
_ as toExtenso,
|
|
1776
|
+
V as toExtensoUpper,
|
|
1777
|
+
$ as toRoman,
|
|
1778
|
+
Bt as toRomanLower
|
|
1779
|
+
};
|