@vizel/core 0.0.1-alpha.1 → 0.0.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.d.ts +13 -13
  3. package/dist/index.js +141 -141
  4. package/dist/index10.js +70 -110
  5. package/dist/index11.js +135 -168
  6. package/dist/index12.js +83 -74
  7. package/dist/index13.js +13 -134
  8. package/dist/index14.js +13 -146
  9. package/dist/index15.js +303 -15
  10. package/dist/index16.js +69 -14
  11. package/dist/index17.js +26 -295
  12. package/dist/index18.js +2 -2
  13. package/dist/index19.js +355 -24
  14. package/dist/index20.js +25 -264
  15. package/dist/index21.js +85 -68
  16. package/dist/index22.js +97 -353
  17. package/dist/index23.js +66 -84
  18. package/dist/index24.js +12 -36
  19. package/dist/index25.js +53 -92
  20. package/dist/index26.js +132 -96
  21. package/dist/index27.js +59 -126
  22. package/dist/index28.js +37 -53
  23. package/dist/index29.js +19 -62
  24. package/dist/index3.js +165 -60
  25. package/dist/index30.js +9 -37
  26. package/dist/index31.js +143 -19
  27. package/dist/index32.js +264 -11
  28. package/dist/index33.js +92 -9
  29. package/dist/index36.js +1 -1
  30. package/dist/index37.js +41 -57
  31. package/dist/index38.js +64 -4
  32. package/dist/index39.js +4 -123
  33. package/dist/index4.js +10 -86
  34. package/dist/index40.js +111 -315
  35. package/dist/index41.js +321 -481
  36. package/dist/index42.js +481 -42
  37. package/dist/index43.js +143 -138
  38. package/dist/index44.js +1 -1
  39. package/dist/index45.js +1 -1
  40. package/dist/index46.js +1 -1
  41. package/dist/index48.js +3 -3
  42. package/dist/index49.js +158 -1458
  43. package/dist/index5.js +132 -10
  44. package/dist/index50.js +1561 -5
  45. package/dist/index51.js +1408 -1467
  46. package/dist/index52.js +704 -183
  47. package/dist/index53.js +5 -723
  48. package/dist/index6.js +48 -131
  49. package/dist/index61.js +1 -1
  50. package/dist/index62.js +1 -1
  51. package/dist/index65.js +1 -1
  52. package/dist/index66.js +53 -1059
  53. package/dist/index67.js +1059 -53
  54. package/dist/index69.js +90 -3
  55. package/dist/index7.js +228 -409
  56. package/dist/index70.js +3 -90
  57. package/dist/index8.js +111 -45
  58. package/dist/index9.js +409 -228
  59. package/package.json +54 -80
