@10x-media/undo-redo 0.1.0-beta.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 +15 -0
- package/LICENSE +21 -0
- package/README.md +54 -0
- package/dist/client/HistoryDebugOverlay.d.ts +30 -0
- package/dist/client/HistoryDebugOverlay.js +201 -0
- package/dist/client/HistoryDebugOverlay.js.map +1 -0
- package/dist/client/UndoRedoControls.d.ts +18 -0
- package/dist/client/UndoRedoControls.js +155 -0
- package/dist/client/UndoRedoControls.js.map +1 -0
- package/dist/client/formatShortcut.js +113 -0
- package/dist/client/formatShortcut.js.map +1 -0
- package/dist/client/historyDebugOverlay.css +206 -0
- package/dist/client/undoRedoControls.css +58 -0
- package/dist/client/useUndoRedo.d.ts +70 -0
- package/dist/client/useUndoRedo.js +259 -0
- package/dist/client/useUndoRedo.js.map +1 -0
- package/dist/exports/client.d.ts +4 -0
- package/dist/exports/client.js +5 -0
- package/dist/exports/i18n.d.ts +3 -0
- package/dist/exports/i18n.js +3 -0
- package/dist/exports/types.d.ts +5 -0
- package/dist/exports/types.js +1 -0
- package/dist/history/historyCore.d.ts +85 -0
- package/dist/history/historyCore.js +318 -0
- package/dist/history/historyCore.js.map +1 -0
- package/dist/history/pathPatterns.d.ts +6 -0
- package/dist/history/pathPatterns.js +45 -0
- package/dist/history/pathPatterns.js.map +1 -0
- package/dist/history/volatileValues.js +51 -0
- package/dist/history/volatileValues.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin/options.d.ts +109 -0
- package/dist/plugin/options.js +52 -0
- package/dist/plugin/options.js.map +1 -0
- package/dist/plugin/registerTranslations.js +19 -0
- package/dist/plugin/registerTranslations.js.map +1 -0
- package/dist/plugin/withUndoRedo.d.ts +34 -0
- package/dist/plugin/withUndoRedo.js +72 -0
- package/dist/plugin/withUndoRedo.js.map +1 -0
- package/dist/schema/fieldConfig.d.ts +36 -0
- package/dist/schema/fieldConfig.js +28 -0
- package/dist/schema/fieldConfig.js.map +1 -0
- package/dist/schema/fieldSchema.d.ts +63 -0
- package/dist/schema/fieldSchema.js +122 -0
- package/dist/schema/fieldSchema.js.map +1 -0
- package/dist/translations/de.js +19 -0
- package/dist/translations/de.js.map +1 -0
- package/dist/translations/en.js +23 -0
- package/dist/translations/en.js.map +1 -0
- package/dist/translations/index.d.ts +15 -0
- package/dist/translations/index.js +30 -0
- package/dist/translations/index.js.map +1 -0
- package/dist/translations/keys.d.ts +22 -0
- package/dist/translations/keys.js +22 -0
- package/dist/translations/keys.js.map +1 -0
- package/dist/translations/useTranslation.js +12 -0
- package/dist/translations/useTranslation.js.map +1 -0
- package/package.json +109 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { keys } from "./keys.js";
|
|
2
|
+
//#region src/translations/en.ts
|
|
3
|
+
/**
|
|
4
|
+
* English values, keyed by the typed constants in `keys.ts` so the two stay in
|
|
5
|
+
* lockstep. The `Record<TranslationKey, string>` annotation makes a missing or
|
|
6
|
+
* unknown key a type error. `translations/index.ts` nests these for Payload.
|
|
7
|
+
*/
|
|
8
|
+
const en = {
|
|
9
|
+
[keys.undo]: "Undo",
|
|
10
|
+
[keys.redo]: "Redo",
|
|
11
|
+
[keys.debug]: "Undo history",
|
|
12
|
+
[keys.debugTooltip]: "Inspect undo history",
|
|
13
|
+
[keys.debugTitle]: "Undo history",
|
|
14
|
+
[keys.debugEmpty]: "No history captured yet.",
|
|
15
|
+
[keys.debugClose]: "Close",
|
|
16
|
+
[keys.debugPending]: "Pending (not captured)",
|
|
17
|
+
[keys.debugOriginal]: "Original state",
|
|
18
|
+
[keys.debugCopy]: "Copy JSON"
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { en };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=en.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"en.js","names":[],"sources":["../../src/translations/en.ts"],"sourcesContent":["import { keys, type TranslationKey } from './keys'\n\n/**\n * English values, keyed by the typed constants in `keys.ts` so the two stay in\n * lockstep. The `Record<TranslationKey, string>` annotation makes a missing or\n * unknown key a type error. `translations/index.ts` nests these for Payload.\n */\nexport const en: Record<TranslationKey, string> = {\n\t[keys.undo]: 'Undo',\n\t[keys.redo]: 'Redo',\n\t[keys.debug]: 'Undo history',\n\t[keys.debugTooltip]: 'Inspect undo history',\n\t[keys.debugTitle]: 'Undo history',\n\t[keys.debugEmpty]: 'No history captured yet.',\n\t[keys.debugClose]: 'Close',\n\t[keys.debugPending]: 'Pending (not captured)',\n\t[keys.debugOriginal]: 'Original state',\n\t[keys.debugCopy]: 'Copy JSON',\n}\n"],"mappings":";;;;;;;AAOA,MAAa,KAAqC;EAChD,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,QAAQ;EACb,KAAK,eAAe;EACpB,KAAK,aAAa;EAClB,KAAK,aAAa;EAClB,KAAK,aAAa;EAClB,KAAK,eAAe;EACpB,KAAK,gBAAgB;EACrB,KAAK,YAAY;AACnB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TranslationKey, keys } from "./keys.js";
|
|
2
|
+
|
|
3
|
+
//#region src/translations/index.d.ts
|
|
4
|
+
/** Per-locale string overrides keyed by this plugin's typed translation keys. */
|
|
5
|
+
type TranslationsOption = {
|
|
6
|
+
[locale: string]: Partial<Record<TranslationKey, string>>;
|
|
7
|
+
};
|
|
8
|
+
/** Per-locale messages merged into `config.i18n.translations`. */
|
|
9
|
+
declare const translations: {
|
|
10
|
+
en: Record<string, Record<string, string>>;
|
|
11
|
+
de: Record<string, Record<string, string>>;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { TranslationsOption, translations };
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import "./keys.js";
|
|
2
|
+
import { de } from "./de.js";
|
|
3
|
+
import { en } from "./en.js";
|
|
4
|
+
//#region src/translations/index.ts
|
|
5
|
+
/**
|
|
6
|
+
* Flat `undoRedo:foo` entries to the nested `{ undoRedo: { foo } }`
|
|
7
|
+
* shape Payload resolves `t('undoRedo:foo')` against (it splits on `:`).
|
|
8
|
+
* Undefined values are skipped so `Partial` override maps pass through.
|
|
9
|
+
*/
|
|
10
|
+
const toNested = (flat) => {
|
|
11
|
+
const out = {};
|
|
12
|
+
for (const [fullKey, value] of Object.entries(flat)) {
|
|
13
|
+
if (typeof value !== "string") continue;
|
|
14
|
+
const separator = fullKey.indexOf(":");
|
|
15
|
+
const namespace = fullKey.slice(0, separator);
|
|
16
|
+
const bucket = out[namespace] ?? {};
|
|
17
|
+
bucket[fullKey.slice(separator + 1)] = value;
|
|
18
|
+
out[namespace] = bucket;
|
|
19
|
+
}
|
|
20
|
+
return out;
|
|
21
|
+
};
|
|
22
|
+
/** Per-locale messages merged into `config.i18n.translations`. */
|
|
23
|
+
const translations = {
|
|
24
|
+
en: toNested(en),
|
|
25
|
+
de: toNested(de)
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { toNested, translations };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/translations/index.ts"],"sourcesContent":["import { de } from './de'\nimport { en } from './en'\nimport type { TranslationKey } from './keys'\n\nexport type { TranslationKey } from './keys'\nexport { keys } from './keys'\n\n/** Per-locale string overrides keyed by this plugin's typed translation keys. */\nexport type TranslationsOption = {\n\t[locale: string]: Partial<Record<TranslationKey, string>>\n}\n\n/**\n * Flat `undoRedo:foo` entries to the nested `{ undoRedo: { foo } }`\n * shape Payload resolves `t('undoRedo:foo')` against (it splits on `:`).\n * Undefined values are skipped so `Partial` override maps pass through.\n */\nexport const toNested = (flat: {\n\t[key: string]: string | undefined\n}): Record<string, Record<string, string>> => {\n\tconst out: Record<string, Record<string, string>> = {}\n\tfor (const [fullKey, value] of Object.entries(flat)) {\n\t\tif (typeof value !== 'string') {\n\t\t\tcontinue\n\t\t}\n\t\tconst separator = fullKey.indexOf(':')\n\t\tconst namespace = fullKey.slice(0, separator)\n\t\tconst bucket = out[namespace] ?? {}\n\t\tbucket[fullKey.slice(separator + 1)] = value\n\t\tout[namespace] = bucket\n\t}\n\treturn out\n}\n\n/** Per-locale messages merged into `config.i18n.translations`. */\nexport const translations = {\n\ten: toNested(en),\n\tde: toNested(de),\n}\n"],"mappings":";;;;;;;;;AAiBA,MAAa,YAAY,SAEqB;CAC7C,MAAM,MAA8C,CAAC;CACrD,KAAK,MAAM,CAAC,SAAS,UAAU,OAAO,QAAQ,IAAI,GAAG;EACpD,IAAI,OAAO,UAAU,UACpB;EAED,MAAM,YAAY,QAAQ,QAAQ,GAAG;EACrC,MAAM,YAAY,QAAQ,MAAM,GAAG,SAAS;EAC5C,MAAM,SAAS,IAAI,cAAc,CAAC;EAClC,OAAO,QAAQ,MAAM,YAAY,CAAC,KAAK;EACvC,IAAI,aAAa;CAClB;CACA,OAAO;AACR;;AAGA,MAAa,eAAe;CAC3B,IAAI,SAAS,EAAE;CACf,IAAI,SAAS,EAAE;AAChB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/translations/keys.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Typed translation keys. Lookups must go through these constants, not string
|
|
4
|
+
* literals (enforced by requireI18nKeysTyped.grit). Every key here must have a
|
|
5
|
+
* value in every locale (`en.ts`, `de.ts`), or it is a type error.
|
|
6
|
+
*/
|
|
7
|
+
declare const keys: {
|
|
8
|
+
readonly undo: "undoRedo:undo";
|
|
9
|
+
readonly redo: "undoRedo:redo";
|
|
10
|
+
readonly debug: "undoRedo:debug";
|
|
11
|
+
readonly debugTooltip: "undoRedo:debugTooltip";
|
|
12
|
+
readonly debugTitle: "undoRedo:debugTitle";
|
|
13
|
+
readonly debugEmpty: "undoRedo:debugEmpty";
|
|
14
|
+
readonly debugClose: "undoRedo:debugClose";
|
|
15
|
+
readonly debugPending: "undoRedo:debugPending";
|
|
16
|
+
readonly debugOriginal: "undoRedo:debugOriginal";
|
|
17
|
+
readonly debugCopy: "undoRedo:debugCopy";
|
|
18
|
+
};
|
|
19
|
+
type TranslationKey = (typeof keys)[keyof typeof keys];
|
|
20
|
+
//#endregion
|
|
21
|
+
export { TranslationKey, keys };
|
|
22
|
+
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/translations/keys.ts
|
|
2
|
+
/**
|
|
3
|
+
* Typed translation keys. Lookups must go through these constants, not string
|
|
4
|
+
* literals (enforced by requireI18nKeysTyped.grit). Every key here must have a
|
|
5
|
+
* value in every locale (`en.ts`, `de.ts`), or it is a type error.
|
|
6
|
+
*/
|
|
7
|
+
const keys = {
|
|
8
|
+
undo: "undoRedo:undo",
|
|
9
|
+
redo: "undoRedo:redo",
|
|
10
|
+
debug: "undoRedo:debug",
|
|
11
|
+
debugTooltip: "undoRedo:debugTooltip",
|
|
12
|
+
debugTitle: "undoRedo:debugTitle",
|
|
13
|
+
debugEmpty: "undoRedo:debugEmpty",
|
|
14
|
+
debugClose: "undoRedo:debugClose",
|
|
15
|
+
debugPending: "undoRedo:debugPending",
|
|
16
|
+
debugOriginal: "undoRedo:debugOriginal",
|
|
17
|
+
debugCopy: "undoRedo:debugCopy"
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { keys };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","names":[],"sources":["../../src/translations/keys.ts"],"sourcesContent":["/**\n * Typed translation keys. Lookups must go through these constants, not string\n * literals (enforced by requireI18nKeysTyped.grit). Every key here must have a\n * value in every locale (`en.ts`, `de.ts`), or it is a type error.\n */\nexport const keys = {\n\tundo: 'undoRedo:undo',\n\tredo: 'undoRedo:redo',\n\tdebug: 'undoRedo:debug',\n\tdebugTooltip: 'undoRedo:debugTooltip',\n\tdebugTitle: 'undoRedo:debugTitle',\n\tdebugEmpty: 'undoRedo:debugEmpty',\n\tdebugClose: 'undoRedo:debugClose',\n\tdebugPending: 'undoRedo:debugPending',\n\tdebugOriginal: 'undoRedo:debugOriginal',\n\tdebugCopy: 'undoRedo:debugCopy',\n} as const\n\nexport type TranslationKey = (typeof keys)[keyof typeof keys]\n"],"mappings":";;;;;;AAKA,MAAa,OAAO;CACnB,MAAM;CACN,MAAM;CACN,OAAO;CACP,cAAc;CACd,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,cAAc;CACd,eAAe;CACf,WAAW;AACZ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useTranslation } from "@payloadcms/ui";
|
|
3
|
+
//#region src/translations/useTranslation.ts
|
|
4
|
+
/**
|
|
5
|
+
* `useTranslation` bound to this plugin's keys, so `t(keys.X)` typechecks without
|
|
6
|
+
* a per-call `@ts-expect-error`. Returns Payload's `{ t, i18n }` unchanged.
|
|
7
|
+
*/
|
|
8
|
+
const useTranslation$1 = () => useTranslation();
|
|
9
|
+
//#endregion
|
|
10
|
+
export { useTranslation$1 as useTranslation };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=useTranslation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTranslation.js","names":["useTranslation","usePayloadTranslation"],"sources":["../../src/translations/useTranslation.ts"],"sourcesContent":["'use client'\n\nimport { useTranslation as usePayloadTranslation } from '@payloadcms/ui'\n\nimport type { TranslationKey } from './keys'\n\n/**\n * `useTranslation` bound to this plugin's keys, so `t(keys.X)` typechecks without\n * a per-call `@ts-expect-error`. Returns Payload's `{ t, i18n }` unchanged.\n */\nexport const useTranslation = () => usePayloadTranslation<Record<string, never>, TranslationKey>()\n"],"mappings":";;;;;;;AAUA,MAAaA,yBAAuBC,eAA6D"}
|
package/package.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@10x-media/undo-redo",
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
|
+
"description": "Introduces undo/redo functionality to Payload forms",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/10x-media/payload-plugins.git",
|
|
9
|
+
"directory": "packages/undo-redo"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/10x-media/payload-plugins/tree/main/packages/undo-redo",
|
|
12
|
+
"bugs": "https://github.com/10x-media/payload-plugins/issues",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"payload",
|
|
15
|
+
"payloadcms",
|
|
16
|
+
"plugin"
|
|
17
|
+
],
|
|
18
|
+
"author": "10x-media",
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=22.18.0"
|
|
21
|
+
},
|
|
22
|
+
"type": "module",
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./types": {
|
|
31
|
+
"types": "./dist/exports/types.d.ts",
|
|
32
|
+
"import": "./dist/exports/types.js",
|
|
33
|
+
"default": "./dist/exports/types.js"
|
|
34
|
+
},
|
|
35
|
+
"./client": {
|
|
36
|
+
"types": "./dist/exports/client.d.ts",
|
|
37
|
+
"import": "./dist/exports/client.js",
|
|
38
|
+
"default": "./dist/exports/client.js"
|
|
39
|
+
},
|
|
40
|
+
"./i18n": {
|
|
41
|
+
"types": "./dist/exports/i18n.d.ts",
|
|
42
|
+
"import": "./dist/exports/i18n.js",
|
|
43
|
+
"default": "./dist/exports/i18n.js"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"dist",
|
|
48
|
+
"README.md",
|
|
49
|
+
"CHANGELOG.md",
|
|
50
|
+
"LICENSE"
|
|
51
|
+
],
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"react-hotkeys-hook": "5.3.3"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@payloadcms/ui": "^3.83.0",
|
|
57
|
+
"payload": "^3.83.0",
|
|
58
|
+
"react": "^19.0.0",
|
|
59
|
+
"react-dom": "^19.0.0"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@payloadcms/db-mongodb": "3.85.0",
|
|
63
|
+
"@payloadcms/db-postgres": "3.85.0",
|
|
64
|
+
"@payloadcms/ui": "3.85.0",
|
|
65
|
+
"@playwright/test": "1.60.0",
|
|
66
|
+
"@types/node": "22.19.19",
|
|
67
|
+
"@types/react": "19.2.15",
|
|
68
|
+
"@types/react-dom": "19.2.3",
|
|
69
|
+
"payload": "3.85.0",
|
|
70
|
+
"playwright": "1.60.0",
|
|
71
|
+
"react": "19.2.6",
|
|
72
|
+
"react-dom": "19.2.6",
|
|
73
|
+
"tsdown": "0.22.1",
|
|
74
|
+
"typescript": "5.9.3",
|
|
75
|
+
"vitest": "4.1.7",
|
|
76
|
+
"@10x-media/payload-test-harness": "0.0.0",
|
|
77
|
+
"@10x-media/tsconfig": "0.0.0",
|
|
78
|
+
"@10x-media/vitest-config": "0.0.0",
|
|
79
|
+
"@10x-media/tsdown-config": "0.0.0"
|
|
80
|
+
},
|
|
81
|
+
"publishConfig": {
|
|
82
|
+
"access": "public"
|
|
83
|
+
},
|
|
84
|
+
"scripts": {
|
|
85
|
+
"build": "tsdown",
|
|
86
|
+
"lint": "biome check src tests dev",
|
|
87
|
+
"lint:fix": "biome check --write src tests dev",
|
|
88
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
89
|
+
"test": "vitest run",
|
|
90
|
+
"test:unit": "vitest run src",
|
|
91
|
+
"test:int": "vitest run tests/int",
|
|
92
|
+
"test:matrix": "DB_MATRIX=mongo vitest run tests/int/matrix.int.spec.ts && DB_MATRIX=postgres vitest run tests/int/matrix.int.spec.ts",
|
|
93
|
+
"test:container": "TEST_DB=container DB_MATRIX=mongo vitest run tests/int/matrix.int.spec.ts && TEST_DB=container DB_MATRIX=postgres vitest run tests/int/matrix.int.spec.ts",
|
|
94
|
+
"test:e2e": "bash scripts/e2e.sh",
|
|
95
|
+
"dev": "pnpm --filter @10x-media/undo-redo-dev dev",
|
|
96
|
+
"start": "pnpm --filter @10x-media/undo-redo-dev start",
|
|
97
|
+
"generate": "pnpm --filter @10x-media/undo-redo-dev generate",
|
|
98
|
+
"generate:types": "pnpm --filter @10x-media/undo-redo-dev generate:types",
|
|
99
|
+
"generate:importmap": "pnpm --filter @10x-media/undo-redo-dev generate:importmap",
|
|
100
|
+
"migrate": "pnpm --filter @10x-media/undo-redo-dev migrate",
|
|
101
|
+
"migrate:create": "pnpm --filter @10x-media/undo-redo-dev migrate:create",
|
|
102
|
+
"migrate:down": "pnpm --filter @10x-media/undo-redo-dev migrate:down",
|
|
103
|
+
"migrate:refresh": "pnpm --filter @10x-media/undo-redo-dev migrate:refresh",
|
|
104
|
+
"migrate:reset": "pnpm --filter @10x-media/undo-redo-dev migrate:reset",
|
|
105
|
+
"migrate:status": "pnpm --filter @10x-media/undo-redo-dev migrate:status",
|
|
106
|
+
"migrate:fresh": "pnpm --filter @10x-media/undo-redo-dev migrate:fresh",
|
|
107
|
+
"clean": "rm -rf dist *.tsbuildinfo dev/.next"
|
|
108
|
+
}
|
|
109
|
+
}
|