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AAe+F,qBAAqB+D,aAE3CH,EAAEI,iBACFJ,EAAEC,OAAOI,iBANb,GARD,G","sources":["webpack://app/../usr/local/bundle/gems/decidim-decidim_awesome-0.8.3/app/packs/src/decidim/decidim_awesome/editors/editor.js","webpack://app/../usr/local/bundle/gems/decidim-decidim_awesome-0.8.3/app/packs/src/decidim/decidim_awesome/forms/rich_text_plugin.js","webpack://app/../usr/local/bundle/gems/decidim-decidim_awesome-0.8.3/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js","webpack://app/../usr/local/bundle/gems/decidim-decidim_awesome-0.8.3/app/packs/src/decidim/decidim_awesome/proposals/custom_fields.js"],"sourcesContent":["/* eslint-disable require-jsdoc */\n\n/*\n* Since version 0.25 we follow a different strategy and opt to destroy and override completely the original editor\n* That's because editors are instantiated directly instead of creating a global function to instantiate them\n*/\n\nimport lineBreakButtonHandler from \"src/decidim/editor/linebreak_module\"\nimport InscrybMDE from \"inscrybmde\"\nimport Europa from \"europa\"\nimport \"inline-attachment/src/inline-attachment\";\nimport \"inline-attachment/src/codemirror-4.inline-attachment\";\nimport \"inline-attachment/src/jquery.inline-attachment\";\nimport hljs from \"highlight.js\";\nimport \"highlight.js/styles/github.css\";\n\n// In 0.26 these files come with Decidim in the folder src/decidim/vendor so the awesome one's could be removed\nimport \"src/vendor/image-resize.min\"\nimport \"src/vendor/image-upload.min\"\n\nconst DecidimAwesome = window.DecidimAwesome || {};\nconst quillFormats = [\"bold\", \"italic\", \"link\", \"underline\", \"header\", \"list\", \"video\", \"image\", \"alt\", \"break\", \"width\", \"style\", \"code\", \"blockquote\", \"indent\"];\n\n// A tricky way to destroy the quill editor\nexport function destroyQuillEditor(container) {\n if (container) {\n const content = $(container).find(\".ql-editor\").html();\n $(container).html(content);\n $(container).siblings(\".ql-toolbar\").remove();\n $(container).find(\"*[class*='ql-']\").removeClass((index, class_name) => (class_name.match(/(^|\\s)ql-\\S+/g) || []).join(\" \"));\n $(container).removeClass((index, class_name) => (class_name.match(/(^|\\s)ql-\\S+/g) || []).join(\" \"));\n if ($(container).next().is(\"p.help-text\")) {\n $(container).next().remove();\n }\n }\n else {\n console.error(`editor [${container}] not exists`);\n }\n}\n\nexport function createQuillEditor(container) {\n const toolbar = $(container).data(\"toolbar\");\n const disabled = $(container).data(\"disabled\");\n\n let quillToolbar = [\n [\"bold\", \"italic\", \"underline\", \"linebreak\"],\n [{ list: \"ordered\" }, { list: \"bullet\" }],\n [\"link\", \"clean\"],\n [\"code\", \"blockquote\"],\n [{ \"indent\": \"-1\"}, { \"indent\": \"+1\" }]\n ];\n\n let addImage = false;\n\n if (toolbar === \"full\") {\n quillToolbar = [\n [{ header: [2, 3, 4, 5, 6, false] }],\n ...quillToolbar\n ];\n if (DecidimAwesome.allow_images_in_full_editor) {\n quillToolbar.push([\"video\", \"image\"]);\n addImage = true;\n } else {\n quillToolbar.push([\"video\"]);\n }\n } else if (toolbar === \"basic\") {\n if (DecidimAwesome.allow_images_in_small_editor) {\n quillToolbar.push([\"video\", \"image\"]);\n addImage = true;\n } else {\n quillToolbar.push([\"video\"]);\n }\n } else if (DecidimAwesome.allow_images_in_small_editor) {\n quillToolbar.push([\"image\"]);\n addImage = true;\n }\n\n let modules = {\n linebreak: {},\n toolbar: {\n container: quillToolbar,\n handlers: {\n \"linebreak\": lineBreakButtonHandler\n }\n }\n };\n\n const $input = $(container).siblings('input[type=\"hidden\"]');\n container.innerHTML = $input.val() || \"\";\n const token = $('meta[name=\"csrf-token\"]').attr(\"content\");\n if (addImage) {\n modules.imageResize = {\n modules: [\"Resize\", \"DisplaySize\"]\n }\n modules.imageUpload = {\n url: $(container).data(\"uploadImagesPath\") || DecidimAwesome.editor_uploader_path,\n method: \"POST\",\n name: \"image\",\n withCredentials: false,\n headers: { \"X-CSRF-Token\": token },\n callbackOK: (serverResponse, next) => {\n $(\"div.ql-toolbar\").last().removeClass(\"editor-loading\")\n next(serverResponse.url);\n },\n callbackKO: (serverError) => {\n $(\"div.ql-toolbar\").last().removeClass(\"editor-loading\")\n console.error(`Image upload error: ${serverError.message}`);\n },\n checkBeforeSend: (file, next) => {\n $(\"div.ql-toolbar\").last().addClass(\"editor-loading\")\n next(file);\n }\n }\n }\n const quill = new Quill(container, {\n modules: modules,\n formats: quillFormats,\n theme: \"snow\"\n });\n\n if (disabled) {\n quill.disable();\n }\n\n quill.on(\"text-change\", () => {\n const text = quill.getText();\n\n // Triggers CustomEvent with the cursor position\n // It is required in input_mentions.js\n let event = new CustomEvent(\"quill-position\", {\n detail: quill.getSelection()\n });\n container.dispatchEvent(event);\n\n if (text === \"\\n\" || text === \"\\n\\n\") {\n $input.val(\"\");\n } else {\n $input.val(quill.root.innerHTML);\n }\n });\n // After editor is ready, linebreak_module deletes two extraneous new lines\n quill.emitter.emit(\"editor-ready\");\n\n if (addImage) {\n const text = $(container).data(\"dragAndDropHelpText\") || DecidimAwesome.texts.drag_and_drop_image;\n $(container).after(`<p class=\"help-text\" style=\"margin-top:-1.5rem;\">${text}</p>`);\n }\n\n // After editor is ready, linebreak_module deletes two extraneous new lines\n quill.emitter.emit(\"editor-ready\");\n\n return quill;\n}\n\nexport function createMarkdownEditor(container) {\n const t = DecidimAwesome.texts.drag_and_drop_image;\n const token = $('meta[name=\"csrf-token\"]').attr(\"content\");\n const $input = $(container).siblings('input[type=\"hidden\"]');\n const $faker = $('<textarea name=\"faker-inscrybmde\"/>');\n const $form = $(container).closest(\"form\");\n const europa = new Europa();\n $faker.val(europa.convert($input.val()));\n $faker.insertBefore($(container));\n $(container).hide();\n const inscrybmde = new InscrybMDE({\n element: $faker[0],\n spellChecker: false,\n renderingConfig: {\n codeSyntaxHighlighting: true,\n hljs: hljs\n }\n });\n $faker[0].InscrybMDE = inscrybmde;\n\n // Allow image upload\n if (DecidimAwesome.allow_images_in_markdown_editor) {\n $(inscrybmde.gui.statusbar).prepend(`<span class=\"help-text\" style=\"float:left;margin:0;text-align:left;\">${t}</span>`);\n inlineAttachment.editors.codemirror4.attach(inscrybmde.codemirror, {\n uploadUrl: DecidimAwesome.editor_uploader_path,\n uploadFieldName: \"image\",\n jsonFieldName: \"url\",\n extraHeaders: { \"X-CSRF-Token\": token }\n });\n }\n\n // convert to html on submit\n $form.on(\"submit\", () => {\n // e.preventDefault();\n $input.val(inscrybmde.markdown(inscrybmde.value()));\n });\n}\n","/**\n * Decidim rich text editor control plugin\n * Renders standard Decidim WYSIWYG editor\n *\n * Registers Decidim Richtext as a subtype for the textarea control\n */\nimport {createQuillEditor} from \"src/decidim/decidim_awesome/editors/editor\"\n\n// configure the class for runtime loading\nif (!window.fbControls) {\n window.fbControls = []\n}\nwindow.fbControls.push(function(controlClass, allControlClasses) {\n const controlTextarea = allControlClasses.textarea\n\n /**\n * DecidimRichtext control class\n *\n * NOTE: I haven't found a way to set the userData value using this plugin\n * For this reason the value of the field must be collected manually\n * from the hidden input name same as the field with the suffix '-input'\n */\n class controlRichtext extends controlTextarea {\n\n /**\n * Class configuration - return the icons & label related to this control\n * @returndefinition object\n */\n static get definition() {\n return {\n icon: \"ðŸ“\",\n i18n: {\n default: \"Rich Text Editor\"\n }\n }\n }\n\n /**\n * configure the richtext editor requirements\n */\n configure() {\n window.fbEditors.richtext = {};\n }\n\n /**\n * build a div DOM element & convert to a richtext editor\n * @return {DOMElement} DOM Element to be injected into the form.\n */\n build() {\n const { value, userData, ...attrs } = this.config;\n\n // hidden input for storing the current HTML value of the div\n this.inputId = `${this.id}-input`;\n // console.log(\"build plugin: this\",this)\n this.input = this.markup(\"input\", null, {\n name: name,\n id: this.inputId,\n type: \"hidden\",\n value: (userData && userData[0]) || value || \"\"\n });\n\n const css = this.markup(\n \"style\",\n `\n #${attrs.id} { height: auto; min-height: 6rem; padding-left: 0; padding-right: 0; }\n #${attrs.id} div.ql-container { height: ${attrs.rows || 1}rem; }\n #${attrs.id} p.help-text { margin-top: .5rem; }\n `,\n { type: \"text/css\" }\n );\n const wrapper_attrs = {...attrs, \"data-toolbar\": \"full\" };\n // console.log(\"build value\", value, \"userData\", userData, \"attrs\", attrs, attrs.id, \"wrapper_attrs\", wrapper_attrs);\n this.wrapper = this.markup(\"div\", null, wrapper_attrs);\n return this.markup(\"div\", [css, this.input, this.wrapper], attrs);\n }\n\n /**\n * When the element is rendered into the DOM, execute the following code to initialise it\n * @param {Object} evt - event\n */\n onRender(evt) {\n // const value = this.config.value || '';\n if (window.fbEditors.richtext[this.id]) {\n // console.log(\"todo destroy\", window.fbEditors.richtext[this.id]);\n // window.fbEditors.richtext[this.id].richtext('destroy')\n }\n\n window.fbEditors.quill[this.id] = {};\n const editor = window.fbEditors.quill[this.id];\n // createQuillEditor does all the job to update the hidden input wrapper\n editor.instance = createQuillEditor(this.wrapper);\n // editor.data = new Delta();\n // if (value) {\n // editor.instance.setContents(window.JSON.parse(this.parsedHtml(value)));\n // }\n // editor.instance.on('text-change', function(delta) {\n // console.log(\"text-change\", \"delta\", delta, \"editor\", editor);\n // // // editor.data = editor.data.compose(delta);\n // });\n\n // console.log(\"render! editor\", editor, \"this\", this, \"value\", value);\n return evt;\n }\n }\n\n // register Decidim richtext as a richtext control\n controlTextarea.register(\"richtext\", controlRichtext, \"textarea\");\n})\n","require(\"formBuilder/dist/form-render.min.js\")\nimport \"src/decidim/decidim_awesome/forms/rich_text_plugin\"\n\nexport default class CustomFieldsRenderer { // eslint-disable-line no-unused-vars\n constructor(container_selector) {\n this.container_selector = container_selector || \".proposal_custom_field:last\";\n this.lang = this.getLang($(\"html\").attr(\"lang\"));\n }\n\n getLang(lang) {\n const langs = {\n // ar: 'ar-SA', // Not in decidim yet\n \"ar\": \"ar-TN\",\n \"ca\": \"ca-ES\",\n \"cs\": \"cs-CZ\",\n \"da\": \"da-DK\",\n \"de\": \"de-DE\",\n \"el\": \"el-GR\",\n \"en\": \"en-US\",\n \"es\": \"es-ES\",\n \"fa\": \"fa-IR\",\n \"fi\": \"fi-FI\",\n \"fr\": \"fr-FR\",\n \"he\": \"he-IL\",\n \"hu\": \"hu-HU\",\n \"it\": \"it-IT\",\n \"ja\": \"ja-JP\",\n \"my\": \"my-MM\",\n \"nb\": \"nb-NO\",\n \"nl\": \"nl-NL\",\n \"pl\": \"pl-PL\",\n \"pt\": \"pt-BR\",\n \"qz\": \"qz-MM\",\n \"ro\": \"ro-RO\",\n \"ru\": \"ru-RU\",\n \"sl\": \"sl-SI\",\n \"th\": \"th-TH\",\n \"tr\": \"tr-TR\",\n \"uk\": \"uk-UA\",\n \"vi\": \"vi-VN\",\n \"zh-TW\": \"zh-TW\",\n \"zh\": \"zh-CN\"\n };\n if (langs[lang]) {\n return langs[lang];\n }\n if (langs[lang.substr(0, 2)]) {\n return langs[lang.substr(0, 2)];\n }\n return \"en-US\";\n }\n\n /*\n * Creates an XML document with a subset of html-compatible dl/dd/dt elements\n * to store the custom fields answers\n */\n dataToXML(data) {\n const $dl = $(\"<dl/>\");\n let $dd, $div, $dt, key, l, label, text, val;\n $dl.attr(\"class\", \"decidim_awesome-custom_fields\");\n $dl.attr(\"data-generator\", \"decidim_awesome\");\n $dl.attr(\"data-version\", window.DecidimAwesome.version);\n for (key in data) {\n // console.log(\"get the data!\", key, data[key]);\n // Richtext plugin does not saves userdata, so we get it from the hidden input\n if (data[key].type == \"textarea\" && data[key].subtype == \"richtext\") {\n data[key].userData = [$(`#${data[key].name}-input`).val()];\n }\n if (data[key].userData && data[key].userData.length) {\n $dt = $(\"<dt/>\");\n $dt.text(data[key].label);\n $dt.attr(\"name\", data[key].name);\n $dd = $(\"<dd/>\");\n // console.log(\"data for\", key, data[key].name, data[key])\n for (val in data[key].userData) {\n $div = $(\"<div/>\");\n label = data[key].userData[val];\n text = null;\n if (data[key].values) {\n l = data[key].values.find((v) => v.value == label);\n if (l) {\n text = label;\n label = l.label;\n }\n } else if (data[key].type == \"date\" && label) {\n l = new Date(label).toLocaleDateString();\n if (l) {\n text = label;\n label = l;\n }\n }\n // console.log(\"userData\", text, \"label\", label, 'key', key, 'data', data)\n if (data[key].type == \"textarea\" && data[key].subtype == \"richtext\") {\n $div.html(label);\n } else {\n $div.text(label);\n }\n if (text) {\n $div.attr(\"alt\", text);\n }\n $dd.append($div);\n }\n $dd.attr(\"id\", data[key].name);\n $dd.attr(\"name\", data[key].type);\n $dl.append($dt);\n $dl.append($dd);\n }\n }\n return `<xml>${$dl[0].outerHTML}</xml>`;\n }\n\n fixBuggyFields() {\n if (!this.$container) {\n return false;\n }\n\n /**\n * Hack to fix required checkboxes being reset\n * Issue: https://github.com/Platoniq/decidim-module-decidim_awesome/issues/82\n */\n this.$container.find(\".formbuilder-checkbox-group\").each((_key, group) => {\n const inputs = $(\".formbuilder-checkbox input\", group);\n const data = this.spec.find((a) => a.type == \"checkbox-group\");\n let values = data.userData;\n if (!inputs.length || !data || !values) {\n return;\n }\n\n inputs.each((_idx, input) => {\n let index = values.indexOf(input.value);\n if (index >= 0) {\n values.splice(index, 1)\n // setting checked=true do not makes the browser aware that the form is valid if the field is required\n if (!input.checked)\n {$(input).click();}\n } else if (input.checked)\n {$(input).click();}\n });\n\n // Fill \"other\" option\n const other_option = $(\".other-option\", inputs.parent())[0];\n const other_val = $(\".other-val\", inputs.parent())[0];\n const other_text = values.join(\" \");\n\n if (other_option) {\n if (other_text) {\n other_option.checked = true;\n other_option.value = other_text;\n other_val.value = other_text;\n } else {\n other_option.checked = false;\n other_option.value = \"\";\n other_val.value = \"\";\n }\n }\n });\n\n /**\n * Hack to fix required radio buttons \"other\" value\n * Issue: https://github.com/Platoniq/decidim-module-decidim_awesome/issues/133\n */\n this.$container.find(\".formbuilder-radio input.other-val\").on(\"input\", (input) => {\n const $input = $(input.currentTarget);\n const $group = $input.closest(\".formbuilder-radio-group\");\n $group.find(\"input\").each((_key, radio) => {\n const name = $(radio).attr(\"name\");\n if (name && name.endsWith(\"[]\")) {\n $(radio).attr(\"name\", name.slice(0, -2));\n }\n });\n });\n }\n\n // Saves xml to the hidden input\n storeData() {\n if (!this.$container) {\n return false;\n }\n const $form = this.$container.closest(\"form\");\n const $body = $form.find(`input[name=\"${this.$element.data(\"name\")}\"]`);\n if ($body.length && this.instance) {\n this.spec = this.instance.userData;\n $body.val(this.dataToXML(this.spec));\n this.$element.data(\"spec\", this.spec);\n }\n // console.log(\"storeData spec\", this.spec, \"$body\", $body,\"$form\",$form,\"this\",this);\n }\n\n init($element) {\n this.$element = $element;\n this.spec = $element.data(\"spec\");\n if (!this.$container) {\n this.$container = $(this.container_selector);\n }\n // console.log(\"init\", $element, \"this\", this)\n // always use the last field (in case of multilang tabs we only render one form due a limitation of the library to handle several instances)\n this.instance = this.$container.formRender({\n i18n: {\n locale: this.lang,\n location: \"https://cdn.jsdelivr.net/npm/formbuilder-languages@1.1.0/\"\n },\n formData: this.spec,\n render: true\n });\n this.fixBuggyFields();\n }\n}\n","import CustomFieldsRenderer from \"src/decidim/decidim_awesome/forms/custom_fields_renderer\"\n\nwindow.DecidimAwesome.CustomFieldsRenderer = window.DecidimAwesome.CustomFieldsRenderer || new CustomFieldsRenderer();\n\n$(() => {\n // use admin multilang specs if exists\n let $el = $(\"proposal_custom_field:first\", \".tabs-title.is-active\");\n $el = $el.length\n ? $el\n : $(\".proposal_custom_field:first\");\n window.DecidimAwesome.CustomFieldsRenderer.init($el);\n\n window.DecidimAwesome.CustomFieldsRenderer.$container.closest(\"form\").on(\"submit\", (e) => {\n if (e.target.checkValidity()) {\n // save current editor\n window.DecidimAwesome.CustomFieldsRenderer.storeData();\n } else {\n e.preventDefault();\n e.target.reportValidity();\n }\n });\n});\n"],"names":["DecidimAwesome","window","quillFormats","fbControls","push","controlClass","allControlClasses","controlTextarea","textarea","controlRichtext","icon","i18n","default","fbEditors","richtext","this","config","value","userData","attrs","inputId","id","input","markup","name","type","css","rows","wrapper_attrs","wrapper","evt","quill","instance","container","toolbar","$","data","disabled","quillToolbar","list","addImage","header","allow_images_in_full_editor","allow_images_in_small_editor","modules","linebreak","handlers","lineBreakButtonHandler","$input","siblings","innerHTML","val","token","attr","imageResize","imageUpload","url","editor_uploader_path","method","withCredentials","headers","callbackOK","serverResponse","next","last","removeClass","callbackKO","serverError","console","error","message","checkBeforeSend","file","addClass","Quill","formats","theme","disable","on","text","getText","event","CustomEvent","detail","getSelection","dispatchEvent","root","emitter","emit","texts","drag_and_drop_image","after","createQuillEditor","register","require","CustomFieldsRenderer","container_selector","lang","getLang","langs","substr","$dd","$div","$dt","key","l","label","$dl","version","subtype","length","values","find","v","Date","toLocaleDateString","html","append","outerHTML","$container","each","_key","group","inputs","_this","spec","a","_idx","index","indexOf","splice","checked","click","other_option","parent","other_val","other_text","join","currentTarget","closest","radio","endsWith","slice","$body","$form","$element","dataToXML","formRender","locale","location","formData","render","fixBuggyFields","$el","init","e","target","checkValidity","storeData","preventDefault","reportValidity"],"sourceRoot":""}