monza-editor 0.3.2 → 0.3.4
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 +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -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,11 @@
|
|
|
1
|
-
interface
|
|
1
|
+
export interface TextareaEvent extends Omit<Event, "target"> {
|
|
2
|
+
target: HTMLTextAreaElement;
|
|
3
|
+
}
|
|
4
|
+
export interface Options {
|
|
2
5
|
highlight: (text: string) => string;
|
|
3
|
-
onChange?: (event:
|
|
4
|
-
onInput?: (event:
|
|
6
|
+
onChange?: (event: TextareaEvent) => void;
|
|
7
|
+
onInput?: (event: TextareaEvent) => void;
|
|
5
8
|
value?: string;
|
|
6
9
|
}
|
|
7
10
|
export declare const initialize: (container: Element, { highlight, onChange, onInput, value }: Options) => void;
|
|
8
|
-
export {};
|
|
9
11
|
//# 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,aAAc,SAAQ,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC;IAC1D,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AAED,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC1C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,UAAU,GACrB,WAAW,OAAO,EAClB,yCAAyC,OAAO,KAC/C,IAyCF,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e=(e,{highlight:t,onChange:l,onInput:a,value:n})=>{e.className+=" main-TdgjvV";let r=e.appendChild(document.createElement("textarea"));r.className+=" textarea-ugnhty editor-ore7X3 text-YtgeQ_",r.setAttribute("spellcheck","false"),r.value=n??"";let d=e.appendChild(document.createElement("pre"));d.className+=" pre-bJTdjq editor-ore7X3";let c=d.appendChild(document.createElement("code"));c.className+=" code-p0LDSQ text-YtgeQ_";let s=()=>{d.scrollTop=r.scrollTop,d.scrollLeft=r.scrollLeft},i=()=>window.requestAnimationFrame(()=>{let e=r.value;c.innerHTML=t("\n"===e.at(-1)?`${e} `:e),s()});r.addEventListener("input",e=>{i(),a?.(e)}),r.addEventListener("scroll",s),l&&r.addEventListener("change",l),i()};export{e as initialize};
|
|
1
|
+
let e=(e,{highlight:t,onChange:l,onInput:a,value:n})=>{e.className+=" main-TdgjvV";let r=e.appendChild(document.createElement("textarea"));r.className+=" textarea-ugnhty editor-ore7X3 text-YtgeQ_",r.setAttribute("spellcheck","false"),r.value=n??"";let d=e.appendChild(document.createElement("pre"));d.className+=" pre-bJTdjq editor-ore7X3";let c=d.appendChild(document.createElement("code"));c.className+=" code-p0LDSQ text-YtgeQ_";let s=()=>{d.scrollTop=r.scrollTop,d.scrollLeft=r.scrollLeft},i=()=>window.requestAnimationFrame(()=>{let e=r.value;c.innerHTML=t("\n"===e.at(-1)?`${e} `:e),s()});r.addEventListener("input",e=>{i(),a?.(e)}),r.addEventListener("scroll",s),l&&r.addEventListener("change",e=>l(e)),i()};export{e as initialize};
|
package/package.json
CHANGED
package/dist/index.test.d.ts
DELETED
package/dist/index.test.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
|
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"}
|