@yamlresume/playground 0.11.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023–Present PPResume (https://ppresume.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to
7
+ deal in the Software without restriction, including without limitation the
8
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9
+ sell copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
+ IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,172 @@
1
+ # @yamlresume/playground
2
+
3
+ A powerful, feature-rich React component for editing and previewing YAML
4
+ resumes. This package powers the [YAMLResume](https://yamlresume.dev) playground
5
+ and can be integrated into other applications.
6
+
7
+ The official playground is at https://yamlresume.dev/playground.
8
+
9
+ ## Features
10
+
11
+ - 📝 **Live YAML Editor**: Monaco-based editor with syntax highlighting for AML.
12
+ - 👁️ **Real-time Preview**: Instant preview of your resume in HTML, Markdown, or
13
+ LaTeX.
14
+ - 📱 **Responsive Design**: Split-pane layout on desktop, tabbed interface on
15
+ mobile.
16
+ - 🌗 **Dark Mode Support**: Built-in dark mode compatibility.
17
+ - ⚠️ **Error Handling**: Graceful error boundaries and validation feedback.
18
+ - 📥 **Export**: Download your resume in multiple formats.
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ npm install @yamlresume/playground @yamlresume/core
24
+ # or
25
+ pnpm add @yamlresume/playground @yamlresume/core
26
+ # or
27
+ yarn add @yamlresume/playground @yamlresume/core
28
+ ```
29
+
30
+ ### Peer Dependencies
31
+
32
+ Ensure you have the following peer dependencies installed:
33
+
34
+ ```bash
35
+ npm install react react-dom tailwindcss
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ### Basic Usage
41
+
42
+ The `Playground` component is the main entry point. It manages the state between
43
+ the editor and the previewer.
44
+
45
+ ```tsx
46
+ import { Playground } from "@yamlresume/playground";
47
+
48
+ function App() {
49
+ return (
50
+ <div style={{ height: "100vh" }}>
51
+ <Playground />
52
+ </div>
53
+ );
54
+ }
55
+ ```
56
+
57
+ ### Controlled Component
58
+
59
+ You can control the YAML content from a parent component:
60
+
61
+ ```tsx
62
+ import { useState } from "react";
63
+ import { Playground } from "@yamlresume/playground";
64
+
65
+ function App() {
66
+ const [yaml, setYaml] = useState("layouts: []")
67
+
68
+ return (
69
+ <div style={{ height: "100vh" }}>
70
+ <Playground yaml={yaml} onChange={(newYaml) => setYaml(newYaml)} />
71
+ </div>
72
+ );
73
+ }
74
+ ```
75
+
76
+ ## API Reference
77
+
78
+ ### Components
79
+
80
+ #### `<Playground />`
81
+
82
+ The main split-view component.
83
+
84
+ | Prop | Type | Default | Description |
85
+ | ---------- | ------------------------- | ----------- | -------------------------------------------------------------- |
86
+ | `yaml` | `string` | `undefined` | The YAML content to display/edit. Defaults to a sample resume. |
87
+ | `onChange` | `(value: string) => void` | `undefined` | Callback fired when editor content changes. |
88
+ | `filename` | `string` | `undefined` | The filename to display in the editor. |
89
+
90
+ #### `<ResumeEditor />`
91
+
92
+ A standalone Monaco editor wrapper configured for YAML resumes.
93
+
94
+ | Prop | Type | Default | Description |
95
+ | ---------- | ------------------------- | ----------- | ---------------- |
96
+ | `value` | `string` | `''` | Editor content. |
97
+ | `onChange` | `(value: string) => void` | `undefined` | Change callback. |
98
+
99
+ #### `<ResumeViewer />`
100
+
101
+ Renders the resume based on the parsed object and selected layout.
102
+
103
+ | Prop | Type | Description |
104
+ | ------------- | ---------------- | ----------------------------------------- |
105
+ | `resume` | `Resume \| null` | The parsed resume object. |
106
+ | `layoutIndex` | `number` | Index of the layout configuration to use. |
107
+
108
+ ### Hooks
109
+
110
+ #### `useResumeState`
111
+
112
+ Manages the parsing and validation state of the resume.
113
+
114
+ ```tsx
115
+ const {
116
+ yaml,
117
+ handleYamlChange,
118
+ activeLayoutIndex,
119
+ setActiveLayoutIndex,
120
+ resume,
121
+ } = useResumeState({ yaml: initialYaml });
122
+ ```
123
+
124
+ #### `useResumeRenderer`
125
+
126
+ Handles the actual rendering logic based on the engine (HTML, Markdown, LaTeX).
127
+
128
+ ```tsx
129
+ const { renderedContent, engine, error } = useResumeRenderer({
130
+ resume,
131
+ layoutIndex,
132
+ });
133
+ ```
134
+
135
+ ## Types
136
+
137
+ The package exports several useful TypeScript types:
138
+
139
+ - `PlaygroundProps`
140
+ - `ResumeViewerProps`
141
+
142
+ ## Utilities
143
+
144
+ The package exports several utility functions:
145
+
146
+ ### `downloadResume(resume: Resume | null, layoutIndex: number)`
147
+
148
+ Downloads the resume for the specified layout index (HTML, Markdown, or LaTeX).
149
+
150
+ ### `copyResumeToClipboard(resume: Resume | null, layoutIndex: number): Promise<void>`
151
+
152
+ Copies the rendered resume content to the clipboard.
153
+
154
+ ### `printResume(resume: Resume | null, layoutIndex: number)`
155
+
156
+ Opens the print dialog for the resume (HTML layouts only).
157
+
158
+ ### `openResumeInNewTab(resume: Resume | null, layoutIndex: number)`
159
+
160
+ Opens the resume in a new browser tab (HTML layouts only).
161
+
162
+ ### `getBasename(filepath: string, removeExtension?: boolean): string`
163
+
164
+ Gets the basename from a filepath.
165
+
166
+ ### `getExtension(engine: LayoutEngine): string`
167
+
168
+ Gets the file extension for a given rendering engine.
169
+
170
+ ## License
171
+
172
+ MIT © [PPResume](https://ppresume.com)