Skip to content

Commit

Permalink
#2 use marked in place of snarkdown, applied to all item descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ymarcon committed Oct 13, 2023
1 parent 513968a commit bf01e72
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 23 deletions.
7 changes: 4 additions & 3 deletions ui/dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
"yarn": ">= 1.6.0"
},
"dependencies": {
"@blitzar/form": "https://gitpkg.now.sh/obiba/blitzar/packages/form?v1.0.10-obiba",
"@blitzar/types": "https://gitpkg.now.sh/obiba/blitzar/packages/types?v1.0.10-obiba",
"@blitzar/utils": "https://gitpkg.now.sh/obiba/blitzar/packages/utils?v1.0.10-obiba"
"@blitzar/form": "https://gitpkg.now.sh/obiba/blitzar/packages/form?v1.0.11-obiba",
"@blitzar/types": "https://gitpkg.now.sh/obiba/blitzar/packages/types?v1.0.11-obiba",
"@blitzar/utils": "https://gitpkg.now.sh/obiba/blitzar/packages/utils?v1.0.11-obiba",
"marked": "^9.1.1"
}
}
2 changes: 1 addition & 1 deletion ui/dev/src/pages/BlitzarFormGroupTest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const schema = {
name: 'TEXT',
type: 'text',
label: 'Text label',
description: 'Text description',
description: 'Text description<br/> with <a href="http://some_path.pdf">a html link</a> and [a markdown link](http://some_path.pdf)',
placeholder: 'Text placeholder',
hint: 'Text hint',
required: true
Expand Down
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"rimraf": "^3.0.0",
"rollup": "^2.45.0",
"rollup-plugin-hypothetical": "^2.1.1",
"snarkdown": "^2.0.0",
"uglify-js": "^3.13.3",
"zlib": "^1.0.5"
},
Expand All @@ -57,6 +56,7 @@
"last 4 iOS versions"
],
"dependencies": {
"dompurify": "^3.0.6",
"vue3-openlayers": "^0.1.63"
}
}
3 changes: 1 addition & 2 deletions ui/src/components/QASection.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { h } from 'vue'
import snarkdown from 'snarkdown'

