@vizel/core 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 (77) hide show
  1. package/README.md +44 -0
  2. package/dist/components.css +1 -0
  3. package/dist/components.css.map +1 -0
  4. package/dist/index.d.ts +2642 -0
  5. package/dist/index.js +150 -0
  6. package/dist/index10.js +118 -0
  7. package/dist/index11.js +174 -0
  8. package/dist/index12.js +78 -0
  9. package/dist/index13.js +141 -0
  10. package/dist/index14.js +150 -0
  11. package/dist/index15.js +20 -0
  12. package/dist/index16.js +17 -0
  13. package/dist/index17.js +308 -0
  14. package/dist/index18.js +52 -0
  15. package/dist/index19.js +29 -0
  16. package/dist/index2.js +93 -0
  17. package/dist/index20.js +268 -0
  18. package/dist/index21.js +72 -0
  19. package/dist/index22.js +360 -0
  20. package/dist/index23.js +87 -0
  21. package/dist/index24.js +39 -0
  22. package/dist/index25.js +95 -0
  23. package/dist/index26.js +104 -0
  24. package/dist/index27.js +136 -0
  25. package/dist/index28.js +56 -0
  26. package/dist/index29.js +69 -0
  27. package/dist/index3.js +69 -0
  28. package/dist/index30.js +40 -0
  29. package/dist/index31.js +26 -0
  30. package/dist/index32.js +15 -0
  31. package/dist/index33.js +12 -0
  32. package/dist/index34.js +19 -0
  33. package/dist/index35.js +60 -0
  34. package/dist/index36.js +17 -0
  35. package/dist/index37.js +66 -0
  36. package/dist/index38.js +6 -0
  37. package/dist/index39.js +125 -0
  38. package/dist/index4.js +89 -0
  39. package/dist/index40.js +329 -0
  40. package/dist/index41.js +489 -0
  41. package/dist/index42.js +50 -0
  42. package/dist/index43.js +676 -0
  43. package/dist/index44.js +6 -0
  44. package/dist/index45.js +6 -0
  45. package/dist/index46.js +240 -0
  46. package/dist/index47.js +84 -0
  47. package/dist/index48.js +288 -0
  48. package/dist/index49.js +1504 -0
  49. package/dist/index5.js +13 -0
  50. package/dist/index50.js +7 -0
  51. package/dist/index51.js +1563 -0
  52. package/dist/index52.js +204 -0
  53. package/dist/index53.js +725 -0
  54. package/dist/index54.js +23 -0
  55. package/dist/index55.js +12 -0
  56. package/dist/index56.js +9 -0
  57. package/dist/index57.js +10 -0
  58. package/dist/index58.js +16 -0
  59. package/dist/index59.js +21 -0
  60. package/dist/index6.js +135 -0
  61. package/dist/index60.js +27 -0
  62. package/dist/index61.js +86 -0
  63. package/dist/index62.js +248 -0
  64. package/dist/index63.js +1234 -0
  65. package/dist/index64.js +736 -0
  66. package/dist/index65.js +5 -0
  67. package/dist/index66.js +1063 -0
  68. package/dist/index67.js +57 -0
  69. package/dist/index68.js +100 -0
  70. package/dist/index69.js +6 -0
  71. package/dist/index7.js +456 -0
  72. package/dist/index70.js +93 -0
  73. package/dist/index8.js +52 -0
  74. package/dist/index9.js +275 -0
  75. package/dist/styles.css +1 -0
  76. package/dist/styles.css.map +1 -0
  77. package/package.json +109 -0
