@vizel/vue 0.0.1-alpha.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.
Files changed (54) hide show
  1. package/README.md +87 -0
  2. package/dist/index.d.ts +981 -0
  3. package/dist/index.js +63 -0
  4. package/dist/index10.js +135 -0
  5. package/dist/index11.js +30 -0
  6. package/dist/index12.js +14 -0
  7. package/dist/index13.js +91 -0
  8. package/dist/index14.js +134 -0
  9. package/dist/index15.js +37 -0
  10. package/dist/index16.js +21 -0
  11. package/dist/index17.js +79 -0
  12. package/dist/index18.js +120 -0
  13. package/dist/index19.js +21 -0
  14. package/dist/index2.js +88 -0
  15. package/dist/index20.js +52 -0
  16. package/dist/index21.js +43 -0
  17. package/dist/index22.js +12 -0
  18. package/dist/index23.js +16 -0
  19. package/dist/index24.js +37 -0
  20. package/dist/index25.js +48 -0
  21. package/dist/index26.js +24 -0
  22. package/dist/index27.js +10 -0
  23. package/dist/index28.js +46 -0
  24. package/dist/index29.js +23 -0
  25. package/dist/index3.js +61 -0
  26. package/dist/index30.js +15 -0
  27. package/dist/index31.js +4 -0
  28. package/dist/index32.js +4 -0
  29. package/dist/index33.js +4 -0
  30. package/dist/index34.js +4 -0
  31. package/dist/index35.js +4 -0
  32. package/dist/index36.js +4 -0
  33. package/dist/index37.js +4 -0
  34. package/dist/index38.js +4 -0
  35. package/dist/index39.js +4 -0
  36. package/dist/index4.js +34 -0
  37. package/dist/index40.js +4 -0
  38. package/dist/index41.js +4 -0
  39. package/dist/index42.js +4 -0
  40. package/dist/index43.js +4 -0
  41. package/dist/index44.js +4 -0
  42. package/dist/index45.js +4 -0
  43. package/dist/index46.js +4 -0
  44. package/dist/index47.js +4 -0
  45. package/dist/index48.js +4 -0
  46. package/dist/index49.js +4 -0
  47. package/dist/index5.js +76 -0
  48. package/dist/index50.js +4 -0
  49. package/dist/index51.js +4 -0
  50. package/dist/index6.js +108 -0
  51. package/dist/index7.js +15 -0
  52. package/dist/index8.js +191 -0
  53. package/dist/index9.js +35 -0
  54. package/package.json +63 -0
