@flourish/sdk 3.19.0 → 3.20.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/README.md CHANGED
@@ -168,6 +168,22 @@ document.body.style.fontFamily = state.body_font.url;
168
168
  #### `hidden`
169
169
  This type is for documenting state properties which should not be editable from the settings panel in the visualisation editor. Any property with a `hidden` type will not be editable within the visualisation editor interface.
170
170
 
171
+ #### Text editor settings
172
+ For `html` type settings, text editing functionality will automatically be added, such as making text bold or italic, adding a link, or referring to column headers from the data. You can add the `editor` property to override which editor functionalities to show. It accepts an object like this:
173
+
174
+ ```yaml
175
+ - property: popup_text
176
+ name: Popup text
177
+ type: html
178
+ editor: # An object specifying the different text editor functions (omitting `editor` will only load style, url and flourish_embed settings)
179
+ style: true # bold/italic/title buttons
180
+ url: true # "Add a link" button
181
+ flourish_embed: true # Add flourish iframe
182
+ bindings: [ data.name, data.values ] # Adds buttons for column headers from dataset. Use `true` to add all data bindings
183
+ bindings_custom: # A list of custom bindings that don't appear in the columns (e.g. {{VALUE}} for dynamic values)
184
+ - ["Current value", "VALUE"] # The first item in array is display label, the second item is what is added to the text
185
+ ```
186
+
171
187
  #### Conditional settings
172
188
  Sometimes you might want to simplify the user experience for Flourish users by hiding some settings depending on whether they are needed or not. You can use the `show_if` and `hide_if` properties to control whether or not a setting should be displayed based on another setting’s value.
173
189
 
package/RELEASE_NOTES.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 3.20.0
2
+ * Add the `html` setting type, which gives you a rich text editor for a settings value
3
+
1
4
  # 3.19.0
2
5
  * Add the `is_premium` top level property in template.yml to indicate that this is a premium template
3
6
 
@@ -175,7 +175,7 @@ function validateImport(template_directory, setting) {
175
175
  }
176
176
  }
177
177
 
178
- const VALID_SETTING_TYPES = new Set(["number", "string", "text", "code", "boolean", "color", "colors", "url", "font", "hidden"]);
178
+ const VALID_SETTING_TYPES = new Set(["number", "string", "text", "html", "code", "boolean", "color", "colors", "url", "font", "hidden"]);
179
179
  function validateSetting(template_directory, conditional_settings, setting) {
180
180
  if (typeof setting !== "object" || Array.isArray(setting)) {
181
181
  throw new Error("template.yml: setting must be a mapping");
@@ -228,9 +228,12 @@ function validateSetting(template_directory, conditional_settings, setting) {
228
228
  throw new Error(`template.yml setting “${property}” has unsupported width property: must be “full”, “half”, “quarter” or “three quarters”`);
229
229
  }
230
230
  if ("size" in setting) {
231
- const can_set_size = setting.type == "code" || setting.type == "text" || (setting.type == "string" && setting.style == "buttons");
232
- if (!can_set_size) throw new Error(`template.yml setting “${property}” has a “size” property; this requires type “text” or “code”, or type “string” with ”style: buttons”`);
233
- else if (setting.size !== "large") throw new Error(`template.yml setting “${property}” has unsupported size property: must be “large”`);
231
+ const can_set_size = setting.type == "code" || setting.type == "text" || setting.type == "html" || (setting.type == "string" && setting.style == "buttons");
232
+ if (!can_set_size) throw new Error(`template.yml setting “${property}” has a “size” property; this requires type “text”, “code” or “html”, or type “string” with ”style: buttons”`);
233
+ else if (setting.size !== "large" && setting.size !== "small") throw new Error(`template.yml setting “${property}” has unsupported size property: must be “large” or “small”`);
234
+ }
235
+ if ("editor" in setting && setting.type != "html") {
236
+ throw new Error(`template.yml setting “${property}” has an “editor” field, but is not of type “html”`);
234
237
  }
235
238
  }
236
239
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flourish/sdk",
3
- "version": "3.19.0",
3
+ "version": "3.20.0",
4
4
  "description": "The Flourish SDK",
5
5
  "module": "src/index.js",
6
6
  "scripts": {
@@ -29,7 +29,7 @@
29
29
  "form-data": "^4.0.0",
30
30
  "handlebars": "^4.7.6",
31
31
  "js-yaml": "^3.14.0",
32
- "minimist": "^1.2.5",
32
+ "minimist": "^1.2.6",
33
33
  "ncp": "^2.0.0",
34
34
  "node-fetch": "^2.6.7",
35
35
  "parse5": "^6.0.1",