monza-editor 0.2.0 → 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 +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/package.json +3 -13
- package/src/css.d.ts +3 -0
- package/src/index.module.css +46 -0
- package/src/index.test.ts +8 -0
- package/src/index.ts +37 -0
- package/tsconfig.json +18 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/LICENSE +0 -21
- package/README.md +0 -11
- package/biome.json +0 -3
- package/cspell.json +0 -13
- package/examples/shiki/index.html +0 -12
- package/examples/shiki/package.json +0 -19
- package/pnpm-workspace.yaml +0 -3
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}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,
|
|
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
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monza-editor",
|
|
3
|
-
"version": "0.2.
|
|
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
|
".": {
|
|
@@ -23,21 +19,15 @@
|
|
|
23
19
|
},
|
|
24
20
|
"scripts": {
|
|
25
21
|
"build": "rslib build",
|
|
26
|
-
"build:tsc": "tsc --emitDeclarationOnly",
|
|
27
22
|
"lint": "biome ci",
|
|
28
23
|
"test": "vitest"
|
|
29
24
|
},
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"shiki": "^3.9.2"
|
|
32
|
-
},
|
|
25
|
+
"dependencies": {},
|
|
33
26
|
"devDependencies": {
|
|
34
|
-
"@biomejs/biome": "^2.1.4",
|
|
35
|
-
"@raviqqe/biome-config": "^2.0.10",
|
|
36
27
|
"@raviqqe/tsconfig": "^2.0.1",
|
|
37
28
|
"@rslib/core": "^0.12.0",
|
|
38
|
-
"@vitest/coverage-v8": "^3.0.2",
|
|
39
29
|
"jsdom": "^26.1.0",
|
|
40
|
-
"typescript": "^5.
|
|
30
|
+
"typescript": "^5.9.2",
|
|
41
31
|
"typescript-plugin-css-modules": "^5.2.0",
|
|
42
32
|
"vitest": "^3.0.2"
|
|
43
33
|
}
|
package/src/css.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
.main {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.text {
|
|
6
|
+
white-space: break-spaces;
|
|
7
|
+
word-break: break-word;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.editor {
|
|
11
|
+
border: none;
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
font-family: var(--font-family, monospace);
|
|
14
|
+
font-size: inherit;
|
|
15
|
+
line-height: inherit;
|
|
16
|
+
margin: 0;
|
|
17
|
+
padding: var(--padding, 0.1rem);
|
|
18
|
+
text-align: left;
|
|
19
|
+
width: 100%;
|
|
20
|
+
height: 100%;
|
|
21
|
+
overflow: scroll;
|
|
22
|
+
overscroll-behavior: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.textarea {
|
|
26
|
+
composes: editor;
|
|
27
|
+
composes: text;
|
|
28
|
+
|
|
29
|
+
/* TODO Support auto height. */
|
|
30
|
+
field-sizing: content;
|
|
31
|
+
resize: none;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.pre {
|
|
35
|
+
composes: editor;
|
|
36
|
+
|
|
37
|
+
position: absolute;
|
|
38
|
+
top: 0;
|
|
39
|
+
left: 0;
|
|
40
|
+
pointer-events: none;
|
|
41
|
+
scrollbar-width: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.code {
|
|
45
|
+
composes: text;
|
|
46
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import styles from "./index.module.css";
|
|
2
|
+
|
|
3
|
+
export const initialize = (
|
|
4
|
+
container: Element,
|
|
5
|
+
highlight: (text: string) => string,
|
|
6
|
+
): void => {
|
|
7
|
+
container.className += ` ${styles.main}`;
|
|
8
|
+
|
|
9
|
+
const textarea = container.appendChild(document.createElement("textarea"));
|
|
10
|
+
textarea.className += ` ${styles.textarea}`;
|
|
11
|
+
textarea.setAttribute("spellcheck", "false");
|
|
12
|
+
|
|
13
|
+
const pre = container.appendChild(document.createElement("pre"));
|
|
14
|
+
pre.className += ` ${styles.pre}`;
|
|
15
|
+
|
|
16
|
+
const code = pre.appendChild(document.createElement("code"));
|
|
17
|
+
code.className += ` ${styles.code}`;
|
|
18
|
+
|
|
19
|
+
const scroll = () => {
|
|
20
|
+
pre.scrollTop = textarea.scrollTop;
|
|
21
|
+
pre.scrollLeft = textarea.scrollLeft;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const update = () =>
|
|
25
|
+
window.requestAnimationFrame(() => {
|
|
26
|
+
const text = textarea.value;
|
|
27
|
+
|
|
28
|
+
code.innerHTML = highlight(text.at(-1) === "\n" ? `${text} ` : text);
|
|
29
|
+
|
|
30
|
+
scroll();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
textarea.addEventListener("input", update);
|
|
34
|
+
textarea.addEventListener("scroll", scroll);
|
|
35
|
+
|
|
36
|
+
update();
|
|
37
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@raviqqe/tsconfig/tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"noEmit": true,
|
|
5
|
+
"outDir": "dist",
|
|
6
|
+
"rootDir": "src",
|
|
7
|
+
"plugins": [
|
|
8
|
+
{
|
|
9
|
+
"name": "typescript-plugin-css-modules",
|
|
10
|
+
"options": {
|
|
11
|
+
"goToDefinition": true,
|
|
12
|
+
"noUncheckedIndexedAccess": true
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"include": ["src"]
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"5.9.2"}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) Yota Toyama
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# Monza editor
|
|
2
|
-
|
|
3
|
-
[](https://github.com/raviqqe/monza-editor/actions)
|
|
4
|
-
[](https://www.npmjs.com/package/monza-editor)
|
|
5
|
-
[](LICENSE)
|
|
6
|
-
|
|
7
|
-
The minimal `textarea` element with syntax highlight.
|
|
8
|
-
|
|
9
|
-
## License
|
|
10
|
-
|
|
11
|
-
[MIT](LICENSE)
|
package/biome.json
DELETED
package/cspell.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Shiki example for Monza editor</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<div id="app"></div>
|
|
10
|
-
<script type="module" src="/src/index.ts"></script>
|
|
11
|
-
</body>
|
|
12
|
-
</html>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@monza-editor/shiki-example",
|
|
3
|
-
"description": "Shiki example for Monza editor",
|
|
4
|
-
"version": "0.1.0",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"start": "vite",
|
|
8
|
-
"build": "tsc && vite build"
|
|
9
|
-
},
|
|
10
|
-
"dependencies": {
|
|
11
|
-
"monza-editor": "workspace:*",
|
|
12
|
-
"shiki": "^3.9.2"
|
|
13
|
-
},
|
|
14
|
-
"devDependencies": {
|
|
15
|
-
"@raviqqe/tsconfig": "^2.0.1",
|
|
16
|
-
"typescript": "~5.9.2",
|
|
17
|
-
"vite": "^7.1.2"
|
|
18
|
-
}
|
|
19
|
-
}
|
package/pnpm-workspace.yaml
DELETED