monza-editor 0.3.2 → 0.3.3
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.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/rslib.config.ts +0 -16
- package/src/css.d.ts +0 -3
- package/src/index.module.css +0 -45
- package/src/index.test.ts +0 -8
- package/src/index.ts +0 -52
- package/tsconfig.json +0 -18
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
interface Options {
|
|
1
|
+
export interface Options {
|
|
2
2
|
highlight: (text: string) => string;
|
|
3
3
|
onChange?: (event: Event) => void;
|
|
4
4
|
onInput?: (event: Event) => void;
|
|
5
5
|
value?: string;
|
|
6
6
|
}
|
|
7
7
|
export declare const initialize: (container: Element, { highlight, onChange, onInput, value }: Options) => void;
|
|
8
|
-
export {};
|
|
9
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,UAAU,GACrB,WAAW,OAAO,EAClB,yCAAyC,OAAO,KAC/C,IAuCF,CAAC"}
|
package/package.json
CHANGED
package/rslib.config.ts
DELETED
package/src/css.d.ts
DELETED
package/src/index.module.css
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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(--me-font-family, monospace);
|
|
14
|
-
font-size: inherit;
|
|
15
|
-
line-height: inherit;
|
|
16
|
-
margin: 0;
|
|
17
|
-
padding: var(--me-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
|
-
resize: none;
|
|
30
|
-
/* TODO field-sizing: content; */
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.pre {
|
|
34
|
-
composes: editor;
|
|
35
|
-
|
|
36
|
-
position: absolute;
|
|
37
|
-
top: 0;
|
|
38
|
-
left: 0;
|
|
39
|
-
pointer-events: none;
|
|
40
|
-
scrollbar-width: 0;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.code {
|
|
44
|
-
composes: text;
|
|
45
|
-
}
|
package/src/index.test.ts
DELETED
package/src/index.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import styles from "./index.module.css";
|
|
2
|
-
|
|
3
|
-
interface Options {
|
|
4
|
-
highlight: (text: string) => string;
|
|
5
|
-
onChange?: (event: Event) => void;
|
|
6
|
-
onInput?: (event: Event) => void;
|
|
7
|
-
value?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const initialize = (
|
|
11
|
-
container: Element,
|
|
12
|
-
{ highlight, onChange, onInput, value }: Options,
|
|
13
|
-
): void => {
|
|
14
|
-
container.className += ` ${styles.main}`;
|
|
15
|
-
|
|
16
|
-
const textarea = container.appendChild(document.createElement("textarea"));
|
|
17
|
-
textarea.className += ` ${styles.textarea}`;
|
|
18
|
-
textarea.setAttribute("spellcheck", "false");
|
|
19
|
-
textarea.value = value ?? "";
|
|
20
|
-
|
|
21
|
-
const pre = container.appendChild(document.createElement("pre"));
|
|
22
|
-
pre.className += ` ${styles.pre}`;
|
|
23
|
-
|
|
24
|
-
const code = pre.appendChild(document.createElement("code"));
|
|
25
|
-
code.className += ` ${styles.code}`;
|
|
26
|
-
|
|
27
|
-
const scroll = () => {
|
|
28
|
-
pre.scrollTop = textarea.scrollTop;
|
|
29
|
-
pre.scrollLeft = textarea.scrollLeft;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const update = () =>
|
|
33
|
-
window.requestAnimationFrame(() => {
|
|
34
|
-
const text = textarea.value;
|
|
35
|
-
|
|
36
|
-
code.innerHTML = highlight(text.at(-1) === "\n" ? `${text} ` : text);
|
|
37
|
-
|
|
38
|
-
scroll();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
textarea.addEventListener("input", (event) => {
|
|
42
|
-
update();
|
|
43
|
-
onInput?.(event);
|
|
44
|
-
});
|
|
45
|
-
textarea.addEventListener("scroll", scroll);
|
|
46
|
-
|
|
47
|
-
if (onChange) {
|
|
48
|
-
textarea.addEventListener("change", onChange);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
update();
|
|
52
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
}
|
package/tsconfig.tsbuildinfo
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"5.9.2"}
|