• Joined on 2026-01-29

@mai/meditor (0.4.1)

Published 2026-09-14 12:39:56 +00:00 by mAi

Installation

@mai:registry=https://mgit.flexsiebels.de/api/packages/mAi/npm/
npm install @mai/meditor@0.4.1
"@mai/meditor": "0.4.1"

About this package

mEditor

A markdown editor as a Svelte package: a textarea/preview pair with wikilink and tag autocomplete, keyboard shortcuts, and a provider interface so the host supplies content resolution instead of the editor knowing about any one product's data.

Extracted from mBrian/src/lib/MarkdownEditor.svelte for m/mWiki#4. See docs/provider-interface.md for what a consumer must supply.

Lives at packages/meditor/ in the m/mkit workspace (moved from the standalone m/mEditor repo 2026-09-14, m/mkit#3), alongside packages/mkit (@mai/mkit). The root bunfig.toml and .gitea/workflows/publish.yml are shared across both packages; see the workspace root README.

Install

Published as @mai/meditor on this Gitea instance's own npm registry, not on the public npm registry — under the mAi account's namespace, since that is the account that cuts every release.

bun add @mai/meditor

Point the @mai scope at the registry in a .npmrc (project root or user level):

@mai:registry=https://mgit.msbls.de/api/packages/mAi/npm/
//mgit.msbls.de/api/packages/mAi/npm/:_authToken=${GITEA_NPM_TOKEN}

A build needs GITEA_NPM_TOKEN set to a Gitea personal access token with the read:package scope — that is what an install needs, publishing a new version needs write:package on top. Gitea's package registry ties write access to the owning account and takes no collaborators: a personal-user namespace like m's can be written to only by that account itself or a site admin, which is why this package lives under mAi rather than m — mAi is the account that mints every release.

A Dokploy build that installs @mai/meditor needs GITEA_NPM_TOKEN set as an environment variable on that build, plus the .npmrc above committed in the consuming repo. That variable is the first thing to check if a Dokploy build fails to resolve the package.

Versioning

Semantic versioning against the exported surface (Editor, EditorProviders, renderMarkdown, the wikilinks helpers) documented in docs/provider-interface.md:

  • patch — a fix with no change to what is exported or how it is called.
  • minor — additive only: a new optional EditorProviders member, a new export, a new optional prop. Existing callers keep compiling unchanged.
  • major — anything a consumer must react to: a removed or renamed export, a new required provider member, a changed function signature.

This applies from the first published version onward, including while the version is below 1.0.0.

A release is followed by a sync commit in m/mWiki (m/mWiki#111, scripts/sync-meditor.ts), since mWiki vendors the built package rather than installing it from this registry.

Use

<script lang="ts">
	import { Editor, type EditorProviders } from '@mai/meditor';

	let value = $state('');
	const providers: EditorProviders = {
		async search(trigger) { /* … */ return []; },
		resolveLink(kind, target, display) { /* … */ return undefined; }
	};
</script>

<Editor bind:value {providers} onsave={() => save(value)} renderOptions={{ blockIds: true }} />

renderOptions (optional) is passed straight through to the same renderMarkdown options a host's own server-side render uses, so the editor's preview stamps data-block/data-lines the same way. Omitted, the preview renders exactly as before.

wikilinks.ts's pure functions (parseWikilinks, extractWikilinkSlugs, rewriteWikilinkTarget) are exported alongside Editor for a consumer's own backlink and rename logic — see docs/provider-interface.md's "Renaming" section for why the rename itself is not part of this package.

Plain resolvers (no Svelte, no Vite)

The package root (@mai/meditor) resolves only through the svelte export condition, because Editor is a Svelte component and no export condition makes a .svelte file loadable by a plain resolver. A server-side consumer that only needs renderMarkdown or the wikilinks helpers — bun test, a plain Node ESM script, anything without a Svelte-aware bundler — imports from the @mai/meditor/headless subpath instead, which never touches Editor.svelte:

import { renderMarkdown } from '@mai/meditor/headless';

Develop

bun install
bun run test:unit # wikilinks.ts, render.ts, preview.ts unit tests
bun run dev       # src/routes is a standalone test consumer, no other repo needed
bun run build     # builds the package into dist/

Dependencies

Dependencies

ID Version
marked ^17.0.3
marked-footnote ^1.4.0

Development Dependencies

ID Version
@sveltejs/adapter-auto ^4.0.0
@sveltejs/kit ^2.15.0
@sveltejs/package ^2.3.0
@sveltejs/vite-plugin-svelte ^5.0.0
@types/bun ^1.3.9
publint ^0.2.0
svelte ^5.0.0
svelte-check ^4.0.0
typescript ^5.0.0
vite ^6.0.0

Peer Dependencies

ID Version
svelte ^5.0.0
Details
npm
2026-09-14 12:39:56 +00:00
1
MIT
15 KiB
Assets (1)
Versions (20) View all
0.9.4 2026-09-29
0.9.3 2026-09-28
0.9.2 2026-09-28
0.9.1 2026-09-28
0.9.0 2026-09-25