polotno-node 2.0.1 → 2.0.3

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
@@ -133,7 +133,9 @@ res.json({ url });
133
133
 
134
134
  ### `instance.run()`
135
135
 
136
- Run any Polotno store API directly inside web-page context
136
+ Run any Polotno store API directly inside web-page context.
137
+
138
+ **Warning: by default every `run` and every export function will create a new page with its own editor and context.** If you want to make and export after you use `instance.run()` you must do it inside the same `run` function.
137
139
 
138
140
  ```js
139
141
  // we can't directly use "json" variable inside the run function
@@ -152,6 +154,40 @@ const url = await instance.run(async (json) => {
152
154
  }, json);
153
155
  ```
154
156
 
157
+ ### `window.config` usage
158
+
159
+ `window.config` is a global object that has some functions from `polotno/config` module. You can use it to add custom fonts and customize some settings.
160
+ Not all options are supported yet. If you see anything missing, please create an issue. You can see all available options in `client.js` file.
161
+
162
+ You should be able to change config before you call `store.loadJSON` function and do you export.
163
+
164
+ ```js
165
+ const url = await instance.run(async (json) => {
166
+ // you can use global "config" object that has some functions from "polotno/config" module
167
+ window.config.unstable_setTextVerticalResizeEnabled(true);
168
+ // you can use global "store" object
169
+ store.loadJSON(json);
170
+ return store.toDataURL();
171
+ }, json);
172
+ ```
173
+
174
+ ## Your own client
175
+
176
+ By default `polotno-node` ships with the default Polotno Editor with its (hopefully) last version. If you use experimental API such as `unstable_registerShapeModel` and `unstable_registerShapeComponent`, the rendering may fail if you use unknow elements types.
177
+
178
+ In that case you can use your own client editor. You need to create a public html page with `store` as global variable and mount just `<Workspace />` component from `polotno/canvas` module. Take a look into `client.html` file and `client.js` file in this repo as a demo. In your own version of the Editor you can use experimental API to define custom components.
179
+
180
+ Pass `url` option to `createInstance` function with public url of your client editor.
181
+
182
+ ```js
183
+ const { createInstance } = require('polotno-node');
184
+
185
+ const instance = await createInstance({
186
+ key: 'KEY',
187
+ url: 'https://yourappdomain.com/client',
188
+ });
189
+ ```
190
+
155
191
  ## Browserless usage
156
192
 
157
193
  By default `polotno-node` will import browser bundle using `chrome-aws-lambda`. But you can use `browserless` instead, to keep your cloud function smaller.