@templatical/editor 0.0.1

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.
@@ -0,0 +1,305 @@
1
+ import { defineComponent as U, inject as f, ref as y, watch as C, openBlock as s, createBlock as B, Transition as J, withCtx as X, createElementBlock as a, createElementVNode as o, createVNode as d, unref as t, toDisplayString as i, createCommentVNode as m, Fragment as b, renderList as H, createTextVNode as R, normalizeClass as q, withDirectives as O, vModelText as Q, nextTick as W } from "vue";
2
+ import { c as F, B as Y, s as Z, S as E, E as tt, X as et, L as lt, C as st, t as at } from "./index-D-iD-7lO.js";
3
+ import { useAiChat as ot } from "@templatical/core/cloud";
4
+ import { L as rt } from "./loader-circle-tM9j2mRh.js";
5
+ import { S as pt } from "./CloudEditor-Wdfv_9xn.js";
6
+ /**
7
+ * @license lucide-vue-next v0.475.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */
12
+ const nt = F("Redo2Icon", [
13
+ ["path", { d: "m15 14 5-5-5-5", key: "12vg1m" }],
14
+ ["path", { d: "M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13", key: "6uklza" }]
15
+ ]);
16
+ /**
17
+ * @license lucide-vue-next v0.475.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */
22
+ const it = F("Undo2Icon", [
23
+ ["path", { d: "M9 14 4 9l5-5", key: "102s5s" }],
24
+ ["path", { d: "M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11", key: "f3b9sd" }]
25
+ ]), dt = {
26
+ key: 0,
27
+ class: "tpl-ai-sidebar tpl:absolute tpl:top-14 tpl:right-0 tpl:bottom-0 tpl:z-[45] tpl:flex tpl:w-[360px] tpl:flex-col tpl:border-l tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg-elevated)]"
28
+ }, ct = { class: "tpl:flex tpl:items-center tpl:justify-between tpl:border-b tpl:border-[var(--tpl-border)] tpl:px-4 tpl:py-3" }, ut = { class: "tpl:flex tpl:items-center tpl:gap-1.5 tpl:text-sm tpl:font-medium tpl:text-[var(--tpl-primary)]" }, vt = { class: "tpl:flex tpl:items-center tpl:gap-1" }, mt = ["title"], ht = { class: "tpl:relative tpl:flex tpl:min-h-0 tpl:flex-1 tpl:flex-col" }, xt = {
29
+ key: 0,
30
+ class: "tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center"
31
+ }, gt = {
32
+ class: "tpl:text-sm",
33
+ style: { color: "var(--tpl-text-muted)" }
34
+ }, ft = {
35
+ key: 1,
36
+ class: "tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center"
37
+ }, yt = {
38
+ class: "tpl:max-w-[240px] tpl:text-sm",
39
+ style: { color: "var(--tpl-text-muted)" }
40
+ }, bt = {
41
+ key: 2,
42
+ class: "tpl:flex tpl:flex-col tpl:gap-4"
43
+ }, kt = {
44
+ key: 0,
45
+ class: "tpl:self-end tpl:rounded-[var(--tpl-radius-sm)] tpl:px-3.5 tpl:py-2.5 tpl:text-sm",
46
+ style: { "background-color": "var(--tpl-primary-light)", color: "var(--tpl-text)", "max-width": "85%", "box-shadow": "var(--tpl-shadow)" }
47
+ }, _t = {
48
+ key: 1,
49
+ class: "tpl:flex tpl:flex-col tpl:gap-2"
50
+ }, wt = {
51
+ key: 1,
52
+ class: "tpl:rounded-[var(--tpl-radius-sm)] tpl:px-3.5 tpl:py-2.5 tpl:text-sm tpl:whitespace-pre-wrap",
53
+ style: { "max-width": "85%", "background-color": "white", color: "var(--tpl-text)", "box-shadow": "var(--tpl-shadow)" }
54
+ }, Ct = {
55
+ key: 0,
56
+ class: "tpl:mx-3 tpl:mb-2 tpl:flex tpl:items-start tpl:gap-2 tpl:rounded-lg tpl:px-3 tpl:py-2 tpl:text-xs",
57
+ style: { "background-color": "var(--tpl-danger-light)", color: "var(--tpl-danger)" }
58
+ }, zt = {
59
+ key: 1,
60
+ class: "tpl:absolute tpl:right-0 tpl:bottom-0 tpl:left-0 tpl:z-10 tpl:px-3 tpl:pb-3",
61
+ style: { "background-color": `color-mix(
62
+ in srgb,
63
+ var(--tpl-bg) 50%,
64
+ transparent
65
+ )`, "backdrop-filter": "blur(2px)" }
66
+ }, St = { class: "tpl:flex tpl:flex-col tpl:gap-1.5" }, Tt = ["onClick"], At = {
67
+ class: "tpl:border-t tpl:p-3",
68
+ style: { "border-color": "var(--tpl-border)" }
69
+ }, Lt = {
70
+ class: "tpl-ai-input-wrapper tpl:flex tpl:items-end tpl:gap-2 tpl:rounded-[var(--tpl-radius)] tpl:border tpl:px-3 tpl:py-2",
71
+ style: { "border-color": "var(--tpl-border)", "background-color": "var(--tpl-bg)" }
72
+ }, It = ["placeholder", "disabled"], Mt = ["disabled"], jt = {
73
+ class: "tpl:m-0 tpl:px-1 tpl:pt-2 tpl:text-center tpl:text-[11px]",
74
+ style: { color: "var(--tpl-text-dim)" }
75
+ }, Bt = /* @__PURE__ */ U({
76
+ __name: "AiChatSidebar",
77
+ props: {
78
+ visible: { type: Boolean },
79
+ onApply: { type: Function }
80
+ },
81
+ emits: ["close"],
82
+ setup(z, { emit: G }) {
83
+ const S = z, P = G, n = f("translations"), h = f("editor"), V = f("authManager"), T = f("mergeTags", []), e = ot({
84
+ authManager: V,
85
+ getTemplateId: () => {
86
+ var l;
87
+ return ((l = h.state.template) == null ? void 0 : l.id) ?? null;
88
+ },
89
+ onApply: S.onApply,
90
+ onError: void 0
91
+ }), c = y(""), x = y(null), A = y(!1), u = y(0), { pause: k, resume: N } = Y(
92
+ () => {
93
+ var r;
94
+ const l = ((r = e.suggestions.value) == null ? void 0 : r.length) ?? 0;
95
+ u.value < l ? u.value++ : k();
96
+ },
97
+ 150,
98
+ { immediate: !1 }
99
+ );
100
+ C(
101
+ () => {
102
+ var l;
103
+ return ((l = e.suggestions.value) == null ? void 0 : l.length) ?? 0;
104
+ },
105
+ (l) => {
106
+ if (k(), l === 0) {
107
+ u.value = 0;
108
+ return;
109
+ }
110
+ u.value = 0, Z(() => N(), 100);
111
+ }
112
+ );
113
+ function _() {
114
+ W(() => {
115
+ x.value && (x.value.scrollTop = x.value.scrollHeight);
116
+ });
117
+ }
118
+ C(
119
+ () => {
120
+ var l;
121
+ return ((l = e.messages.value) == null ? void 0 : l.length) ?? 0;
122
+ },
123
+ () => _()
124
+ ), C(
125
+ () => S.visible,
126
+ async (l) => {
127
+ var r;
128
+ l && !A.value && (A.value = !0, await e.loadConversation(), (((r = e.messages.value) == null ? void 0 : r.length) ?? 0) === 0 && h.content.value.blocks.length === 0 && e.loadSuggestions(h.content.value, T));
129
+ }
130
+ );
131
+ async function w() {
132
+ const l = c.value.trim();
133
+ !l || e.isGenerating.value || (c.value = "", e.error.value = null, e.failedPrompt.value = null, _(), await e.sendPrompt(l, h.content.value, T), e.failedPrompt.value && (c.value = e.failedPrompt.value), _());
134
+ }
135
+ function L(l) {
136
+ return l.replace(/```json[\s\S]*?```/g, "").replace(/```json[\s\S]*/g, "").trim();
137
+ }
138
+ function $(l) {
139
+ k(), c.value = l, w();
140
+ }
141
+ function D(l) {
142
+ l.key === "Enter" && !l.shiftKey && (l.preventDefault(), w());
143
+ }
144
+ return (l, r) => (s(), B(J, {
145
+ "enter-active-class": "tpl-ai-slide-enter-active",
146
+ "enter-from-class": "tpl:translate-x-full",
147
+ "enter-to-class": "tpl:translate-x-0",
148
+ "leave-active-class": "tpl-ai-slide-leave-active",
149
+ "leave-from-class": "tpl:translate-x-0",
150
+ "leave-to-class": "tpl:translate-x-full"
151
+ }, {
152
+ default: X(() => {
153
+ var I, M, j;
154
+ return [
155
+ z.visible ? (s(), a("div", dt, [
156
+ o("div", ct, [
157
+ o("div", ut, [
158
+ d(t(E), {
159
+ size: 13,
160
+ "stroke-width": 2
161
+ }),
162
+ o("span", null, i(t(n).aiChat.title), 1)
163
+ ]),
164
+ o("div", vt, [
165
+ (((I = t(e).messages.value) == null ? void 0 : I.length) ?? 0) > 0 ? (s(), a("button", {
166
+ key: 0,
167
+ class: "tpl:rounded-md tpl:p-0.5 tpl:transition-colors tpl:duration-150",
168
+ style: { color: "var(--tpl-text-muted)" },
169
+ title: t(n).aiChat.clear,
170
+ onClick: r[0] || (r[0] = (p) => t(e).clearChat())
171
+ }, [
172
+ d(t(tt), {
173
+ size: 14,
174
+ "stroke-width": 2
175
+ })
176
+ ], 8, mt)) : m("", !0),
177
+ o("button", {
178
+ class: "tpl:rounded-md tpl:p-0.5 tpl:transition-colors tpl:duration-150",
179
+ style: { color: "var(--tpl-text-muted)" },
180
+ onClick: r[1] || (r[1] = (p) => P("close"))
181
+ }, [
182
+ d(t(et), {
183
+ size: 14,
184
+ "stroke-width": 2
185
+ })
186
+ ])
187
+ ])
188
+ ]),
189
+ o("div", ht, [
190
+ o("div", {
191
+ ref_key: "messagesContainer",
192
+ ref: x,
193
+ class: "tpl:flex-1 tpl:overflow-y-auto tpl:p-4"
194
+ }, [
195
+ t(e).isLoadingHistory.value ? (s(), a("div", xt, [
196
+ d(t(rt), {
197
+ class: "tpl-spinner",
198
+ size: 24,
199
+ "stroke-width": 2,
200
+ style: { color: "var(--tpl-text-muted)" }
201
+ }),
202
+ o("p", gt, i(t(n).aiChat.loadingHistory), 1)
203
+ ])) : (((M = t(e).messages.value) == null ? void 0 : M.length) ?? 0) === 0 ? (s(), a("div", ft, [
204
+ d(t(E), {
205
+ size: 32,
206
+ "stroke-width": 1.5,
207
+ style: { color: "var(--tpl-text-dim)" }
208
+ }),
209
+ o("p", yt, i(t(n).aiChat.placeholder), 1)
210
+ ])) : (s(), a("div", bt, [
211
+ (s(!0), a(b, null, H(t(e).messages.value, (p, g) => {
212
+ var v;
213
+ return s(), a("div", {
214
+ key: p.id,
215
+ class: "tpl:flex tpl:flex-col tpl:gap-2"
216
+ }, [
217
+ p.role === "user" ? (s(), a("div", kt, i(p.content), 1)) : (s(), a("div", _t, [
218
+ !L(p.content) && t(e).isGenerating.value && g === (((v = t(e).messages.value) == null ? void 0 : v.length) ?? 0) - 1 ? (s(), B(lt, { key: 0 })) : (s(), a("div", wt, i(L(p.content) || t(n).aiChat.applied), 1)),
219
+ p.id === t(e).lastApplyMessageId.value && !t(e).isGenerating.value ? (s(), a("button", {
220
+ key: 2,
221
+ class: "tpl:inline-flex tpl:items-center tpl:gap-1.5 tpl:self-start tpl:rounded-md tpl:border tpl:px-2.5 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150",
222
+ style: { "border-color": "var(--tpl-border)", color: "var(--tpl-text-muted)", "background-color": "transparent" },
223
+ onClick: r[2] || (r[2] = (K) => t(e).toggleLastRevert())
224
+ }, [
225
+ t(e).isLastChangeReverted.value ? (s(), a(b, { key: 0 }, [
226
+ d(t(nt), {
227
+ size: 12,
228
+ "stroke-width": 2
229
+ }),
230
+ R(" " + i(t(n).aiChat.reapply), 1)
231
+ ], 64)) : (s(), a(b, { key: 1 }, [
232
+ d(t(it), {
233
+ size: 12,
234
+ "stroke-width": 2
235
+ }),
236
+ R(" " + i(t(n).aiChat.revert), 1)
237
+ ], 64))
238
+ ])) : m("", !0)
239
+ ]))
240
+ ]);
241
+ }), 128))
242
+ ]))
243
+ ], 512),
244
+ t(e).error.value ? (s(), a("div", Ct, [
245
+ d(t(st), {
246
+ size: 14,
247
+ "stroke-width": 2,
248
+ class: "tpl:mt-0.5 tpl:shrink-0"
249
+ }),
250
+ o("span", null, i(t(e).error.value === "ai_apply_failed" ? t(n).aiChat.applyFailed : t(n).aiChat.error), 1)
251
+ ])) : m("", !0),
252
+ (((j = t(e).suggestions.value) == null ? void 0 : j.length) ?? 0) > 0 ? (s(), a("div", zt, [
253
+ o("div", St, [
254
+ (s(!0), a(b, null, H(t(e).suggestions.value ?? [], (p, g) => {
255
+ var v;
256
+ return s(), a("button", {
257
+ key: g,
258
+ class: q([
259
+ "tpl-suggestion-btn tpl:cursor-pointer tpl:rounded-[var(--tpl-radius-sm)] tpl:border tpl:px-3 tpl:py-2 tpl:text-left tpl:text-xs tpl:leading-snug tpl:transition-all tpl:duration-300 tpl:ease-out",
260
+ (((v = t(e).suggestions.value) == null ? void 0 : v.length) ?? 0) - 1 - g < u.value ? "tpl:translate-y-0 tpl:opacity-100" : "tpl:pointer-events-none tpl:-translate-y-2 tpl:opacity-0"
261
+ ]),
262
+ style: { "border-color": "var(--tpl-border)", color: "var(--tpl-primary)", "background-color": "white", "box-shadow": "var(--tpl-shadow)" },
263
+ onClick: (K) => $(p)
264
+ }, i(p), 11, Tt);
265
+ }), 128))
266
+ ])
267
+ ])) : m("", !0)
268
+ ]),
269
+ o("div", At, [
270
+ o("div", Lt, [
271
+ O(o("textarea", {
272
+ "onUpdate:modelValue": r[3] || (r[3] = (p) => c.value = p),
273
+ class: "tpl:max-h-32 tpl:min-h-[64px] tpl:flex-1 tpl:resize-none tpl:border-none tpl:bg-transparent tpl:font-sans tpl:text-sm tpl:outline-none",
274
+ style: { color: "var(--tpl-text)" },
275
+ placeholder: t(n).aiChat.inputPlaceholder,
276
+ disabled: t(e).isGenerating.value,
277
+ rows: "3",
278
+ onKeydown: D
279
+ }, null, 40, It), [
280
+ [Q, c.value]
281
+ ]),
282
+ o("button", {
283
+ class: "tpl-ai-send-btn tpl:flex tpl:shrink-0 tpl:items-center tpl:justify-center tpl:rounded-md tpl:p-1.5 tpl:transition-all tpl:duration-150 tpl:disabled:opacity-40",
284
+ style: { color: "var(--tpl-primary)" },
285
+ disabled: !c.value.trim() || t(e).isGenerating.value,
286
+ onClick: w
287
+ }, [
288
+ d(t(pt), {
289
+ size: 16,
290
+ "stroke-width": 2
291
+ })
292
+ ], 8, Mt)
293
+ ]),
294
+ o("p", jt, i(t(n).aiMenu.disclaimer), 1)
295
+ ])
296
+ ])) : m("", !0)
297
+ ];
298
+ }),
299
+ _: 1
300
+ }));
301
+ }
302
+ }), Pt = /* @__PURE__ */ at(Bt, [["__scopeId", "data-v-3d9d0cf5"]]);
303
+ export {
304
+ Pt as default
305
+ };
@@ -0,0 +1,69 @@
1
+ import { defineComponent as v, inject as y, computed as h, openBlock as l, createElementBlock as a, Fragment as x, renderList as b, normalizeStyle as o, createElementVNode as n, createBlock as _, resolveDynamicComponent as w, toDisplayString as s } from "vue";
2
+ import { u as C, S as F, I as M, t as S } from "./index-D-iD-7lO.js";
3
+ import "@templatical/types";
4
+ import { S as T } from "./shield-check-Ngi9jAQc.js";
5
+ const D = {
6
+ class: "tpl-ai-feature-menu tpl:w-[280px] tpl:overflow-hidden tpl:rounded-[var(--tpl-radius)] tpl:py-1",
7
+ style: { "background-color": "var(--tpl-bg-elevated)", border: "1px solid var(--tpl-border)", "box-shadow": "var(--tpl-shadow-lg)", "backdrop-filter": "blur(8px)", "-webkit-backdrop-filter": "blur(8px)" }
8
+ }, A = ["onClick"], I = { class: "tpl:flex tpl:min-w-0 tpl:flex-col tpl:gap-0.5" }, z = {
9
+ class: "tpl:text-sm tpl:font-medium",
10
+ style: { color: "var(--tpl-text)" }
11
+ }, B = {
12
+ class: "tpl:text-xs tpl:leading-snug",
13
+ style: { color: "var(--tpl-text-muted)" }
14
+ }, E = /* @__PURE__ */ v({
15
+ __name: "AiFeatureMenu",
16
+ props: {
17
+ activeFeature: {}
18
+ },
19
+ emits: ["select"],
20
+ setup(i, { emit: c }) {
21
+ const p = c, { t: r } = C(), u = y("aiConfig"), d = {
22
+ "ai-chat": "chat",
23
+ "design-reference": "designToTemplate",
24
+ scoring: "scoring"
25
+ }, m = [
26
+ { key: "ai-chat", icon: F },
27
+ { key: "design-reference", icon: M },
28
+ { key: "scoring", icon: T }
29
+ ], g = h(
30
+ () => m.filter((e) => u.isFeatureEnabled(d[e.key]))
31
+ );
32
+ function f(e) {
33
+ return e === "ai-chat" ? r.aiMenu.aiAssistant : e === "design-reference" ? r.aiMenu.designToTemplate : r.aiMenu.templateScore;
34
+ }
35
+ function k(e) {
36
+ return e === "ai-chat" ? r.aiMenu.aiAssistantDesc : e === "design-reference" ? r.aiMenu.designToTemplateDesc : r.aiMenu.templateScoreDesc;
37
+ }
38
+ return (e, j) => (l(), a("div", D, [
39
+ (l(!0), a(x, null, b(g.value, (t) => (l(), a("button", {
40
+ key: t.key,
41
+ class: "tpl-ai-feature-menu-item tpl:flex tpl:w-full tpl:cursor-pointer tpl:items-start tpl:gap-3 tpl:border-none tpl:px-3 tpl:py-2.5 tpl:text-left tpl:transition-colors tpl:duration-100",
42
+ style: o({
43
+ backgroundColor: i.activeFeature === t.key ? "var(--tpl-primary-light)" : "transparent"
44
+ }),
45
+ onClick: (K) => p("select", t.key)
46
+ }, [
47
+ n("div", {
48
+ class: "tpl:mt-0.5 tpl:flex tpl:size-7 tpl:shrink-0 tpl:items-center tpl:justify-center tpl:rounded-[var(--tpl-radius-sm)]",
49
+ style: o({
50
+ backgroundColor: i.activeFeature === t.key ? "var(--tpl-primary)" : "var(--tpl-bg-active)",
51
+ color: i.activeFeature === t.key ? "white" : "var(--tpl-text-muted)"
52
+ })
53
+ }, [
54
+ (l(), _(w(t.icon), {
55
+ size: 15,
56
+ "stroke-width": 2
57
+ }))
58
+ ], 4),
59
+ n("div", I, [
60
+ n("span", z, s(f(t.key)), 1),
61
+ n("span", B, s(k(t.key)), 1)
62
+ ])
63
+ ], 12, A))), 128))
64
+ ]));
65
+ }
66
+ }), $ = /* @__PURE__ */ S(E, [["__scopeId", "data-v-5200b3b6"]]);
67
+ export {
68
+ $ as default
69
+ };