export default {
name: 'QASection',
Expand All @@ -24,7 +23,7 @@ export default {
const defaultBodyClass = 'text-subtitle1 text-grey-8' + (props.head ? ' q-mt-md' : '')
children.push(h('div', {
class: props.bodyClass ? props.bodyClass : defaultBodyClass,
innerHTML: snarkdown(props.body)
innerHTML: props.body
}))
}

Expand Down
6 changes: 6 additions & 0 deletions ui/src/utils/blitzar/bitem.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { marked } from 'marked'

class BItem {

constructor(tr) {
this.tr = tr
}

trmd(text) {
return text ? marked.parse(this.tr(text), {headerIds: false, mangle: false}) : text
}

// rewrites $('VAR') to formData.VAR
static variableRefRewrite(script) {
const doRewrite = (match, p1, offset, string) => {
Expand Down
6 changes: 3 additions & 3 deletions ui/src/utils/blitzar/datetime-bitems.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DateBItem extends BItem {
id: prefix + item.name,
component: 'QADate',
label: this.tr(item.label),
subLabel: this.tr(item.description),
subLabel: this.trmd(item.description),
placeholder: this.tr(item.placeholder),
hint: this.tr(item.hint),
parseInput: (val) => val !== null && val.length === 0 ? null : val,
Expand All @@ -33,7 +33,7 @@ class DatetimeBItem extends BItem {
id: prefix + item.name,
component: 'QADatetime',
label: this.tr(item.label),
subLabel: this.tr(item.description),
subLabel: this.trmd(item.description),
placeholder: this.tr(item.placeholder),
hint: this.tr(item.hint),
parseInput: (val) => val !== null && val.length === 0 ? null : val,
Expand All @@ -56,7 +56,7 @@ class TimeBItem extends BItem {
id: prefix + item.name,
component: 'QATime',
label: this.tr(item.label),
subLabel: this.tr(item.description),
subLabel: this.trmd(item.description),
placeholder: this.tr(item.placeholder),
hint: this.tr(item.hint),
parseInput: (val) => val !== null && val.length === 0 ? null : val,
Expand Down
2 changes: 1 addition & 1 deletion ui/src/utils/blitzar/geo-bitems.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MapBItem extends BItem {
id: prefix + item.name,
component: 'QAMap',
label: this.tr(item.label),
subLabel: this.tr(item.description),
subLabel: this.trmd(item.description),
defaultValue: typeof item.defaultValue === 'string' ? JSON.parse(item.defaultValue) : item.defaultValue,
labelClasses: item.labelClass,
multiple: item.multiple,
Expand Down
2 changes: 1 addition & 1 deletion ui/src/utils/blitzar/logical-bitems.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ToggleBItem extends BItem {
id: prefix + item.name,
component: 'QToggle',
label: this.tr(item.label),
subLabel: this.tr(item.description),
subLabel: this.trmd(item.description),
defaultValue: item.default ? (item.default === 'true' ? true : false) : undefined,
labelClasses: item.labelClass
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/utils/blitzar/misc-bitems.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SectionBItem extends BItem {
identifier: (prefix + item.name).replaceAll('.', '_').toLowerCase(),
head: this.tr(item.label),
headClass: item.labelClass,
body: this.tr(item.description),
body: this.trmd(item.description),
bodyClass: item.descriptionClass
}
}
Expand Down
6 changes: 3 additions & 3 deletions ui/src/utils/blitzar/number-bitems.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NumberBItem extends BItem {
component: 'QInput',
type: 'number',
label: this.tr(item.label),
subLabel: this.tr(item.description),
subLabel: this.trmd(item.description),
hint: this.tr(item.hint),
parseInput: Number,
defaultValue: item.default ? Number.parseFloat(item.default) : undefined,
Expand All @@ -32,7 +32,7 @@ class SliderBItem extends BItem {
id: prefix + item.name,
component: 'QSlider',
label: this.tr(item.label),
subLabel: this.tr(item.description),
subLabel: this.trmd(item.description),
defaultValue: item.default ? Number.parseFloat(item.default) : undefined,
min: item.min ? item.min : 0,
max: item.max ? item.max : 100,
Expand All @@ -53,7 +53,7 @@ class RatingBItem extends BItem {
id: prefix + item.name,
component: 'QRating',
label: this.tr(item.label),
subLabel: this.tr(item.description),
subLabel: this.trmd(item.description),
hint: this.tr(item.hint),
max: item.max ? item.max : 5,
icon: item.icon ? item.icon : "star",
Expand Down
4 changes: 2 additions & 2 deletions ui/src/utils/blitzar/options-bitems.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class RadioGroupBItem extends BItem {
id: prefix + item.name,
component: 'QOptionGroup',
label: this.tr(item.label),
subLabel: this.tr(item.description),
subLabel: this.trmd(item.description),
defaultValue: item.default,
options: item.options ? item.options.map(opt => {
return {
Expand All @@ -36,7 +36,7 @@ class CheckboxGroupBItem extends BItem {
id: prefix + item.name,
component: 'QOptionGroup',
label: this.tr(item.label),
subLabel: this.tr(item.description),
subLabel: this.trmd(item.description),
defaultValue: BItem.stringToArray(item.default),
type: 'checkbox',
options: item.options ? item.options.map(opt => {
Expand Down
6 changes: 3 additions & 3 deletions ui/src/utils/blitzar/select-bitems.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SelectBItem extends BItem {
id: prefix + item.name,
component: 'QSelect',
label: this.tr(item.label),
subLabel: this.tr(item.description),
subLabel: this.trmd(item.description),
hint: this.tr(item.hint),
defaultValue: item.multiple ? BItem.stringToArray(item.default) : item.default,
options: item.options ? item.options.map(opt => {
Expand Down Expand Up @@ -41,7 +41,7 @@ class AutocompleteBItem extends BItem {
id: prefix + item.name,
component: 'QAAutocomplete',
label: this.tr(item.label),
subLabel: this.tr(item.description),
subLabel: this.trmd(item.description),
hint: this.tr(item.hint),
defaultValue: item.multiple ? BItem.stringToArray(item.default) : item.default,
options: item.options ? item.options.map(opt => {
Expand All @@ -68,7 +68,7 @@ class ImageSelectBItem extends BItem {
id: prefix + item.name,
component: 'QAImageSelect',
label: this.tr(item.label),
subLabel: this.tr(item.description),
subLabel: this.trmd(item.description),
hint: this.tr(item.hint),
defaultValue: item.multiple ? BItem.stringToArray(item.default) : item.default,
options: item.options ? item.options.map(opt => {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/utils/blitzar/text-bitems.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TextBItem extends BItem {
id: prefix + item.name,
component: 'QInput',
label: this.tr(item.label),
subLabel: this.tr(item.description),
subLabel: this.trmd(item.description),
placeholder: this.tr(item.placeholder),
hint: this.tr(item.hint),
defaultValue: item.default,
Expand All @@ -33,7 +33,7 @@ class TextAreaBItem extends BItem {
component: 'QInput',
type: 'textarea',
label: this.tr(item.label),
subLabel: this.tr(item.description),
subLabel: this.trmd(item.description),
placeholder: this.tr(item.placeholder),
hint: this.tr(item.hint),
defaultValue: item.default,
Expand Down

0 comments on commit bf01e72

Please sign in to comment.