@@ -0,0 +1,204 @@
1
+ import { keydownHandler as v } from "./index67.js";
2
+ import { Selection as u, NodeSelection as m, Plugin as w, TextSelection as x } from "./index41.js";
3
+ import { Slice as g, Fragment as h } from "./index63.js";
4
+ import { DecorationSet as S, Decoration as A } from "./index49.js";
5
+ class i extends u {
6
+ /**
7
+ Create a gap cursor.
8
+ */
9
+ constructor(e) {
10
+ super(e, e);
11
+ }
12
+ map(e, t) {
13
+ let o = e.resolve(t.map(this.head));
14
+ return i.valid(o) ? new i(o) : u.near(o);
15
+ }
16
+ content() {
17
+ return g.empty;
18
+ }
19
+ eq(e) {
20
+ return e instanceof i && e.head == this.head;
21
+ }
22
+ toJSON() {
23
+ return { type: "gapcursor", pos: this.head };
24
+ }
25
+ /**
26
+ @internal
27
+ */
28
+ static fromJSON(e, t) {
29
+ if (typeof t.pos != "number")
30
+ throw new RangeError("Invalid input for GapCursor.fromJSON");
31
+ return new i(e.resolve(t.pos));
32
+ }
33
+ /**
34
+ @internal
35
+ */
36
+ getBookmark() {
37
+ return new d(this.anchor);
38
+ }
39
+ /**
40
+ @internal
41
+ */
42
+ static valid(e) {
43
+ let t = e.parent;
44
+ if (t.isTextblock || !b(e) || !y(e))
45
+ return !1;
46
+ let o = t.type.spec.allowGapCursor;
47
+ if (o != null)
48
+ return o;
49
+ let r = t.contentMatchAt(e.index()).defaultType;
50
+ return r && r.isTextblock;
51
+ }
52
+ /**
53
+ @internal
54
+ */
55
+ static findGapCursorFrom(e, t, o = !1) {
56
+ e: for (; ; ) {
57
+ if (!o && i.valid(e))
58
+ return e;
59
+ let r = e.pos, s = null;
60
+ for (let l = e.depth; ; l--) {
61
+ let a = e.node(l);
62
+ if (t > 0 ? e.indexAfter(l) < a.childCount : e.index(l) > 0) {
63
+ s = a.child(t > 0 ? e.indexAfter(l) : e.index(l) - 1);
64
+ break;
65
+ } else if (l == 0)
66
+ return null;
67
+ r += t;
68
+ let f = e.doc.resolve(r);
69
+ if (i.valid(f))
70
+ return f;
71
+ }
72
+ for (; ; ) {
73
+ let l = t > 0 ? s.firstChild : s.lastChild;
74
+ if (!l) {
75
+ if (s.isAtom && !s.isText && !m.isSelectable(s)) {
76
+ e = e.doc.resolve(r + s.nodeSize * t), o = !1;
77
+ continue e;
78
+ }
79
+ break;
80
+ }
81
+ s = l, r += t;
82
+ let a = e.doc.resolve(r);
83
+ if (i.valid(a))
84
+ return a;
85
+ }
86
+ return null;
87
+ }
88
+ }
89
+ }
90
+ i.prototype.visible = !1;
91
+ i.findFrom = i.findGapCursorFrom;
92
+ u.jsonID("gapcursor", i);
93
+ class d {
94
+ constructor(e) {
95
+ this.pos = e;
96
+ }
97
+ map(e) {
98
+ return new d(e.map(this.pos));
99
+ }
100
+ resolve(e) {
101
+ let t = e.resolve(this.pos);
102
+ return i.valid(t) ? new i(t) : u.near(t);
103
+ }
104
+ }
105
+ function C(n) {
106
+ return n.isAtom || n.spec.isolating || n.spec.createGapCursor;
107
+ }
108
+ function b(n) {
109
+ for (let e = n.depth; e >= 0; e--) {
110
+ let t = n.index(e), o = n.node(e);
111
+ if (t == 0) {
112
+ if (o.type.spec.isolating)
113
+ return !0;
114
+ continue;
115
+ }
116
+ for (let r = o.child(t - 1); ; r = r.lastChild) {
117
+ if (r.childCount == 0 && !r.inlineContent || C(r.type))
118
+ return !0;
119
+ if (r.inlineContent)
120
+ return !1;
121
+ }
122
+ }
123
+ return !0;
124
+ }
125
+ function y(n) {
126
+ for (let e = n.depth; e >= 0; e--) {
127
+ let t = n.indexAfter(e), o = n.node(e);
128
+ if (t == o.childCount) {
129
+ if (o.type.spec.isolating)
130
+ return !0;
131
+ continue;
132
+ }
133
+ for (let r = o.child(t); ; r = r.firstChild) {
134
+ if (r.childCount == 0 && !r.inlineContent || C(r.type))
135
+ return !0;
136
+ if (r.inlineContent)
137
+ return !1;
138
+ }
139
+ }
140
+ return !0;
141
+ }
142
+ function B() {
143
+ return new w({
144
+ props: {
145
+ decorations: F,
146
+ createSelectionBetween(n, e, t) {
147
+ return e.pos == t.pos && i.valid(t) ? new i(t) : null;
148
+ },
149
+ handleClick: T,
150
+ handleKeyDown: k,
151
+ handleDOMEvents: { beforeinput: D }
152
+ }
153
+ });
154
+ }
155
+ const k = v({
156
+ ArrowLeft: c("horiz", -1),
157
+ ArrowRight: c("horiz", 1),
158
+ ArrowUp: c("vert", -1),
159
+ ArrowDown: c("vert", 1)
160
+ });
161
+ function c(n, e) {
162
+ const t = n == "vert" ? e > 0 ? "down" : "up" : e > 0 ? "right" : "left";
163
+ return function(o, r, s) {
164
+ let l = o.selection, a = e > 0 ? l.$to : l.$from, f = l.empty;
165
+ if (l instanceof x) {
166
+ if (!s.endOfTextblock(t) || a.depth == 0)
167
+ return !1;
168
+ f = !1, a = o.doc.resolve(e > 0 ? a.after() : a.before());
169
+ }
170
+ let p = i.findGapCursorFrom(a, e, f);
171
+ return p ? (r && r(o.tr.setSelection(new i(p))), !0) : !1;
172
+ };
173
+ }
174
+ function T(n, e, t) {
175
+ if (!n || !n.editable)
176
+ return !1;
177
+ let o = n.state.doc.resolve(e);
178
+ if (!i.valid(o))
179
+ return !1;
180
+ let r = n.posAtCoords({ left: t.clientX, top: t.clientY });
181
+ return r && r.inside > -1 && m.isSelectable(n.state.doc.nodeAt(r.inside)) ? !1 : (n.dispatch(n.state.tr.setSelection(new i(o))), !0);
182
+ }
183
+ function D(n, e) {
184
+ if (e.inputType != "insertCompositionText" || !(n.state.selection instanceof i))
185
+ return !1;
186
+ let { $from: t } = n.state.selection, o = t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);
187
+ if (!o)
188
+ return !1;
189
+ let r = h.empty;
190
+ for (let l = o.length - 1; l >= 0; l--)
191
+ r = h.from(o[l].createAndFill(null, r));
192
+ let s = n.state.tr.replace(t.pos, t.pos, new g(r, 0, 0));
193
+ return s.setSelection(x.near(s.doc.resolve(t.pos + 1))), n.dispatch(s), !1;
194
+ }
195
+ function F(n) {
196
+ if (!(n.selection instanceof i))
197
+ return null;
198
+ let e = document.createElement("div");
199
+ return e.className = "ProseMirror-gapcursor", S.create(n.doc, [A.widget(n.selection.head, e, { key: "gapcursor" })]);
200
+ }
201
+ export {
202
+ i as GapCursor,
203
+ B as gapCursor
204
+ };