@lupinum/ginko-editor 0.1.0 → 0.18.0
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 -73
- package/LICENSE +1 -1
- package/README.md +15 -340
- package/dist/assets.d.ts +70 -0
- package/dist/assets.js +31 -0
- package/dist/core/component-props.d.ts +87 -0
- package/dist/core/component-props.js +134 -0
- package/dist/core/convert.d.ts +24 -0
- package/dist/core/convert.js +278 -0
- package/dist/core/editor.d.ts +60 -0
- package/dist/core/editor.js +85 -0
- package/dist/core/extensions.d.ts +38 -0
- package/dist/core/extensions.js +444 -0
- package/dist/core/file-images.d.ts +9 -0
- package/dist/core/file-images.js +54 -0
- package/dist/core/image-frame.d.ts +23 -0
- package/dist/core/image-frame.js +24 -0
- package/dist/core/index.d.ts +17 -0
- package/dist/core/index.js +17 -0
- package/dist/core/link-card.d.ts +20 -0
- package/dist/core/link-card.js +70 -0
- package/dist/core/link.d.ts +3 -0
- package/dist/core/link.js +8 -0
- package/dist/core/move.d.ts +11 -0
- package/dist/core/move.js +37 -0
- package/dist/core/paste-html.d.ts +6 -0
- package/dist/core/paste-html.js +384 -0
- package/dist/core/paste.d.ts +21 -0
- package/dist/core/paste.js +108 -0
- package/dist/core/problems.d.ts +31 -0
- package/dist/core/problems.js +54 -0
- package/dist/core/search.d.ts +47 -0
- package/dist/core/search.js +148 -0
- package/dist/core/slash.d.ts +93 -0
- package/dist/core/slash.js +215 -0
- package/dist/core/table.d.ts +34 -0
- package/dist/core/table.js +141 -0
- package/dist/core/uploads.d.ts +23 -0
- package/dist/core/uploads.js +71 -0
- package/dist/core/use-editor.d.ts +19 -0
- package/dist/core/use-editor.js +53 -0
- package/dist/index.d.ts +6 -15
- package/dist/index.js +6 -5668
- package/dist/issues.d.ts +49 -0
- package/dist/issues.js +9 -0
- package/dist/today.d.ts +6 -0
- package/dist/today.js +19 -0
- package/dist/useUpload.d.ts +48 -0
- package/dist/useUpload.js +59 -0
- package/dist/values.d.ts +14 -0
- package/dist/values.js +36 -0
- package/package.json +35 -95
- package/dist/GinkoEditor.vue.d.ts +0 -96
- package/dist/GinkoImagePicker.vue.d.ts +0 -36
- package/dist/agent/AGENTS.md +0 -13
- package/dist/agent/pages/docs/getting-started/collaboration.md +0 -435
- package/dist/agent/pages/docs/getting-started/component-coverage.md +0 -107
- package/dist/agent/pages/docs/getting-started/customize.md +0 -384
- package/dist/agent/pages/docs/getting-started/images.md +0 -188
- package/dist/agent/pages/docs/getting-started/in-place-editing.md +0 -110
- package/dist/agent/pages/docs/getting-started/layout-blocks.md +0 -148
- package/dist/agent/pages/docs/getting-started/runtime.md +0 -111
- package/dist/agent/pages/docs/getting-started.md +0 -128
- package/dist/authoring-D7MJezVG.js +0 -1780
- package/dist/authoring-D7MJezVG.js.map +0 -1
- package/dist/authoring.d.ts +0 -122
- package/dist/authoring.js +0 -2
- package/dist/collaboration.d.ts +0 -14
- package/dist/collaboration.js +0 -907
- package/dist/collaboration.js.map +0 -1
- package/dist/composables/useAssetRequests.d.ts +0 -44
- package/dist/composables/useCollaborationBinding.d.ts +0 -59
- package/dist/composables/useDevice.d.ts +0 -10
- package/dist/composables/useInsertMenu.d.ts +0 -67
- package/dist/composables/useMarkdownSync.d.ts +0 -96
- package/dist/composables/useStableAuthoringKit.d.ts +0 -16
- package/dist/documentConfig-Z6LdrWZj.js +0 -2360
- package/dist/documentConfig-Z6LdrWZj.js.map +0 -1
- package/dist/editorProps.d.ts +0 -124
- package/dist/index.js.map +0 -1
- package/dist/layout-kit.d.ts +0 -922
- package/dist/lib/collaboration/presence-record.d.ts +0 -18
- package/dist/lib/collaboration/presence.d.ts +0 -103
- package/dist/lib/collaboration/protocol.d.ts +0 -133
- package/dist/lib/collaboration/recovery.d.ts +0 -45
- package/dist/lib/collaboration/session.d.ts +0 -163
- package/dist/lib/collaboration/validation.d.ts +0 -42
- package/dist/lib/component-converters.d.ts +0 -119
- package/dist/lib/config/documentConfig.d.ts +0 -19
- package/dist/lib/config/editorConfig.d.ts +0 -38
- package/dist/lib/container-items.d.ts +0 -55
- package/dist/lib/conversionInvariants.d.ts +0 -3
- package/dist/lib/conversionLogger.d.ts +0 -10
- package/dist/lib/conversionPipeline.d.ts +0 -17
- package/dist/lib/conversionState.d.ts +0 -10
- package/dist/lib/conversionTypes.d.ts +0 -50
- package/dist/lib/editor-operations.d.ts +0 -39
- package/dist/lib/environment.d.ts +0 -6
- package/dist/lib/extensions/code-block.d.ts +0 -18
- package/dist/lib/extensions/component-boundary.d.ts +0 -9
- package/dist/lib/extensions/container-items.d.ts +0 -29
- package/dist/lib/extensions/element.d.ts +0 -19
- package/dist/lib/extensions/file.d.ts +0 -24
- package/dist/lib/extensions/heading.d.ts +0 -5
- package/dist/lib/extensions/image-upload.d.ts +0 -39
- package/dist/lib/extensions/image.d.ts +0 -39
- package/dist/lib/extensions/index.d.ts +0 -10
- package/dist/lib/extensions/inline-element.d.ts +0 -13
- package/dist/lib/extensions/markdown-clipboard.d.ts +0 -21
- package/dist/lib/extensions/profile.d.ts +0 -11
- package/dist/lib/extensions/slot.d.ts +0 -16
- package/dist/lib/extensions/span-style.d.ts +0 -15
- package/dist/lib/extensions/video.d.ts +0 -15
- package/dist/lib/image-properties.d.ts +0 -20
- package/dist/lib/input-rules.d.ts +0 -7
- package/dist/lib/markdown.d.ts +0 -11
- package/dist/lib/marks.d.ts +0 -7
- package/dist/lib/mdcToTiptap.d.ts +0 -20
- package/dist/lib/mdcTypes.d.ts +0 -20
- package/dist/lib/nodes.d.ts +0 -57
- package/dist/lib/nodeviews/block-actions.d.ts +0 -7
- package/dist/lib/nodeviews/code.d.ts +0 -4
- package/dist/lib/nodeviews/columns.d.ts +0 -17
- package/dist/lib/nodeviews/component.d.ts +0 -6
- package/dist/lib/nodeviews/icons.d.ts +0 -26
- package/dist/lib/nodeviews/image.d.ts +0 -9
- package/dist/lib/nodeviews/items.d.ts +0 -15
- package/dist/lib/nodeviews/lifecycle.d.ts +0 -45
- package/dist/lib/nodeviews/popover.d.ts +0 -15
- package/dist/lib/nodeviews/settings.d.ts +0 -11
- package/dist/lib/nodeviews/table-operations.d.ts +0 -50
- package/dist/lib/nodeviews/table.d.ts +0 -4
- package/dist/lib/profiles.d.ts +0 -62
- package/dist/lib/property-input.d.ts +0 -10
- package/dist/lib/property-step.d.ts +0 -77
- package/dist/lib/props.d.ts +0 -13
- package/dist/lib/stripStyleNodes.d.ts +0 -2
- package/dist/lib/tiptapToMdc.d.ts +0 -18
- package/dist/presence-record-CLdPZWKC.js +0 -291
- package/dist/presence-record-CLdPZWKC.js.map +0 -1
- package/dist/runtime.d.ts +0 -13
- package/dist/runtime.js +0 -3
- package/dist/style.css +0 -2
- package/dist/types.d.ts +0 -126
- package/dist/ui/GinkoActionButton.vue.d.ts +0 -8
- package/dist/ui/GinkoInsertMenu.vue.d.ts +0 -49
- package/dist/ui/GinkoKeyboardDock.vue.d.ts +0 -15
- package/dist/ui/GinkoNodePopover.vue.d.ts +0 -21
- package/dist/ui/GinkoRecipeIcon.vue.d.ts +0 -6
- package/dist/ui/GinkoSelectionToolbar.vue.d.ts +0 -10
- package/dist/ui/GinkoToolbar.vue.d.ts +0 -26
- package/dist/ui/GinkoToolbarIcon.vue.d.ts +0 -6
- package/dist/ui/block-shortcuts.d.ts +0 -6
- package/dist/ui/commands.d.ts +0 -78
- package/dist/ui/context.d.ts +0 -23
- package/dist/ui/editor-keyboard.d.ts +0 -15
- package/dist/ui/messages.d.ts +0 -214
- package/dist/ui/messages.de.d.ts +0 -6
- package/dist/ui/recipe-command.d.ts +0 -14
- package/dist/ui/recipe-search.d.ts +0 -47
- package/dist/ui/slash-command.d.ts +0 -17
- package/dist/ui/writingRecipes.d.ts +0 -13
- package/skills/ginko-editor/SKILL.md +0 -40
- package/skills/ginko-editor/agents/openai.yaml +0 -4
- package/skills/ginko-editor/references/in-place-editing.md +0 -50
- package/skills/ginko-editor/references/quickstart.md +0 -55
package/dist/issues.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { InjectionKey } from 'vue';
|
|
2
|
+
export interface Issue {
|
|
3
|
+
path: string;
|
|
4
|
+
message: string;
|
|
5
|
+
code?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Issues that belong exactly to this field (its own path, its locale leaf, an image's alt text), not to its list rows. */
|
|
8
|
+
export declare function ownIssues(issues: readonly Issue[], path: string, locales: readonly string[]): Issue[];
|
|
9
|
+
/** Issues under a path, for lists that show row problems. */
|
|
10
|
+
export declare function issuesUnder(issues: readonly Issue[], path: string): Issue[];
|
|
11
|
+
/** Set by the sheet: a field that still needs a confirmation blocks saving (UI.md 5, "Noch richtig?"). */
|
|
12
|
+
export declare const BLOCKERS: InjectionKey<Map<string, string>>;
|
|
13
|
+
/** Set by the form: fields that hold input back (the Markdown editor's pause) hand it over before a save. */
|
|
14
|
+
export declare const FLUSHERS: InjectionKey<Set<() => Promise<void>>>;
|
|
15
|
+
/**
|
|
16
|
+
* Set by a form in a foreign language (Alles bearbeiten, a quick-task sheet): the translation state of one translatable
|
|
17
|
+
* leaf, by its path (`name`, or `days.<rowId>.dish` inside a list), the main-language text, and "Englisch stimmt noch".
|
|
18
|
+
*/
|
|
19
|
+
export interface TranslationState {
|
|
20
|
+
state: (leaf: string) => 'missing' | 'stale' | 'fine' | undefined;
|
|
21
|
+
/** The whole stored main-language text of a leaf (Markdown as written). */
|
|
22
|
+
source: (leaf: string) => string;
|
|
23
|
+
/** "Englisch stimmt noch": keeps an outdated translation as current. Without it, the outdated note shows without that button. */
|
|
24
|
+
confirm?: (leaf: string) => void;
|
|
25
|
+
/** "Deutsch": the main language's name, for the source line and the hints. */
|
|
26
|
+
mainName: () => string;
|
|
27
|
+
/**
|
|
28
|
+
* The note under a leaf whose translation is missing: what the website shows without it, from the stored entry's
|
|
29
|
+
* translation state (Alles bearbeiten). Without it, `hiddenWithout` or the main-language fallback decides the note.
|
|
30
|
+
*/
|
|
31
|
+
missingNote?: (leaf: string) => string;
|
|
32
|
+
/** Where the entry's history shows what changed in the main language ("Was hat sich geändert?"). */
|
|
33
|
+
changesUrl?: () => string | undefined;
|
|
34
|
+
/** The entry's page in the open language (none while it is not translated), and its link while it is online. */
|
|
35
|
+
address?: () => {
|
|
36
|
+
path: string;
|
|
37
|
+
href?: string;
|
|
38
|
+
} | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Set when the website leaves the whole entry out of this language while the leaf has no text there (a page, such
|
|
41
|
+
* as an event): the entry's title and the language's name ("Englisch"), so the hint says what goes missing instead
|
|
42
|
+
* of promising the main-language text.
|
|
43
|
+
*/
|
|
44
|
+
hiddenWithout?: (leaf: string) => {
|
|
45
|
+
title: string;
|
|
46
|
+
language: string;
|
|
47
|
+
} | undefined;
|
|
48
|
+
}
|
|
49
|
+
export declare const TRANSLATION: InjectionKey<TranslationState>;
|
package/dist/issues.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function ownIssues(issues, path, locales) {
|
|
2
|
+
return issues.filter((i) => i.path === path || i.path === `${path}.alt` || locales.some((l) => i.path === `${path}.${l}`));
|
|
3
|
+
}
|
|
4
|
+
export function issuesUnder(issues, path) {
|
|
5
|
+
return issues.filter((i) => i.path === path || i.path.startsWith(`${path}.`));
|
|
6
|
+
}
|
|
7
|
+
export const BLOCKERS = Symbol("ginko:blockers");
|
|
8
|
+
export const FLUSHERS = Symbol("ginko:flushers");
|
|
9
|
+
export const TRANSLATION = Symbol("ginko:translation");
|
package/dist/today.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Today's date in `timeZone`, moving on at midnight: an editor left open overnight offers the new
|
|
4
|
+
* "Heute", "Diese Woche" and week state, not yesterday's.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useToday(timeZone: MaybeRefOrGetter<string>): import("vue").ComputedRef<string>;
|
package/dist/today.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { computed, ref, toValue } from "vue";
|
|
2
|
+
import { todayIn } from "@lupinum/ginko/internal";
|
|
3
|
+
const tick = ref(0);
|
|
4
|
+
let ticking = false;
|
|
5
|
+
export function useToday(timeZone) {
|
|
6
|
+
if (typeof document !== "undefined" && !ticking) {
|
|
7
|
+
ticking = true;
|
|
8
|
+
setInterval(() => {
|
|
9
|
+
tick.value++;
|
|
10
|
+
}, 6e4);
|
|
11
|
+
document.addEventListener("visibilitychange", () => {
|
|
12
|
+
if (document.visibilityState === "visible") tick.value++;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return computed(() => {
|
|
16
|
+
void tick.value;
|
|
17
|
+
return todayIn(toValue(timeZone));
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export interface UploadOptions {
|
|
3
|
+
kind: 'image' | 'file';
|
|
4
|
+
/** Field id; the key under which a running upload blocks the save. */
|
|
5
|
+
id: () => string;
|
|
6
|
+
/** Message when the failure carries none. */
|
|
7
|
+
generic: string;
|
|
8
|
+
/** Note shown while the upload or the server check runs. */
|
|
9
|
+
blockedText: string;
|
|
10
|
+
/** True while the server checks the stored upload. */
|
|
11
|
+
processing: Ref<boolean>;
|
|
12
|
+
/** Returns a message to refuse a file before any upload. */
|
|
13
|
+
precheck?: (file: File) => string | undefined;
|
|
14
|
+
}
|
|
15
|
+
/** The upload flow both file and photo fields share: picker, cancel, error, retry and save blocking. */
|
|
16
|
+
export declare function useUpload(options: UploadOptions): {
|
|
17
|
+
picker: Ref<HTMLInputElement | null, HTMLInputElement | null>;
|
|
18
|
+
sending: Ref<boolean, boolean>;
|
|
19
|
+
error: Ref<string | null, string | null>;
|
|
20
|
+
retryFile: Ref<{
|
|
21
|
+
readonly lastModified: number;
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly webkitRelativePath: string;
|
|
24
|
+
readonly size: number;
|
|
25
|
+
readonly type: string;
|
|
26
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
27
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
28
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
29
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
30
|
+
text: () => Promise<string>;
|
|
31
|
+
} | null, File | {
|
|
32
|
+
readonly lastModified: number;
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly webkitRelativePath: string;
|
|
35
|
+
readonly size: number;
|
|
36
|
+
readonly type: string;
|
|
37
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
38
|
+
bytes: () => Promise<Uint8Array<ArrayBuffer>>;
|
|
39
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
40
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
41
|
+
text: () => Promise<string>;
|
|
42
|
+
} | null>;
|
|
43
|
+
cancel: () => void | undefined;
|
|
44
|
+
pick: () => void;
|
|
45
|
+
onPicked: (event: Event, onUploaded: (id: string) => void) => void;
|
|
46
|
+
retry: () => void;
|
|
47
|
+
choose: (file: File, onUploaded: (id: string) => void) => Promise<void>;
|
|
48
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { computed, inject, onBeforeUnmount, ref, watchEffect } from "vue";
|
|
2
|
+
import { useGinkoAssets } from "./assets.js";
|
|
3
|
+
import { BLOCKERS } from "./issues.js";
|
|
4
|
+
export function useUpload(options) {
|
|
5
|
+
const assets = useGinkoAssets();
|
|
6
|
+
const picker = ref(null);
|
|
7
|
+
const sending = ref(false);
|
|
8
|
+
const error = ref(null);
|
|
9
|
+
const retryFile = ref(null);
|
|
10
|
+
let cancelUpload;
|
|
11
|
+
let lastUploaded;
|
|
12
|
+
const cancel = () => cancelUpload?.();
|
|
13
|
+
onBeforeUnmount(cancel);
|
|
14
|
+
async function choose(file, onUploaded) {
|
|
15
|
+
error.value = null;
|
|
16
|
+
retryFile.value = null;
|
|
17
|
+
const refused = options.precheck?.(file);
|
|
18
|
+
if (refused) {
|
|
19
|
+
error.value = refused;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
retryFile.value = file;
|
|
23
|
+
lastUploaded = onUploaded;
|
|
24
|
+
sending.value = true;
|
|
25
|
+
const controller = new AbortController();
|
|
26
|
+
cancelUpload = () => controller.abort();
|
|
27
|
+
try {
|
|
28
|
+
const id = await assets.upload(options.kind, file, controller.signal);
|
|
29
|
+
if (!controller.signal.aborted) onUploaded(id);
|
|
30
|
+
} catch (failure) {
|
|
31
|
+
if (!controller.signal.aborted) error.value = failure instanceof Error ? failure.message : options.generic;
|
|
32
|
+
} finally {
|
|
33
|
+
sending.value = false;
|
|
34
|
+
cancelUpload = void 0;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function pick() {
|
|
38
|
+
picker.value?.click();
|
|
39
|
+
}
|
|
40
|
+
function onPicked(event, onUploaded) {
|
|
41
|
+
const input = event.target;
|
|
42
|
+
const file = input.files?.[0];
|
|
43
|
+
input.value = "";
|
|
44
|
+
if (file) void choose(file, onUploaded);
|
|
45
|
+
}
|
|
46
|
+
function retry() {
|
|
47
|
+
if (retryFile.value && lastUploaded) void choose(retryFile.value, lastUploaded);
|
|
48
|
+
else pick();
|
|
49
|
+
}
|
|
50
|
+
const blockers = inject(BLOCKERS, void 0);
|
|
51
|
+
const busy = computed(() => sending.value || options.processing.value);
|
|
52
|
+
watchEffect(() => {
|
|
53
|
+
if (!blockers) return;
|
|
54
|
+
if (busy.value) blockers.set(options.id(), options.blockedText);
|
|
55
|
+
else blockers.delete(options.id());
|
|
56
|
+
});
|
|
57
|
+
onBeforeUnmount(() => blockers?.delete(options.id()));
|
|
58
|
+
return { picker, sending, error, retryFile, cancel, pick, onPicked, retry, choose };
|
|
59
|
+
}
|
package/dist/values.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { textIn } from '@lupinum/ginko/internal';
|
|
2
|
+
/** A list row id: 10 characters, as the server expects (SPEC 2.2 list). */
|
|
3
|
+
export declare function newRowId(): string;
|
|
4
|
+
/** The currency's sign in a language ("€", "CHF", "¥", "S$"). */
|
|
5
|
+
export declare function currencySign(currency: string, locale: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* What a person typed → the amount in minor units of `currency` (cents for EUR, whole yen for JPY), or null.
|
|
8
|
+
* In de "12,5", "12.50", "12", "12," and "1.234,50" all read; the sign or the code of the currency may be typed too.
|
|
9
|
+
* The language's decimal mark is always a decimal. The other mark is a decimal when it stands alone and at most as many
|
|
10
|
+
* digits follow as the currency has ("12.50"), else it groups thousands ("1.234").
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseMoney(input: string, currency: string, locale: string): number | null;
|
|
13
|
+
/** 1250 EUR in de → "12,50" (the input format; the currency is shown next to the field). */
|
|
14
|
+
export declare function formatAmount(amount: number, currency: string, locale: string): string;
|
package/dist/values.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { minorDigits } from "@lupinum/ginko/internal";
|
|
2
|
+
export { textIn } from "@lupinum/ginko/internal";
|
|
3
|
+
export function newRowId() {
|
|
4
|
+
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
5
|
+
const bytes = crypto.getRandomValues(new Uint8Array(10));
|
|
6
|
+
return Array.from(bytes, (b) => alphabet[b % alphabet.length]).join("");
|
|
7
|
+
}
|
|
8
|
+
function decimalMark(locale) {
|
|
9
|
+
return new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
|
|
10
|
+
}
|
|
11
|
+
export function currencySign(currency, locale) {
|
|
12
|
+
return new Intl.NumberFormat(locale, { style: "currency", currency }).formatToParts(0).find((p) => p.type === "currency")?.value ?? currency;
|
|
13
|
+
}
|
|
14
|
+
export function parseMoney(input, currency, locale) {
|
|
15
|
+
const digits = minorDigits(currency);
|
|
16
|
+
const text = input.trim().replace(/\s/g, "").replace(currencySign(currency, locale), "").replace(currency, "");
|
|
17
|
+
if (!/^[\d.,]+$/.test(text)) return null;
|
|
18
|
+
const marks = text.match(/[.,]/g) ?? [];
|
|
19
|
+
const kind = marks[marks.length - 1];
|
|
20
|
+
let mark;
|
|
21
|
+
if (kind !== void 0) {
|
|
22
|
+
const alone = marks.every((m) => m === kind);
|
|
23
|
+
const after = text.length - text.lastIndexOf(kind) - 1;
|
|
24
|
+
if (!alone) mark = kind;
|
|
25
|
+
else if (marks.length === 1 && (kind === decimalMark(locale) || digits > 0 && after <= digits)) mark = kind;
|
|
26
|
+
}
|
|
27
|
+
const at = mark === void 0 ? text.length : text.lastIndexOf(mark);
|
|
28
|
+
const whole = text.slice(0, at).replace(/[.,]/g, "");
|
|
29
|
+
const fraction = text.slice(at + 1);
|
|
30
|
+
if (!/^\d+$/.test(whole) || !/^\d*$/.test(fraction) || fraction.length > digits) return null;
|
|
31
|
+
return Math.round(Number(`${whole}.${fraction || "0"}`) * 10 ** digits);
|
|
32
|
+
}
|
|
33
|
+
export function formatAmount(amount, currency, locale) {
|
|
34
|
+
const digits = minorDigits(currency);
|
|
35
|
+
return (amount / 10 ** digits).toFixed(digits).replace(".", decimalMark(locale));
|
|
36
|
+
}
|
package/package.json
CHANGED
|
@@ -1,121 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lupinum/ginko-editor",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A portable Vue editor for Ginko content.",
|
|
3
|
+
"version": "0.18.0",
|
|
5
4
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
"**/*.css"
|
|
8
|
-
],
|
|
5
|
+
"description": "Editing logic for Ginko bricks: the headless Markdown editor, uploads, issues and value helpers.",
|
|
9
6
|
"license": "MIT",
|
|
10
7
|
"author": "Lupinum OG <info@lupinum.com> (https://lupinum.com)",
|
|
11
|
-
"homepage": "https://ginko-editor.lupinum.com",
|
|
12
8
|
"repository": {
|
|
13
9
|
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/lupinum-dev/ginko
|
|
10
|
+
"url": "git+https://github.com/lupinum-dev/ginko.git",
|
|
11
|
+
"directory": "packages/ginko-editor"
|
|
15
12
|
},
|
|
13
|
+
"homepage": "https://github.com/lupinum-dev/ginko/tree/main/packages/ginko-editor#readme",
|
|
16
14
|
"bugs": {
|
|
17
|
-
"url": "https://github.com/lupinum-dev/ginko
|
|
15
|
+
"url": "https://github.com/lupinum-dev/ginko/issues"
|
|
18
16
|
},
|
|
19
17
|
"engines": {
|
|
20
|
-
"node": "
|
|
18
|
+
"node": "^22.18.0 || ^24.0.0 || ^26.0.0"
|
|
21
19
|
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"CHANGELOG.md"
|
|
23
|
+
],
|
|
22
24
|
"exports": {
|
|
23
25
|
".": {
|
|
24
26
|
"types": "./dist/index.d.ts",
|
|
25
27
|
"import": "./dist/index.js"
|
|
26
|
-
}
|
|
27
|
-
"./authoring": {
|
|
28
|
-
"types": "./dist/authoring.d.ts",
|
|
29
|
-
"import": "./dist/authoring.js"
|
|
30
|
-
},
|
|
31
|
-
"./runtime": {
|
|
32
|
-
"types": "./dist/runtime.d.ts",
|
|
33
|
-
"import": "./dist/runtime.js"
|
|
34
|
-
},
|
|
35
|
-
"./collaboration": {
|
|
36
|
-
"types": "./dist/collaboration.d.ts",
|
|
37
|
-
"import": "./dist/collaboration.js"
|
|
38
|
-
},
|
|
39
|
-
"./style.css": "./dist/style.css",
|
|
40
|
-
"./package.json": "./package.json",
|
|
41
|
-
"./agent-docs": "./dist/agent/AGENTS.md"
|
|
28
|
+
}
|
|
42
29
|
},
|
|
43
|
-
"types": "./dist/index.d.ts",
|
|
44
|
-
"files": [
|
|
45
|
-
"dist",
|
|
46
|
-
"skills",
|
|
47
|
-
"README.md",
|
|
48
|
-
"CHANGELOG.md",
|
|
49
|
-
"LICENSE"
|
|
50
|
-
],
|
|
51
30
|
"publishConfig": {
|
|
52
31
|
"access": "public"
|
|
53
32
|
},
|
|
54
|
-
"devDependencies": {
|
|
55
|
-
"@changesets/changelog-github": "0.7.0",
|
|
56
|
-
"@changesets/cli": "2.31.0",
|
|
57
|
-
"@eslint/js": "10.0.1",
|
|
58
|
-
"@lupinum/ginko-content": "1.0.0-beta.11",
|
|
59
|
-
"@tiptap/core": "3.31.4",
|
|
60
|
-
"@tiptap/pm": "3.31.4",
|
|
61
|
-
"@tiptap/vue-3": "3.31.4",
|
|
62
|
-
"@types/node": "26.1.1",
|
|
63
|
-
"@vitejs/plugin-vue": "^6.0.6",
|
|
64
|
-
"@vue/test-utils": "^2.4.10",
|
|
65
|
-
"eslint": "^10.4.1",
|
|
66
|
-
"eslint-plugin-vue": "^10.9.0",
|
|
67
|
-
"jsdom": "^29.1.1",
|
|
68
|
-
"pkg-pr-new": "0.0.87",
|
|
69
|
-
"typescript": "~5.9.3",
|
|
70
|
-
"typescript-eslint": "^8.59.1",
|
|
71
|
-
"vite": "8.1.5",
|
|
72
|
-
"vitest": "^4.1.8",
|
|
73
|
-
"vue": "3.5.42",
|
|
74
|
-
"vue-tsc": "^3.3.7",
|
|
75
|
-
"yaml": "2.9.0"
|
|
76
|
-
},
|
|
77
33
|
"peerDependencies": {
|
|
78
|
-
"
|
|
79
|
-
"@tiptap/core": "^3.31.4",
|
|
80
|
-
"@tiptap/pm": "^3.31.4",
|
|
81
|
-
"@tiptap/vue-3": "^3.31.4",
|
|
82
|
-
"vue": "^3.5.40"
|
|
83
|
-
},
|
|
84
|
-
"peerDependenciesMeta": {
|
|
85
|
-
"@tiptap/vue-3": {
|
|
86
|
-
"optional": true
|
|
87
|
-
},
|
|
88
|
-
"vue": {
|
|
89
|
-
"optional": true
|
|
90
|
-
}
|
|
34
|
+
"vue": "^3.5.0"
|
|
91
35
|
},
|
|
92
36
|
"dependencies": {
|
|
93
|
-
"@
|
|
94
|
-
"@tiptap/
|
|
95
|
-
"@tiptap/extension-
|
|
96
|
-
"@tiptap/extension-
|
|
97
|
-
"@tiptap/extension-
|
|
98
|
-
"@tiptap/extension-
|
|
99
|
-
"@tiptap/extension-
|
|
100
|
-
"@tiptap/extension-table
|
|
101
|
-
"@tiptap/
|
|
102
|
-
"
|
|
103
|
-
|
|
37
|
+
"@lupinum/ginko": "^0.18.0",
|
|
38
|
+
"@tiptap/core": "3.34.0",
|
|
39
|
+
"@tiptap/extension-blockquote": "3.34.0",
|
|
40
|
+
"@tiptap/extension-code": "3.34.0",
|
|
41
|
+
"@tiptap/extension-document": "3.34.0",
|
|
42
|
+
"@tiptap/extension-image": "3.34.0",
|
|
43
|
+
"@tiptap/extension-list": "3.34.0",
|
|
44
|
+
"@tiptap/extension-table": "3.34.0",
|
|
45
|
+
"@tiptap/pm": "3.34.0",
|
|
46
|
+
"@tiptap/starter-kit": "3.34.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@lupinum/ginko-components": "0.18.0",
|
|
50
|
+
"@vue/test-utils": "2.6.0",
|
|
51
|
+
"happy-dom": "21.0.4",
|
|
52
|
+
"unbuild": "3.6.1",
|
|
53
|
+
"vue": "3.5.45",
|
|
54
|
+
"vue-tsc": "3.3.14"
|
|
104
55
|
},
|
|
105
56
|
"scripts": {
|
|
106
|
-
"build
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
"docs:agent": "node scripts/agent-docs.mjs",
|
|
111
|
-
"dev": "pnpm build:library && pnpm docs:dev",
|
|
112
|
-
"docs:dev": "pnpm --dir docs dev",
|
|
113
|
-
"lint": "eslint . && node scripts/lint-changesets.mjs",
|
|
114
|
-
"test": "vitest run && node --test scripts/*.test.mjs",
|
|
115
|
-
"test:packed": "node scripts/test-packed.mjs",
|
|
116
|
-
"test:compat": "pnpm build:library && pnpm typecheck && pnpm test",
|
|
117
|
-
"typecheck": "vue-tsc --noEmit",
|
|
118
|
-
"verify": "pnpm audit:all && pnpm lint && pnpm typecheck && pnpm test && pnpm build && pnpm test:packed",
|
|
119
|
-
"audit:all": "node scripts/audit.mjs"
|
|
120
|
-
}
|
|
57
|
+
"build": "unbuild"
|
|
58
|
+
},
|
|
59
|
+
"main": "./dist/index.js",
|
|
60
|
+
"types": "./dist/index.d.ts"
|
|
121
61
|
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { type GinkoEditorProps } from './editorProps.js';
|
|
2
|
-
import type { ConversionErrorPayload, ConversionRecoveredPayload } from './lib/conversionPipeline.js';
|
|
3
|
-
import type { EditorAssetRequest, EditorFile, EditorImage, EditorVideo, GinkoEditorHandle } from './types.js';
|
|
4
|
-
import { type EditorActions } from './ui/commands.js';
|
|
5
|
-
declare var __VLS_1: {
|
|
6
|
-
state: {
|
|
7
|
-
readonly status: import("./collaboration.js").CollaborationStatus;
|
|
8
|
-
readonly version: number;
|
|
9
|
-
readonly pendingSteps: number;
|
|
10
|
-
readonly message?: string | undefined;
|
|
11
|
-
readonly code?: import("./collaboration.js").CollaborationStateCode | undefined;
|
|
12
|
-
} | undefined;
|
|
13
|
-
session: import("./collaboration.js").EditorCollaborationSession;
|
|
14
|
-
}, __VLS_15: {
|
|
15
|
-
recipe: import("./authoring.js").AuthoringRecipe;
|
|
16
|
-
}, __VLS_17: {
|
|
17
|
-
actions: EditorActions;
|
|
18
|
-
};
|
|
19
|
-
type __VLS_Slots = {} & {
|
|
20
|
-
collaboration?: (props: typeof __VLS_1) => any;
|
|
21
|
-
} & {
|
|
22
|
-
'recipe-preview'?: (props: typeof __VLS_15) => any;
|
|
23
|
-
} & {
|
|
24
|
-
toolbar?: (props: typeof __VLS_17) => any;
|
|
25
|
-
};
|
|
26
|
-
declare const __VLS_base: import("vue").DefineComponent<GinkoEditorProps, GinkoEditorHandle, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
27
|
-
"conversion-error": (payload: ConversionErrorPayload) => any;
|
|
28
|
-
"conversion-recovered": (payload: ConversionRecoveredPayload) => any;
|
|
29
|
-
"request-file": (request: EditorAssetRequest<EditorFile>) => any;
|
|
30
|
-
"request-image": (request: EditorAssetRequest<EditorImage>) => any;
|
|
31
|
-
"request-image-metadata": (assetId: string) => any;
|
|
32
|
-
"pending-change": (pending: boolean) => any;
|
|
33
|
-
"request-video": (request: EditorAssetRequest<EditorVideo>) => any;
|
|
34
|
-
"update:modelValue": (value: string) => any;
|
|
35
|
-
}, string, import("vue").PublicProps, Readonly<GinkoEditorProps> & Readonly<{
|
|
36
|
-
"onConversion-error"?: ((payload: ConversionErrorPayload) => any) | undefined;
|
|
37
|
-
"onConversion-recovered"?: ((payload: ConversionRecoveredPayload) => any) | undefined;
|
|
38
|
-
"onRequest-file"?: ((request: EditorAssetRequest<EditorFile>) => any) | undefined;
|
|
39
|
-
"onRequest-image"?: ((request: EditorAssetRequest<EditorImage>) => any) | undefined;
|
|
40
|
-
"onRequest-image-metadata"?: ((assetId: string) => any) | undefined;
|
|
41
|
-
"onPending-change"?: ((pending: boolean) => any) | undefined;
|
|
42
|
-
"onRequest-video"?: ((request: EditorAssetRequest<EditorVideo>) => any) | undefined;
|
|
43
|
-
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
44
|
-
}>, {
|
|
45
|
-
imageUpload: import("./types.js").ImageUploadHandler;
|
|
46
|
-
header: boolean;
|
|
47
|
-
disabled: boolean;
|
|
48
|
-
videoOutput: "html" | "mdc";
|
|
49
|
-
profile: import("./index.js").EditorProfileName;
|
|
50
|
-
showMarkdownMarkers: boolean;
|
|
51
|
-
codeBlockTheme: "atom-dark" | "dark" | "default" | "github-dark" | "github-dim" | "github-light" | "visual-studio-dark";
|
|
52
|
-
placeholder: string;
|
|
53
|
-
fileOutput: "markdown" | "mdc";
|
|
54
|
-
imageOutput: "markdown" | "mdc";
|
|
55
|
-
shortcuts: import("./index.js").EditorShortcuts;
|
|
56
|
-
ariaLabel: string;
|
|
57
|
-
variant: "default" | "inline";
|
|
58
|
-
sourceToggle: boolean;
|
|
59
|
-
toolbarPlacement: "top" | "keyboard" | "auto" | false;
|
|
60
|
-
selectionToolbar: "auto" | "always" | false;
|
|
61
|
-
selectionToolbarItems: readonly import("./index.js").EditorToolbarGroup[];
|
|
62
|
-
toolbarItems: readonly import("./index.js").EditorToolbarGroup[];
|
|
63
|
-
messages: import("./index.js").EditorMessages;
|
|
64
|
-
overlayContainer: globalThis.HTMLElement;
|
|
65
|
-
imageDropTarget: globalThis.HTMLElement;
|
|
66
|
-
imagePicker: import("./types.js").ImagePicker;
|
|
67
|
-
imageMaxBytes: number;
|
|
68
|
-
assetProvider: import("./types.js").AssetProvider;
|
|
69
|
-
authoringKit: Readonly<import("./authoring.js").AuthoringKitSource<Record<string, {
|
|
70
|
-
kind: "block" | "inline";
|
|
71
|
-
props: Record<string, import("@lupinum/ginko-content/cms-contract").PortableComponentPropPolicyV2>;
|
|
72
|
-
slots: readonly string[];
|
|
73
|
-
allowedParents: readonly string[] | null;
|
|
74
|
-
allowedChildren: readonly string[] | null;
|
|
75
|
-
media: {
|
|
76
|
-
sourceProp: string;
|
|
77
|
-
altProp: string | null;
|
|
78
|
-
titleProp: string | null;
|
|
79
|
-
filenameProp: string | null;
|
|
80
|
-
} | null;
|
|
81
|
-
}>>>;
|
|
82
|
-
collaboration: import("./collaboration.js").EditorCollaborationSession;
|
|
83
|
-
enableFiles: boolean;
|
|
84
|
-
enableImages: boolean;
|
|
85
|
-
enableImageMetadata: boolean;
|
|
86
|
-
enableVideo: boolean;
|
|
87
|
-
syncDebounceMs: number;
|
|
88
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
89
|
-
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
90
|
-
declare const _default: typeof __VLS_export;
|
|
91
|
-
export default _default;
|
|
92
|
-
type __VLS_WithSlots<T, S> = T & {
|
|
93
|
-
new (): {
|
|
94
|
-
$slots: S;
|
|
95
|
-
};
|
|
96
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { EditorImage, EditorImagePickerItem } from './types.js';
|
|
2
|
-
import { type EditorMessages } from './ui/messages.js';
|
|
3
|
-
type __VLS_Props = {
|
|
4
|
-
messages?: EditorMessages;
|
|
5
|
-
open: boolean;
|
|
6
|
-
images: readonly EditorImagePickerItem[];
|
|
7
|
-
query?: string;
|
|
8
|
-
loading?: boolean;
|
|
9
|
-
error?: string;
|
|
10
|
-
hasMore?: boolean;
|
|
11
|
-
enableUpload?: boolean;
|
|
12
|
-
overlayContainer?: string | globalThis.HTMLElement;
|
|
13
|
-
};
|
|
14
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
15
|
-
select: (image: EditorImage) => any;
|
|
16
|
-
upload: () => any;
|
|
17
|
-
"update:open": (open: boolean) => any;
|
|
18
|
-
"update:query": (query: string) => any;
|
|
19
|
-
"load-more": () => any;
|
|
20
|
-
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
21
|
-
onSelect?: ((image: EditorImage) => any) | undefined;
|
|
22
|
-
onUpload?: (() => any) | undefined;
|
|
23
|
-
"onUpdate:open"?: ((open: boolean) => any) | undefined;
|
|
24
|
-
"onUpdate:query"?: ((query: string) => any) | undefined;
|
|
25
|
-
"onLoad-more"?: (() => any) | undefined;
|
|
26
|
-
}>, {
|
|
27
|
-
error: string;
|
|
28
|
-
loading: boolean;
|
|
29
|
-
query: string;
|
|
30
|
-
messages: EditorMessages;
|
|
31
|
-
overlayContainer: string | globalThis.HTMLElement;
|
|
32
|
-
hasMore: boolean;
|
|
33
|
-
enableUpload: boolean;
|
|
34
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
35
|
-
declare const _default: typeof __VLS_export;
|
|
36
|
-
export default _default;
|
package/dist/agent/AGENTS.md
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# @lupinum/ginko-editor 0.1.0 documentation
|
|
2
|
-
|
|
3
|
-
These pages match the installed version 0.1.0. Prefer them over the
|
|
4
|
-
website, which may describe a different version.
|
|
5
|
-
|
|
6
|
-
- [Getting started](./pages/docs/getting-started.md) — /docs/getting-started
|
|
7
|
-
- [Share an editing session](./pages/docs/getting-started/collaboration.md) — /docs/getting-started/collaboration
|
|
8
|
-
- [Component coverage](./pages/docs/getting-started/component-coverage.md) — /docs/getting-started/component-coverage
|
|
9
|
-
- [Customize the editor](./pages/docs/getting-started/customize.md) — /docs/getting-started/customize
|
|
10
|
-
- [Images](./pages/docs/getting-started/images.md) — /docs/getting-started/images
|
|
11
|
-
- [Edit text in place](./pages/docs/getting-started/in-place-editing.md) — /docs/getting-started/in-place-editing
|
|
12
|
-
- [Layout blocks](./pages/docs/getting-started/layout-blocks.md) — /docs/getting-started/layout-blocks
|
|
13
|
-
- [Validate content on the server](./pages/docs/getting-started/runtime.md) — /docs/getting-started/runtime
|