@lit-pigeon/core 0.2.0 → 0.3.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/README.md +57 -0
- package/dist/index.d.ts +18 -0
- package/package.json +18 -2
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @lit-pigeon/core
|
|
2
|
+
|
|
3
|
+
The pure TypeScript engine behind the [Lit Pigeon](https://github.com/snxstudio/lit-pigeon)
|
|
4
|
+
email editor — document schema, immutable `EditorState` + `Transaction`
|
|
5
|
+
system, commands, undo/redo history, a ProseMirror-inspired plugin registry,
|
|
6
|
+
and the starter-template / brand-kit / asset / row-library storage
|
|
7
|
+
interfaces. Zero runtime UI dependencies, so it runs in the browser, Node, or
|
|
8
|
+
an edge worker.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @lit-pigeon/core
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import {
|
|
20
|
+
createDefaultDocument,
|
|
21
|
+
EditorState,
|
|
22
|
+
createHistoryPlugin,
|
|
23
|
+
validateDocument,
|
|
24
|
+
getStarterTemplates,
|
|
25
|
+
} from '@lit-pigeon/core';
|
|
26
|
+
|
|
27
|
+
// Start from a blank document, or a starter template.
|
|
28
|
+
const doc = createDefaultDocument();
|
|
29
|
+
const [welcome] = getStarterTemplates(); // welcome / newsletter / transactional / promo
|
|
30
|
+
// welcome.document is a PigeonDocument
|
|
31
|
+
|
|
32
|
+
// Drive edits through immutable transactions (with undo/redo history).
|
|
33
|
+
let state = EditorState.create({ doc, plugins: [createHistoryPlugin()] });
|
|
34
|
+
const tr = state.createTransaction();
|
|
35
|
+
// ...apply command steps to `tr`, then:
|
|
36
|
+
state = state.apply(tr);
|
|
37
|
+
|
|
38
|
+
// Validate before rendering / persisting.
|
|
39
|
+
const errors = validateDocument(state.doc);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`PigeonDocument` is a plain JSON tree (`body → rows → columns → blocks`), so it
|
|
43
|
+
serialises anywhere. Render it to email HTML with
|
|
44
|
+
[`@lit-pigeon/renderer-mjml`](../renderer-mjml) or
|
|
45
|
+
[`@lit-pigeon/ssr`](../ssr).
|
|
46
|
+
|
|
47
|
+
Also exported: the command set (`insertBlock`, `moveBlock`, `insertRow`,
|
|
48
|
+
`resizeColumns`, …), `createBlock`/`createRow` factories, `undo`/`redo`, the
|
|
49
|
+
block registry (`registerBlock`, `getBlockDefinition`), and in-memory storage
|
|
50
|
+
adapters (`InMemoryTemplateStorage`, `InMemoryBrandKitStorage`,
|
|
51
|
+
`InMemoryAssetStorage`, `InMemoryRowLibraryStorage`).
|
|
52
|
+
|
|
53
|
+
Part of [Lit Pigeon](https://github.com/snxstudio/lit-pigeon) — open-source drag-and-drop email editor.
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ export declare interface AssetManagerConfig {
|
|
|
60
60
|
presignedUpload?: {
|
|
61
61
|
getUploadParams: (file: File) => Promise<PresignedUploadParams>;
|
|
62
62
|
};
|
|
63
|
+
stock?: StockConfig;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
/**
|
|
@@ -766,6 +767,23 @@ export declare interface Step {
|
|
|
766
767
|
invert(doc: PigeonDocument): Step;
|
|
767
768
|
}
|
|
768
769
|
|
|
770
|
+
export declare interface StockConfig {
|
|
771
|
+
/** Unsplash Access Key (used client-side). Enables the Unsplash source. */
|
|
772
|
+
unsplash?: {
|
|
773
|
+
accessKey: string;
|
|
774
|
+
};
|
|
775
|
+
/** Pexels API key (used client-side). Enables the Pexels source. */
|
|
776
|
+
pexels?: {
|
|
777
|
+
apiKey: string;
|
|
778
|
+
};
|
|
779
|
+
/**
|
|
780
|
+
* utm_source label for Unsplash attribution links and the download-ping
|
|
781
|
+
* request. Unsplash guidelines require identifying your application.
|
|
782
|
+
* Defaults to "lit-pigeon" when unset; hosts should override.
|
|
783
|
+
*/
|
|
784
|
+
appName?: string;
|
|
785
|
+
}
|
|
786
|
+
|
|
769
787
|
/**
|
|
770
788
|
* Built-in system link types. `unsubscribe`/`view-in-browser` emit fixed
|
|
771
789
|
* `{{…}}` placeholder hrefs (conventional ESP tokens, resolved by the host at
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lit-pigeon/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Pure TypeScript engine for the Pigeon email editor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
|
-
"dist"
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
18
20
|
],
|
|
19
21
|
"dependencies": {
|
|
20
22
|
"immer": "^10.1.0",
|
|
@@ -37,6 +39,20 @@
|
|
|
37
39
|
"directory": "packages/core"
|
|
38
40
|
},
|
|
39
41
|
"license": "MIT",
|
|
42
|
+
"homepage": "https://github.com/snxstudio/lit-pigeon/tree/main/packages/core#readme",
|
|
43
|
+
"bugs": "https://github.com/snxstudio/lit-pigeon/issues",
|
|
44
|
+
"author": "Lit Pigeon Contributors",
|
|
45
|
+
"keywords": [
|
|
46
|
+
"email",
|
|
47
|
+
"email-template",
|
|
48
|
+
"email-editor",
|
|
49
|
+
"mjml",
|
|
50
|
+
"html-email",
|
|
51
|
+
"lit",
|
|
52
|
+
"web-components",
|
|
53
|
+
"drag-and-drop",
|
|
54
|
+
"no-code"
|
|
55
|
+
],
|
|
40
56
|
"scripts": {
|
|
41
57
|
"build": "vite build",
|
|
42
58
|
"dev": "vite build --watch",
|