@vizel/core 0.0.1-alpha.6 → 1.0.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.
Files changed (75) hide show
  1. package/dist/components.css +1 -1
  2. package/dist/components.css.map +1 -1
  3. package/dist/index.d.ts +230 -15
  4. package/dist/index.js +78 -75
  5. package/dist/index10.js +1 -1
  6. package/dist/index11.js +4 -4
  7. package/dist/index14.js +1 -1
  8. package/dist/index15.js +134 -127
  9. package/dist/index17.js +2 -2
  10. package/dist/index18.js +1 -1
  11. package/dist/index19.js +86 -86
  12. package/dist/index20.js +2 -2
  13. package/dist/index21.js +2 -2
  14. package/dist/index22.js +16 -13
  15. package/dist/index24.js +164 -11
  16. package/dist/index25.js +12 -53
  17. package/dist/index26.js +49 -136
  18. package/dist/index27.js +132 -59
  19. package/dist/index28.js +66 -32
  20. package/dist/index29.js +35 -21
  21. package/dist/index3.js +91 -90
  22. package/dist/index30.js +23 -9
  23. package/dist/index31.js +9 -147
  24. package/dist/index32.js +138 -256
  25. package/dist/index33.js +258 -85
  26. package/dist/index34.js +91 -15
  27. package/dist/index35.js +63 -57
  28. package/dist/index36.js +4 -15
  29. package/dist/index37.js +115 -56
  30. package/dist/index38.js +327 -4
  31. package/dist/index39.js +11 -121
  32. package/dist/index4.js +1 -1
  33. package/dist/index40.js +481 -321
  34. package/dist/index41.js +42 -481
  35. package/dist/index42.js +683 -37
  36. package/dist/index43.js +4 -679
  37. package/dist/index44.js +4 -4
  38. package/dist/index45.js +238 -4
  39. package/dist/index46.js +54 -210
  40. package/dist/index47.js +16 -81
  41. package/dist/index48.js +57 -285
  42. package/dist/index49.js +14 -1501
  43. package/dist/index5.js +78 -68
  44. package/dist/index50.js +286 -5
  45. package/dist/index51.js +4 -4
  46. package/dist/index52.js +1408 -1467
  47. package/dist/index53.js +5 -723
  48. package/dist/index54.js +1112 -21
  49. package/dist/index55.js +722 -9
  50. package/dist/index56.js +83 -6
  51. package/dist/index57.js +245 -7
  52. package/dist/index58.js +3 -14
  53. package/dist/index59.js +1230 -17
  54. package/dist/index6.js +1 -1
  55. package/dist/index60.js +733 -24
  56. package/dist/index61.js +21 -84
  57. package/dist/index62.js +10 -246
  58. package/dist/index63.js +7 -3
  59. package/dist/index64.js +7 -1231
  60. package/dist/index65.js +11 -731
  61. package/dist/index66.js +17 -1059
  62. package/dist/index67.js +21 -51
  63. package/dist/index68.js +54 -3
  64. package/dist/index69.js +1061 -98
  65. package/dist/index7.js +108 -96
  66. package/dist/index70.js +98 -91
  67. package/dist/index71.js +93 -0
  68. package/dist/index72.js +6 -0
  69. package/dist/index8.js +1 -1
  70. package/dist/index9.js +75 -65
  71. package/dist/mathematics.css +1 -0
  72. package/dist/mathematics.css.map +1 -0
  73. package/dist/styles.css +1 -1
  74. package/dist/styles.css.map +1 -1
  75. package/package.json +90 -52
package/dist/index3.js CHANGED
@@ -1,71 +1,70 @@
1
- import s from "@tiptap/extension-blockquote";
2
- import m from "@tiptap/extension-bold";
3
- import l from "@tiptap/extension-bullet-list";
4
- import d from "@tiptap/extension-code";
1
+ import a from "@tiptap/extension-blockquote";
2
+ import s from "@tiptap/extension-bold";
3
+ import m from "@tiptap/extension-bullet-list";
4
+ import l from "@tiptap/extension-code";
5
5
  import c from "@tiptap/extension-document";