@@ -0,0 +1,120 @@
1
+ import { defineComponent as A, useSlots as K, ref as C, computed as z, watch as $, nextTick as M, createElementBlock as u, openBlock as r, normalizeClass as O, Fragment as k, renderSlot as d, createBlock as _, unref as g, renderList as w, createElementVNode as T, toDisplayString as F } from "vue";
2
+ import { groupVizelSlashCommands as H } from "@vizel/core";
3
+ import L from "./index19.js";
4
+ import S from "./index20.js";
5
+ const N = {
6
+ key: 0,
7
+ class: "vizel-slash-menu-group",
8
+ "data-vizel-slash-menu-group": ""
9
+ }, R = { class: "vizel-slash-menu-group-header" }, P = /* @__PURE__ */ A({
10
+ __name: "VizelSlashMenu",
11
+ props: {
12
+ items: {},
13
+ class: {},
14
+ showGroups: { type: Boolean, default: !0 },
15
+ groupOrder: {}
16
+ },
17
+ emits: ["command"],
18
+ setup(b, { expose: D, emit: G }) {
19
+ const m = b, B = G, p = K(), n = C(0), y = C([]), c = z(() => !m.showGroups || m.items.length <= 5 ? [{ name: "", items: m.items }] : H(m.items, m.groupOrder)), f = z(() => c.value.flatMap((e) => e.items));
20
+ $(
21
+ () => m.items,
22
+ () => {
23
+ n.value = 0, y.value = [];
24
+ }
25
+ ), $(n, async (e) => {
26
+ await M();
27
+ const a = y.value[e];
28
+ a && a.scrollIntoView({ block: "nearest", behavior: "smooth" });
29
+ });
30
+ function v(e) {
31
+ const a = f.value[e];
32
+ a && B("command", a);
33
+ }
34
+ function E() {
35
+ if (c.value.length <= 1) return;
36
+ let e = 0, a = 0;
37
+ for (let t = 0; t < c.value.length; t++) {
38
+ const s = c.value[t];
39
+ if (s) {
40
+ if (n.value < a + s.items.length) {
41
+ e = t;
42
+ break;
43
+ }
44
+ a += s.items.length;
45
+ }
46
+ }
47
+ const i = (e + 1) % c.value.length;
48
+ let l = 0;
49
+ for (let t = 0; t < i; t++) {
50
+ const s = c.value[t];
51
+ s && (l += s.items.length);
52
+ }
53
+ n.value = l;
54
+ }
55
+ function V(e) {
56
+ return e.key === "ArrowUp" ? (n.value = (n.value + f.value.length - 1) % f.value.length, !0) : e.key === "ArrowDown" ? (n.value = (n.value + 1) % f.value.length, !0) : e.key === "Enter" ? (v(n.value), !0) : e.key === "Tab" ? (e.preventDefault(), E(), !0) : !1;
57
+ }
58
+ D({
59
+ onKeyDown: V
60
+ });
61
+ function o(e, a) {
62
+ let i = 0;
63
+ for (let l = 0; l < e; l++) {
64
+ const t = c.value[l];
65
+ t && (i += t.items.length);
66
+ }
67
+ return i + a;
68
+ }
69
+ return (e, a) => (r(), u("div", {
70
+ class: O(["vizel-slash-menu", e.$props.class]),
71
+ "data-vizel-slash-menu": ""
72
+ }, [
73
+ f.value.length === 0 ? (r(), u(k, { key: 0 }, [
74
+ g(p).empty ? d(e.$slots, "empty", { key: 0 }) : (r(), _(L, { key: 1 }))
75
+ ], 64)) : (r(!0), u(k, { key: 1 }, w(c.value, (i, l) => (r(), u(k, {
76
+ key: i.name || l
77
+ }, [
78
+ i.name ? (r(), u("div", N, [
79
+ T("div", R, F(i.name), 1),
80
+ (r(!0), u(k, null, w(i.items, (t, s) => (r(), u("div", {
81
+ key: t.title,
82
+ ref_for: !0,
83
+ ref: (h) => y.value[o(l, s)] = h
84
+ }, [
85
+ g(p).item ? d(e.$slots, "item", {
86
+ key: 0,
87
+ item: t,
88
+ isSelected: o(l, s) === n.value,
89
+ onClick: () => v(o(l, s))
90
+ }) : (r(), _(S, {
91
+ key: 1,
92
+ item: t,
93
+ "is-selected": o(l, s) === n.value,
94
+ onClick: (h) => v(o(l, s))
95
+ }, null, 8, ["item", "is-selected", "onClick"]))
96
+ ]))), 128))
97
+ ])) : (r(!0), u(k, { key: 1 }, w(i.items, (t, s) => (r(), u("div", {
98
+ key: t.title,
99
+ ref_for: !0,
100
+ ref: (h) => y.value[o(l, s)] = h
101
+ }, [
102
+ g(p).item ? d(e.$slots, "item", {
103
+ key: 0,
104
+ item: t,
105
+ isSelected: o(l, s) === n.value,
106
+ onClick: () => v(o(l, s))
107
+ }) : (r(), _(S, {
108
+ key: 1,
109
+ item: t,
110
+ "is-selected": o(l, s) === n.value,
111
+ onClick: (h) => v(o(l, s))
112
+ }, null, 8, ["item", "is-selected", "onClick"]))
113
+ ]))), 128))
114
+ ], 64))), 128))
115
+ ], 2));
116
+ }
117
+ });
118
+ export {
119
+ P as default
120
+ };
@@ -0,0 +1,21 @@
1
+ import { defineComponent as a, useSlots as o, createElementBlock as s, openBlock as t, normalizeClass as n, renderSlot as r, unref as p, Fragment as m, createTextVNode as u } from "vue";
2
+ const f = /* @__PURE__ */ a({
3
+ __name: "VizelSlashMenuEmpty",
4
+ props: {
5
+ class: {}
6
+ },
7
+ setup(c) {
8
+ const l = o();
9
+ return (e, d) => (t(), s("div", {
10
+ class: n(["vizel-slash-menu-empty", e.$props.class]),
11
+ "data-vizel-slash-menu-empty": ""
12
+ }, [
13
+ p(l).default ? r(e.$slots, "default", { key: 0 }) : (t(), s(m, { key: 1 }, [
14
+ u("No results")
15
+ ], 64))
16
+ ], 2));
17
+ }
18
+ });
19
+ export {
20
+ f as default
21
+ };
package/dist/index2.js ADDED
@@ -0,0 +1,88 @@
1
+ import { defineComponent as B, mergeModels as m, useModel as M, useSlots as g, watch as y, createElementBlock as h, openBlock as n, normalizeClass as C, createBlock as s, createCommentVNode as f, renderSlot as c, unref as a, withCtx as z } from "vue";
2
+ import { getVizelMarkdown as b, setVizelMarkdown as D } from "@vizel/core";
3
+ import { useVizelEditor as E } from "./index26.js";
4
+ import p from "./index3.js";
5
+ import U from "./index9.js";
6
+ const F = /* @__PURE__ */ B({
7
+ __name: "Vizel",
8
+ props: /* @__PURE__ */ m({
9
+ initialContent: {},
10
+ initialMarkdown: {},
11
+ transformDiagramsOnImport: { type: Boolean, default: !0 },
12
+ placeholder: {},
13
+ editable: { type: Boolean, default: !0 },
14
+ autofocus: { type: [Boolean, String, Number], default: !1 },
15
+ features: {},
16
+ class: {},
17
+ showBubbleMenu: { type: Boolean, default: !0 },
18
+ enableEmbed: { type: Boolean, default: !1 }
19
+ }, {
20
+ markdown: {},
21
+ markdownModifiers: {}
22
+ }),
23
+ emits: /* @__PURE__ */ m(["update", "create", "destroy", "selectionUpdate", "focus", "blur"], ["update:markdown"]),
24
+ setup(r, { expose: k, emit: v }) {
25
+ const o = r, l = v, i = M(r, "markdown"), w = g();
26
+ let d = !1;
27
+ const t = E({
28
+ ...o.initialContent !== void 0 && { initialContent: o.initialContent },
29
+ ...o.initialMarkdown !== void 0 && { initialMarkdown: o.initialMarkdown },
30
+ transformDiagramsOnImport: o.transformDiagramsOnImport,
31
+ ...o.placeholder !== void 0 && { placeholder: o.placeholder },
32
+ editable: o.editable,
33
+ autofocus: o.autofocus,
34
+ ...o.features !== void 0 && { features: o.features },
35
+ onUpdate: (e) => {
36
+ l("update", e), !d && i.value !== void 0 && (i.value = b(e.editor));
37
+ },
38
+ onCreate: (e) => l("create", e),
39
+ onDestroy: () => l("destroy"),
40
+ onSelectionUpdate: (e) => l("selectionUpdate", e),
41
+ onFocus: (e) => l("focus", e),
42
+ onBlur: (e) => l("blur", e)
43
+ });
44
+ return y(i, (e) => {
45
+ if (e === void 0 || !t.value) return;
46
+ const u = b(t.value);
47
+ e !== u && (d = !0, D(t.value, e, {
48
+ transformDiagrams: o.transformDiagramsOnImport
49
+ }), d = !1);
50
+ }), k({
51
+ /** The underlying Tiptap editor instance */
52
+ get editor() {
53
+ return t.value;
54
+ },
55
+ /**
56
+ * Get the underlying Tiptap editor instance
57
+ * @deprecated Use the `editor` property instead
58
+ */
59
+ getEditor: () => t.value
60
+ }), (e, u) => (n(), h("div", {
61
+ class: C(["vizel-root", e.$props.class]),
62
+ "data-vizel-root": ""
63
+ }, [
64
+ a(t) ? (n(), s(U, {
65
+ key: 0,
66
+ editor: a(t)
67
+ }, null, 8, ["editor"])) : f("", !0),
68
+ r.showBubbleMenu && a(t) && a(w)["bubble-menu"] ? (n(), s(p, {
69
+ key: 1,
70
+ editor: a(t),
71
+ "enable-embed": r.enableEmbed ?? !1
72
+ }, {
73
+ default: z(() => [
74
+ c(e.$slots, "bubble-menu", { editor: a(t) })
75
+ ]),
76
+ _: 3
77
+ }, 8, ["editor", "enable-embed"])) : r.showBubbleMenu && a(t) ? (n(), s(p, {
78
+ key: 2,
79
+ editor: a(t),
80
+ "enable-embed": r.enableEmbed ?? !1
81
+ }, null, 8, ["editor", "enable-embed"])) : f("", !0),
82
+ c(e.$slots, "default", { editor: a(t) })
83
+ ], 2));
84
+ }
85
+ });
86
+ export {
87
+ F as default
88
+ };
@@ -0,0 +1,52 @@
1
+ import { defineComponent as r, createElementBlock as t, openBlock as s, normalizeClass as u, createElementVNode as l, createCommentVNode as k, createVNode as v, Fragment as c, renderList as z, unref as f, toDisplayString as n, createTextVNode as y } from "vue";
2
+ import { splitVizelTextByMatches as g } from "@vizel/core";
3
+ import x from "./index11.js";
4
+ const V = ["data-selected"], p = { class: "vizel-slash-menu-icon" }, S = { class: "vizel-slash-menu-text" }, _ = { class: "vizel-slash-menu-title" }, B = {
5
+ key: 0,
6
+ class: "vizel-slash-menu-highlight"
7
+ }, C = { class: "vizel-slash-menu-description" }, M = {
8
+ key: 0,
9
+ class: "vizel-slash-menu-shortcut"
10
+ }, E = /* @__PURE__ */ r({
11
+ __name: "VizelSlashMenuItem",
12
+ props: {
13
+ item: {},
14
+ isSelected: { type: Boolean },
15
+ class: {},
16
+ titleMatches: {}
17
+ },
18
+ emits: ["click"],
19
+ setup(e, { emit: o }) {
20
+ const m = o;
21
+ return (d, a) => (s(), t("button", {
22
+ type: "button",
23
+ class: u([
24
+ "vizel-slash-menu-item",
25
+ { "is-selected": e.isSelected },
26
+ d.$props.class
27
+ ]),
28
+ "data-selected": e.isSelected || void 0,
29
+ onClick: a[0] || (a[0] = (i) => m("click"))
30
+ }, [
31
+ l("span", p, [
32
+ v(x, {
33
+ name: e.item.icon
34
+ }, null, 8, ["name"])
35
+ ]),
36
+ l("div", S, [
37
+ l("span", _, [
38
+ (s(!0), t(c, null, z(f(g)(e.item.title, e.titleMatches), (i, h) => (s(), t(c, { key: h }, [
39
+ i.highlight ? (s(), t("mark", B, n(i.text), 1)) : (s(), t(c, { key: 1 }, [
40
+ y(n(i.text), 1)
41
+ ], 64))
42
+ ], 64))), 128))
43
+ ]),
44
+ l("span", C, n(e.item.description), 1)
45
+ ]),
46
+ e.item.shortcut ? (s(), t("span", M, n(e.item.shortcut), 1)) : k("", !0)
47
+ ], 10, V));
48
+ }
49
+ });
50
+ export {
51
+ E as default
52
+ };
@@ -0,0 +1,43 @@
1
+ import { defineComponent as i, ref as n, computed as T, provide as h, onMounted as d, watch as c, onBeforeUnmount as f, renderSlot as p } from "vue";
2
+ import { VIZEL_DEFAULT_THEME_STORAGE_KEY as E, VIZEL_DEFAULT_THEME as g, getStoredVizelTheme as _, getVizelSystemTheme as v, resolveVizelTheme as S, applyVizelTheme as s, createVizelSystemThemeListener as V, storeVizelTheme as y } from "@vizel/core";
3
+ import { VIZEL_THEME_CONTEXT_KEY as z } from "./index31.js";
4
+ const b = /* @__PURE__ */ i({
5
+ __name: "VizelThemeProvider",
6
+ props: {
7
+ defaultTheme: { default: g },
8
+ storageKey: { default: E },
9
+ targetSelector: {},
10
+ disableTransitionOnChange: { type: Boolean, default: !1 }
11
+ },
12
+ setup(m) {
13
+ const t = m, r = n(_(t.storageKey) ?? t.defaultTheme), o = n(v()), a = T(() => S(r.value, o.value));
14
+ function u(e) {
15
+ r.value = e, y(t.storageKey, e);
16
+ }
17
+ h(z, {
18
+ get theme() {
19
+ return r.value;
20
+ },
21
+ get resolvedTheme() {
22
+ return a.value;
23
+ },
24
+ get systemTheme() {
25
+ return o.value;
26
+ },
27
+ setTheme: u
28
+ });
29
+ let l = null;
30
+ return d(() => {
31
+ s(a.value, t.targetSelector, t.disableTransitionOnChange), l = V((e) => {
32
+ o.value = e;
33
+ });
34
+ }), c(a, (e) => {
35
+ s(e, t.targetSelector, t.disableTransitionOnChange);
36
+ }), f(() => {
37
+ l && l();
38
+ }), (e, C) => p(e.$slots, "default");
39
+ }
40
+ });
41
+ export {
42
+ b as default
43
+ };
@@ -0,0 +1,12 @@
1
+ import { provide as e, inject as t } from "vue";
2
+ const o = /* @__PURE__ */ Symbol("vizel-icon-context");
3
+ function c(n) {
4
+ e(o, { customIcons: n });
5
+ }
6
+ function r() {
7
+ return t(o, {});
8
+ }
9
+ export {
10
+ c as provideVizelIcons,
11
+ r as useVizelIconContext
12
+ };
@@ -0,0 +1,16 @@
1
+ import { inject as t, computed as i } from "vue";
2
+ const o = /* @__PURE__ */ Symbol("vizel-editor");
3
+ function r() {
4
+ const e = t(o);
5
+ if (!e)
6
+ throw new Error("useVizelContext must be used within a VizelProvider");
7
+ return i(() => e());
8
+ }
9
+ function u() {
10
+ return t(o, null);
11
+ }
12
+ export {
13
+ o as VIZEL_CONTEXT_KEY,
14
+ r as useVizelContext,
15
+ u as useVizelContextSafe
16
+ };
@@ -0,0 +1,37 @@
1
+ import { handleVizelSuggestionEscape as m, createVizelSuggestionContainer as c } from "@vizel/core";
2
+ import { ref as o, createApp as s, h as d } from "vue";
3
+ import f from "./index18.js";
4
+ function R(u = {}) {
5
+ return {
6
+ render: () => {
7
+ let t = null, n = null;
8
+ const r = o(null), a = o([]), l = o(null);
9
+ return {
10
+ onStart: (e) => {
11
+ a.value = e.items, l.value = e.command, n = c(), t = s({
12
+ setup() {
13
+ return () => d(f, {
14
+ items: a.value,
15
+ ...u.className !== void 0 && { class: u.className },
16
+ ref: r,
17
+ onCommand: (i) => {
18
+ l.value?.(i);
19
+ }
20
+ });
21
+ }
22
+ }), t.mount(n.menuContainer), n.updatePosition(e.clientRect);
23
+ },
24
+ onUpdate: (e) => {
25
+ a.value = e.items, l.value = e.command, n?.updatePosition(e.clientRect);
26
+ },
27
+ onKeyDown: (e) => m(e.event) ? !0 : r.value?.onKeyDown(e.event) ?? !1,
28
+ onExit: () => {
29
+ t?.unmount(), n?.destroy(), t = null, n = null;
30
+ }
31
+ };
32
+ }
33
+ };
34
+ }
35
+ export {
36
+ R as createVizelSlashMenuRenderer
37
+ };
@@ -0,0 +1,48 @@
1
+ import { VIZEL_DEFAULT_AUTO_SAVE_OPTIONS as h, createVizelAutoSaveHandlers as f } from "@vizel/core";
2
+ import { reactive as i, onMounted as U, watch as S, onBeforeUnmount as C, computed as t } from "vue";
3
+ function A(o, u = {}) {
4
+ const r = { ...h, ...u }, a = i({
5
+ status: "saved",
6
+ hasUnsavedChanges: !1,
7
+ lastSaved: null,
8
+ error: null
9
+ });
10
+ let n = null, e = null;
11
+ const l = (s) => {
12
+ s.status !== void 0 && (a.status = s.status), s.hasUnsavedChanges !== void 0 && (a.hasUnsavedChanges = s.hasUnsavedChanges), s.lastSaved !== void 0 && (a.lastSaved = s.lastSaved), s.error !== void 0 && (a.error = s.error);
13
+ }, d = () => {
14
+ const s = o();
15
+ if (n && e && (n.off("update", e.handleUpdate), e.cancel()), n = s ?? null, !(n && r.enabled)) {
16
+ e = null;
17
+ return;
18
+ }
19
+ e = f(() => n, r, l), n.on("update", e.handleUpdate);
20
+ };
21
+ U(() => {
22
+ d();
23
+ }), S(
24
+ () => o(),
25
+ () => {
26
+ d();
27
+ }
28
+ ), C(() => {
29
+ n && e && (n.off("update", e.handleUpdate), e.cancel());
30
+ });
31
+ async function v() {
32
+ await e?.saveNow();
33
+ }
34
+ async function c() {
35
+ return await e?.restore() ?? null;
36
+ }
37
+ return {
38
+ status: t(() => a.status),
39
+ hasUnsavedChanges: t(() => a.hasUnsavedChanges),
40
+ lastSaved: t(() => a.lastSaved),
41
+ error: t(() => a.error),
42
+ save: v,
43
+ restore: c
44
+ };
45
+ }
46
+ export {
47
+ A as useVizelAutoSave
48
+ };
@@ -0,0 +1,24 @@
1
+ import { createVizelEditorInstance as l, registerVizelUploadEventHandler as d } from "@vizel/core";
2
+ import { shallowRef as u, onMounted as c, onBeforeUnmount as m } from "vue";
3
+ import { createVizelSlashMenuRenderer as p } from "./index24.js";
4
+ function E(o = {}) {
5
+ const { features: e, extensions: r = [], ...i } = o, a = typeof e?.image == "object" ? e.image : {}, t = u(null);
6
+ let n = null;
7
+ return c(() => {
8
+ const { editor: s } = l({
9
+ ...i,
10
+ ...e !== void 0 && { features: e },
11
+ extensions: r,
12
+ createSlashMenuRenderer: p
13
+ });
14
+ t.value = s, n = d({
15
+ getEditor: () => t.value,
16
+ getImageOptions: () => a
17
+ });
18
+ }), m(() => {
19
+ n?.(), t.value?.destroy();
20
+ }), t;
21
+ }
22
+ export {
23
+ E as useVizelEditor
24
+ };
@@ -0,0 +1,10 @@
1
+ import { getVizelEditorState as o } from "@vizel/core";
2
+ import { computed as r } from "vue";
3
+ import { useVizelState as i } from "./index29.js";
4
+ function p(t) {
5
+ const e = i(t);
6
+ return r(() => (e.value, o(t())));
7
+ }
8
+ export {
9
+ p as useVizelEditorState
10
+ };
@@ -0,0 +1,46 @@
1
+ import { getVizelMarkdown as k, createVizelMarkdownSyncHandlers as p } from "@vizel/core";
2
+ import { ref as d, watch as w, onBeforeUnmount as M, computed as g } from "vue";
3
+ function y(o, f = {}) {
4
+ const { initialValue: s, ...m } = f, t = d(s ?? ""), a = d(!1);
5
+ let l = null;
6
+ const i = () => (l || (l = p(m)), l);
7
+ let r = !1;
8
+ w(
9
+ o,
10
+ (e) => {
11
+ if (!e || r) return;
12
+ const n = i();
13
+ s !== void 0 ? (n.setMarkdown(e, s), t.value = s) : t.value = k(e), r = !0;
14
+ const u = () => {
15
+ n.handleUpdate(e), a.value = n.isPending();
16
+ const c = () => {
17
+ n.isPending() ? requestAnimationFrame(c) : (t.value = n.getMarkdown(), a.value = !1);
18
+ };
19
+ requestAnimationFrame(c);
20
+ };
21
+ e.on("update", u);
22
+ },
23
+ { immediate: !0 }
24
+ ), M(() => {
25
+ l?.destroy();
26
+ });
27
+ const h = (e) => {
28
+ const n = o();
29
+ if (!n) return;
30
+ i().setMarkdown(n, e), t.value = e, a.value = !1;
31
+ }, v = () => {
32
+ const e = o();
33
+ if (!e) return;
34
+ const n = i();
35
+ n.flush(e), t.value = n.getMarkdown(), a.value = !1;
36
+ };
37
+ return {
38
+ markdown: t,
39
+ setMarkdown: h,
40
+ isPending: g(() => a.value),
41
+ flush: v
42
+ };
43
+ }
44
+ export {
45
+ y as useVizelMarkdown
46
+ };
@@ -0,0 +1,23 @@
1
+ import { ref as a, watch as u, onBeforeUnmount as f } from "vue";
2
+ function l(i) {
3
+ const e = a(0);
4
+ let n = null;
5
+ function o() {
6
+ e.value++;
7
+ }
8
+ function r(t) {
9
+ n && n !== t && n.off("transaction", o), n = t ?? null, n && n.on("transaction", o);
10
+ }
11
+ return u(
12
+ i,
13
+ (t) => {
14
+ r(t);
15
+ },
16
+ { immediate: !0 }
17
+ ), f(() => {
18
+ n && n.off("transaction", o);
19
+ }), e;
20
+ }
21
+ export {
22
+ l as useVizelState
23
+ };
package/dist/index3.js ADDED
@@ -0,0 +1,61 @@
1
+ import { defineComponent as b, useSlots as v, ref as g, computed as h, watch as w, onBeforeUnmount as k, createElementBlock as B, createCommentVNode as a, openBlock as s, normalizeClass as E, renderSlot as S, createBlock as D, unref as z } from "vue";
2
+ import { BubbleMenuPlugin as K } from "@vizel/core";
3
+ import C from "./index6.js";
4
+ import { useVizelContextSafe as M } from "./index23.js";
5
+ const $ = /* @__PURE__ */ b({
6
+ __name: "VizelBubbleMenu",
7
+ props: {
8
+ editor: {},
9
+ class: {},
10
+ showDefaultMenu: { type: Boolean, default: !0 },
11
+ pluginKey: { default: "vizelBubbleMenu" },
12
+ updateDelay: { default: 100 },
13
+ shouldShow: {},
14
+ enableEmbed: { type: Boolean }
15
+ },
16
+ setup(u) {
17
+ const n = u, r = v(), i = g(null), d = M(), t = h(() => n.editor ?? d?.());
18
+ function o(e) {
19
+ e.key === "Escape" && t.value && !t.value.view.state.selection.empty && (e.preventDefault(), t.value.commands.setTextSelection(t.value.view.state.selection.to));
20
+ }
21
+ return w(
22
+ [t, i],
23
+ ([e, l], [, m]) => {
24
+ if (!(e && l)) return;
25
+ m && (e.unregisterPlugin(n.pluginKey), document.removeEventListener("keydown", o));
26
+ const c = K({
27
+ pluginKey: n.pluginKey,
28
+ editor: e,
29
+ element: l,
30
+ updateDelay: n.updateDelay,
31
+ ...n.shouldShow && {
32
+ shouldShow: ({ editor: f, from: p, to: y }) => n.shouldShow?.({ editor: f, from: p, to: y }) ?? !1
33
+ },
34
+ options: {
35
+ placement: "top"
36
+ }
37
+ });
38
+ e.registerPlugin(c), document.addEventListener("keydown", o);
39
+ },
40
+ { immediate: !0 }
41
+ ), k(() => {
42
+ t.value && t.value.unregisterPlugin(n.pluginKey), document.removeEventListener("keydown", o);
43
+ }), (e, l) => t.value ? (s(), B("div", {
44
+ key: 0,
45
+ ref_key: "menuRef",
46
+ ref: i,
47
+ class: E(["vizel-bubble-menu", e.$props.class]),
48
+ "data-vizel-bubble-menu": "",
49
+ style: { visibility: "hidden" }
50
+ }, [
51
+ z(r).default ? S(e.$slots, "default", { key: 0 }) : u.showDefaultMenu ? (s(), D(C, {
52
+ key: 1,
53
+ editor: t.value,
54
+ "enable-embed": n.enableEmbed
55
+ }, null, 8, ["editor", "enable-embed"])) : a("", !0)
56
+ ], 2)) : a("", !0);
57
+ }
58
+ });
59
+ export {
60
+ $ as default
61
+ };
@@ -0,0 +1,15 @@
1
+ import { inject as r } from "vue";
2
+ import { VIZEL_THEME_CONTEXT_KEY as t } from "./index31.js";
3
+ function o() {
4
+ const e = r(t);
5
+ if (!e)
6
+ throw new Error("useVizelTheme must be used within a VizelThemeProvider");
7
+ return e;
8
+ }
9
+ function u() {
10
+ return r(t, null);
11
+ }
12
+ export {
13
+ o as useVizelTheme,
14
+ u as useVizelThemeSafe
15
+ };
@@ -0,0 +1,4 @@
1
+ const e = /* @__PURE__ */ Symbol("VizelThemeContext");
2
+ export {
3
+ e as VIZEL_THEME_CONTEXT_KEY
4
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./index2.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./index3.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./index4.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./index5.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./index6.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./index7.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./index8.js";
2
+ export {
3
+ f as default
4
+ };