@krainovsd/markdown-editor 0.0.3 → 0.0.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.
Files changed (47) hide show
  1. package/README.md +21 -1
  2. package/lib/cjs/editor-qKPDa91b.js +2 -0
  3. package/lib/cjs/editor-qKPDa91b.js.map +1 -0
  4. package/lib/cjs/index.js +2 -0
  5. package/lib/cjs/index.js.map +1 -0
  6. package/lib/cjs/markdown_plugin-IXFRDWyN.js +2 -0
  7. package/lib/cjs/markdown_plugin-IXFRDWyN.js.map +1 -0
  8. package/lib/cjs/vendor_vim-BHa51_r7.js +2 -0
  9. package/lib/cjs/vendor_vim-BHa51_r7.js.map +1 -0
  10. package/lib/cjs/vendor_y.next-CVyX1ZQB.js +2 -0
  11. package/lib/cjs/vendor_y.next-CVyX1ZQB.js.map +1 -0
  12. package/lib/cjs/vendor_y.websocket-Dr9ojjFR.js +2 -0
  13. package/lib/cjs/vendor_y.websocket-Dr9ojjFR.js.map +1 -0
  14. package/lib/cjs/vendor_yjs-DXWp84x5.js +2 -0
  15. package/lib/cjs/vendor_yjs-DXWp84x5.js.map +1 -0
  16. package/lib/esm/editor-CLyV23xt.js +2 -0
  17. package/lib/esm/editor-CLyV23xt.js.map +1 -0
  18. package/lib/esm/index.js +1 -1
  19. package/lib/esm/index.js.map +1 -1
  20. package/lib/esm/markdown_plugin-DdBeaig8.js +2 -0
  21. package/lib/esm/markdown_plugin-DdBeaig8.js.map +1 -0
  22. package/lib/esm/vendor_vim-PF2jWG0J.js +2 -0
  23. package/lib/esm/vendor_vim-PF2jWG0J.js.map +1 -0
  24. package/lib/esm/vendor_y.next-B9hhKe5T.js +2 -0
  25. package/lib/esm/vendor_y.next-B9hhKe5T.js.map +1 -0
  26. package/lib/esm/vendor_y.websocket-gIpX3Cmo.js +2 -0
  27. package/lib/esm/vendor_y.websocket-gIpX3Cmo.js.map +1 -0
  28. package/lib/esm/vendor_yjs-otxZW90b.js +2 -0
  29. package/lib/esm/vendor_yjs-otxZW90b.js.map +1 -0
  30. package/package.json +5 -4
  31. package/tmp/app/helpers/common-test.d.ts +1 -1
  32. package/tmp/extensions/index.d.ts +2 -2
  33. package/tmp/extensions/init-extensions.d.ts +2 -2
  34. package/tmp/extensions/keymaps/init-key-map.d.ts +17 -3
  35. package/tmp/extensions/markdown/image/image-widget.d.ts +9 -10
  36. package/tmp/extensions/markdown/markdown-parser.d.ts +2 -0
  37. package/tmp/extensions/settings/init-settings.d.ts +1 -1
  38. package/tmp/extensions/theme/theme-types.d.ts +4 -1
  39. package/tmp/index.d.ts +1 -1
  40. package/tmp/lib/utils/index.d.ts +1 -0
  41. package/tmp/lib/utils/random-string.d.ts +1 -0
  42. package/tmp/module/Editor/Editor.d.ts +6 -5
  43. package/tmp/module/Editor/lib/init-editor-provider.d.ts +3 -4
  44. package/tmp/module/Editor/lib/init-editor-state.d.ts +1 -1
  45. package/tmp/module/Editor/lib/init-editor.d.ts +2 -2
  46. package/lib/cjs/bundle.cjs +0 -2
  47. package/lib/cjs/bundle.cjs.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krainovsd/markdown-editor",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Krainov markdown-editor",