6
- import p from "@tiptap/extension-dropcursor";
7
- import f from "@tiptap/extension-gapcursor";
8
- import u from "@tiptap/extension-hard-break";
9
- import h from "@tiptap/extension-heading";
10
- import x from "@tiptap/extension-history";
11
- import E from "@tiptap/extension-horizontal-rule";
12
- import g from "@tiptap/extension-italic";
13
- import b from "@tiptap/extension-list-item";
14
- import k from "@tiptap/extension-list-keymap";
15
- import z from "@tiptap/extension-ordered-list";
6
+ import d from "@tiptap/extension-dropcursor";
7
+ import p from "@tiptap/extension-gapcursor";
8
+ import f from "@tiptap/extension-hard-break";
9
+ import u from "@tiptap/extension-heading";
10
+ import h from "@tiptap/extension-history";
11
+ import x from "@tiptap/extension-horizontal-rule";
12
+ import E from "@tiptap/extension-italic";
13
+ import g from "@tiptap/extension-list-item";
14
+ import b from "@tiptap/extension-list-keymap";
15
+ import k from "@tiptap/extension-ordered-list";
16
16
  import y from "@tiptap/extension-paragraph";
17
- import C from "@tiptap/extension-placeholder";
18
- import V from "@tiptap/extension-strike";
19
- import O from "@tiptap/extension-text";
20
- import j from "./index37.js";
21
- import { createVizelCharacterCountExtension as B } from "./index4.js";
22
- import { createVizelCodeBlockExtension as a } from "./index5.js";
23
- import { createVizelDetailsExtensions as L } from "./index6.js";
24
- import { createVizelDiagramExtension as v } from "./index7.js";
25
- import { createVizelDragHandleExtensions as w } from "./index8.js";
26
- import { createVizelEmbedExtension as H } from "./index9.js";
27
- import { vizelDefaultBase64Upload as T, createVizelImageUploadExtensions as D, defaultImageResizeOptions as S } from "./index11.js";
28
- import { createVizelLinkExtension as U } from "./index13.js";
29
- import { createVizelMarkdownExtension as I } from "./index14.js";
30
- import { createVizelMathematicsExtensions as M } from "./index15.js";
31
- import { VizelSlashCommand as F } from "./index17.js";
32
- import { createVizelTableExtensions as P } from "./index18.js";
33
- import { createVizelTaskListExtensions as R } from "./index20.js";
34
- import { createVizelTextColorExtensions as q } from "./index21.js";
35
- import { defaultSlashCommands as G } from "./index32.js";
36
- function K(e = {}) {
17
+ import z from "@tiptap/extension-placeholder";
18
+ import C from "@tiptap/extension-strike";
19
+ import V from "@tiptap/extension-text";
20
+ import O from "./index35.js";
21
+ import { createVizelCharacterCountExtension as j } from "./index4.js";
22
+ import { createVizelDetailsExtensions as w } from "./index6.js";
23
+ import { createVizelDiagramExtension as B } from "./index7.js";
24
+ import { createVizelDragHandleExtensions as L } from "./index8.js";
25
+ import { createVizelEmbedExtension as v } from "./index9.js";
26
+ import { vizelDefaultBase64Upload as H, createVizelImageUploadExtensions as T, defaultImageResizeOptions as D } from "./index11.js";
27
+ import { createVizelLinkExtension as S } from "./index13.js";
28
+ import { createVizelMarkdownExtension as U } from "./index14.js";
29
+ import { createVizelMathematicsExtensions as I } from "./index15.js";
30
+ import { VizelSlashCommand as M } from "./index17.js";
31
+ import { createVizelTableExtensions as F } from "./index18.js";
32
+ import { createVizelTaskListExtensions as P } from "./index20.js";
33
+ import { createVizelTextColorExtensions as R } from "./index21.js";
34
+ import { defaultSlashCommands as q } from "./index33.js";
35
+ function G(e = {}) {
37
36
  const { headingLevels: o = [1, 2, 3] } = e;
38
37
  return [
39
38
  // Nodes
40
39
  c,
41
40
  y,
42
- O,
43
- h.configure({ levels: o }),
44
- s,
45
- l,
46
- z,
47
- b,
48
- // CodeBlock is added separately based on feature options
49
- u,
50
- E,
51
- // Marks
41
+ V,
42
+ u.configure({ levels: o }),
43
+ a,
52
44
  m,
53
- d,
45
+ k,
54
46
  g,
55
- V,
56
- j,
57
- // Functionality
58
- p.configure({ color: "#3b82f6", width: 2 }),
47
+ // CodeBlock is added separately based on feature options
59
48
  f,
60
49
  x,
61
- k
50
+ // Marks
51
+ s,
52
+ l,
53
+ E,
54
+ C,
55
+ O,
56
+ // Functionality
57
+ d.configure({ color: "#3b82f6", width: 2 }),
58
+ p,
59
+ h,
60
+ b
62
61
  ];
63
62
  }
64
- function N(e, o) {
63
+ function K(e, o) {
65
64
  if (o.slashCommand === !1) return;
66
- const t = typeof o.slashCommand == "object" ? o.slashCommand : {}, i = t.items ?? G;
65
+ const t = typeof o.slashCommand == "object" ? o.slashCommand : {}, i = t.items ?? q;
67
66
  e.push(
68
- F.configure({
67
+ M.configure({
69
68
  items: i,
70
69
  ...t.suggestion !== void 0 && {
71
70
  suggestion: t.suggestion
@@ -73,11 +72,11 @@ function N(e, o) {
73
72
  })
74
73
  );
75
74
  }
76
- function _(e, o) {
75
+ function N(e, o) {
77
76
  if (o.image === !1) return;
78
- const t = typeof o.image == "object" ? o.image : {}, i = t.onUpload ?? T, n = t.resize !== !1;
77
+ const t = typeof o.image == "object" ? o.image : {}, i = t.onUpload ?? H, n = t.resize !== !1;
79
78
  e.push(
80
- ...D({
79
+ ...T({
81
80
  upload: {
82
81
  onUpload: i,
83
82
  ...t.maxFileSize !== void 0 && { maxFileSize: t.maxFileSize },
@@ -89,86 +88,88 @@ function _(e, o) {
89
88
  onUploadError: t.onUploadError
90
89
  }
91
90
  },
92
- resize: n ? S : !1
91
+ resize: n ? D : !1
93
92
  })
94
93
  );
95
94
  }
96
- function A(e, o) {
95
+ function _(e, o) {
97
96
  if (o.markdown === !1) return;
98
97
  const t = typeof o.markdown == "object" ? o.markdown : {};
99
- e.push(I(t));
98
+ e.push(U(t));
100
99
  }
101
- function J(e, o) {
100
+ function A(e, o) {
102
101
  if (o.taskList === !1) return;
103
102
  const t = typeof o.taskList == "object" ? o.taskList : {};
104
- e.push(...R(t));
103
+ e.push(...P(t));
105
104
  }
106
- function Q(e, o) {
105
+ function J(e, o) {
107
106
  if (o.characterCount === !1) return;
108
107
  const t = typeof o.characterCount == "object" ? o.characterCount : {};
109
- e.push(B(t));
108
+ e.push(j(t));
110
109
  }
111
- function W(e, o) {
110
+ function Q(e, o) {
112
111
  if (o.textColor === !1) return;
113
112
  const t = typeof o.textColor == "object" ? o.textColor : {};
114
- e.push(...q(t));
113
+ e.push(...R(t));
115
114
  }
116
- function X(e, o) {
117
- if (o.codeBlock !== !1)
118
- if (o.codeBlock === !0 || typeof o.codeBlock == "object") {
119
- const t = typeof o.codeBlock == "object" ? o.codeBlock : {};
120
- e.push(...a(t));
121
- } else
122
- e.push(...a());
115
+ async function W(e, o) {
116
+ if (o.codeBlock === !1)
117
+ return;
118
+ const { createVizelCodeBlockExtension: t } = await import("./index5.js");
119
+ if (o.codeBlock === !0 || typeof o.codeBlock == "object") {
120
+ const i = typeof o.codeBlock == "object" ? o.codeBlock : {};
121
+ e.push(...await t(i));
122
+ } else
123
+ e.push(...await t());
123
124
  }
124
- function Y(e, o) {
125
+ function X(e, o) {
125
126
  if (o.mathematics === !1) return;
126
127
  const t = typeof o.mathematics == "object" ? o.mathematics : {};
127
- e.push(...M(t));
128
+ e.push(...I(t));
128
129
  }
129
- function Z(e, o) {
130
+ function Y(e, o) {
130
131
  if (o.dragHandle === !1) return;
131
132
  const t = typeof o.dragHandle == "object" ? o.dragHandle : {};
132
- e.push(...w(t));
133
+ e.push(...L(t));
133
134
  }
134
- function $(e, o) {
135
+ function Z(e, o) {
135
136
  if (o.details === !1) return;
136
137
  const t = typeof o.details == "object" ? o.details : {};
137
- e.push(...L(t));
138
+ e.push(...w(t));
138
139
  }
139
- function oo(e, o) {
140
+ function $(e, o) {
140
141
  if (o.embed === !1) return;
141
142
  const t = typeof o.embed == "object" ? o.embed : {};
142
- e.push(H(t));
143
+ e.push(v(t));
143
144
  }
144
- function to(e, o) {
145
+ function oo(e, o) {
145
146
  if (o.diagram === !1) return;
146
147
  const t = typeof o.diagram == "object" ? o.diagram : {};
147
- e.push(v(t));
148
+ e.push(B(t));
148
149
  }
149
- function Fo(e = {}) {
150
+ async function Io(e = {}) {
150
151
  const {
151
152
  placeholder: o = "Type '/' for commands...",
152
153
  headingLevels: t = [1, 2, 3],
153
154
  features: i = {}
154
155
  } = e, n = [
155
- ...K({ headingLevels: t }),
156
- C.configure({
156
+ ...G({ headingLevels: t }),
157
+ z.configure({
157
158
  placeholder: o,
158
159
  emptyEditorClass: "vizel-editor-empty",
159
160
  emptyNodeClass: "vizel-node-empty"
160
161
  })
161
162
  ];
162
- if (N(n, i), i.table !== !1) {
163
+ if (K(n, i), i.table !== !1) {
163
164
  const r = typeof i.table == "object" ? i.table : {};
164
- n.push(...P(r));
165
+ n.push(...F(r));
165
166
  }
166
167
  if (i.link !== !1) {
167
168
  const r = typeof i.link == "object" ? i.link : {};
168
- n.push(U(r));
169
+ n.push(S(r));
169
170
  }
170
- return _(n, i), A(n, i), J(n, i), Q(n, i), W(n, i), X(n, i), Y(n, i), Z(n, i), $(n, i), oo(n, i), to(n, i), n;
171
+ return N(n, i), _(n, i), A(n, i), J(n, i), Q(n, i), X(n, i), Y(n, i), Z(n, i), $(n, i), oo(n, i), await W(n, i), n;
171
172
  }
172
173
  export {
173
- Fo as createVizelExtensions
174
+ Io as createVizelExtensions
174
175
  };
package/dist/index30.js CHANGED
@@ -1,12 +1,26 @@
1
- function g(i, e) {
2
- if (!e || e.length === 0)
3
- return [{ text: i, highlight: !1 }];
4
- const t = [];
5
- let l = 0;
6
- for (const [h, s] of e)
7
- h > l && t.push({ text: i.slice(l, h), highlight: !1 }), t.push({ text: i.slice(h, s + 1), highlight: !0 }), l = s + 1;
8
- return l < i.length && t.push({ text: i.slice(l), highlight: !1 }), t;
1
+ const r = "50";
2
+ function c() {
3
+ const e = document.createElement("div");
4
+ e.style.position = "absolute", e.style.zIndex = "50", document.body.appendChild(e);
5
+ const n = document.createElement("div");
6
+ return e.appendChild(n), {
7
+ container: e,
8
+ menuContainer: n,
9
+ updatePosition: (o) => {
10
+ if (!o) return;
11
+ const t = o();
12
+ t && (e.style.top = `${t.bottom + window.scrollY}px`, e.style.left = `${t.left + window.scrollX}px`);
13
+ },
14
+ destroy: () => {
15
+ e.remove();
16
+ }
17
+ };
18
+ }
19
+ function d(e) {
20
+ return e.key === "Escape";
9
21
  }
10
22
  export {
11
- g as splitVizelTextByMatches
23
+ r as VIZEL_SUGGESTION_Z_INDEX,
24
+ c as createVizelSuggestionContainer,
25
+ d as handleVizelSuggestionEscape
12
26
  };
package/dist/index31.js CHANGED
@@ -1,150 +1,12 @@
1
- import { PluginKey as S, Plugin as A } from "./index41.js";
2
- import { DecorationSet as E, Decoration as M } from "./index49.js";
3
- import { VIZEL_DEFAULT_IMAGE_MAX_FILE_SIZE as _, VIZEL_DEFAULT_FILE_MIME_TYPES as P } from "./index10.js";
4
- const d = new S("vizel-image-upload"), U = (e) => typeof e == "object" && e !== null && "type" in e && (e.type === "add" || e.type === "remove");
5
- function T(e) {
6
- const { placeholderClass: o = "vizel-image-placeholder", imageClass: r = "vizel-image-uploading" } = e;
7
- return new A({
8
- key: d,
9
- state: {
10
- init() {
11
- return E.empty;
12
- },
13
- apply(t, i) {
14
- let a = i.map(t.mapping, t.doc);
15
- const s = t.getMeta(d), n = U(s) ? s : void 0;
16
- if (n?.type === "add") {
17
- const { id: l, pos: g, previewSrc: p } = n, c = document.createElement("div");
18
- c.setAttribute("class", o);
19
- const u = document.createElement("img");
20
- u.setAttribute("class", r), u.src = p, c.appendChild(u);
21
- const m = document.createElement("div");
22
- m.setAttribute("class", "vizel-image-spinner"), c.appendChild(m);
23
- const f = M.widget(g, c, { id: l });
24
- a = a.add(t.doc, [f]);
25
- } else n?.type === "remove" && (a = a.remove(
26
- a.find(void 0, void 0, (l) => l.id === n.id)
27
- ));
28
- return a;
29
- }
30
- },
31
- props: {
32
- decorations(t) {
33
- return d.getState(t) ?? E.empty;
34
- }
35
- }
36
- });
37
- }
38
- function F(e, o) {
39
- const r = d.getState(e);
40
- if (!r)
41
- return null;
42
- const t = r.find(void 0, void 0, (i) => i.id === o);
43
- return t.length > 0 ? t[0]?.from ?? null : null;
44
- }
45
- function x(e, o) {
46
- const r = o.maxFileSize ?? _, t = o.allowedTypes ?? P;
47
- if (!t.includes(e.type))
48
- return {
49
- type: "invalid_type",
50
- message: `File type "${e.type}" is not allowed. Allowed types: ${t.join(", ")}`,
51
- file: e
52
- };
53
- if (e.size > r) {
54
- const i = (r / 1048576).toFixed(1);
55
- return {
56
- type: "file_too_large",
57
- message: `File size (${(e.size / (1024 * 1024)).toFixed(1)}MB) exceeds maximum allowed size (${i}MB)`,
58
- file: e
59
- };
60
- }
61
- return null;
62
- }
63
- function v(e) {
64
- const { onUpload: o, maxFileSize: r, allowedTypes: t, onValidationError: i, onUploadError: a } = e;
65
- return (s, n, l) => {
66
- const g = x(s, {
67
- ...r !== void 0 && { maxFileSize: r },
68
- ...t !== void 0 && { allowedTypes: t }
69
- });
70
- if (g) {
71
- i?.(g);
72
- return;
73
- }
74
- const p = {}, c = new FileReader();
75
- c.readAsDataURL(s), c.onload = () => {
76
- if (typeof c.result != "string") return;
77
- const u = c.result, m = n.state.tr;
78
- m.selection.empty || m.deleteSelection(), m.setMeta(d, {
79
- type: "add",
80
- id: p,
81
- pos: l,
82
- previewSrc: u
83
- }), n.dispatch(m), o(s).then((f) => {
84
- const y = F(n.state, p);
85
- if (y === null)
86
- return;
87
- const { schema: h } = n.state, z = h.nodes.image?.create({ src: f });
88
- if (!z) {
89
- console.warn("Image node type not found in schema");
90
- return;
91
- }
92
- const I = n.state.tr.replaceWith(y, y, z).setMeta(d, {
93
- type: "remove",
94
- id: p
95
- });
96
- n.dispatch(I);
97
- }).catch((f) => {
98
- if (a?.(f, s), F(n.state, p) !== null) {
99
- const h = n.state.tr.setMeta(d, {
100
- type: "remove",
101
- id: p
102
- });
103
- n.dispatch(h);
104
- }
105
- });
106
- };
107
- };
108
- }
109
- function b(e, o, r) {
110
- const t = o.clipboardData?.files;
111
- if (!t || t.length === 0)
112
- return !1;
113
- const i = Array.from(t).filter((s) => s.type.startsWith("image/"));
114
- if (i.length === 0)
115
- return !1;
116
- o.preventDefault();
117
- const a = e.state.selection.from;
118
- for (const s of i)
119
- r(s, e, a);
120
- return !0;
121
- }
122
- function B(e, o, r, t) {
123
- if (r)
124
- return !1;
125
- const i = o.dataTransfer?.files;
126
- if (!i || i.length === 0)
127
- return !1;
128
- const a = Array.from(i).filter((l) => l.type.startsWith("image/"));
129
- if (a.length === 0)
130
- return !1;
131
- o.preventDefault();
132
- const n = e.posAtCoords({
133
- left: o.clientX,
134
- top: o.clientY
135
- })?.pos ?? e.state.selection.from;
136
- for (const l of a)
137
- t(l, e, n);
138
- return !0;
139
- }
140
- function C() {
141
- return d;
1
+ function g(i, e) {
2
+ if (!e || e.length === 0)
3
+ return [{ text: i, highlight: !1 }];
4
+ const t = [];
5
+ let l = 0;
6
+ for (const [h, s] of e)
7
+ h > l && t.push({ text: i.slice(l, h), highlight: !1 }), t.push({ text: i.slice(h, s + 1), highlight: !0 }), l = s + 1;
8
+ return l < i.length && t.push({ text: i.slice(l), highlight: !1 }), t;
142
9
  }
143
10
  export {
144
- T as createVizelImageUploadPlugin,
145
- v as createVizelImageUploader,
146
- C as getVizelImageUploadPluginKey,
147
- B as handleVizelImageDrop,
148
- b as handleVizelImagePaste,
149
- x as validateVizelImageFile
11
+ g as splitVizelTextByMatches
150
12
  };