package/dist/index5.js CHANGED
@@ -1,13 +1,135 @@
1
- import n from "./index38.js";
2
- function u(e = {}) {
3
- const { limit: o = null, mode: r = "textSize", wordCounter: t } = e;
4
- return n.configure({
5
- limit: o,
6
- mode: r,
7
- ...t !== void 0 && { wordCounter: t }
8
- });
1
+ import H from "./index40.js";
2
+ import { createLowlight as T, all as V } from "lowlight";
3
+ import { renderVizelIcon as S } from "./index22.js";
4
+ const w = T(V);
5
+ function N() {
6
+ return w.listLanguages().sort((t, p) => t.localeCompare(p)).map((t) => ({
7
+ id: t,
8
+ // Capitalize first letter for display name
9
+ name: t.charAt(0).toUpperCase() + t.slice(1)
10
+ }));
11
+ }
12
+ function O() {
13
+ return N().map((u) => u.id);
14
+ }
15
+ function W(u) {
16
+ const t = u.toLowerCase();
17
+ return N().find((p) => p.id === t);
18
+ }
19
+ function q(u = {}) {
20
+ const {
21
+ defaultLanguage: t = "plaintext",
22
+ lineNumbers: p = !1,
23
+ lowlight: x = w
24
+ } = u;
25
+ return [H.extend({
26
+ addAttributes() {
27
+ return {
28
+ ...this.parent?.(),
29
+ language: {
30
+ default: t,
31
+ parseHTML: (n) => n.getAttribute("data-language") || n.querySelector("code")?.getAttribute("class")?.replace("language-", "") || t,
32
+ renderHTML: (n) => ({
33
+ "data-language": n.language || t,
34
+ class: `language-${n.language || t}`
35
+ })
36
+ },
37
+ lineNumbers: {
38
+ default: p,
39
+ parseHTML: (n) => n.getAttribute("data-line-numbers") === "true",
40
+ renderHTML: (n) => n.lineNumbers ? { "data-line-numbers": "true" } : {}
41
+ }
42
+ };
43
+ },
44
+ addNodeView() {
45
+ return ({ node: n, getPos: f, editor: d }) => {
46
+ const g = document.createElement("div");
47
+ g.classList.add("vizel-code-block"), n.attrs.lineNumbers && g.classList.add("vizel-code-block-line-numbers");
48
+ const o = document.createElement("div");
49
+ o.classList.add("vizel-code-block-language-selector"), o.setAttribute("contenteditable", "false");
50
+ const l = document.createElement("input");
51
+ l.type = "text", l.classList.add("vizel-code-block-language-input"), l.value = n.attrs.language || t, l.placeholder = "language";
52
+ const k = `vizel-languages-${Math.random().toString(36).slice(2, 9)}`, v = document.createElement("datalist");
53
+ v.id = k, l.setAttribute("list", k);
54
+ for (const e of N()) {
55
+ const a = document.createElement("option");
56
+ a.value = e.id, a.label = e.name, v.appendChild(a);
57
+ }
58
+ const C = () => {
59
+ const e = typeof f == "function" ? f() : null;
60
+ if (e != null) {
61
+ const a = l.value.toLowerCase().trim() || t;
62
+ l.value = a;
63
+ const { tr: c } = d.state, i = d.state.doc.nodeAt(e);
64
+ i && (c.setNodeMarkup(e, void 0, {
65
+ ...i.attrs,
66
+ language: a
67
+ }), d.view.dispatch(c));
68
+ }
69
+ };
70
+ l.addEventListener("change", C), l.addEventListener("blur", C), l.addEventListener("keydown", (e) => {
71
+ e.key === "Enter" && (e.preventDefault(), e.stopPropagation(), C(), l.blur());
72
+ });
73
+ const s = document.createElement("button");
74
+ s.type = "button", s.classList.add("vizel-code-block-line-numbers-toggle"), s.innerHTML = S("listOrdered", { width: 16, height: 16 }), n.attrs.lineNumbers && s.classList.add("active"), s.title = n.attrs.lineNumbers ? "Hide line numbers" : "Show line numbers", o.appendChild(s), o.appendChild(l), o.appendChild(v);
75
+ const L = document.createElement("div");
76
+ L.classList.add("vizel-code-block-container");
77
+ const r = document.createElement("div");
78
+ r.classList.add("vizel-code-block-gutter"), r.setAttribute("contenteditable", "false"), r.setAttribute("aria-hidden", "true");
79
+ const E = document.createElement("pre"), b = document.createElement("code");
80
+ b.classList.add(`language-${n.attrs.language || t}`), E.appendChild(b), L.appendChild(r), L.appendChild(E), g.appendChild(o), g.appendChild(L);
81
+ const z = () => {
82
+ const e = b.textContent || "", a = e.split(`
83
+ `), c = e.endsWith(`
84
+ `) && a.length > 1 ? a.length - 1 : Math.max(1, a.length);
85
+ if (r.children.length !== c) {
86
+ r.innerHTML = "";
87
+ for (let i = 1; i <= c; i++) {
88
+ const m = document.createElement("div");
89
+ m.classList.add("vizel-code-block-line-number"), m.textContent = String(i), r.appendChild(m);
90
+ }
91
+ }
92
+ };
93
+ n.attrs.lineNumbers && setTimeout(z, 0);
94
+ let A = n.attrs.language, h = n.attrs.lineNumbers;
95
+ s.addEventListener("click", (e) => {
96
+ e.preventDefault(), e.stopPropagation();
97
+ const a = typeof f == "function" ? f() : null;
98
+ if (a != null) {
99
+ const c = !h, { tr: i } = d.state, m = d.state.doc.nodeAt(a);
100
+ m && (i.setNodeMarkup(a, void 0, {
101
+ ...m.attrs,
102
+ lineNumbers: c
103
+ }), d.view.dispatch(i));
104
+ }
105
+ });
106
+ const M = (e) => {
107
+ A = e, l.value = e || t, b.className = `language-${e || t}`;
108
+ }, y = (e) => {
109
+ h = e, g.classList.toggle("vizel-code-block-line-numbers", e), s.classList.toggle("active", e), s.title = e ? "Hide line numbers" : "Show line numbers";
110
+ };
111
+ return {
112
+ dom: g,
113
+ contentDOM: b,
114
+ update(e) {
115
+ return e.type.name !== "codeBlock" ? !1 : (e.attrs.language !== A && M(e.attrs.language), e.attrs.lineNumbers !== h && y(e.attrs.lineNumbers), h && setTimeout(z, 0), !0);
116
+ },
117
+ ignoreMutation(e) {
118
+ return r.contains(e.target) || o.contains(e.target);
119
+ }
120
+ };
121
+ };
122
+ }
123
+ }).configure({
124
+ lowlight: x,
125
+ defaultLanguage: t
126
+ })];
9
127
  }
10
128
  export {
11
- n as CharacterCount,
12
- u as createVizelCharacterCountExtension
129
+ H as CodeBlockLowlight,
130
+ q as createVizelCodeBlockExtension,
131
+ W as findVizelLanguage,
132
+ O as getAllVizelLanguageIds,
133
+ N as getVizelRegisteredLanguages,
134
+ w as lowlight
13
135
  };