5
5
  "type": "module",
6
6
  "author": "KrainovSD <denislosev48@gmail.com>",
@@ -29,8 +29,9 @@
29
29
  ],
30
30
  "scripts": {
31
31
  "dev": "vite",
32
+ "build:dev": "vite build",
32
33
  "build": "npm run build:types && npm run build:js",
33
- "build:js": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript --no-stdin --environment BUILD:production,NODE_ENV:production",
34
+ "build:js": "rm -rf lib && rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript --no-stdin --environment BUILD:production,NODE_ENV:production",
34
35
  "build:types": "tspc -p tsconfig.build.json",
35
36
  "lint": "eslint src/** -c ./eslint.config.js --color --max-warnings 0",
36
37
  "lint:debug": "eslint --debug eslint.config.js",
@@ -54,9 +55,9 @@
54
55
  "rollup-plugin-postcss": "4.0.2",
55
56
  "sass": "1.83.0",
56
57
  "sass-embedded": "1.81.0",
57
- "ts-patch": "^3.3.0",
58
+ "ts-patch": "3.3.0",
58
59
  "typescript": "5.6.3",
59
- "typescript-transform-paths": "^3.5.2",
60
+ "typescript-transform-paths": "3.5.2",
60
61
  "vite": "5.4.10"
61
62
  },
