@lapismd/mira-editor 0.0.1

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 (46) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE.md +4 -0
  3. package/README.md +70 -0
  4. package/dist/assets/logo.png +0 -0
  5. package/dist/assets.d.ts +4 -0
  6. package/dist/features.d.ts +164 -0
  7. package/dist/features.d.ts.map +1 -0
  8. package/dist/features.js +348 -0
  9. package/dist/index.d.ts +12 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +7 -0
  12. package/dist/index.test.d.ts +2 -0
  13. package/dist/index.test.d.ts.map +1 -0
  14. package/dist/index.test.js +179 -0
  15. package/dist/mira-editor-about-dialog.svelte +28 -0
  16. package/dist/mira-editor-about-dialog.svelte.d.ts +7 -0
  17. package/dist/mira-editor-about-dialog.svelte.d.ts.map +1 -0
  18. package/dist/mira-editor-toolbar.svelte +805 -0
  19. package/dist/mira-editor-toolbar.svelte.d.ts +6 -0
  20. package/dist/mira-editor-toolbar.svelte.d.ts.map +1 -0
  21. package/dist/mira-editor-toolbar.test.d.ts +2 -0
  22. package/dist/mira-editor-toolbar.test.d.ts.map +1 -0
  23. package/dist/mira-editor-toolbar.test.js +199 -0
  24. package/dist/mira-editor.svelte +492 -0
  25. package/dist/mira-editor.svelte.d.ts +24 -0
  26. package/dist/mira-editor.svelte.d.ts.map +1 -0
  27. package/dist/mira-editor.test.d.ts +2 -0
  28. package/dist/mira-editor.test.d.ts.map +1 -0
  29. package/dist/mira-editor.test.js +208 -0
  30. package/dist/styles.css +165 -0
  31. package/dist/test-setup.d.ts +8 -0
  32. package/dist/test-setup.d.ts.map +1 -0
  33. package/dist/test-setup.js +31 -0
  34. package/dist/toolbar-model.d.ts +32 -0
  35. package/dist/toolbar-model.d.ts.map +1 -0
  36. package/dist/toolbar-model.js +148 -0
  37. package/dist/toolbar-model.test.d.ts +2 -0
  38. package/dist/toolbar-model.test.d.ts.map +1 -0
  39. package/dist/toolbar-model.test.js +46 -0
  40. package/dist/types.d.ts +88 -0
  41. package/dist/types.d.ts.map +1 -0
  42. package/dist/types.js +1 -0
  43. package/dist/version.d.ts +3 -0
  44. package/dist/version.d.ts.map +1 -0
  45. package/dist/version.js +2 -0
  46. package/package.json +56 -0
