0
votes

I'm using TinyMCE WYSIWYG editor in my html form. I want to change icons (16x16 images) of existing toolbar buttons, i.e. bold button, italic button, etc. The idea is to put my own drawings instead of basic B, I, etc icons.

I found how to add a brand new button with my custom icon to toolbar via tinymce.Editor.addButton('myButton', {... 'image': '/path/to/my/drawing'}) method, but I still have no idea how to replace icons for already existing buttons.

3

3 Answers

2
votes

an other solution, in CSS (Work on IE 11, Firefox 67.x and Chrome 74) for TinyMce v5 :

Image example

Please note that the word Gras in ...[aria-label="Gras"] is a result of translate, so you must change it in your own code.

    /*Hide original svg:*/
    .tox-tbtn[aria-label="Gras"] .tox-icon svg {
        display: none;
    }

    /*Dimensions of svg icon:*/
    .tox-tbtn[aria-label="Gras"] .tox-icon {
        display: list-item;
        list-style: none;
        width: 18px;
        height: 18px;
    }

    /*Svg icon:*/
    [aria-label='Gras'].tox-tbtn .tox-icon {
        background-image: url("/build/admin/images/tinyMceBoutonGras.svg");
        background-repeat: no-repeat;
        background-position: center center;
    }

Here, the same example with SVG convert in Base64 :

    /*Hide original svg:*/
    .tox-tbtn[aria-label="Gras"] .tox-icon svg {
        display: none;
    }

    /*Dimensions of svg icon:*/
    .tox-tbtn[aria-label="Gras"] .tox-icon {
        display: list-item;
        list-style: none;
        width: 18px;
        height: 18px;
    }

    /*Svg icon (In base64):*/
    [aria-label='Gras'].tox-tbtn .tox-icon {
        background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIiAgIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIgICB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLz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DMgLTAuNDU3OTAyNCwtMC4wNjQzIC0wLjI4NDc5MywwIC0wLjUxNjUzNjMsMC4wODM4IC0wLjIzMTc0MzIsMC4wODM4IC0wLjQxNjAyMSwwLjI1Njg4IC0wLjE3NTkwMTYsMC4xNjc1MiAtMC4yNzkyMDg5LDAuNDI3MTkgLTAuMTAwNTE1MSwwLjI1Njg3IC0wLjEwMDUxNTEsMC41OTQ3MSAwLDAuNjg5NjUgMC4zNjU3NjM1LDEuMDU1NCAwLjM2NTc2MzUsMC4zNjU3NyAxLjA4MDUzOCwwLjM2NTc3IDAuMDYxNDI2LDAgMC4xMzQwMjAyLC0wLjAwMyAwLjA3NTM4NiwtMC4wMDMgMC4xMzY4MTI0LC0wLjAwOCB2IC0wLjgxNTI4IEggMi4zODM5MDQgdiAtMC43ODQ1OCBoIDEuOTE4MTY0NCB6IiAvPiAgICA8L2c+ICA8L2c+PC9zdmc+);
        background-repeat: no-repeat;
        background-position: center center;
    }

Hope this help, Yan

0
votes

I found the solution, but probably you know easier ways, so feel free to answer.

It could be done by creating your own skin for TinyMCE. But skins don't look easy to create and TinyMCESkinCreator doesn't seem help in deep customization. So I found cool third-party skin which has evident place for storing of these icons - img/sprites16px.png. So I was able to redraw any of them in graphic editor.

I successfully replaced B letter for bold to russian letter Ж by editing the spritelist:

my result