@luutuankiet/clipboard2markdown 0.4.0 → 0.4.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 CHANGED
@@ -58,7 +58,7 @@ cat diagram.json | c2m excalidraw - # same, from stdin
58
58
 
59
59
  The Mermaid is deliberately lossy: positions, colours, fonts and arrow curves are dropped; boxes, labels, connections, line style and grouping are kept. The canvas stays the master copy.
60
60
 
61
- **Diagrams as PNG** (`c2m excalidraw --png`, Node 20+, any OS): draws one or more diagrams locally, for pasting into a Google Doc. No browser is needed and the drawing makes no network request; the share link is uploaded as usual (skip it with `--no-upload`). Input is the JSON array above or a whole scene (`{"elements": [...]}`, such as a `.excalidraw` file).
61
+ **Diagrams as PNG** (`c2m excalidraw --png`, Node 20+, any OS): draws one or more diagrams locally, for pasting into a Google Doc. No browser is needed and the drawing makes no network request; the share link is uploaded as usual (skip it with `--no-upload`). Input is the JSON array above or a whole scene (`{"elements": [...]}`, such as a `.excalidraw` file); a scene's elements may use the same shorthand (`label`, `start`/`end`, arrows without `points`), and a scene without it is drawn as is.
62
62
 
63
63
  ```bash
64
64
  c2m excalidraw --png a.json b.json # PNGs in ~/.cache/c2m/renders/
package/bin/excalidraw.js CHANGED
@@ -111,7 +111,9 @@ PNG (for pasting into a Google Doc)
111
111
  Draws each diagram locally (no browser; the drawing itself makes no network
112
112
  request) and uploads it for its share link as above. Each input is either
113
113
  the element array described here or a whole scene ({"elements": [...]},
114
- e.g. a .excalidraw file). For each input <name>.json it writes:
114
+ e.g. a .excalidraw file). A scene's elements may use the same shorthand
115
+ (label, start/end, arrows without points); a scene without it is drawn and
116
+ uploaded as is. For each input <name>.json it writes:
115
117
  <name>.png for the document: scale 3, lowered until the image
116
118
  has at most 25,000,000 pixels (Google Docs' limit)
117
119
  <name>.review.png for a quick look: at most 1000 px on the long side
@@ -156,11 +158,24 @@ async function upload(scene, fetchImpl) {
156
158
  }
157
159
  }
158
160
 
159
- // A whole scene ({elements: [...]}, as in a .excalidraw file) is drawn as is;
160
- // anything else goes through the skeleton builder.
161
+ // The help's shorthand: `label`, `start`/`end`, or an arrow/line left without
162
+ // points for the builder to route. A real Excalidraw element has none of these.
163
+ function usesShorthand(el) {
164
+ if (!el || typeof el !== 'object') return false;
165
+ if ('label' in el || 'start' in el || 'end' in el) return true;
166
+ return (el.type === 'arrow' || el.type === 'line') && !Array.isArray(el.points);
167
+ }
168
+
169
+ // A whole scene ({elements: [...]}, as in a .excalidraw file) is drawn as is,
170
+ // unless it uses the shorthand: then it goes through the skeleton builder like
171
+ // an element array, keeping the scene's own appState and files.
161
172
  function toScene(input) {
162
173
  if (input && !Array.isArray(input) && Array.isArray(input.elements)) {
163
- return { scene: input, preview: null, warnings: [] };
174
+ if (!input.elements.some(usesShorthand)) return { scene: input, preview: null, warnings: [] };
175
+ var built = buildSkeleton(input.elements);
176
+ if (input.appState) built.scene.appState = input.appState;
177
+ if (input.files) built.scene.files = input.files;
178
+ return built;
164
179
  }
165
180
  return buildSkeleton(input);
166
181
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luutuankiet/clipboard2markdown",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Convert rich clipboard HTML from Jira, Confluence, Slack and Google apps into clean Markdown, and back.",
5
5
  "type": "module",
6
6
  "bin": {