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Ae,UAAGtC,GAC9C,IAGN,E","sources":["webpack://grapesjs-tooltip/webpack/universalModuleDefinition","webpack://grapesjs-tooltip/webpack/bootstrap","webpack://grapesjs-tooltip/webpack/runtime/define property getters","webpack://grapesjs-tooltip/webpack/runtime/hasOwnProperty shorthand","webpack://grapesjs-tooltip/webpack/runtime/make namespace object","webpack://grapesjs-tooltip/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"grapesjs-tooltip\"] = factory();\n\telse\n\t\troot[\"grapesjs-tooltip\"] = factory();\n})(typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : this), () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { BlockProperties, ComponentDefinition, Plugin } from 'grapesjs';\n\ntype TraitsProperty = ComponentDefinition['traits'];\n\nexport type PluginOptions = {\n /**\n * The ID used to create tooltip block and component\n * @default 'tooltip'\n */\n id?: string;\n\n /**\n * The ID used to create tooltip block and component\n * @default 'Tooltip'\n */\n labelTooltip?: string,\n\n /**\n * Object to extend the default tooltip block. Pass a falsy value to avoid adding the block.\n * @example\n * { label: 'Tooltip', category: 'Extra', ... }\n */\n blockTooltip?: Partial;\n\n /**\n * Object to extend the default tooltip properties.\n * @example\n * { name: 'Tooltip', droppable: false, ... }\n */\n propsTooltip?: ComponentDefinition;\n\n /**\n * A function which allows to extend default traits by receiving the original array and returning a new one.\n */\n extendTraits?: (traits: TraitsProperty) => TraitsProperty,\n\n /**\n * Tooltip attribute prefix.\n * @default 'data-tooltip'\n */\n attrTooltip?: string,\n\n /**\n * Tooltip class prefix.\n * @default 'tooltip-component'\n */\n classTooltip?: string,\n\n /**\n * Custom CSS styles for the tooltip component, this will replace the default one.\n * @default 'tooltip-component'\n */\n style?: string,\n\n /**\n * Additional CSS styles for the tooltip component.\n * @default 'tooltip-component'\n */\n styleAdditional?: string,\n\n /**\n * Make all tooltip relative classes private.\n * @default true\n */\n privateClasses?: boolean,\n\n /**\n * Indicate if the tooltip can be styled.\n * You can pass an array of which proprties can be styled.\n * @example ['color', 'background-color']\n */\n stylableTooltip?: string[] | boolean,\n\n /**\n * If true, force the tooltip to be shown when the default \"Style tooltip\" trait button is clicked.\n * @default true\n */\n showTooltipOnStyle?: boolean,\n};\n\nconst plugin: Plugin = (editor, opts = {}) => {\n const options: PluginOptions = {\n // The ID used to create tooltip block and component\n id: 'tooltip',\n\n // Label of the tooltip. Used for the block and component name\n labelTooltip: 'Tooltip',\n\n // Object to extend the default tooltip block, eg. { label: 'Tooltip', category: 'Extra', ... }.\n // Pass a falsy value to avoid adding the block\n blockTooltip: {},\n\n // Object to extend the default tooltip properties, eg. `{ name: 'Tooltip', droppable: false, ... }`\n propsTooltip: {},\n\n // A function which allows to extend default traits by receiving the original array and returning a new one\n extendTraits: traits => traits,\n\n // Tooltip attribute prefix\n attrTooltip: 'data-tooltip',\n\n // Tooltip class prefix\n classTooltip: 'tooltip-component',\n\n // Custom CSS styles, this will replace the default one\n style: '',\n\n // Additional CSS styles\n styleAdditional: '',\n\n // Make all tooltip relative classes private\n privateClasses: true,\n\n // Indicate if the tooltip can be styled. You can also pass an array\n // of which proprties can be styled. Eg. `['color', 'background-color']`\n stylableTooltip: [\n 'background-color',\n 'padding',\n 'padding-top',\n 'padding-right',\n 'padding-bottom',\n 'padding-left',\n 'font-family',\n 'font-size',\n 'font-weight',\n 'letter-spacing',\n 'color',\n 'line-height',\n 'text-align',\n 'border-radius',\n 'border-top-left-radius',\n 'border-top-right-radius',\n 'border-bottom-left-radius',\n 'border-bottom-right-radius',\n 'border',\n 'border-width',\n 'border-style',\n 'border-color',\n ],\n\n // If true, force the tooltip to be shown\n showTooltipOnStyle: true,\n ...opts\n };\n\n const {\n propsTooltip,\n classTooltip,\n style,\n styleAdditional,\n privateClasses,\n stylableTooltip,\n showTooltipOnStyle,\n blockTooltip,\n extendTraits,\n } = options;\n\n const id = options.id!;\n const labelTooltip = options.labelTooltip!;\n const attrTooltip = options.attrTooltip!;\n\n // Create block\n if (blockTooltip) {\n editor.BlockManager.add(id, {\n media: `\n \n `,\n label: labelTooltip,\n category: 'Extra',\n select: true,\n content: { type: id },\n ...blockTooltip\n });\n }\n\n const classTooltipBody = `${classTooltip}__body`;\n const classTooltipEmpty = `${classTooltip}--empty`;\n const attrTooltipVis = `${attrTooltip}-visible`;\n const attrTooltipPos = `${attrTooltip}-pos`;\n const attrTooltipLen = `${attrTooltip}-length`;\n const traitIdStyleTooltip = 'style-tooltip';\n\n if (privateClasses) {\n editor.SelectorManager.getAll().add([\n { private: 1, name: classTooltip },\n { private: 1, name: classTooltipBody },\n { private: 1, name: classTooltipEmpty },\n ])\n }\n\n // Create component\n editor.Components.addType(id, {\n isComponent: el => el.hasAttribute?.(attrTooltip),\n model: {\n defaults: {\n name: labelTooltip,\n classes: [classTooltip],\n attributes: { [attrTooltip]: labelTooltip },\n styles: (style || `\n .${classTooltip} {\n position: relative;\n display: inline-block;\n vertical-align: top;\n }\n\n .${classTooltipEmpty} {\n width: 50px;\n height: 50px;\n }\n\n .${classTooltipBody},\n [${attrTooltip}]::after {\n font-family: Helvetica, sans-serif;\n background: rgba(55, 61, 73, 0.95);\n border-radius: 3px;\n bottom: 100%;\n color: #fff;\n content: attr(${attrTooltip});\n display: block;\n font-size: 12px;\n left: 50%;\n line-height: normal;\n max-width: 32rem;\n opacity: 0;\n overflow: hidden;\n padding: 8px 16px;\n pointer-events: none;\n position: absolute;\n text-overflow: ellipsis;\n transform: translate(-50%, 0);\n transition: opacity 0.25s, transform 0.25s;\n white-space: nowrap;\n box-sizing: border-box;\n z-index: 10;\n }\n\n [${attrTooltipVis}=true]::after,\n [${attrTooltip}]:focus::after,\n [${attrTooltip}]:hover::after {\n opacity: 1;\n transform: translate(-50%, -0.5rem);\n }\n\n [${attrTooltipPos}=right]::after {\n bottom: 50%;\n left: 100%;\n transform: translate(0, 50%);\n }\n\n [${attrTooltipPos}=right]:focus::after,\n [${attrTooltipPos}=right]:hover::after,\n [${attrTooltipVis}=true][${attrTooltipPos}=right]::after {\n transform: translate(0.5rem, 50%);\n }\n\n [${attrTooltipPos}=bottom]::after {\n bottom: auto;\n top: 100%;\n transform: translate(-50%, 0);\n }\n\n [${attrTooltipPos}=bottom]:focus::after,\n [${attrTooltipPos}=bottom]:hover::after,\n [${attrTooltipVis}=true][${attrTooltipPos}=bottom]::after {\n transform: translate(-50%, 0.5rem);\n }\n\n [${attrTooltipPos}=left]::after {\n bottom: 50%;\n left: auto;\n right: 100%;\n transform: translate(0, 50%);\n }\n\n [${attrTooltipPos}=left]:focus::after,\n [${attrTooltipPos}=left]:hover::after,\n [${attrTooltipVis}=true][${attrTooltipPos}=left]::after {\n transform: translate(-0.5rem, 50%);\n }\n\n [${attrTooltipLen}=small]::after {\n white-space: normal;\n width: 80px;\n }\n\n [${attrTooltipLen}=medium]::after {\n white-space: normal;\n width: 150px;\n }\n\n [${attrTooltipLen}=large]::after {\n white-space: normal;\n width: 300px;\n }\n\n [${attrTooltipLen}=fit]::after {\n white-space: normal;\n width: 100%;\n }\n\n // IE 11 bugfix\n button[${attrTooltip}] {\n overflow: visible;\n }\n `) + styleAdditional,\n traits: extendTraits!([\n {\n name: attrTooltip,\n label: 'Text',\n }, {\n name: attrTooltipPos,\n label: 'Position',\n type: 'select',\n options: [\n { value: 'top', name: 'Top' },\n { value: 'right', name: 'Right' },\n { value: 'bottom', name: 'Bottom' },\n { value: 'left', name: 'Left' },\n ]\n }, {\n name: attrTooltipLen,\n label: 'Length',\n type: 'select',\n options: [\n { value: '', name: 'One line' },\n { value: 'small', name: 'Small' },\n { value: 'medium', name: 'Medium' },\n { value: 'large', name: 'Large' },\n { value: 'fit', name: 'Fit' },\n ]\n }, {\n name: attrTooltipVis,\n label: 'Visible',\n type: 'checkbox',\n valueTrue: 'true',\n }, {\n name: traitIdStyleTooltip,\n labelButton: 'Style tooltip',\n type: 'button',\n full: true,\n command: (editor) => {\n const openSm = editor.Panels.getButton('views', 'open-sm');\n openSm?.set('active', true);\n const ruleTooltip = editor.Css.getRules(`.${classTooltipBody}`)[0];\n ruleTooltip.set('stylable', stylableTooltip);\n editor.StyleManager.select(ruleTooltip);\n\n if (showTooltipOnStyle) {\n const selected = editor.getSelected();\n if (selected?.is(id)) {\n selected.addAttributes({ [attrTooltipVis]: 'true' });\n // @ts-ignore\n editor.once('style:target', () => {\n selected.addAttributes({ [attrTooltipVis]: 'false' });\n });\n }\n }\n },\n },\n ]),\n ...(propsTooltip as any),\n },\n\n init() {\n this.listenTo(this.components(), 'add remove', this.checkEmpty);\n this.checkEmpty();\n },\n\n checkEmpty() {\n const empty = !this.components().length;\n this[empty ? 'addClass' : 'removeClass'](`${classTooltipEmpty}`);\n },\n },\n });\n};\n\nexport default plugin;"],"names":["root","factory","exports","module","define","amd","globalThis","window","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","editor","opts","options","id","labelTooltip","blockTooltip","propsTooltip","extendTraits","traits","attrTooltip","classTooltip","style","styleAdditional","privateClasses","stylableTooltip","showTooltipOnStyle","BlockManager","add","media","label","category","select","content","type","classTooltipBody","classTooltipEmpty","attrTooltipVis","attrTooltipPos","attrTooltipLen","SelectorManager","getAll","private","name","Components","addType","isComponent","el","hasAttribute","model","defaults","classes","attributes","styles","valueTrue","labelButton","full","command","openSm","Panels","getButton","set","ruleTooltip","Css","getRules","StyleManager","getSelected","is","addAttributes","once","init","listenTo","components","checkEmpty","length"],"sourceRoot":""}