@@ -0,0 +1,179 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import BoldIcon from "@lucide/svelte/icons/bold";
3
+ import MiraEditor from ".";
4
+ import packageManifest from "../package.json";
5
+ import { createMiraEditorExtensions, defaultMiraEditorEditMode, MiraFeature, resolveMiraEditorBlockControls, resolveMiraEditorEditMode, resolveMiraEditorFeatures, resolveMiraEditorModes, resolveMiraEditorSlashCommands, resolveMiraEditorToolbarActions, resolveMiraEditorToolbarDefinitions, resolveMiraEditorToolbarItems, } from "./features";
6
+ import { MIRA_EDITOR_VERSION } from "./version";
7
+ describe("Mira Editor feature resolution", () => {
8
+ it("keeps the public version synchronized with the package manifest", () => {
9
+ expect(MIRA_EDITOR_VERSION).toBe(packageManifest.version);
10
+ });
11
+ it("exports the Svelte editor from the package root", () => {
12
+ expect(MiraEditor).toBeTruthy();
13
+ });
14
+ it("enables the onboarding feature set by default", () => {
15
+ const features = resolveMiraEditorFeatures();
16
+ expect(features[MiraFeature.Toolbar]).toBe(true);
17
+ expect(features[MiraFeature.Mermaid]).toBe(true);
18
+ expect(features[MiraFeature.SlashCommands]).toBe(true);
19
+ expect(features[MiraFeature.BlockControls]).toBe(true);
20
+ expect(features[MiraFeature.LivePreviewMode]).toBe(true);
21
+ });
22
+ it("filters toolbar items by feature flags", () => {
23
+ expect(resolveMiraEditorToolbarItems({
24
+ features: {
25
+ [MiraFeature.Mermaid]: false,
26
+ [MiraFeature.Tables]: false,
27
+ },
28
+ })).not.toEqual(expect.arrayContaining(["mermaid", "table"]));
29
+ });
30
+ it("keeps block controls compatible and filters contextual items by feature", () => {
31
+ expect(resolveMiraEditorBlockControls()).toBe(true);
32
+ expect(resolveMiraEditorBlockControls({
33
+ featureConfigs: {
34
+ [MiraFeature.BlockControls]: { toolbar: true },
35
+ },
36
+ features: {
37
+ [MiraFeature.Headings]: false,
38
+ [MiraFeature.Images]: false,
39
+ },
40
+ })).toMatchObject({
41
+ enabled: true,
42
+ toolbar: {
43
+ items: expect.not.arrayContaining([
44
+ "heading1",
45
+ "heading2",
46
+ "heading3",
47
+ "image",
48
+ ]),
49
+ },
50
+ });
51
+ expect(resolveMiraEditorBlockControls({
52
+ features: { [MiraFeature.BlockControls]: false },
53
+ })).toBe(false);
54
+ });
55
+ it("includes every smart action in the default toolbar", () => {
56
+ expect(resolveMiraEditorToolbarItems()).toEqual(expect.arrayContaining([
57
+ "heading",
58
+ "bold",
59
+ "italic",
60
+ "strikethrough",
61
+ "inlineCode",
62
+ "quote",
63
+ "bulletList",
64
+ "numberedList",
65
+ "taskList",
66
+ "link",
67
+ ]));
68
+ });
69
+ it("filters new smart actions through their owning features", () => {
70
+ expect(resolveMiraEditorToolbarItems({
71
+ features: {
72
+ [MiraFeature.Formatting]: false,
73
+ [MiraFeature.Code]: false,
74
+ [MiraFeature.Lists]: false,
75
+ },
76
+ })).not.toEqual(expect.arrayContaining(["strikethrough", "inlineCode", "numberedList"]));
77
+ });
78
+ it("maps mode features to available modes", () => {
79
+ expect(resolveMiraEditorModes({
80
+ [MiraFeature.SourceMode]: false,
81
+ [MiraFeature.SplitMode]: false,
82
+ })).toEqual(["live-preview", "preview"]);
83
+ });
84
+ it("resolves the configurable default edit mode", () => {
85
+ expect(defaultMiraEditorEditMode).toBe("live-preview");
86
+ expect(resolveMiraEditorEditMode("source", [
87
+ "source",
88
+ "live-preview",
89
+ "preview",
90
+ ])).toBe("source");
91
+ expect(resolveMiraEditorEditMode("source", ["live-preview", "preview"])).toBe("live-preview");
92
+ expect(resolveMiraEditorEditMode("live-preview", ["source", "preview"])).toBe("source");
93
+ });
94
+ it("merges configured and direct toolbar actions", () => {
95
+ const configured = {
96
+ id: "configured",
97
+ label: "Configured action",
98
+ icon: BoldIcon,
99
+ run: () => undefined,
100
+ };
101
+ const direct = {
102
+ id: "direct",
103
+ label: "Direct action",
104
+ icon: BoldIcon,
105
+ run: () => undefined,
106
+ };
107
+ expect(resolveMiraEditorToolbarActions({
108
+ featureConfigs: {
109
+ [MiraFeature.Toolbar]: {
110
+ actions: [configured],
111
+ },
112
+ },
113
+ toolbarActions: [direct],
114
+ })).toEqual([configured, direct]);
115
+ });
116
+ it("merges configured and direct toolbar groups", () => {
117
+ const configured = {
118
+ id: "configured",
119
+ items: [],
120
+ };
121
+ const direct = {
122
+ id: "direct",
123
+ align: "end",
124
+ items: [],
125
+ };
126
+ expect(resolveMiraEditorToolbarDefinitions({
127
+ featureConfigs: {
128
+ [MiraFeature.Toolbar]: {
129
+ toolbars: [configured],
130
+ },
131
+ },
132
+ toolbars: [direct],
133
+ })).toEqual([configured, direct]);
134
+ });
135
+ it("adds Mermaid by default and omits it when disabled", () => {
136
+ expect(createMiraEditorExtensions().some((extension) => extension.name === "mermaid")).toBe(true);
137
+ expect(createMiraEditorExtensions({
138
+ features: {
139
+ [MiraFeature.Mermaid]: false,
140
+ },
141
+ })).not.toEqual(expect.arrayContaining([expect.objectContaining({ name: "mermaid" })]));
142
+ });
143
+ it("adds slash commands by default and filters them by feature flags", () => {
144
+ expect(createMiraEditorExtensions().some((extension) => extension.name === "default-slash-commands")).toBe(true);
145
+ expect(resolveMiraEditorSlashCommands({
146
+ features: {
147
+ [MiraFeature.Tables]: false,
148
+ },
149
+ }).map((command) => command.id)).not.toContain("table");
150
+ });
151
+ it("uses markdown templates for default slash command cursor placement", () => {
152
+ expect(resolveMiraEditorSlashCommands().find((command) => command.id === "heading1")?.insert).toEqual({
153
+ markdown: "# ",
154
+ selection: 2,
155
+ });
156
+ });
157
+ it("supports custom slash commands", () => {
158
+ expect(resolveMiraEditorSlashCommands({
159
+ featureConfigs: {
160
+ [MiraFeature.SlashCommands]: {
161
+ disableDefaultCommands: true,
162
+ commands: [
163
+ {
164
+ id: "custom",
165
+ label: "Custom",
166
+ insert: "custom",
167
+ },
168
+ ],
169
+ },
170
+ },
171
+ })).toEqual([
172
+ {
173
+ id: "custom",
174
+ label: "Custom",
175
+ insert: "custom",
176
+ },
177
+ ]);
178
+ });
179
+ });
@@ -0,0 +1,28 @@
1
+ <script lang="ts">
2
+ import * as Dialog from "@lapismd/mira/ui/dialog";
3
+ import miraLogo from "./assets/logo.png";
4
+ import { MIRA_EDITOR_VERSION } from "./version";
5
+
6
+ let { open = $bindable(false) }: { open?: boolean } = $props();
7
+ </script>
8
+
9
+ <Dialog.Root bind:open>
10
+ <Dialog.Content class="mira-editor-about-dialog">
11
+ <Dialog.Header class="mira-editor-about-dialog__header">
12
+ <Dialog.Title>About Mira</Dialog.Title>
13
+ <Dialog.Description>Mira Markdown Editor</Dialog.Description>
14
+ </Dialog.Header>
15
+ <div class="mira-editor-about-dialog__logo-viewport">
16
+ <img
17
+ class="mira-editor-about-dialog__logo-image"
18
+ src={miraLogo}
19
+ alt="Mira MDE logo"
20
+ width="960"
21
+ height="337"
22
+ />
23
+ </div>
24
+ <p class="mira-editor-about-dialog__version">
25
+ Version {MIRA_EDITOR_VERSION}
26
+ </p>
27
+ </Dialog.Content>
28
+ </Dialog.Root>
@@ -0,0 +1,7 @@
1
+ type $$ComponentProps = {
2
+ open?: boolean;
3
+ };
4
+ declare const MiraEditorAboutDialog: import("svelte").Component<$$ComponentProps, {}, "open">;
5
+ type MiraEditorAboutDialog = ReturnType<typeof MiraEditorAboutDialog>;
6
+ export default MiraEditorAboutDialog;
7
+ //# sourceMappingURL=mira-editor-about-dialog.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mira-editor-about-dialog.svelte.d.ts","sourceRoot":"","sources":["../src/mira-editor-about-dialog.svelte.ts"],"names":[],"mappings":"AAOC,KAAK,gBAAgB,GAAI;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AA0B7C,QAAA,MAAM,qBAAqB,0DAAwC,CAAC;AACpE,KAAK,qBAAqB,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACtE,eAAe,qBAAqB,CAAC"}