{"version":3,"file":"taiga-ui-editor-extensions-font-color.mjs","sources":["../../../projects/editor/extensions/font-color/index.ts","../../../projects/editor/extensions/font-color/taiga-ui-editor-extensions-font-color.ts"],"sourcesContent":["import {type Command, Extension, type GlobalAttributes} from '@tiptap/core';\n\nexport interface TuiFontColorOptions {\n    types: string[];\n}\n\ndeclare module '@tiptap/core' {\n    interface Commands<ReturnType> {\n        fontColor: {\n            /**\n             * Set the font color\n             */\n            setFontColor(fontColor: string): ReturnType;\n            /**\n             * Unset the font color\n             */\n            unsetFontColor(): ReturnType;\n        };\n    }\n}\n\nexport const TuiFontColor = Extension.create<TuiFontColorOptions>({\n    name: 'fontColor',\n\n    addOptions(): TuiFontColorOptions {\n        return {types: ['textStyle']};\n    },\n\n    addGlobalAttributes(): GlobalAttributes {\n        return [\n            {\n                types: this.options.types,\n                attributes: {\n                    fontColor: {\n                        default: null,\n                        renderHTML: ({fontColor}) =>\n                            fontColor\n                                ? {\n                                      style: `color: ${fontColor}`,\n                                  }\n                                : {},\n                        parseHTML: ({style}) => style.color.replaceAll(/['\"]+/g, ''),\n                        keepOnSplit: false,\n                    },\n                },\n            },\n        ];\n    },\n\n    addCommands(): {\n        setFontColor?(fontColor: string): Command;\n        unsetFontColor?(): Command;\n    } {\n        return {\n            setFontColor:\n                (fontColor) =>\n                ({chain}) =>\n                    chain().setMark('textStyle', {fontColor}).run(),\n            unsetFontColor:\n                () =>\n                ({chain}) =>\n                    chain().setMark('textStyle', {fontColor: null}).run(),\n        };\n    },\n});\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAqBa,MAAA,YAAY,GAAG,SAAS,CAAC,MAAM,CAAsB;AAC9D,IAAA,IAAI,EAAE,WAAW;IAEjB,UAAU,GAAA;AACN,QAAA,OAAO,EAAC,KAAK,EAAE,CAAC,WAAW,CAAC,EAAC,CAAC;KACjC;IAED,mBAAmB,GAAA;QACf,OAAO;AACH,YAAA;AACI,gBAAA,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;AACzB,gBAAA,UAAU,EAAE;AACR,oBAAA,SAAS,EAAE;AACP,wBAAA,OAAO,EAAE,IAAI;wBACb,UAAU,EAAE,CAAC,EAAC,SAAS,EAAC,KACpB,SAAS;AACL,8BAAE;gCACI,KAAK,EAAE,CAAU,OAAA,EAAA,SAAS,CAAE,CAAA;AAC/B,6BAAA;AACH,8BAAE,EAAE;AACZ,wBAAA,SAAS,EAAE,CAAC,EAAC,KAAK,EAAC,KAAK,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC;AAC5D,wBAAA,WAAW,EAAE,KAAK;AACrB,qBAAA;AACJ,iBAAA;AACJ,aAAA;SACJ,CAAC;KACL;IAED,WAAW,GAAA;QAIP,OAAO;YACH,YAAY,EACR,CAAC,SAAS,KACV,CAAC,EAAC,KAAK,EAAC,KACJ,KAAK,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,EAAC,SAAS,EAAC,CAAC,CAAC,GAAG,EAAE;YACvD,cAAc,EACV,MACA,CAAC,EAAC,KAAK,EAAC,KACJ,KAAK,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC,GAAG,EAAE;SAChE,CAAC;KACL;AACJ,CAAA;;AChED;;AAEG;;;;"}