62
63
  "dependencies": {
@@ -1 +1 @@
1
- export declare const COMMON_TEST = "\n\n<https://www.markdownguide.org>\n\n**<https://www.markdownguide.org>**\n\n\n[Duck Duck Go](https://duckduckgo.com)\n\n**[EFF](https://eff.org)**\n\n***[EFF](https://eff.org)***\n\n> ***[EFF](https://eff.org)***\n\n\n![test](https://mdg.imgix.net/assets/images/san-juan-mountains.jpg?auto=format&fit=clip&q=40&w=300)\n\n**![test](https://mdg.imgix.net/assets/images/san-juan-mountains.jpg?auto=format&fit=clip&q=40&w=300)**\n\n\n> ***![test](https://mdg.imgix.net/assets/images/san-juan-mountains.jpg?auto=format&fit=clip&q=40&w=300)***\n\n``` JS\nimport { param } from \"module\";\n\nconst btn = document.getElementById('btn');\nlet count: number = 0;\n\nfunction render(){\n const regexp = /test^/\n btn.innerText = `Count: ${count}`;\n}\n\nbtn.addEventListener(\"click\", (e) => {\n // Count from 1 to 10.\n if (count < 10){\n count += 1;\n render();\n }\n})\n\nconst boolean = true\nconst object = {\n value: boolean\n}\nconst array = [1, \"test\"] \n\n```\n";
1
+ export declare const COMMON_TEST = "\n## Heading level 2\n### Heading level 3\n#### Heading level 4\n##### Heading level 5\n###### Heading level 6\nHeading level 1\n===============\nHeading level 2\n---------------\nI just love **bold text**.\nI just love __bold text__.\nLove**is**bold\n\nItalicized text is the *cat's meow*.\nItalicized text is the _cat's meow_.\nA*cat*meow\n\nThis text is ***really important***.\nThis text is ___really important___.\nThis text is __*really important*__.\nThis text is **_really important_**.\nThis is really***very***important text.\n\n> Dorothy followed her through many of the beautiful rooms in her castle.\n>\n> The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.\n\n> Dorothy followed her through many of the beautiful rooms in her castle.\n>\n>> The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.\n\n> #### The quarterly results look great!\n>\n> - Revenue was off the chart.\n> - Profits were higher than ever.\n>\n> *Everything* is going according to **plan**.\n\n![test](https://mdg.imgix.net/assets/images/san-juan-mountains.jpg?auto=format&fit=clip&q=40&w=300)\n\n\n![test](https://mdg.imgix.net/assets/images/san-juan-mountains.jpg?auto=format&fit=clip&q=40&w=300)\n\n\n\n![test](https://mdg.imgix.net/assets/images/san-juan-mountains.jpg?auto=format&fit=clip&q=40&w=280)\n\n";
@@ -1,8 +1,8 @@
1
1
  export * from "./compartments";
2
2
  export * from "./init-extensions";
3
3
  export { getDarkTheme, getLightTheme } from "./theme";
4
- export type { InitKeyMapsOptions, HandleEnterKeyMapEditorFunction } from "./keymaps";
4
+ export type { InitKeyMapsOptions, HandleEnterKeyMapEditorFunction, HandleEscapeKeyMapEditorFunction, DefaultKeyMapsOptions, CustomKeyMap, } from "./keymaps";
5
5
  export type { InitListenersOptions, GetChangeEventOptions, GetFocusEventOptions, HandleBlurEditorFunction, HandleChangeEditorFunction, HandleFocusEditorFunction, } from "./listeners";
6
6
  export type { DecorationPlugin, GetDecorationFunction, GetDecorationOptions, GetSelectionDecorationFunction, GetSelectionDecorationOptions, InitMarkdownOptions, } from "./markdown";
7
7
  export type { InitSettingsOptions } from "./settings";
8
- export type { HighlightConfig, InitThemeOptions, ThemeConfig, ThemeOptions } from "./theme";
8
+ export type { HighlightConfig, InitThemeOptions, ThemeConfig, ThemeOptions, EditorTheme, } from "./theme";
@@ -1,6 +1,6 @@
1
1
  import type { Extension } from "@codemirror/state";
2
2
  import type { WebsocketProvider } from "y-websocket";
3
- import { type Text } from "yjs";
3
+ import type { Text } from "yjs";
4
4
  import { type InitKeyMapsOptions } from "./keymaps";
5
5
  import { type InitListenersOptions } from "./listeners";
6
6
  import { type InitMarkdownOptions } from "./markdown";
@@ -11,4 +11,4 @@ export type InitExtensionsOptions = {
11
11
  multiCursorText: Text | undefined;
12
12
  provider: WebsocketProvider | undefined;
13
13
  } & ExtensionsOptions;
14
- export declare const initExtensions: ({ onBlur, onChange, onFocus, onEnter, readonly, vimMode, multiCursorText, provider, theme, dark, light, languages, }: InitExtensionsOptions) => Extension[];
14
+ export declare const initExtensions: ({ onBlur, onChange, onFocus, onEnter, onEscape, readonly, vimMode, multiCursorText, provider, theme, dark, light, languages, keyMaps, defaultKeyMaps, }: InitExtensionsOptions) => Promise<Extension[]>;
@@ -1,9 +1,23 @@
1
1
  import type { Extension } from "@codemirror/state";
2
- import { type EditorView } from "@codemirror/view";
2
+ import { type EditorView, type KeyBinding } from "@codemirror/view";
3
+ import { type EditorTheme, type ThemeOptions } from "../theme";
3
4
  export type InitKeyMapsOptions = {
4
5
  onEnter?: HandleEnterKeyMapEditorFunction;
6
+ onEscape?: HandleEscapeKeyMapEditorFunction;
7
+ keyMaps?: CustomKeyMap[];
8
+ defaultKeyMaps?: DefaultKeyMapsOptions;
5
9
  };
10
+ export type CustomKeyMap = KeyBinding;
6
11
  export type HandleEnterKeyMapEditorFunction = (view: EditorView) => boolean;
7
- export declare const initKeyMaps: ({ onEnter, multiCursorMode, }: InitKeyMapsOptions & {
12
+ export type HandleEscapeKeyMapEditorFunction = (view: EditorView) => boolean;
13
+ export type DefaultKeyMapsOptions = {
14
+ vim?: boolean;
15
+ theme?: boolean;
16
+ };
17
+ export declare const initKeyMaps: ({ onEnter, onEscape, multiCursorMode, keyMaps, defaultKeyMaps, theme: initialTheme, vimMode: initialVimMode, dark, light, }: InitKeyMapsOptions & {
8
18
  multiCursorMode: boolean;
9
- }) => Extension;
19
+ vimMode: boolean;
20
+ theme: EditorTheme;
21
+ dark?: ThemeOptions;
22
+ light?: ThemeOptions;
23
+ }) => Promise<Extension>;
@@ -1,15 +1,14 @@
1
1
  import { type EditorView, WidgetType } from "@codemirror/view";
2
2
  export declare class ImageWidget extends WidgetType {
3
- private readonly text;
4
- private readonly link;
3
+ private text;
4
+ private link;
5
+ private from;
6
+ private to;
5
7
  view: EditorView | undefined;
6
- constructor(text: string, link: string);
7
- /** recursively find the link text node in line */
8
- getTextNode(line: ChildNode | Node | null | undefined): ChildNode | null;
9
- getMinLength(): number;
10
- isCorrectNode(node: ChildNode | Node | null | undefined): node is ChildNode | Node;
11
- selectLink(node: ChildNode | Node, selection: Selection, start?: number): void;
12
- handleClick(event: MouseEvent): false | undefined;
8
+ constructor(text: string, link: string, from: number, to: number);
9
+ get key(): string;
10
+ eq(widget: ImageWidget): boolean;
11
+ updateDOM(): boolean;
13
12
  toDOM(view: EditorView): HTMLElement;
14
- destroy(dom: HTMLElement): void;
13
+ destroy(): void;
15
14
  }
@@ -0,0 +1,2 @@
1
+ import type { MarkdownExtension } from "@lezer/markdown";
2
+ export declare const markdownParserPlugin: MarkdownExtension;
@@ -3,4 +3,4 @@ export type InitSettingsOptions = {
3
3
  readonly?: boolean;
4
4
  vimMode?: boolean;
5
5
  };
6
- export declare function InitSettings({ readonly, vimMode }: InitSettingsOptions): Extension[];
6
+ export declare function InitSettings({ readonly, vimMode, }: InitSettingsOptions): Promise<Extension[]>;
@@ -1,7 +1,8 @@
1
+ export type EditorTheme = "dark" | "light";
1
2
  export type InitThemeOptions = {
2
3
  dark?: ThemeOptions;
3
4
  light?: ThemeOptions;
4
- theme?: "dark" | "light";
5
+ theme?: EditorTheme;
5
6
  };
6
7
  export type ThemeOptions = {
7
8
  themeConfig?: ThemeConfig;
@@ -19,6 +20,8 @@ export type ThemeConfig = {
19
20
  linkColor?: string;
20
21
  blockquoteColor?: string;
21
22
  mentionColor?: string;
23
+ vimSelectionFocused?: string;
24
+ vimSelection?: string;
22
25
  };
23
26
  export type HighlightConfig = {
24
27
  keyword?: string;
package/tmp/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export type { EditorInterface, EditorArguments, MultiCursorOptions } from "./module";
2
2
  export { Editor } from "./module";
3
- export type { ExtensionsOptions, InitExtensionsOptions, DecorationPlugin, GetDecorationFunction, GetDecorationOptions, GetSelectionDecorationFunction, GetSelectionDecorationOptions, HighlightConfig, InitKeyMapsOptions, InitListenersOptions, InitMarkdownOptions, InitSettingsOptions, InitThemeOptions, ThemeConfig, ThemeOptions, GetChangeEventOptions, GetFocusEventOptions, HandleBlurEditorFunction, HandleChangeEditorFunction, HandleEnterKeyMapEditorFunction, HandleFocusEditorFunction, } from "./extensions";
3
+ export type { ExtensionsOptions, InitExtensionsOptions, DecorationPlugin, GetDecorationFunction, GetDecorationOptions, GetSelectionDecorationFunction, GetSelectionDecorationOptions, HighlightConfig, InitKeyMapsOptions, InitListenersOptions, InitMarkdownOptions, InitSettingsOptions, InitThemeOptions, ThemeConfig, ThemeOptions, GetChangeEventOptions, GetFocusEventOptions, HandleBlurEditorFunction, HandleChangeEditorFunction, HandleEnterKeyMapEditorFunction, HandleFocusEditorFunction, HandleEscapeKeyMapEditorFunction, DefaultKeyMapsOptions, EditorTheme, CustomKeyMap, } from "./extensions";
@@ -3,3 +3,4 @@ export * from "./tick";
3
3
  export * from "./get-decoration";
4
4
  export * from "./is-in-range";
5
5
  export * from "./is-range-overlap";
6
+ export * from "./random-string";
@@ -0,0 +1 @@
1
+ export declare function randomString(length?: number): string;
@@ -1,16 +1,17 @@
1
1
  import { EditorView } from "@codemirror/view";
2
- import { type WebsocketProvider } from "y-websocket";
2
+ import type { WebsocketProvider } from "y-websocket";
3
+ import { type EditorTheme } from "../../extensions";
3
4
  import { type EditorArguments } from "./Editor.types";
4
5
  export declare class Editor {
5
- view: EditorView;
6
+ view: EditorView | undefined;
6
7
  provider: WebsocketProvider | undefined;
7
8
  arguments: EditorArguments;
8
9
  constructor(options: EditorArguments);
9
10
  focus: () => void;
10
- getContent: () => string;
11
+ getContent: () => string | undefined;
11
12
  setReadonly: (readonly: boolean) => void;
12
- setTheme: (theme?: "dark" | "light") => void;
13
- setVimMode: (mode: boolean) => void;
13
+ setTheme: (theme?: EditorTheme) => void;
14
+ setVimMode: (mode: boolean) => Promise<void>;
14
15
  setUserProvider: (name?: string, color?: string) => void;
15
16
  destroy: () => void;
16
17
  }
@@ -1,10 +1,9 @@
1
- import { WebsocketProvider } from "y-websocket";
2
1
  import type { MultiCursorOptions } from "../Editor.types";
3
2
  type InitEditorProviderOptions = {
4
3
  initialText?: string;
5
4
  } & MultiCursorOptions;
6
- export declare function initEditorProvider({ roomId, url, userName, userColor, initialText, onStartProvider, }: InitEditorProviderOptions): {
7
- provider: WebsocketProvider;
5
+ export declare function initEditorProvider({ roomId, url, userName, userColor, initialText, onStartProvider, }: InitEditorProviderOptions): Promise<{
6
+ provider: import("y-websocket").WebsocketProvider;
8
7
  multiCursorText: import("yjs").Text;
9
- };
8
+ }>;
10
9
  export {};
@@ -3,5 +3,5 @@ import { type InitExtensionsOptions } from "../../../extensions";
3
3
  type InitEditorStateOptions = {
4
4
  text: string;
5
5
  } & InitExtensionsOptions;
6
- export declare function initEditorState({ text, ...rest }: InitEditorStateOptions): EditorState;
6
+ export declare function initEditorState({ text, ...rest }: InitEditorStateOptions): Promise<EditorState>;
7
7
  export {};
@@ -1,7 +1,7 @@
1
1
  import { EditorView } from "@codemirror/view";
2
2
  import { type WebsocketProvider } from "y-websocket";
3
3
  import type { EditorArguments } from "../Editor.types";
4
- export declare function initEditor({ multiCursor, root, initialText, ...rest }: EditorArguments): {
4
+ export declare function initEditor({ multiCursor, root, initialText, ...rest }: EditorArguments): Promise<{
5
5
  view: EditorView;
6
6
  provider: WebsocketProvider | undefined;
7
- };
7
+ }>;