@glifox/gnosis 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.
package/LICENCE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 feraxhp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # gnosis
2
+
3
+ _GNOSIS_ is an extension-pack for codemirror to support WYSIWYG markdown edition.
4
+
5
+ ## Why another **_WYSIWYG_ markdown editor**?
6
+
7
+ I went into a lot of research over the internet, and found some _WYSIWYG markdown editor's_,
8
+ unfurtunetly they are not as good as the **obsidian** editor. The problem here
9
+ it is not open sourse... _so i decide to create my own_.
10
+
11
+ ## Similar proyects
12
+
13
+ 1. [Inoxia](https://ixora.karawale.in/)
14
+ 2. [Silverbullet](https://silverbullet.md/)
15
+ 3. [Markword](https://github.com/fuermosi777/markword)
16
+
17
+ ## TO-DO
18
+
19
+ ### **Block-level**
20
+ - [x] change: `paragraph`
21
+ - [x] change: `heading`
22
+ - [x] change: `hr`
23
+ - [x] change: `list`
24
+ - [x] change: `listitem`
25
+ - [x] change: `checkbox`
26
+ - [x] change: `code`
27
+ - [ ] change: `html`
28
+ - [ ] change: `blockquote`
29
+ - [ ] change: `table`
30
+
31
+ ### **Inline-level**
32
+ - [x] change: `strong`
33
+ - [x] change: `em`
34
+ - [x] change: `codespan`
35
+ - [ ] change: `br`
36
+ - [x] change: `del`
37
+ - [ ] change: `link`
38
+ - [ ] change: `image`
39
+ - [x] change: `text`
40
+ - [ ] change: `tags`
41
+
42
+ ### Features
43
+ - [x] change the way mk shows.
44
+ - [x] Auto complete list enters
45
+ - [x] Bulleds
46
+ - [x] ++ Numeric
47
+ - [x] doble enter -- indent
48
+ - [x] Code highliting
49
+
50
+ ## More ideas?
51
+
52
+ Feel free to open an [issue](https://github.com/feraxhp/gnosis/issues)
53
+ requesting new features.
@@ -0,0 +1,364 @@
1
+ var $ = Object.defineProperty;
2
+ var I = (t, o, s) => o in t ? $(t, o, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[o] = s;
3
+ var b = (t, o, s) => I(t, typeof o != "symbol" ? o + "" : o, s);
4
+ import { languages as P } from "@codemirror/language-data";
5
+ import { markdown as y } from "@codemirror/lang-markdown";
6
+ import { GFM as R } from "@lezer/markdown";
7
+ import { Tag as X, styleTags as D } from "@lezer/highlight";
8
+ import { ViewPlugin as B, Decoration as l, WidgetType as C } from "@codemirror/view";
9
+ import { syntaxTree as F } from "@codemirror/language";
10
+ import { EditorView as k } from "codemirror";
11
+ const d = X.define("none"), N = D({
12
+ "Blockquote/...": d,
13
+ HorizontalRule: d,
14
+ "ATXHeading1/... SetextHeading1/...": d,
15
+ "ATXHeading2/... SetextHeading2/...": d,
16
+ "ATXHeading3/...": d,
17
+ "ATXHeading4/...": d,
18
+ "ATXHeading5/...": d,
19
+ "ATXHeading6/...": d,
20
+ "Comment CommentBlock": d,
21
+ Escape: d,
22
+ Entity: d,
23
+ "Emphasis/...": d,
24
+ "StrongEmphasis/...": d,
25
+ "Strikethrough/...": d,
26
+ "TableHeader/...": d,
27
+ "Link/... Image/...": d,
28
+ "OrderedList/... BulletList/...": d,
29
+ "BlockQuote/...": d,
30
+ "InlineCode CodeText": d,
31
+ "URL Autolink": d,
32
+ "HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark StrikethroughMark": d,
33
+ "CodeInfo LinkLabel TaskMarker TableDelimiter": d,
34
+ LinkTitle: d,
35
+ Paragraph: d
36
+ }), O = { props: [N] }, f = (t, o, s = {}) => {
37
+ const a = class {
38
+ constructor(c) {
39
+ b(this, "decorations");
40
+ b(this, "conf");
41
+ this.conf = o, this.decorations = t(c, this.conf);
42
+ }
43
+ update(c) {
44
+ (c.docChanged || c.viewportChanged || c.selectionSet) && (this.decorations = t(c.view, this.conf));
45
+ }
46
+ };
47
+ return B.fromClass(a, { decorations: (i) => i.decorations, ...s });
48
+ }, w = (t, o, s) => {
49
+ const a = t.state.selection.ranges;
50
+ for (let i of a)
51
+ if (i.from >= o && i.from <= s || i.to >= o && i.to <= s || i.from <= o && i.to >= s)
52
+ return !0;
53
+ return !1;
54
+ }, T = (t, o) => {
55
+ for (const { from: s, to: a } of t.visibleRanges)
56
+ F(t.state).iterate({ ...o, from: s, to: a });
57
+ };
58
+ function W(t, o) {
59
+ const s = ["Document"], a = {}, i = {
60
+ HorizontalRule: (n, e, r = !0) => [
61
+ l.line({ class: "hr " + (r ? "sw" : "") }).range(n),
62
+ l.mark({ class: "mk" }).range(n, e)
63
+ ]
64
+ }, c = [];
65
+ return T(t, {
66
+ enter: ({ type: n, from: e, to: r }) => (n.name in i && c.push(...i[n.name](e, r, w(t, e, r))), s.includes(n.name) || n.name in a)
67
+ }), l.set(c, !1);
68
+ }
69
+ const _ = (t) => {
70
+ const {
71
+ color: o = "black"
72
+ } = t || {};
73
+ return k.baseTheme({
74
+ ".hr": { position: "relative" },
75
+ ".hr > .mk": { fontSize: "0" },
76
+ ".hr.sw > .mk": { fontSize: "inherit" },
77
+ ".hr::before": {
78
+ content: '""',
79
+ position: "absolute",
80
+ width: "calc(100% - 12px)",
81
+ height: ".2ch",
82
+ backgroundColor: o
83
+ },
84
+ ".hr.sw::before": { width: "0", height: "0" }
85
+ });
86
+ }, H = (t = {}) => [
87
+ f(W, {}),
88
+ _(t == null ? void 0 : t.color)
89
+ ];
90
+ function j(t, o) {
91
+ const s = ["FencedCode"], a = {
92
+ StrongEmphasis: (n = !0, e, r) => l.mark({ class: "il st " + (n ? "sw" : "") }).range(e, r),
93
+ Strikethrough: (n = !0, e, r) => l.mark({ class: "il sk " + (n ? "sw" : "") }).range(e, r),
94
+ InlineCode: (n = !0, e, r) => l.mark({ class: "il ic " + (n ? "sw" : "") }).range(e, r),
95
+ Emphasis: (n = !0, e, r) => l.mark({ class: "il it " + (n ? "sw" : "") }).range(e, r),
96
+ Mark: (n, e) => l.mark({ class: "mkl" }).range(n, e)
97
+ }, i = ["EmphasisMark", "CodeMark", "StrikethroughMark"], c = [];
98
+ return T(t, {
99
+ enter: ({ type: { name: n }, from: e, to: r }) => i.includes(n) ? (c.push(a.Mark(e, r)), !1) : (n in a && c.push(
100
+ a[n](
101
+ w(t, e, r),
102
+ e,
103
+ r
104
+ )
105
+ ), !s.includes(n))
106
+ }), l.set(c, !1);
107
+ }
108
+ const q = k.baseTheme({
109
+ ".it ": { fontStyle: "italic" },
110
+ ".st ": { fontWeight: "bold" },
111
+ ".sk ": { textDecoration: "line-through" },
112
+ ".ic ": {
113
+ fontFamily: "monospace",
114
+ paddingInline: ".6ch",
115
+ borderRadius: ".6ch"
116
+ }
117
+ }), Q = k.baseTheme({
118
+ ".il .mkl": { fontSize: "0" },
119
+ ".il.sw .mkl": { fontSize: "inherit" }
120
+ }), S = (t = {}) => {
121
+ const {
122
+ hideMarks: o = !0
123
+ } = t;
124
+ return [
125
+ f(j, {}),
126
+ q,
127
+ o ? Q : []
128
+ ];
129
+ };
130
+ class U extends C {
131
+ constructor(s) {
132
+ super();
133
+ b(this, "checked", !1);
134
+ this.checked = s;
135
+ }
136
+ // eq(other) { return other.checked == this.checked }
137
+ toDOM() {
138
+ let s = document.createElement("span");
139
+ s.setAttribute("aria-hidden", "true"), s.className = "TaskMark";
140
+ let a = s.appendChild(document.createElement("input"));
141
+ return a.type = "checkbox", a.checked = this.checked, s;
142
+ }
143
+ ignoreEvent() {
144
+ return !1;
145
+ }
146
+ }
147
+ function V(t, o) {
148
+ const s = [
149
+ "Document",
150
+ "ListItem",
151
+ "Task"
152
+ ], a = {
153
+ BulletList: "bl",
154
+ OrderedList: "ol"
155
+ }, i = {
156
+ ListMark: (e, r, g, u = !0) => l.mark({ class: `${g} lm ${u ? "sw" : ""}` }).range(e, r),
157
+ TaskMarker: (e, r, g, u = !0) => {
158
+ const m = t.state.doc.sliceString(e + 1, r - 1) === "x";
159
+ return u ? l.mark({ class: `tm ${m ? "ck" : ""}` }).range(e, r) : l.replace({
160
+ widget: new U(m)
161
+ }).range(e, r);
162
+ }
163
+ }, c = [], n = [];
164
+ return T(t, {
165
+ enter: ({ type: e, from: r, to: g }) => e.name in a ? (n.push({ name: e.name, from: r, to: g }), !0) : (e.name in i && c.push(i[e.name](
166
+ r,
167
+ g,
168
+ a[n.slice(-1)[0].name],
169
+ w(t, r, g)
170
+ )), s.includes(e.name)),
171
+ leave: ({ type: { name: e }, from: r, to: g }) => {
172
+ const u = n.slice(-1)[0];
173
+ u && u.name === e && u.from === r && u.to === g && n.pop();
174
+ }
175
+ }), l.set(c, !1);
176
+ }
177
+ const G = (t, o) => {
178
+ var a;
179
+ let s = t.target;
180
+ if (s.nodeName === "INPUT" && ((a = s.parentElement) != null && a.classList.contains("TaskMark"))) return K(o, o.posAtDOM(s));
181
+ }, K = (t, o) => {
182
+ const s = o - 2, a = o - 1;
183
+ let i = t.state.doc.sliceString(Math.max(0, s), a), c;
184
+ if (i === "x") c = { from: s, to: a, insert: " " };
185
+ else if (i === " ") c = { from: s, to: a, insert: "x" };
186
+ else return !1;
187
+ return t.dispatch({ changes: c }), !0;
188
+ }, J = (t) => {
189
+ const {
190
+ color: o = "black"
191
+ } = t || {};
192
+ return k.baseTheme({
193
+ /* Bullet list Point */
194
+ ".lm.bl": {
195
+ position: "relative",
196
+ paddingInlineStart: "1ch",
197
+ color: "transparent"
198
+ },
199
+ ".lm.bl::before": {
200
+ content: '""',
201
+ display: "inline",
202
+ position: "absolute",
203
+ backgroundColor: o,
204
+ borderRadius: "50%",
205
+ top: "50%",
206
+ left: ".5ch",
207
+ transform: "translate(0, -50%)",
208
+ height: ".4em",
209
+ width: ".4em"
210
+ },
211
+ ".lm.bl.sw, .lm.bl.sw::before": {
212
+ backgroundColor: "transparent",
213
+ color: "inherit"
214
+ }
215
+ });
216
+ }, A = (t = {}) => [
217
+ f(V, {}, { eventHandlers: { mousedown: G } }),
218
+ J(t == null ? void 0 : t.color)
219
+ ];
220
+ class L extends C {
221
+ constructor(s) {
222
+ super();
223
+ b(this, "classes", "");
224
+ this.classes = s;
225
+ }
226
+ toDOM() {
227
+ let s = document.createElement("span");
228
+ return s.setAttribute("aria-hidden", "true"), s.className = this.classes, s.textContent = " ", s;
229
+ }
230
+ ignoreEvent() {
231
+ return !1;
232
+ }
233
+ }
234
+ function x(t, o) {
235
+ const {
236
+ mode: s
237
+ /* type, mark */
238
+ } = o, a = ["Document", "Blockquote"], i = {
239
+ FencedCode: M,
240
+ CodeBlock: M
241
+ }, c = {
242
+ CodeMark: (e, r) => l.mark({ class: "cb-mk" }).range(e, r),
243
+ CodeInfo: (e, r) => l.mark({ class: "cb-mi" }).range(e, r)
244
+ }, n = [];
245
+ return T(t, {
246
+ enter: ({ type: { name: e }, from: r, to: g }) => (s === "type" && e in i && n.push(...i[e](t, r, g)), s === "mark" && e in c && n.push(c[e](r, g)), a.includes(e) || e in i)
247
+ }), {
248
+ type: l.set(n, !0),
249
+ mark: l.set(n, !0)
250
+ }[s];
251
+ }
252
+ const M = (t, o, s) => {
253
+ const a = [], i = t.state.doc.lineAt(o), c = o - i.from, n = w(t, i.from, s), e = i.number, r = t.state.doc.sliceString(o, s).split(`
254
+ `).length;
255
+ for (let g = e; g < r + e; g++) {
256
+ const u = ["cb-content"], { from: m, to: p } = t.state.doc.line(g), h = Math.max(m + c, 0);
257
+ h === p ? (u.push("wg"), a.push(l.widget({ widget: new L(u.join(" ") + " start"), side: 0 }).range(h)), a.push(l.widget({ widget: new L(u.join(" ") + " end"), side: 1 }).range(h))) : (g === e && u.push("cb-start"), g === r + e - 1 && u.push("cb-end"), n && u.push("sw"), p > h && a.push(l.mark({ class: u.join(" ") }).range(h, p))), m !== h && a.push(l.mark({ class: "cb-spacer" }).range(m, h)), a.push(l.line({ class: "cb-line" }).range(m));
258
+ }
259
+ return a;
260
+ }, Y = k.baseTheme({
261
+ ".cb-content": { backgroundColor: "#e1e4ea" }
262
+ }), Z = () => k.baseTheme({
263
+ ".cb-start": { borderRadius: "1ch 1ch 0 0" },
264
+ ".cb-end ": { borderRadius: "0 0 1ch 1ch" },
265
+ ".cb-start.cb-end": { borderRadius: "1ch" },
266
+ ".cb-line": { display: "flex !important" },
267
+ ".cb-content": {
268
+ display: "inline-block",
269
+ zIndex: "-1",
270
+ flex: "1",
271
+ marginLeft: "2px",
272
+ paddingLeft: "6px",
273
+ paddingRigth: "2px"
274
+ },
275
+ ".cb-content.wg": { cursor: "text" },
276
+ ".cb-content.wg.start": {
277
+ maxWidth: "1px",
278
+ Width: "1px",
279
+ paddingLeft: "5px"
280
+ },
281
+ ".cb-content.wg.end": {
282
+ marginLeft: "0",
283
+ paddingLeft: "0"
284
+ },
285
+ ".cb-mi, .cb-mk": { color: "transparent" },
286
+ ".cb-content.sw > .cb-mi, .cb-content.sw > .cb-mk": { color: "inherit" }
287
+ }), z = (t = {}) => [
288
+ f(x, { mode: "mark" }),
289
+ f(x, { mode: "type" }),
290
+ Y,
291
+ Z()
292
+ ];
293
+ function v(t, o) {
294
+ const s = ["Document"], a = {
295
+ ATXHeading1: (n, e = !0) => l.line({ class: "h1 hg " + (e ? "sw" : "") }).range(n),
296
+ ATXHeading2: (n, e = !0) => l.line({ class: "h2 hg " + (e ? "sw" : "") }).range(n),
297
+ ATXHeading3: (n, e = !0) => l.line({ class: "h3 hg " + (e ? "sw" : "") }).range(n),
298
+ ATXHeading4: (n, e = !0) => l.line({ class: "h4 hg " + (e ? "sw" : "") }).range(n),
299
+ ATXHeading5: (n, e = !0) => l.line({ class: "h5 hg " + (e ? "sw" : "") }).range(n),
300
+ ATXHeading6: (n, e = !0) => l.line({ class: "h6 hg " + (e ? "sw" : "") }).range(n)
301
+ }, i = {
302
+ HeaderMark: (n, e) => l.mark({ class: "mk" }).range(n, e)
303
+ }, c = [];
304
+ return T(t, {
305
+ enter: ({ type: n, from: e, to: r }) => (n.name in a && c.push(a[n.name](e, w(t, e, r))), n.name in i && c.push(i[n.name](e, r + 1)), s.includes(n.name) || n.name in a)
306
+ }), l.set(c, !1);
307
+ }
308
+ const ee = k.baseTheme({
309
+ ".h1 ": { fontSize: "2.6rem" },
310
+ ".h2 ": { fontSize: "2.0rem" },
311
+ ".h3 ": { fontSize: "1.8rem" },
312
+ ".h4 ": { fontSize: "1.6rem" },
313
+ ".h5 ": { fontSize: "1.4rem" },
314
+ ".h6 ": { fontSize: "1.2rem" }
315
+ }), te = k.baseTheme({
316
+ ".hg .mk": { fontSize: "0" },
317
+ ".hg.sw .mk": { fontSize: "inherit" }
318
+ }), E = (t = {}) => [
319
+ f(v, {}),
320
+ ee,
321
+ te
322
+ ], ne = (t = { markdown: {} }) => {
323
+ const {
324
+ markdown: {
325
+ defaultCodeLanguage: o,
326
+ codeLanguages: s,
327
+ addKeymap: a,
328
+ base: i,
329
+ completeHTMLTags: c,
330
+ htmlTagLanguage: n,
331
+ extensions: e = []
332
+ },
333
+ inline: r,
334
+ Heading: g,
335
+ Hr: u,
336
+ List: m,
337
+ Code: p
338
+ } = t, h = {
339
+ defaultCodeLanguage: o,
340
+ codeLanguages: s || P,
341
+ addKeymap: a,
342
+ base: i,
343
+ completeHTMLTags: c,
344
+ htmlTagLanguage: n,
345
+ extensions: [...e, R, O]
346
+ };
347
+ return [
348
+ y(h),
349
+ S(r),
350
+ E(g),
351
+ A(m),
352
+ H(u),
353
+ z(p)
354
+ ];
355
+ };
356
+ typeof window < "u" && (window.gnosis = ne, window.HrPlugin = H, window.ListPlugin = A, window.CodePlugin = z, window.InlinePlugin = S, window.HeadingPlugin = E);
357
+ export {
358
+ z as CodePlugin,
359
+ E as HeadingPlugin,
360
+ H as HrPlugin,
361
+ S as InlinePlugin,
362
+ A as ListPlugin,
363
+ ne as gnosis
364
+ };
@@ -0,0 +1,2 @@
1
+ (function(d,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("@codemirror/language-data"),require("@codemirror/lang-markdown"),require("@lezer/markdown"),require("@lezer/highlight"),require("@codemirror/view"),require("@codemirror/language"),require("codemirror")):typeof define=="function"&&define.amd?define(["exports","@codemirror/language-data","@codemirror/lang-markdown","@lezer/markdown","@lezer/highlight","@codemirror/view","@codemirror/language","codemirror"],m):(d=typeof globalThis<"u"?globalThis:d||self,m(d.gnosis={},d.languageData,d.langMarkdown,d.markdown,d.highlight,d.view,d.language,d.codemirror))})(this,function(d,m,b,R,P,i,X,p){"use strict";var Z=Object.defineProperty;var v=(d,m,b)=>m in d?Z(d,m,{enumerable:!0,configurable:!0,writable:!0,value:b}):d[m]=b;var M=(d,m,b)=>v(d,typeof m!="symbol"?m+"":m,b);const u=P.Tag.define("none"),q={props:[P.styleTags({"Blockquote/...":u,HorizontalRule:u,"ATXHeading1/... SetextHeading1/...":u,"ATXHeading2/... SetextHeading2/...":u,"ATXHeading3/...":u,"ATXHeading4/...":u,"ATXHeading5/...":u,"ATXHeading6/...":u,"Comment CommentBlock":u,Escape:u,Entity:u,"Emphasis/...":u,"StrongEmphasis/...":u,"Strikethrough/...":u,"TableHeader/...":u,"Link/... Image/...":u,"OrderedList/... BulletList/...":u,"BlockQuote/...":u,"InlineCode CodeText":u,"URL Autolink":u,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark StrikethroughMark":u,"CodeInfo LinkLabel TaskMarker TableDelimiter":u,LinkTitle:u,Paragraph:u})]},T=(t,a,r={})=>{const s=class{constructor(l){M(this,"decorations");M(this,"conf");this.conf=a,this.decorations=t(l,this.conf)}update(l){(l.docChanged||l.viewportChanged||l.selectionSet)&&(this.decorations=t(l.view,this.conf))}};return i.ViewPlugin.fromClass(s,{decorations:c=>c.decorations,...r})},D=(t,a,r)=>{const s=t.state.selection.ranges;for(let c of s)if(c.from>=a&&c.from<=r||c.to>=a&&c.to<=r||c.from<=a&&c.to>=r)return!0;return!1},w=(t,a)=>{for(const{from:r,to:s}of t.visibleRanges)X.syntaxTree(t.state).iterate({...a,from:r,to:s})};function B(t,a){const r=["Document"],s={},c={HorizontalRule:(n,e,o=!0)=>[i.Decoration.line({class:"hr "+(o?"sw":"")}).range(n),i.Decoration.mark({class:"mk"}).range(n,e)]},l=[];return w(t,{enter:({type:n,from:e,to:o})=>(n.name in c&&l.push(...c[n.name](e,o,D(t,e,o))),r.includes(n.name)||n.name in s)}),i.Decoration.set(l,!1)}const V=t=>{const{color:a="black"}=t||{};return p.EditorView.baseTheme({".hr":{position:"relative"},".hr > .mk":{fontSize:"0"},".hr.sw > .mk":{fontSize:"inherit"},".hr::before":{content:'""',position:"absolute",width:"calc(100% - 12px)",height:".2ch",backgroundColor:a},".hr.sw::before":{width:"0",height:"0"}})},H=(t={})=>[T(B,{}),V(t==null?void 0:t.color)];function O(t,a){const r=["FencedCode"],s={StrongEmphasis:(n=!0,e,o)=>i.Decoration.mark({class:"il st "+(n?"sw":"")}).range(e,o),Strikethrough:(n=!0,e,o)=>i.Decoration.mark({class:"il sk "+(n?"sw":"")}).range(e,o),InlineCode:(n=!0,e,o)=>i.Decoration.mark({class:"il ic "+(n?"sw":"")}).range(e,o),Emphasis:(n=!0,e,o)=>i.Decoration.mark({class:"il it "+(n?"sw":"")}).range(e,o),Mark:(n,e)=>i.Decoration.mark({class:"mkl"}).range(n,e)},c=["EmphasisMark","CodeMark","StrikethroughMark"],l=[];return w(t,{enter:({type:{name:n},from:e,to:o})=>c.includes(n)?(l.push(s.Mark(e,o)),!1):(n in s&&l.push(s[n](D(t,e,o),e,o)),!r.includes(n))}),i.Decoration.set(l,!1)}const W=p.EditorView.baseTheme({".it ":{fontStyle:"italic"},".st ":{fontWeight:"bold"},".sk ":{textDecoration:"line-through"},".ic ":{fontFamily:"monospace",paddingInline:".6ch",borderRadius:".6ch"}}),$=p.EditorView.baseTheme({".il .mkl":{fontSize:"0"},".il.sw .mkl":{fontSize:"inherit"}}),S=(t={})=>{const{hideMarks:a=!0}=t;return[T(O,{}),W,a?$:[]]};class j extends i.WidgetType{constructor(r){super();M(this,"checked",!1);this.checked=r}toDOM(){let r=document.createElement("span");r.setAttribute("aria-hidden","true"),r.className="TaskMark";let s=r.appendChild(document.createElement("input"));return s.type="checkbox",s.checked=this.checked,r}ignoreEvent(){return!1}}function F(t,a){const r=["Document","ListItem","Task"],s={BulletList:"bl",OrderedList:"ol"},c={ListMark:(e,o,g,h=!0)=>i.Decoration.mark({class:`${g} lm ${h?"sw":""}`}).range(e,o),TaskMarker:(e,o,g,h=!0)=>{const k=t.state.doc.sliceString(e+1,o-1)==="x";return h?i.Decoration.mark({class:`tm ${k?"ck":""}`}).range(e,o):i.Decoration.replace({widget:new j(k)}).range(e,o)}},l=[],n=[];return w(t,{enter:({type:e,from:o,to:g})=>e.name in s?(n.push({name:e.name,from:o,to:g}),!0):(e.name in c&&l.push(c[e.name](o,g,s[n.slice(-1)[0].name],D(t,o,g))),r.includes(e.name)),leave:({type:{name:e},from:o,to:g})=>{const h=n.slice(-1)[0];h&&h.name===e&&h.from===o&&h.to===g&&n.pop()}}),i.Decoration.set(l,!1)}const N=(t,a)=>{var s;let r=t.target;if(r.nodeName==="INPUT"&&((s=r.parentElement)!=null&&s.classList.contains("TaskMark")))return _(a,a.posAtDOM(r))},_=(t,a)=>{const r=a-2,s=a-1;let c=t.state.doc.sliceString(Math.max(0,r),s),l;if(c==="x")l={from:r,to:s,insert:" "};else if(c===" ")l={from:r,to:s,insert:"x"};else return!1;return t.dispatch({changes:l}),!0},Q=t=>{const{color:a="black"}=t||{};return p.EditorView.baseTheme({".lm.bl":{position:"relative",paddingInlineStart:"1ch",color:"transparent"},".lm.bl::before":{content:'""',display:"inline",position:"absolute",backgroundColor:a,borderRadius:"50%",top:"50%",left:".5ch",transform:"translate(0, -50%)",height:".4em",width:".4em"},".lm.bl.sw, .lm.bl.sw::before":{backgroundColor:"transparent",color:"inherit"}})},C=(t={})=>[T(F,{},{eventHandlers:{mousedown:N}}),Q(t==null?void 0:t.color)];class z extends i.WidgetType{constructor(r){super();M(this,"classes","");this.classes=r}toDOM(){let r=document.createElement("span");return r.setAttribute("aria-hidden","true"),r.className=this.classes,r.textContent=" ",r}ignoreEvent(){return!1}}function y(t,a){const{mode:r}=a,s=["Document","Blockquote"],c={FencedCode:A,CodeBlock:A},l={CodeMark:(e,o)=>i.Decoration.mark({class:"cb-mk"}).range(e,o),CodeInfo:(e,o)=>i.Decoration.mark({class:"cb-mi"}).range(e,o)},n=[];return w(t,{enter:({type:{name:e},from:o,to:g})=>(r==="type"&&e in c&&n.push(...c[e](t,o,g)),r==="mark"&&e in l&&n.push(l[e](o,g)),s.includes(e)||e in c)}),{type:i.Decoration.set(n,!0),mark:i.Decoration.set(n,!0)}[r]}const A=(t,a,r)=>{const s=[],c=t.state.doc.lineAt(a),l=a-c.from,n=D(t,c.from,r),e=c.number,o=t.state.doc.sliceString(a,r).split(`
2
+ `).length;for(let g=e;g<o+e;g++){const h=["cb-content"],{from:k,to:L}=t.state.doc.line(g),f=Math.max(k+l,0);f===L?(h.push("wg"),s.push(i.Decoration.widget({widget:new z(h.join(" ")+" start"),side:0}).range(f)),s.push(i.Decoration.widget({widget:new z(h.join(" ")+" end"),side:1}).range(f))):(g===e&&h.push("cb-start"),g===o+e-1&&h.push("cb-end"),n&&h.push("sw"),L>f&&s.push(i.Decoration.mark({class:h.join(" ")}).range(f,L))),k!==f&&s.push(i.Decoration.mark({class:"cb-spacer"}).range(k,f)),s.push(i.Decoration.line({class:"cb-line"}).range(k))}return s},U=p.EditorView.baseTheme({".cb-content":{backgroundColor:"#e1e4ea"}}),G=()=>p.EditorView.baseTheme({".cb-start":{borderRadius:"1ch 1ch 0 0"},".cb-end ":{borderRadius:"0 0 1ch 1ch"},".cb-start.cb-end":{borderRadius:"1ch"},".cb-line":{display:"flex !important"},".cb-content":{display:"inline-block",zIndex:"-1",flex:"1",marginLeft:"2px",paddingLeft:"6px",paddingRigth:"2px"},".cb-content.wg":{cursor:"text"},".cb-content.wg.start":{maxWidth:"1px",Width:"1px",paddingLeft:"5px"},".cb-content.wg.end":{marginLeft:"0",paddingLeft:"0"},".cb-mi, .cb-mk":{color:"transparent"},".cb-content.sw > .cb-mi, .cb-content.sw > .cb-mk":{color:"inherit"}}),x=(t={})=>[T(y,{mode:"mark"}),T(y,{mode:"type"}),U,G()];function K(t,a){const r=["Document"],s={ATXHeading1:(n,e=!0)=>i.Decoration.line({class:"h1 hg "+(e?"sw":"")}).range(n),ATXHeading2:(n,e=!0)=>i.Decoration.line({class:"h2 hg "+(e?"sw":"")}).range(n),ATXHeading3:(n,e=!0)=>i.Decoration.line({class:"h3 hg "+(e?"sw":"")}).range(n),ATXHeading4:(n,e=!0)=>i.Decoration.line({class:"h4 hg "+(e?"sw":"")}).range(n),ATXHeading5:(n,e=!0)=>i.Decoration.line({class:"h5 hg "+(e?"sw":"")}).range(n),ATXHeading6:(n,e=!0)=>i.Decoration.line({class:"h6 hg "+(e?"sw":"")}).range(n)},c={HeaderMark:(n,e)=>i.Decoration.mark({class:"mk"}).range(n,e)},l=[];return w(t,{enter:({type:n,from:e,to:o})=>(n.name in s&&l.push(s[n.name](e,D(t,e,o))),n.name in c&&l.push(c[n.name](e,o+1)),r.includes(n.name)||n.name in s)}),i.Decoration.set(l,!1)}const J=p.EditorView.baseTheme({".h1 ":{fontSize:"2.6rem"},".h2 ":{fontSize:"2.0rem"},".h3 ":{fontSize:"1.8rem"},".h4 ":{fontSize:"1.6rem"},".h5 ":{fontSize:"1.4rem"},".h6 ":{fontSize:"1.2rem"}}),Y=p.EditorView.baseTheme({".hg .mk":{fontSize:"0"},".hg.sw .mk":{fontSize:"inherit"}}),E=(t={})=>[T(K,{}),J,Y],I=(t={markdown:{}})=>{const{markdown:{defaultCodeLanguage:a,codeLanguages:r,addKeymap:s,base:c,completeHTMLTags:l,htmlTagLanguage:n,extensions:e=[]},inline:o,Heading:g,Hr:h,List:k,Code:L}=t,f={defaultCodeLanguage:a,codeLanguages:r||m.languages,addKeymap:s,base:c,completeHTMLTags:l,htmlTagLanguage:n,extensions:[...e,R.GFM,q]};return[b.markdown(f),S(o),E(g),C(k),H(h),x(L)]};typeof window<"u"&&(window.gnosis=I,window.HrPlugin=H,window.ListPlugin=C,window.CodePlugin=x,window.InlinePlugin=S,window.HeadingPlugin=E),d.CodePlugin=x,d.HeadingPlugin=E,d.HrPlugin=H,d.InlinePlugin=S,d.ListPlugin=C,d.gnosis=I,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@glifox/gnosis",
3
+ "version": "0.0.1",
4
+
5
+ "author": "feraxhp",
6
+ "license": "MIT",
7
+ "main": "dist/gnosis.umd.js",
8
+ "module": "dist/gnosis.mjs",
9
+ "repository": { "type": "git", "url": "git+https://github.com/glifox/gnosis.git" },
10
+ "bugs": { "url": "https://github.com/glifox/gnosis/issues" },
11
+ "homepage": "https://gnosis.feraxhp.com/",
12
+ "files": [
13
+ "dist",
14
+ "README.md"
15
+ ],
16
+
17
+ "dependencies": {
18
+ "@codemirror/lang-markdown": "^6.3.2",
19
+ "@codemirror/language": "^6.10.8",
20
+ "@codemirror/language-data": "^6.5.1",
21
+ "@codemirror/state": "^6.5.1",
22
+ "@codemirror/view": "^6.36.2",
23
+ "@lezer/common": "^1.2.3",
24
+ "@lezer/highlight": "^1.2.1",
25
+ "@lezer/markdown": "^1.4.0",
26
+ "codemirror": "^6.0.1"
27
+ },
28
+ "devDependencies": {
29
+ "vite": "^6.0.7"
30
+ },
31
+
32
+ "scripts": {
33
+ "start": "cd sample && vite --host",
34
+ "preview": "cd sample && vite --port $PORT",
35
+ "build": "vite build"
36
+ },
37
+
38
+ "keywords": [
39
+ "WYSIWYG",
40
+ "markdown",
41
+ "editor",
42
+ "codemirror",
43
+ "extension"
44
+ ],
45
+
46
+ "publishConfig": {
47
+ "access": "public"
48
+ }
49
+ }