monza-editor 0.2.1 → 0.2.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.
package/dist/index.css CHANGED
@@ -1 +1 @@
1
- .main-TdgjvV{position:relative}.text-YtgeQ_{white-space:break-spaces;word-break:break-word}.editor-ore7X3{box-sizing:border-box;font-family:var(--font-family,monospace);font-size:inherit;line-height:inherit;padding:var(--padding,.1rem);text-align:left;border:none;width:100%;height:100%;margin:0}.textarea-ugnhty{field-sizing:content;resize:none}.pre-bJTdjq{pointer-events:none;position:absolute;top:0;left:0}
1
+ .main-TdgjvV{position:relative}.text-YtgeQ_{white-space:break-spaces;word-break:break-word}.editor-ore7X3{box-sizing:border-box;font-family:var(--font-family,monospace);font-size:inherit;line-height:inherit;padding:var(--padding,.1rem);text-align:left;overscroll-behavior:none;border:none;width:100%;height:100%;margin:0;overflow:scroll}.textarea-ugnhty{field-sizing:content;resize:none}.pre-bJTdjq{pointer-events:none;scrollbar-width:0;position:absolute;top:0;left:0}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,GACrB,WAAW,OAAO,EAClB,WAAW,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,KAClC,IAuBF,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,GACrB,WAAW,OAAO,EAClB,WAAW,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,KAClC,IA+BF,CAAC"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- let e=(e,t)=>{e.className+=" main-TdgjvV";let a=e.appendChild(document.createElement("textarea"));a.className+=" textarea-ugnhty editor-ore7X3 text-YtgeQ_";let l=e.appendChild(document.createElement("pre"));l.className+=" pre-bJTdjq editor-ore7X3";let n=l.appendChild(document.createElement("code"));n.className+=" code-p0LDSQ text-YtgeQ_";let i=()=>window.requestAnimationFrame(()=>{n.innerHTML=t(a.value),a.style.height="0",a.style.height=`max(${a.scrollHeight}px, 100%)`});a.addEventListener("input",i),i()};export{e as initialize};
1
+ let e=(e,t)=>{e.className+=" main-TdgjvV";let l=e.appendChild(document.createElement("textarea"));l.className+=" textarea-ugnhty editor-ore7X3 text-YtgeQ_",l.setAttribute("spellcheck","false");let a=e.appendChild(document.createElement("pre"));a.className+=" pre-bJTdjq editor-ore7X3";let n=a.appendChild(document.createElement("code"));n.className+=" code-p0LDSQ text-YtgeQ_";let r=()=>{a.scrollTop=l.scrollTop,a.scrollLeft=l.scrollLeft},d=()=>window.requestAnimationFrame(()=>{let e=l.value;n.innerHTML=t("\n"===e.at(-1)?`${e} `:e),r()});l.addEventListener("input",d),l.addEventListener("scroll",r),d()};export{e as initialize};
package/package.json CHANGED
@@ -1,16 +1,12 @@
1
1
  {
2
2
  "name": "monza-editor",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "The minimal textarea with syntax highlight",
5
5
  "repository": "https://github.com/raviqqe/monza-editor",
6
6
  "license": "MIT",
7
7
  "publishConfig": {
8
8
  "provenance": true
9
9
  },
10
- "engines": {
11
- "node": "^24.5.0"
12
- },
13
- "packageManager": "pnpm@10.14.0+sha512.ad27a79641b49c3e481a16a805baa71817a04bbe06a38d17e60e2eaee83f6a146c6a688125f5792e48dd5ba30e7da52a5cda4c3992b9ccf333f9ce223af84748",
14
10
  "type": "module",
15
11
  "exports": {
16
12
  ".": {
@@ -26,15 +22,10 @@
26
22
  "lint": "biome ci",
27
23
  "test": "vitest"
28
24
  },
29
- "dependencies": {
30
- "shiki": "^3.9.2"
31
- },
25
+ "dependencies": {},
32
26
  "devDependencies": {
33
- "@biomejs/biome": "^2.1.4",
34
- "@raviqqe/biome-config": "^2.0.10",
35
27
  "@raviqqe/tsconfig": "^2.0.1",
36
28
  "@rslib/core": "^0.12.0",
37
- "@vitest/coverage-v8": "^3.0.2",
38
29
  "jsdom": "^26.1.0",
39
30
  "typescript": "^5.9.2",
40
31
  "typescript-plugin-css-modules": "^5.2.0",
@@ -18,12 +18,15 @@
18
18
  text-align: left;
19
19
  width: 100%;
20
20
  height: 100%;
21
+ overflow: scroll;
22
+ overscroll-behavior: none;
21
23
  }
22
24
 
23
25
  .textarea {
24
26
  composes: editor;
25
27
  composes: text;
26
28
 
29
+ /* TODO Support auto height. */
27
30
  field-sizing: content;
28
31
  resize: none;
29
32
  }
@@ -35,6 +38,7 @@
35
38
  top: 0;
36
39
  left: 0;
37
40
  pointer-events: none;
41
+ scrollbar-width: 0;
38
42
  }
39
43
 
40
44
  .code {
package/src/index.ts CHANGED
@@ -8,6 +8,7 @@ export const initialize = (
8
8
 
9
9
  const textarea = container.appendChild(document.createElement("textarea"));
10
10
  textarea.className += ` ${styles.textarea}`;
11
+ textarea.setAttribute("spellcheck", "false");
11
12
 
12
13
  const pre = container.appendChild(document.createElement("pre"));
13
14
  pre.className += ` ${styles.pre}`;
@@ -15,15 +16,22 @@ export const initialize = (
15
16
  const code = pre.appendChild(document.createElement("code"));
16
17
  code.className += ` ${styles.code}`;
17
18
 
19
+ const scroll = () => {
20
+ pre.scrollTop = textarea.scrollTop;
21
+ pre.scrollLeft = textarea.scrollLeft;
22
+ };
23
+
18
24
  const update = () =>
19
25
  window.requestAnimationFrame(() => {
20
- code.innerHTML = highlight(textarea.value);
26
+ const text = textarea.value;
27
+
28
+ code.innerHTML = highlight(text.at(-1) === "\n" ? `${text} ` : text);
21
29
 
22
- textarea.style.height = "0";
23
- textarea.style.height = `max(${textarea.scrollHeight}px, 100%)`;
30
+ scroll();
24
31
  });
25
32
 
26
33
  textarea.addEventListener("input", update);
34
+ textarea.addEventListener("scroll", scroll);
27
35
 
28
36
  update();
29
37
  };