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 CHANGED
@@ -1,9 +1,11 @@
1
- interface Options {
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: Event) => void;
4
- onInput?: (event: Event) => void;
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,UAAU,OAAO;IACf,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"}
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monza-editor",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "The textarea element with syntax highlight",
5
5
  "repository": "https://github.com/raviqqe/monza-editor",
6
6
  "license": "MIT",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
package/rslib.config.ts DELETED
@@ -1,16 +0,0 @@
1
- import { defineConfig } from "@rslib/core";
2
-
3
- export default defineConfig({
4
- lib: [
5
- {
6
- dts: true,
7
- format: "esm",
8
- output: {
9
- minify: true,
10
- },
11
- },
12
- ],
13
- output: {
14
- target: "web",
15
- },
16
- });
package/src/css.d.ts DELETED
@@ -1,3 +0,0 @@
1
- declare module "*.module.css" {
2
- export default styles satisfies { [key: string]: string };
3
- }
@@ -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
@@ -1,8 +0,0 @@
1
- import { it } from "vitest";
2
- import { initialize } from "./index.js";
3
-
4
- it("initializes an editor", () => {
5
- const editor = document.createElement("div");
6
-
7
- initialize(editor, { highlight: (text) => text });
8
- });
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
- }
@@ -1 +0,0 @@
1
- {"version":"5.9.2"}
package/vitest.config.ts DELETED
@@ -1,7 +0,0 @@
1
- import { defineConfig } from "vitest/config";
2
-
3
- export default defineConfig({
4
- test: {
5
- environment: "jsdom",
6
- },
7
- });