{"version":3,"file":"link_controller-DB8kNfIa.js","sources":["../../../app/javascript/controllers/editor/link_controller.js"],"sourcesContent":["import ApplicationController from '../application_controller'\nimport Browser from \"../models/browser\";\n\n// events dispatched from this controller\n// list:added: fired when the list is connected to the dom, dispatched event contains id and the client url\n// list:removed: fired when the list is removed, the dispatched event contains the id of the removed element\n\nexport default class extends ApplicationController {\n static values = {\n initial: String,\n id: String,\n toggle: { type: Boolean, default: false }\n }\n static targets = ['linkButton']\n\n initialize() {\n super.initialize()\n }\n\n toggle() {\n if(this.toggleValue) {\n this.abortEditing()\n } else {\n this.edit()\n }\n }\n\n highlight() {\n this.linkButtonTarget.classList.replace('bg-night-10', 'bg-night-20')\n }\n\n unhighlight() {\n this.linkButtonTarget.classList.replace('bg-night-20', 'bg-night-10')\n }\n\n edit() {\n this.highlight()\n\n this.dispatch(\n 'edit',\n {\n target: this.editForm,\n detail: {\n id: this.idValue,\n url: this.initialValue,\n element: this.element\n }\n }\n )\n\n this.toggleValue = true\n }\n\n abortEditing() {\n this.dispatch(\n 'abort',\n {\n target: this.editForm\n }\n )\n\n this.toggleValue = false\n this.unhighlight();\n }\n\n onEditAborted() {\n this.toggleValue = false\n this.unhighlight();\n }\n\n updateUrl({ detail: newUrl }) {\n this.initialValue = newUrl\n }\n\n // private\n\n initialValueChanged() {\n this.element.dataset.clientUrl = this.initialValue\n }\n\n get editForm() {\n return this.element.closest('[data-controller*=\"compose\"]').querySelector('[data-controller=\"link--edit\"]')\n }\n}\n"],"names":["link_controller","ApplicationController","newUrl","__publicField"],"mappings":"uNAOe,MAAKA,UAASC,CAAsB,CAQjD,YAAa,CACX,MAAM,WAAU,CACpB,CAEE,QAAS,CACJ,KAAK,YACN,KAAK,aAAY,EAEjB,KAAK,KAAI,CAEf,CAEE,WAAY,CACV,KAAK,iBAAiB,UAAU,QAAQ,cAAe,aAAa,CACxE,CAEE,aAAc,CACZ,KAAK,iBAAiB,UAAU,QAAQ,cAAe,aAAa,CACxE,CAEE,MAAO,CACL,KAAK,UAAS,EAEd,KAAK,SACH,OACA,CACE,OAAQ,KAAK,SACb,OAAQ,CACN,GAAI,KAAK,QACT,IAAK,KAAK,aACV,QAAS,KAAK,OACxB,CACA,CACA,EAEI,KAAK,YAAc,EACvB,CAEE,cAAe,CACb,KAAK,SACH,QACA,CACE,OAAQ,KAAK,QACrB,CACA,EAEI,KAAK,YAAc,GACnB,KAAK,YAAa,CACtB,CAEE,eAAgB,CACd,KAAK,YAAc,GACnB,KAAK,YAAa,CACtB,CAEE,UAAU,CAAE,OAAQC,GAAU,CAC5B,KAAK,aAAeA,CACxB,CAIE,qBAAsB,CACpB,KAAK,QAAQ,QAAQ,UAAY,KAAK,YAC1C,CAEE,IAAI,UAAW,CACb,OAAO,KAAK,QAAQ,QAAQ,8BAA8B,EAAE,cAAc,gCAAgC,CAC9G,CACA,CA3EEC,EADkBH,EACX,SAAS,CACd,QAAS,OACT,GAAI,OACJ,OAAQ,CAAE,KAAM,QAAS,QAAS,EAAK,CAC3C,GACEG,EANkBH,EAMX,UAAU,CAAC,YAAY"}