@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.
- package/CHANGELOG.md +7 -0
- package/LICENSE.md +4 -0
- package/README.md +70 -0
- package/dist/assets/logo.png +0 -0
- package/dist/assets.d.ts +4 -0
- package/dist/features.d.ts +164 -0
- package/dist/features.d.ts.map +1 -0
- package/dist/features.js +348 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/dist/index.test.js +179 -0
- package/dist/mira-editor-about-dialog.svelte +28 -0
- package/dist/mira-editor-about-dialog.svelte.d.ts +7 -0
- package/dist/mira-editor-about-dialog.svelte.d.ts.map +1 -0
- package/dist/mira-editor-toolbar.svelte +805 -0
- package/dist/mira-editor-toolbar.svelte.d.ts +6 -0
- package/dist/mira-editor-toolbar.svelte.d.ts.map +1 -0
- package/dist/mira-editor-toolbar.test.d.ts +2 -0
- package/dist/mira-editor-toolbar.test.d.ts.map +1 -0
- package/dist/mira-editor-toolbar.test.js +199 -0
- package/dist/mira-editor.svelte +492 -0
- package/dist/mira-editor.svelte.d.ts +24 -0
- package/dist/mira-editor.svelte.d.ts.map +1 -0
- package/dist/mira-editor.test.d.ts +2 -0
- package/dist/mira-editor.test.d.ts.map +1 -0
- package/dist/mira-editor.test.js +208 -0
- package/dist/styles.css +165 -0
- package/dist/test-setup.d.ts +8 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/test-setup.js +31 -0
- package/dist/toolbar-model.d.ts +32 -0
- package/dist/toolbar-model.d.ts.map +1 -0
- package/dist/toolbar-model.js +148 -0
- package/dist/toolbar-model.test.d.ts +2 -0
- package/dist/toolbar-model.test.d.ts.map +1 -0
- package/dist/toolbar-model.test.js +46 -0
- package/dist/types.d.ts +88 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/package.json +56 -0
package/CHANGELOG.md
ADDED
package/LICENSE.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# @lapismd/mira-editor
|
|
2
|
+
|
|
3
|
+
Opinionated, batteries-included Svelte editor for quick onboarding. The package
|
|
4
|
+
root defaults to `MiraEditor` and also exports `MiraEditorToolbar`, feature
|
|
5
|
+
configuration, and toolbar helpers.
|
|
6
|
+
|
|
7
|
+
```svelte
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import {
|
|
10
|
+
MiraEditor,
|
|
11
|
+
MiraEditorToolbar,
|
|
12
|
+
MiraFeature,
|
|
13
|
+
} from "@lapismd/mira-editor";
|
|
14
|
+
import SparklesIcon from "@lucide/svelte/icons/sparkles";
|
|
15
|
+
import Settings2Icon from "@lucide/svelte/icons/settings-2";
|
|
16
|
+
import "@lapismd/mira-editor/styles.css";
|
|
17
|
+
|
|
18
|
+
let value = "# Hello Mira";
|
|
19
|
+
let mode = "live-preview";
|
|
20
|
+
|
|
21
|
+
const toolbars = [
|
|
22
|
+
{
|
|
23
|
+
id: "document",
|
|
24
|
+
label: "Document",
|
|
25
|
+
align: "start",
|
|
26
|
+
items: [
|
|
27
|
+
{
|
|
28
|
+
id: "insert-summary",
|
|
29
|
+
label: "Insert summary",
|
|
30
|
+
icon: SparklesIcon,
|
|
31
|
+
run(editor) {
|
|
32
|
+
editor.insertMarkdown("\n## Summary\n\n");
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: "dropdown",
|
|
37
|
+
id: "settings",
|
|
38
|
+
label: "Document settings",
|
|
39
|
+
icon: Settings2Icon,
|
|
40
|
+
items: [
|
|
41
|
+
{
|
|
42
|
+
id: "insert-frontmatter",
|
|
43
|
+
label: "Insert frontmatter",
|
|
44
|
+
run(editor) {
|
|
45
|
+
editor.insertMarkdown("---\ntitle: Untitled\n---\n\n");
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<MiraEditorToolbar bind:mode {value} {toolbars} />
|
|
56
|
+
|
|
57
|
+
<MiraEditor
|
|
58
|
+
bind:value
|
|
59
|
+
bind:mode
|
|
60
|
+
defaultEditMode="live-preview"
|
|
61
|
+
features={{
|
|
62
|
+
[MiraFeature.Tables]: true,
|
|
63
|
+
[MiraFeature.Mermaid]: true,
|
|
64
|
+
[MiraFeature.Toolbar]: false,
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
For DOM mounting without a Svelte application, use `createMiraEditor` from
|
|
70
|
+
`@lapismd/mira-vanilla`.
|
|
Binary file
|
package/dist/assets.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { Component } from "svelte";
|
|
2
|
+
import type { MiraEditorSelection, MiraMarkdownActionId } from "@lapismd/mira/core";
|
|
3
|
+
import { type MiraBlockControlsOptions, type MiraBlockToolbarConfig, type MiraExtension, type MiraMarkdownBlockHandle, type MiraMarkdownBlockRange, type MiraMode, type MiraSlashCommand, type MiraTemplateSelection, type MiraTextRange, type MiraToolbarPlacement } from "@lapismd/mira/extensions";
|
|
4
|
+
export type MiraEditorEditMode = Extract<MiraMode, "live-preview" | "source">;
|
|
5
|
+
export declare const MiraFeature: {
|
|
6
|
+
readonly Toolbar: "toolbar";
|
|
7
|
+
readonly ModeSwitch: "mode-switch";
|
|
8
|
+
readonly Formatting: "formatting";
|
|
9
|
+
readonly Headings: "headings";
|
|
10
|
+
readonly Lists: "lists";
|
|
11
|
+
readonly Links: "links";
|
|
12
|
+
readonly Tables: "tables";
|
|
13
|
+
readonly GridTables: "grid-tables";
|
|
14
|
+
readonly Mermaid: "mermaid";
|
|
15
|
+
readonly Code: "code";
|
|
16
|
+
readonly Math: "math";
|
|
17
|
+
readonly Frontmatter: "frontmatter";
|
|
18
|
+
readonly Images: "images";
|
|
19
|
+
readonly Embeds: "embeds";
|
|
20
|
+
readonly Wikilinks: "wikilinks";
|
|
21
|
+
readonly Tags: "tags";
|
|
22
|
+
readonly SlashCommands: "slash-commands";
|
|
23
|
+
readonly BlockControls: "block-controls";
|
|
24
|
+
readonly SourceMode: "source-mode";
|
|
25
|
+
readonly LivePreviewMode: "live-preview-mode";
|
|
26
|
+
readonly PreviewMode: "preview-mode";
|
|
27
|
+
readonly SplitMode: "split-mode";
|
|
28
|
+
};
|
|
29
|
+
export type MiraFeatureName = (typeof MiraFeature)[keyof typeof MiraFeature];
|
|
30
|
+
export type MiraFeatureFlags = Partial<Record<MiraFeatureName, boolean>>;
|
|
31
|
+
export type MiraEditorToolbarItem = "heading" | "bold" | "italic" | "strikethrough" | "inlineCode" | "quote" | "bulletList" | "numberedList" | "taskList" | "link" | "image" | "table" | "gridTable" | "code" | "math" | "mermaid";
|
|
32
|
+
export type MiraEditorToolbarActionContext = {
|
|
33
|
+
value: string;
|
|
34
|
+
mode: MiraMode;
|
|
35
|
+
readonly: boolean;
|
|
36
|
+
focus: () => void;
|
|
37
|
+
getMarkdown: () => string;
|
|
38
|
+
getMode: () => MiraMode;
|
|
39
|
+
getIndentGuides?: () => boolean;
|
|
40
|
+
getIndentWidth?: () => number;
|
|
41
|
+
getIndentWithTabs?: () => boolean;
|
|
42
|
+
getSelection: () => MiraEditorSelection | null;
|
|
43
|
+
applyMarkdownAction?: (action: MiraMarkdownActionId) => boolean;
|
|
44
|
+
insertMarkdown: (markdown: string) => void;
|
|
45
|
+
insertImage?: () => void;
|
|
46
|
+
setIndentGuides?: (enabled: boolean) => void;
|
|
47
|
+
setIndentWidth?: (width: number) => void;
|
|
48
|
+
setIndentWithTabs?: (enabled: boolean) => void;
|
|
49
|
+
setMarkdown: (markdown: string) => void;
|
|
50
|
+
setMode: (mode: MiraMode) => void;
|
|
51
|
+
setReadonly: (readonly: boolean) => void;
|
|
52
|
+
setSelection: (selection: MiraEditorSelection) => void;
|
|
53
|
+
block?: MiraMarkdownBlockRange;
|
|
54
|
+
blocks?: MiraMarkdownBlockRange[];
|
|
55
|
+
handle?: MiraMarkdownBlockHandle;
|
|
56
|
+
affectedRange?: MiraMarkdownBlockRange;
|
|
57
|
+
replaceRange?: (markdown: string, range: MiraTextRange, selection?: MiraTemplateSelection) => void;
|
|
58
|
+
};
|
|
59
|
+
export type MiraEditorToolbarPlacement = MiraToolbarPlacement;
|
|
60
|
+
type MiraEditorToolbarDynamicBoolean = boolean | ((context: MiraEditorToolbarActionContext) => boolean);
|
|
61
|
+
export type MiraEditorToolbarMenuAction = {
|
|
62
|
+
type?: "item";
|
|
63
|
+
id: string;
|
|
64
|
+
label: string;
|
|
65
|
+
icon?: Component<Record<string, unknown>>;
|
|
66
|
+
shortcut?: string;
|
|
67
|
+
checked?: MiraEditorToolbarDynamicBoolean;
|
|
68
|
+
disabled?: MiraEditorToolbarDynamicBoolean;
|
|
69
|
+
run: (context: MiraEditorToolbarActionContext) => void;
|
|
70
|
+
};
|
|
71
|
+
export type MiraEditorToolbarMenuLabel = {
|
|
72
|
+
type: "label";
|
|
73
|
+
id?: string;
|
|
74
|
+
label: string;
|
|
75
|
+
};
|
|
76
|
+
export type MiraEditorToolbarMenuSeparator = {
|
|
77
|
+
type: "separator";
|
|
78
|
+
id?: string;
|
|
79
|
+
};
|
|
80
|
+
export type MiraEditorToolbarMenuItem = MiraEditorToolbarMenuAction | MiraEditorToolbarMenuLabel | MiraEditorToolbarMenuSeparator;
|
|
81
|
+
export type MiraEditorToolbarButtonAction = {
|
|
82
|
+
type?: "button";
|
|
83
|
+
id: string;
|
|
84
|
+
label: string;
|
|
85
|
+
icon: Component<Record<string, unknown>>;
|
|
86
|
+
group?: string;
|
|
87
|
+
placements?: readonly MiraEditorToolbarPlacement[];
|
|
88
|
+
shortcut?: string;
|
|
89
|
+
tooltip?: string;
|
|
90
|
+
disabled?: MiraEditorToolbarDynamicBoolean;
|
|
91
|
+
pressed?: MiraEditorToolbarDynamicBoolean;
|
|
92
|
+
run: (context: MiraEditorToolbarActionContext) => void;
|
|
93
|
+
};
|
|
94
|
+
export type MiraEditorToolbarDropdownAction = {
|
|
95
|
+
type: "dropdown";
|
|
96
|
+
id: string;
|
|
97
|
+
label: string;
|
|
98
|
+
icon: Component<Record<string, unknown>>;
|
|
99
|
+
tooltip?: string;
|
|
100
|
+
disabled?: MiraEditorToolbarDynamicBoolean;
|
|
101
|
+
items: MiraEditorToolbarMenuItem[];
|
|
102
|
+
};
|
|
103
|
+
export type MiraEditorToolbarAction = MiraEditorToolbarButtonAction | MiraEditorToolbarDropdownAction;
|
|
104
|
+
export type MiraEditorToolbarDefinition = {
|
|
105
|
+
id: string;
|
|
106
|
+
label?: string;
|
|
107
|
+
align?: "start" | "end";
|
|
108
|
+
items: MiraEditorToolbarAction[];
|
|
109
|
+
};
|
|
110
|
+
export type MiraEditorToolbarConfig = {
|
|
111
|
+
items?: MiraEditorToolbarItem[];
|
|
112
|
+
actions?: MiraEditorToolbarAction[];
|
|
113
|
+
toolbars?: MiraEditorToolbarDefinition[];
|
|
114
|
+
};
|
|
115
|
+
export type MiraEditorMermaidConfig = {
|
|
116
|
+
enabled?: boolean;
|
|
117
|
+
};
|
|
118
|
+
export type MiraEditorBlockControlsConfig = {
|
|
119
|
+
enabled?: boolean;
|
|
120
|
+
toolbar?: boolean | MiraBlockToolbarConfig;
|
|
121
|
+
};
|
|
122
|
+
export type MiraEditorSlashCommandId = "heading1" | "heading2" | "heading3" | "numberedList" | "bulletList" | "taskList" | "quote" | "callout" | "code" | "math" | "table" | "gridTable" | "mermaid";
|
|
123
|
+
export type MiraEditorSlashCommandConfig = {
|
|
124
|
+
commands?: MiraSlashCommand[];
|
|
125
|
+
disableDefaultCommands?: MiraEditorSlashCommandId[] | true;
|
|
126
|
+
};
|
|
127
|
+
export type MiraEditorFeatureConfigs = {
|
|
128
|
+
[MiraFeature.Toolbar]?: MiraEditorToolbarConfig;
|
|
129
|
+
[MiraFeature.Mermaid]?: MiraEditorMermaidConfig;
|
|
130
|
+
[MiraFeature.BlockControls]?: MiraEditorBlockControlsConfig;
|
|
131
|
+
[MiraFeature.SlashCommands]?: MiraEditorSlashCommandConfig;
|
|
132
|
+
};
|
|
133
|
+
export type ResolvedMiraEditorFeatures = Record<MiraFeatureName, boolean>;
|
|
134
|
+
export declare const defaultMiraEditorFeatures: ResolvedMiraEditorFeatures;
|
|
135
|
+
export declare const defaultMiraEditorEditMode: MiraEditorEditMode;
|
|
136
|
+
export declare function resolveMiraEditorFeatures(features?: MiraFeatureFlags): ResolvedMiraEditorFeatures;
|
|
137
|
+
export declare function resolveMiraEditorBlockControls({ featureConfigs, features, }?: {
|
|
138
|
+
featureConfigs?: MiraEditorFeatureConfigs;
|
|
139
|
+
features?: MiraFeatureFlags;
|
|
140
|
+
}): boolean | MiraBlockControlsOptions;
|
|
141
|
+
export declare function createMiraEditorExtensions({ featureConfigs, features, }?: {
|
|
142
|
+
featureConfigs?: MiraEditorFeatureConfigs;
|
|
143
|
+
features?: MiraFeatureFlags;
|
|
144
|
+
}): MiraExtension[];
|
|
145
|
+
export declare function resolveMiraEditorSlashCommands({ featureConfigs, features, }?: {
|
|
146
|
+
featureConfigs?: MiraEditorFeatureConfigs;
|
|
147
|
+
features?: MiraFeatureFlags;
|
|
148
|
+
}): MiraSlashCommand[];
|
|
149
|
+
export declare function resolveMiraEditorToolbarItems({ featureConfigs, features, }?: {
|
|
150
|
+
featureConfigs?: MiraEditorFeatureConfigs;
|
|
151
|
+
features?: MiraFeatureFlags;
|
|
152
|
+
}): MiraEditorToolbarItem[];
|
|
153
|
+
export declare function resolveMiraEditorToolbarActions({ featureConfigs, toolbarActions, }?: {
|
|
154
|
+
featureConfigs?: MiraEditorFeatureConfigs;
|
|
155
|
+
toolbarActions?: MiraEditorToolbarAction[];
|
|
156
|
+
}): MiraEditorToolbarAction[];
|
|
157
|
+
export declare function resolveMiraEditorToolbarDefinitions({ featureConfigs, toolbars, }?: {
|
|
158
|
+
featureConfigs?: MiraEditorFeatureConfigs;
|
|
159
|
+
toolbars?: MiraEditorToolbarDefinition[];
|
|
160
|
+
}): MiraEditorToolbarDefinition[];
|
|
161
|
+
export declare function resolveMiraEditorModes(features?: MiraFeatureFlags): MiraMode[];
|
|
162
|
+
export declare function resolveMiraEditorEditMode(defaultEditMode?: MiraEditorEditMode, modeOptions?: MiraMode[]): MiraEditorEditMode;
|
|
163
|
+
export {};
|
|
164
|
+
//# sourceMappingURL=features.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../src/features.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAC1B,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,QAAQ,EAAE,cAAc,GAAG,QAAQ,CAAC,CAAC;AAE9E,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;CAuBd,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAE7E,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;AAEzE,MAAM,MAAM,qBAAqB,GAC7B,SAAS,GAC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wB,CAqB1C;AAED,wBAAgB,0BAA0B,CAAC,EACzC,cAAmB,EACnB,QAAa,GACd,GAAE;IACD,cAAc,CAAC,EAAE,wBAAwB,CAAC;IAC1C,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CACxB,GAAG,aAAa,EAAE,CAyBvB;AAED,wBAAgB,8BAA8B,CAAC,EAC7C,cAAmB,EACnB,QAAa,GACd,GAAE;IACD,cAAc,CAAC,EAAE,wBAAwB,CAAC;IAC1C,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CACxB,GAAG,gBAAgB,EAAE,CAU1B;AAED,wBAAgB,6BAA6B,CAAC,EAC5C,cAAmB,EACnB,QAAa,GACd,GAAE;IACD,cAAc,CAAC,EAAE,wBAAwB,CAAC;IAC1C,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CACxB,GAAG,qBAAqB,EAAE,CAQ/B;AAED,wBAAgB,+BAA+B,CAAC,EAC9C,cAAmB,EACnB,cAAmB,GACpB,GAAE;IACD,cAAc,CAAC,EAAE,wBAAwB,CAAC;IAC1C,cAAc,CAAC,EAAE,uBAAuB,EAAE,CAAC;CACvC,GAAG,uBAAuB,EAAE,CAKjC;AAED,wBAAgB,mCAAmC,CAAC,EAClD,cAAmB,EACnB,QAAa,GACd,GAAE;IACD,cAAc,CAAC,EAAE,wBAAwB,CAAC;IAC1C,QAAQ,CAAC,EAAE,2BAA2B,EAAE,CAAC;CACrC,GAAG,2BAA2B,EAAE,CAKrC;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,GAAE,gBAAqB,GAC9B,QAAQ,EAAE,CAkBZ;AAED,wBAAgB,yBAAyB,CACvC,eAAe,GAAE,kBAA8C,EAC/D,WAAW,GAAE,QAAQ,EAA6B,GACjD,kBAAkB,CAWpB"}
|
package/dist/features.js
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { mermaidExtension } from "@lapismd/mira-plugin-mermaid";
|
|
2
|
+
import { createSlashSnippet, miraBlockToolbarItemIds, } from "@lapismd/mira/extensions";
|
|
3
|
+
export const MiraFeature = {
|
|
4
|
+
Toolbar: "toolbar",
|
|
5
|
+
ModeSwitch: "mode-switch",
|
|
6
|
+
Formatting: "formatting",
|
|
7
|
+
Headings: "headings",
|
|
8
|
+
Lists: "lists",
|
|
9
|
+
Links: "links",
|
|
10
|
+
Tables: "tables",
|
|
11
|
+
GridTables: "grid-tables",
|
|
12
|
+
Mermaid: "mermaid",
|
|
13
|
+
Code: "code",
|
|
14
|
+
Math: "math",
|
|
15
|
+
Frontmatter: "frontmatter",
|
|
16
|
+
Images: "images",
|
|
17
|
+
Embeds: "embeds",
|
|
18
|
+
Wikilinks: "wikilinks",
|
|
19
|
+
Tags: "tags",
|
|
20
|
+
SlashCommands: "slash-commands",
|
|
21
|
+
BlockControls: "block-controls",
|
|
22
|
+
SourceMode: "source-mode",
|
|
23
|
+
LivePreviewMode: "live-preview-mode",
|
|
24
|
+
PreviewMode: "preview-mode",
|
|
25
|
+
SplitMode: "split-mode",
|
|
26
|
+
};
|
|
27
|
+
export const defaultMiraEditorFeatures = {
|
|
28
|
+
[MiraFeature.Toolbar]: true,
|
|
29
|
+
[MiraFeature.ModeSwitch]: true,
|
|
30
|
+
[MiraFeature.Formatting]: true,
|
|
31
|
+
[MiraFeature.Headings]: true,
|
|
32
|
+
[MiraFeature.Lists]: true,
|
|
33
|
+
[MiraFeature.Links]: true,
|
|
34
|
+
[MiraFeature.Tables]: true,
|
|
35
|
+
[MiraFeature.GridTables]: true,
|
|
36
|
+
[MiraFeature.Mermaid]: true,
|
|
37
|
+
[MiraFeature.Code]: true,
|
|
38
|
+
[MiraFeature.Math]: true,
|
|
39
|
+
[MiraFeature.Frontmatter]: true,
|
|
40
|
+
[MiraFeature.Images]: true,
|
|
41
|
+
[MiraFeature.Embeds]: true,
|
|
42
|
+
[MiraFeature.Wikilinks]: true,
|
|
43
|
+
[MiraFeature.Tags]: true,
|
|
44
|
+
[MiraFeature.SlashCommands]: true,
|
|
45
|
+
[MiraFeature.BlockControls]: true,
|
|
46
|
+
[MiraFeature.SourceMode]: true,
|
|
47
|
+
[MiraFeature.LivePreviewMode]: true,
|
|
48
|
+
[MiraFeature.PreviewMode]: true,
|
|
49
|
+
[MiraFeature.SplitMode]: true,
|
|
50
|
+
};
|
|
51
|
+
export const defaultMiraEditorEditMode = "live-preview";
|
|
52
|
+
const defaultToolbarItems = [
|
|
53
|
+
"heading",
|
|
54
|
+
"bold",
|
|
55
|
+
"italic",
|
|
56
|
+
"strikethrough",
|
|
57
|
+
"inlineCode",
|
|
58
|
+
"quote",
|
|
59
|
+
"bulletList",
|
|
60
|
+
"numberedList",
|
|
61
|
+
"taskList",
|
|
62
|
+
"link",
|
|
63
|
+
"image",
|
|
64
|
+
"table",
|
|
65
|
+
"gridTable",
|
|
66
|
+
"code",
|
|
67
|
+
"math",
|
|
68
|
+
"mermaid",
|
|
69
|
+
];
|
|
70
|
+
const defaultSlashCommands = [
|
|
71
|
+
createSlashSnippet({
|
|
72
|
+
id: "heading1",
|
|
73
|
+
label: "Heading 1",
|
|
74
|
+
description: "Large section heading",
|
|
75
|
+
group: "Basic",
|
|
76
|
+
keywords: ["h1", "title"],
|
|
77
|
+
markdown: "# <|>",
|
|
78
|
+
}),
|
|
79
|
+
createSlashSnippet({
|
|
80
|
+
id: "heading2",
|
|
81
|
+
label: "Heading 2",
|
|
82
|
+
description: "Section heading",
|
|
83
|
+
group: "Basic",
|
|
84
|
+
keywords: ["h2"],
|
|
85
|
+
markdown: "## <|>",
|
|
86
|
+
}),
|
|
87
|
+
createSlashSnippet({
|
|
88
|
+
id: "heading3",
|
|
89
|
+
label: "Heading 3",
|
|
90
|
+
description: "Subsection heading",
|
|
91
|
+
group: "Basic",
|
|
92
|
+
keywords: ["h3"],
|
|
93
|
+
markdown: "### <|>",
|
|
94
|
+
}),
|
|
95
|
+
createSlashSnippet({
|
|
96
|
+
id: "numberedList",
|
|
97
|
+
label: "Numbered list",
|
|
98
|
+
description: "Start an ordered list",
|
|
99
|
+
group: "Basic",
|
|
100
|
+
keywords: ["ordered list", "ol"],
|
|
101
|
+
markdown: "1. <|>",
|
|
102
|
+
}),
|
|
103
|
+
createSlashSnippet({
|
|
104
|
+
id: "bulletList",
|
|
105
|
+
label: "Bullet list",
|
|
106
|
+
description: "Start an unordered list",
|
|
107
|
+
group: "Basic",
|
|
108
|
+
keywords: ["unordered list", "ul"],
|
|
109
|
+
markdown: "- <|>",
|
|
110
|
+
}),
|
|
111
|
+
createSlashSnippet({
|
|
112
|
+
id: "taskList",
|
|
113
|
+
label: "Task list",
|
|
114
|
+
description: "Start a checklist",
|
|
115
|
+
group: "Basic",
|
|
116
|
+
keywords: ["checkbox", "todo"],
|
|
117
|
+
markdown: "- [ ] <|>",
|
|
118
|
+
}),
|
|
119
|
+
createSlashSnippet({
|
|
120
|
+
id: "quote",
|
|
121
|
+
label: "Blockquote",
|
|
122
|
+
description: "Start a quote block",
|
|
123
|
+
group: "Basic",
|
|
124
|
+
keywords: ["quote"],
|
|
125
|
+
markdown: "> <|>",
|
|
126
|
+
}),
|
|
127
|
+
createSlashSnippet({
|
|
128
|
+
id: "callout",
|
|
129
|
+
label: "Callout",
|
|
130
|
+
description: "Insert an Obsidian-style callout",
|
|
131
|
+
group: "Basic",
|
|
132
|
+
keywords: ["admonition", "note"],
|
|
133
|
+
markdown: "> [!note] <|>\n> ",
|
|
134
|
+
}),
|
|
135
|
+
createSlashSnippet({
|
|
136
|
+
id: "code",
|
|
137
|
+
label: "Code block",
|
|
138
|
+
description: "Insert a fenced code block",
|
|
139
|
+
group: "Blocks",
|
|
140
|
+
keywords: ["fence", "pre"],
|
|
141
|
+
markdown: "```\n<|>\n```",
|
|
142
|
+
}),
|
|
143
|
+
createSlashSnippet({
|
|
144
|
+
id: "math",
|
|
145
|
+
label: "Math block",
|
|
146
|
+
description: "Insert a KaTeX block",
|
|
147
|
+
group: "Blocks",
|
|
148
|
+
keywords: ["katex", "latex", "equation"],
|
|
149
|
+
markdown: "$$\n<|>\n$$",
|
|
150
|
+
}),
|
|
151
|
+
createSlashSnippet({
|
|
152
|
+
id: "table",
|
|
153
|
+
label: "Table",
|
|
154
|
+
description: "Insert a pipe table",
|
|
155
|
+
group: "Blocks",
|
|
156
|
+
keywords: ["pipe table"],
|
|
157
|
+
markdown: "| Column | Value |\n| --- | --- |\n| Item | Detail |\n",
|
|
158
|
+
}),
|
|
159
|
+
createSlashSnippet({
|
|
160
|
+
id: "gridTable",
|
|
161
|
+
label: "Grid table",
|
|
162
|
+
description: "Insert a grid table",
|
|
163
|
+
group: "Blocks",
|
|
164
|
+
keywords: ["rst table"],
|
|
165
|
+
markdown: "+--------+--------+\n| Column | Value |\n+========+========+\n| Item | Detail |\n+--------+--------+\n",
|
|
166
|
+
}),
|
|
167
|
+
createSlashSnippet({
|
|
168
|
+
id: "mermaid",
|
|
169
|
+
label: "Mermaid diagram",
|
|
170
|
+
description: "Insert a Mermaid fenced block",
|
|
171
|
+
group: "Blocks",
|
|
172
|
+
keywords: ["diagram", "flowchart"],
|
|
173
|
+
markdown: "```mermaid\nflowchart TD\n <|>A[Start] --> B[Done]\n```\n",
|
|
174
|
+
}),
|
|
175
|
+
];
|
|
176
|
+
export function resolveMiraEditorFeatures(features = {}) {
|
|
177
|
+
return {
|
|
178
|
+
...defaultMiraEditorFeatures,
|
|
179
|
+
...features,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
export function resolveMiraEditorBlockControls({ featureConfigs = {}, features = {}, } = {}) {
|
|
183
|
+
const resolvedFeatures = resolveMiraEditorFeatures(features);
|
|
184
|
+
const config = featureConfigs[MiraFeature.BlockControls];
|
|
185
|
+
if (!resolvedFeatures[MiraFeature.BlockControls] ||
|
|
186
|
+
config?.enabled === false) {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
if (!config?.toolbar) {
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
const toolbar = config.toolbar === true ? {} : config.toolbar;
|
|
193
|
+
const items = (toolbar.items ?? miraBlockToolbarItemIds).filter((item) => isBlockToolbarItemAvailable(item, resolvedFeatures));
|
|
194
|
+
return {
|
|
195
|
+
enabled: true,
|
|
196
|
+
toolbar: { ...toolbar, items },
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
export function createMiraEditorExtensions({ featureConfigs = {}, features = {}, } = {}) {
|
|
200
|
+
const resolvedFeatures = resolveMiraEditorFeatures(features);
|
|
201
|
+
const extensions = [];
|
|
202
|
+
if (resolvedFeatures[MiraFeature.Mermaid] &&
|
|
203
|
+
featureConfigs[MiraFeature.Mermaid]?.enabled !== false) {
|
|
204
|
+
extensions.push(mermaidExtension());
|
|
205
|
+
}
|
|
206
|
+
if (resolvedFeatures[MiraFeature.SlashCommands]) {
|
|
207
|
+
const slashCommands = resolveMiraEditorSlashCommands({
|
|
208
|
+
featureConfigs,
|
|
209
|
+
features,
|
|
210
|
+
});
|
|
211
|
+
if (slashCommands.length > 0) {
|
|
212
|
+
extensions.push({
|
|
213
|
+
name: "default-slash-commands",
|
|
214
|
+
slashCommands,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return extensions;
|
|
219
|
+
}
|
|
220
|
+
export function resolveMiraEditorSlashCommands({ featureConfigs = {}, features = {}, } = {}) {
|
|
221
|
+
const resolvedFeatures = resolveMiraEditorFeatures(features);
|
|
222
|
+
const config = featureConfigs[MiraFeature.SlashCommands];
|
|
223
|
+
const defaultCommands = defaultSlashCommands
|
|
224
|
+
.filter((command) => isDefaultSlashCommandEnabled(command.id, config?.disableDefaultCommands))
|
|
225
|
+
.filter((command) => isSlashCommandAvailable(command.id, resolvedFeatures));
|
|
226
|
+
return [...defaultCommands, ...(config?.commands ?? [])];
|
|
227
|
+
}
|
|
228
|
+
export function resolveMiraEditorToolbarItems({ featureConfigs = {}, features = {}, } = {}) {
|
|
229
|
+
const resolvedFeatures = resolveMiraEditorFeatures(features);
|
|
230
|
+
const configuredItems = featureConfigs[MiraFeature.Toolbar]?.items ?? defaultToolbarItems;
|
|
231
|
+
return configuredItems.filter((item) => isToolbarItemAvailable(item, resolvedFeatures));
|
|
232
|
+
}
|
|
233
|
+
export function resolveMiraEditorToolbarActions({ featureConfigs = {}, toolbarActions = [], } = {}) {
|
|
234
|
+
return [
|
|
235
|
+
...(featureConfigs[MiraFeature.Toolbar]?.actions ?? []),
|
|
236
|
+
...toolbarActions,
|
|
237
|
+
];
|
|
238
|
+
}
|
|
239
|
+
export function resolveMiraEditorToolbarDefinitions({ featureConfigs = {}, toolbars = [], } = {}) {
|
|
240
|
+
return [
|
|
241
|
+
...(featureConfigs[MiraFeature.Toolbar]?.toolbars ?? []),
|
|
242
|
+
...toolbars,
|
|
243
|
+
];
|
|
244
|
+
}
|
|
245
|
+
export function resolveMiraEditorModes(features = {}) {
|
|
246
|
+
const resolvedFeatures = resolveMiraEditorFeatures(features);
|
|
247
|
+
const modes = [];
|
|
248
|
+
if (resolvedFeatures[MiraFeature.SourceMode]) {
|
|
249
|
+
modes.push("source");
|
|
250
|
+
}
|
|
251
|
+
if (resolvedFeatures[MiraFeature.LivePreviewMode]) {
|
|
252
|
+
modes.push("live-preview");
|
|
253
|
+
}
|
|
254
|
+
if (resolvedFeatures[MiraFeature.PreviewMode]) {
|
|
255
|
+
modes.push("preview");
|
|
256
|
+
}
|
|
257
|
+
if (resolvedFeatures[MiraFeature.SplitMode]) {
|
|
258
|
+
modes.push("split");
|
|
259
|
+
}
|
|
260
|
+
return modes;
|
|
261
|
+
}
|
|
262
|
+
export function resolveMiraEditorEditMode(defaultEditMode = defaultMiraEditorEditMode, modeOptions = resolveMiraEditorModes()) {
|
|
263
|
+
if (modeOptions.includes(defaultEditMode)) {
|
|
264
|
+
return defaultEditMode;
|
|
265
|
+
}
|
|
266
|
+
if (modeOptions.includes(defaultMiraEditorEditMode)) {
|
|
267
|
+
return defaultMiraEditorEditMode;
|
|
268
|
+
}
|
|
269
|
+
if (modeOptions.includes("source")) {
|
|
270
|
+
return "source";
|
|
271
|
+
}
|
|
272
|
+
return defaultMiraEditorEditMode;
|
|
273
|
+
}
|
|
274
|
+
function isBlockToolbarItemAvailable(item, features) {
|
|
275
|
+
switch (item) {
|
|
276
|
+
case "heading1":
|
|
277
|
+
case "heading2":
|
|
278
|
+
case "heading3":
|
|
279
|
+
return features[MiraFeature.Headings];
|
|
280
|
+
case "task":
|
|
281
|
+
case "bulletList":
|
|
282
|
+
case "numberedList":
|
|
283
|
+
case "quote":
|
|
284
|
+
return features[MiraFeature.Lists];
|
|
285
|
+
case "image":
|
|
286
|
+
return features[MiraFeature.Images];
|
|
287
|
+
case "paragraph":
|
|
288
|
+
case "divider":
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function isToolbarItemAvailable(item, features) {
|
|
293
|
+
switch (item) {
|
|
294
|
+
case "bold":
|
|
295
|
+
case "italic":
|
|
296
|
+
case "strikethrough":
|
|
297
|
+
return features[MiraFeature.Formatting];
|
|
298
|
+
case "heading":
|
|
299
|
+
return features[MiraFeature.Headings];
|
|
300
|
+
case "quote":
|
|
301
|
+
case "bulletList":
|
|
302
|
+
case "numberedList":
|
|
303
|
+
case "taskList":
|
|
304
|
+
return features[MiraFeature.Lists];
|
|
305
|
+
case "link":
|
|
306
|
+
return features[MiraFeature.Links];
|
|
307
|
+
case "image":
|
|
308
|
+
return features[MiraFeature.Images];
|
|
309
|
+
case "table":
|
|
310
|
+
return features[MiraFeature.Tables];
|
|
311
|
+
case "gridTable":
|
|
312
|
+
return features[MiraFeature.GridTables];
|
|
313
|
+
case "mermaid":
|
|
314
|
+
return features[MiraFeature.Mermaid];
|
|
315
|
+
case "inlineCode":
|
|
316
|
+
case "code":
|
|
317
|
+
return features[MiraFeature.Code];
|
|
318
|
+
case "math":
|
|
319
|
+
return features[MiraFeature.Math];
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function isDefaultSlashCommandEnabled(command, disabled) {
|
|
323
|
+
return disabled === true ? false : !disabled?.includes(command);
|
|
324
|
+
}
|
|
325
|
+
function isSlashCommandAvailable(command, features) {
|
|
326
|
+
switch (command) {
|
|
327
|
+
case "heading1":
|
|
328
|
+
case "heading2":
|
|
329
|
+
case "heading3":
|
|
330
|
+
return features[MiraFeature.Headings];
|
|
331
|
+
case "numberedList":
|
|
332
|
+
case "bulletList":
|
|
333
|
+
case "taskList":
|
|
334
|
+
case "quote":
|
|
335
|
+
case "callout":
|
|
336
|
+
return features[MiraFeature.Lists];
|
|
337
|
+
case "table":
|
|
338
|
+
return features[MiraFeature.Tables];
|
|
339
|
+
case "gridTable":
|
|
340
|
+
return features[MiraFeature.GridTables];
|
|
341
|
+
case "mermaid":
|
|
342
|
+
return features[MiraFeature.Mermaid];
|
|
343
|
+
case "code":
|
|
344
|
+
return features[MiraFeature.Code];
|
|
345
|
+
case "math":
|
|
346
|
+
return features[MiraFeature.Math];
|
|
347
|
+
}
|
|
348
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import MiraEditor from "./mira-editor.svelte";
|
|
2
|
+
import MiraEditorToolbar from "./mira-editor-toolbar.svelte";
|
|
3
|
+
import { createMiraEditorExtensions, defaultMiraEditorEditMode, defaultMiraEditorFeatures, MiraFeature, resolveMiraEditorBlockControls, resolveMiraEditorEditMode, resolveMiraEditorFeatures, resolveMiraEditorModes, resolveMiraEditorSlashCommands, resolveMiraEditorToolbarActions, resolveMiraEditorToolbarDefinitions, resolveMiraEditorToolbarItems } from "./features";
|
|
4
|
+
export { createMiraEditorExtensions, defaultMiraEditorEditMode, defaultMiraEditorFeatures, MiraEditor, MiraEditorToolbar, MiraFeature, resolveMiraEditorBlockControls, resolveMiraEditorEditMode, resolveMiraEditorFeatures, resolveMiraEditorModes, resolveMiraEditorSlashCommands, resolveMiraEditorToolbarActions, resolveMiraEditorToolbarDefinitions, resolveMiraEditorToolbarItems, };
|
|
5
|
+
export { isMiraEditMode, miraEditorModeLabels, miraEditorToolbarItemLabels, markdownActionForMiraToolbarItem, miraViewOptionsLabel, miraViewToggleLabel, resolveMiraAlternateEditMode, resolveMiraModeAfterSplit, resolveMiraViewModeMenuItems, resolveMiraViewToggleMode, templateForMiraToolbarItem, } from "./toolbar-model";
|
|
6
|
+
export type { MiraEditorEditMode, MiraEditorHandle, MiraEditorProps, MiraOutlineVariant, MiraEditorToolbarProps, MiraFrontmatterConfig, } from "./types";
|
|
7
|
+
export type { MiraEditorBlockControlsConfig, MiraEditorFeatureConfigs, MiraEditorMermaidConfig, MiraEditorSlashCommandConfig, MiraEditorSlashCommandId, MiraEditorToolbarAction, MiraEditorToolbarActionContext, MiraEditorToolbarButtonAction, MiraEditorToolbarConfig, MiraEditorToolbarDefinition, MiraEditorToolbarDropdownAction, MiraEditorToolbarItem, MiraEditorToolbarMenuAction, MiraEditorToolbarMenuItem, MiraEditorToolbarMenuLabel, MiraEditorToolbarMenuSeparator, MiraEditorToolbarPlacement, MiraFeatureFlags, MiraFeatureName, ResolvedMiraEditorFeatures, } from "./features";
|
|
8
|
+
export type { MiraViewModeMenuItem } from "./toolbar-model";
|
|
9
|
+
export type { MiraMarkdownActionId } from "@lapismd/mira/core";
|
|
10
|
+
export { MIRA_EDITOR_VERSION } from "./version";
|
|
11
|
+
export default MiraEditor;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,iBAAiB,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,EACzB,WAAW,EACX,8BAA8B,EAC9B,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,8BAA8B,EAC9B,+BAA+B,EAC/B,mCAAmC,EACnC,6BAA6B,EAC9B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,EACzB,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,8BAA8B,EAC9B,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,8BAA8B,EAC9B,+BAA+B,EAC/B,mCAAmC,EACnC,6BAA6B,GAC9B,CAAC;AACF,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,2BAA2B,EAC3B,gCAAgC,EAChC,oBAAoB,EACpB,mBAAmB,EACnB,4BAA4B,EAC5B,yBAAyB,EACzB,4BAA4B,EAC5B,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,6BAA6B,EAC7B,wBAAwB,EACxB,uBAAuB,EACvB,4BAA4B,EAC5B,wBAAwB,EACxB,uBAAuB,EACvB,8BAA8B,EAC9B,6BAA6B,EAC7B,uBAAuB,EACvB,2BAA2B,EAC3B,+BAA+B,EAC/B,qBAAqB,EACrB,2BAA2B,EAC3B,yBAAyB,EACzB,0BAA0B,EAC1B,8BAA8B,EAC9B,0BAA0B,EAC1B,gBAAgB,EAChB,eAAe,EACf,0BAA0B,GAC3B,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,eAAe,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import MiraEditor from "./mira-editor.svelte";
|
|
2
|
+
import MiraEditorToolbar from "./mira-editor-toolbar.svelte";
|
|
3
|
+
import { createMiraEditorExtensions, defaultMiraEditorEditMode, defaultMiraEditorFeatures, MiraFeature, resolveMiraEditorBlockControls, resolveMiraEditorEditMode, resolveMiraEditorFeatures, resolveMiraEditorModes, resolveMiraEditorSlashCommands, resolveMiraEditorToolbarActions, resolveMiraEditorToolbarDefinitions, resolveMiraEditorToolbarItems, } from "./features";
|
|
4
|
+
export { createMiraEditorExtensions, defaultMiraEditorEditMode, defaultMiraEditorFeatures, MiraEditor, MiraEditorToolbar, MiraFeature, resolveMiraEditorBlockControls, resolveMiraEditorEditMode, resolveMiraEditorFeatures, resolveMiraEditorModes, resolveMiraEditorSlashCommands, resolveMiraEditorToolbarActions, resolveMiraEditorToolbarDefinitions, resolveMiraEditorToolbarItems, };
|
|
5
|
+
export { isMiraEditMode, miraEditorModeLabels, miraEditorToolbarItemLabels, markdownActionForMiraToolbarItem, miraViewOptionsLabel, miraViewToggleLabel, resolveMiraAlternateEditMode, resolveMiraModeAfterSplit, resolveMiraViewModeMenuItems, resolveMiraViewToggleMode, templateForMiraToolbarItem, } from "./toolbar-model";
|
|
6
|
+
export { MIRA_EDITOR_VERSION } from "./version";
|
|
7
|
+
export default MiraEditor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
|