-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.min.js.map
7 lines (7 loc) · 16.7 KB
/
plugin.min.js.map
1
2
3
4
5
6
7
{
"version": 3,
"sources": ["plugin.js"],
"sourcesContent": ["(function mapPlugin(tinymce) {\n \"use strict\";\n\n const SERVICES = [\"google_staticmap\", \"google_embed\"];\n SERVICES[\"google_staticmap\"] = {\n name: \"Google Static Map\",\n api: \"//maps.googleapis.com/maps/api/staticmap?\",\n type: \"img\"\n };\n SERVICES[\"google_embed\"] = {\n name: \"Google Embed Map\",\n api: \"//www.google.com/maps/embed/v1/place?\",\n type: \"iframe\"\n };\n const MARKER_REGEX = /^(?:color:)?([^|]*)(?:\\|.*)?$/;\n\n function buildURL(url, params) {\n const pairs = [];\n let key, value;\n\n for (key in params) {\n value = params[key];\n if (value) {\n pairs.push(key + \"=\" + value);\n }\n }\n url += pairs.join(\"&\");\n return url;\n }\n\n function buildMap(data, useInlineStyle) {\n const service = SERVICES[data.service || \"google_staticmap\"];\n if (!service) {\n return \"\";\n }\n const type = service.type;\n // So the service name is not built into the URL.\n delete data.service;\n\n const width = data.width;\n const height = data.height;\n\n data.size = width + \"x\" + height;\n if (data.scale) {\n data.scale = 2;\n }\n\n if (data.markers) {\n data.markers = data.markers.replace(MARKER_REGEX, \"color:$1|\" + data.center);\n }\n const location = data.center || data.q;\n\n if (type === \"iframe\") {\n data.q = data.center;\n delete data.center;\n delete data.markers;\n delete data.width;\n delete data.height;\n delete data.size;\n delete data.scale;\n delete data.format;\n }\n\n // If no key is provided, try to use key in setting if any.\n if (!data.key) {\n data.key = service.key || \"\";\n }\n\n let html = buildURL(service.api, data);\n html = \"<\" + type + \" src='\" + html + \"'\";\n html += \" width='\" + width + \"' height='\" + height + \"'\";\n if (type === \"img\") {\n html += \" alt='Map of \" + location + \"' title='\" + location + \"'\";\n }\n if (useInlineStyle) {\n html += \" style='max-width:100%;height:auto'\";\n }\n html += \" />\";\n return html;\n }\n\n /* PLUGIN */\n function Plugin(editor, url) {\n this.editor = editor;\n this.url = url;\n\n // Map default API key in settings for each services.\n SERVICES.forEach(function buildAPIKey(name) {\n const service = SERVICES[name];\n service.key = editor.options.get(name + \"_api_key\") || \"\";\n });\n\n this.formFields = [\n {\n type: \"listbox\",\n name: \"service\",\n label: \"Map service\",\n tooltip: \"Available: Google.\",\n items: SERVICES.map(function buildItems(service) {\n return { text: SERVICES[service].name, value: service };\n }),\n },\n {\n type: \"input\",\n name: \"key\",\n label: \"API Key\"\n },\n {\n type: \"input\",\n name: \"center\",\n label: \"Location\",\n tooltip: \"This parameter takes a location as either a comma-separated {latitude,longitude} pair (e.g. '40.714728,-73.998672') or a string address (e.g. 'city hall, new york, ny') identifying a unique location on the face of the earth\",\n },\n {\n type: \"grid\",\n columns: 2,\n items: [\n {\n type: \"listbox\",\n name: \"zoom\",\n label: \"Zoom level\",\n tooltip: \"This parameter takes a numerical value corresponding to the zoom level of the region desired\",\n items: [\"10\", \"11\", \"12\", \"13\", \"14\", \"15\", \"16\", \"17\", \"18\", \"19\", \"20\"].map(function buildItems(level) {\n return { text: level, value: level + \"\" };\n }),\n },\n {\n type: \"listbox\",\n name: \"markers\",\n label: \"Marker\",\n items: [\"No marker\", \"black\", \"brown\", \"green\", \"purple\", \"yellow\", \"blue\", \"gray\", \"orange\", \"red\", \"white\"].map(function buildItems(color, index) {\n const value = index === 0 ? \"\" : color;\n return { text: color, value: value };\n }),\n }\n ]\n },\n {\n type: \"grid\",\n columns: 2,\n items: [\n {\n type: \"input\",\n name: \"width\",\n label: \"Width\",\n },\n {\n type: \"input\",\n name: \"height\",\n label: \"Height\",\n }\n ]\n },\n {\n type: \"checkbox\",\n label: \"Retina (2x)\",\n name: \"retina\",\n },\n {\n type: \"listbox\",\n name: \"maptype\",\n label: \"Map type\",\n tooltip: \"The map type to display. Default to roadmap.\",\n items: [\"roadmap\", \"satellite\"].map(function buildItems(level) {\n return { text: level, value: level };\n }),\n },\n {\n type: \"textarea\",\n name: \"style\",\n label: \"Style\",\n tooltip: \"Custom style to alter the presentation of a specific feature (roads, parks, and other features) of the map\",\n multiline: true,\n rows: 3,\n },\n {\n type: \"listbox\",\n name: \"format\",\n label: \"Format\",\n tooltip: \"JPEG typically provides greater compression, while GIF and PNG provide greater detail.\",\n items: [\"png8\", \"png32\", \"gif\", \"jpg\", \"jpg-baseline\"].map(function buildItems(level) {\n return { text: level, value: level };\n }),\n }\n ];\n\n this.showDialog = this.showDialog.bind(this);\n this.init(editor, url);\n }\n\n Plugin.prototype.init = function init(editor, url) {\n const plugin = this;\n\n editor.addCommand(\"beInsertMap\", function insert(ui, value, args) {\n editor.insertContent(buildMap(args));\n });\n\n const mapSVG = `<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\" viewBox=\"0 0 296.999 296.999\" xml:space=\"preserve\" width=\"24px\" height=\"24px\">\n <g>\n <path d=\"M141.914,185.802c1.883,1.656,4.234,2.486,6.587,2.486c2.353,0,4.705-0.83,6.587-2.486 c2.385-2.101,58.391-52.021,58.391-103.793c0-35.842-29.148-65.002-64.977-65.002c-35.83,0-64.979,29.16-64.979,65.002 C83.521,133.781,139.529,183.701,141.914,185.802z M148.501,65.025c9.302,0,16.845,7.602,16.845,16.984 c0,9.381-7.543,16.984-16.845,16.984c-9.305,0-16.847-7.604-16.847-16.984C131.654,72.627,139.196,65.025,148.501,65.025z\" fill=\"#333333\"/>\n <path d=\"M273.357,185.773l-7.527-26.377c-1.222-4.281-5.133-7.232-9.583-7.232h-53.719c-1.942,2.887-3.991,5.785-6.158,8.699 c-15.057,20.23-30.364,33.914-32.061,35.41c-4.37,3.848-9.983,5.967-15.808,5.967c-5.821,0-11.434-2.117-15.81-5.969 c-1.695-1.494-17.004-15.18-32.06-35.408c-2.167-2.914-4.216-5.813-6.158-8.699h-53.72c-4.45,0-8.361,2.951-9.583,7.232 l-8.971,31.436l200.529,36.73L273.357,185.773z\" fill=\"#333333\"/>\n <path d=\"M296.617,267.291l-19.23-67.396l-95.412,80.098h105.06c3.127,0,6.072-1.467,7.955-3.963 C296.873,273.533,297.474,270.297,296.617,267.291z\" fill=\"#333333\"/>\n <path d=\"M48.793,209.888l-30.44-5.576L0.383,267.291c-0.857,3.006-0.256,6.242,1.628,8.738c1.883,2.496,4.828,3.963,7.955,3.963 h38.827V209.888z\" fill=\"#333333\"/>\n <polygon points=\"62.746,212.445 62.746,279.992 160.273,279.992 208.857,239.207\" fill=\"#333333\"/>\n </g>\n </svg>`;\n\n editor.ui.registry.addIcon(\"map\", mapSVG);\n\n // Add a button that opens a window\n editor.ui.registry.addButton(\"map\", {\n icon: \"map\",\n tooltip: \"Insert/edit map\",\n onAction: (_) => plugin.showDialog()\n });\n\n editor.ui.registry.addMenuItem(\"map\", {\n icon: \"map\",\n text: \"Map\",\n onAction: (_) => plugin.showDialog(),\n context: \"insert\"\n });\n };\n\n Plugin.prototype.showDialog = function showDialog() {\n const plugin = this;\n const editor = this.editor;\n const dom = editor.dom;\n let params = {};\n let mapElement;\n\n // Parse the current map source for values to insert into\n // the dialog inputs.\n mapElement = editor.selection.getNode();\n\n if (mapElement) {\n let src = dom.getAttrib(mapElement, \"src\");\n if (!src) {\n src = dom.getAttrib(mapElement, \"data-mce-p-src\");\n }\n if (src.indexOf(\"//\") === 0) {\n src = \"https:\" + src;\n }\n if (src.indexOf(\"http\") === 0) {\n const srcURL = new URL(src);\n const searchParams = new URLSearchParams(srcURL.search);\n\n for (const [key, value] of searchParams) {\n params[key] = value;\n }\n }\n\n if (params.retina === \"true\") {\n params.retina = true;\n } else {\n params.retina = false;\n }\n\n if (!params.center) {\n // The selection is an embed iframe map with `q` instead of `center`.\n params.center = params.q || \"\";\n }\n\n params.service = \"google_staticmap\";\n SERVICES.forEach(function buildParams(name) {\n const service = SERVICES[name];\n if (src.indexOf(service.api) > -1) {\n params.service = name;\n }\n });\n\n if (params.markers) {\n params.markers = params.markers.replace(MARKER_REGEX, \"$1\");\n }\n\n params.width = dom.getAttrib(mapElement, \"width\");\n params.height = dom.getAttrib(mapElement, \"height\");\n }\n\n if (!params.width) {\n params.width = \"400\";\n }\n if (!params.height) {\n params.height = \"300\";\n }\n\n // Reset this so `.render` runs correctly.\n this.window = null;\n\n this.window = this.editor.windowManager.open({\n title: \"Insert a map\",\n size: \"medium\",\n initialData: params,\n body:\n {\n type: \"panel\",\n items: [\n {\n type: \"grid\",\n columns: 2,\n items: [\n {\n type: \"panel\",\n items: this.formFields,\n },\n {\n type: \"htmlpanel\",\n html: \"<div id='map'></div>\"\n }\n ]\n },\n ]\n },\n buttons: [\n {\n type: \"cancel\",\n name: \"cancel\",\n text: \"Cancel\"\n },\n {\n type: \"submit\",\n name: \"save\",\n text: \"Save\",\n primary: true\n }\n ],\n onChange: function onChange(api) {\n plugin.render();\n },\n onSubmit: function onSubmit(api) {\n plugin.onsubmit();\n api.close();\n }\n });\n\n this.render();\n };\n\n Plugin.prototype.onsubmit = function onSubmit(event) {\n const window = this.window;\n // Insert content when the window form is submitted\n const data = window.getData();\n this.editor.insertContent(buildMap(data));\n };\n\n Plugin.prototype.render = function render(event) {\n const data = this.window.getData();\n let html = \"\";\n if (data[\"key\"] === \"\") {\n html = \"<div class='error'>Please enter a Google Maps API key.</div>\";\n } else {\n html = buildMap(data, true);\n }\n\n const mapCtrl = $AM.find(\"#map\")[0];\n mapCtrl.innerHTML = html;\n\n return html;\n };\n\n // Register plugin\n tinymce.PluginManager.add(\"map\", (editor, url) => {\n const plugin = new Plugin(editor, url);\n\n return {\n getMetadata: () => ({\n name: \"Map - Fully customizable map for your content.\",\n url: \"http://www.brandextract.com\",\n })\n };\n });\n})(window.tinymce);\n"],
"mappings": "OAAC,SAAmBA,EAAS,CAC3B,aAEA,IAAMC,EAAW,CAAC,mBAAoB,cAAc,EACpDA,EAAS,iBAAsB,CAC7B,KAAM,oBACN,IAAK,4CACL,KAAM,KACR,EACAA,EAAS,aAAkB,CACzB,KAAM,mBACN,IAAK,wCACL,KAAM,QAC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cD,EAASC,CAAI,CAAC,CAC1C,EAEAQ,EAAO,UAAU,OAAS,SAAgBgB,EAAO,CAC/C,IAAMxB,EAAO,KAAK,OAAO,QAAQ,EAC7BO,EAAO,GACPP,EAAK,MAAW,GAClBO,EAAO,+DAEPA,EAAOR,EAASC,EAAM,EAAI,EAG5B,IAAMyB,EAAU,IAAI,KAAK,MAAM,EAAE,CAAC,EAClC,OAAAA,EAAQ,UAAYlB,EAEbA,CACT,EAGAjB,EAAQ,cAAc,IAAI,MAAO,CAACmB,EAAQf,IAAQ,CAChD,IAAMoB,EAAS,IAAIN,EAAOC,EAAQf,CAAG,EAErC,MAAO,CACL,YAAa,KAAO,CAClB,KAAM,iDACN,IAAK,6BACP,EACF,CACF,CAAC,CACH,GAAG,OAAO,OAAO",
"names": ["tinymce", "SERVICES", "MARKER_REGEX", "buildURL", "url", "params", "pairs", "key", "value", "buildMap", "data", "useInlineStyle", "service", "type", "width", "height", "location", "html", "Plugin", "editor", "name", "level", "color", "index", "plugin", "ui", "args", "_", "dom", "mapElement", "src", "srcURL", "searchParams", "api", "event", "mapCtrl"]
}