craft-redactorcustomstyles icon indicating copy to clipboard operation
craft-redactorcustomstyles copied to clipboard

clearStyles not working

Open keyurkadam opened this issue 2 years ago • 8 comments

please check this.

{ "buttons": [ "html", "formatting", "bold", "italic", "unorderedlist", "redactoranchors", "orderedlist", "link", "file", "image", "video", "sup" ], "plugins": [ "alignment", "widget", "fullscreen", "video", "table", "customstyles", "redactoranchors" ], "linkNewTab": true, "toolbarFixed": true, "imageResizable": true, "imagePosition": true, "imageFloatMargin": "20px", "customstyles": { "customStyles": { "dropdown": { "Download Button": { "args": { "tag": "div", "class": "btn file-dwonload-a", "type": "toggle" }, "title": "Download Button" }, "Special Headeing": { "args": { "tag": "div", "class": "special-headeing", "type": "toggle" }, "title": "Special Heading" }, "clearStyles": { "api": "module.inline.clearformat" } } } } }

keyurkadam avatar Jan 24 '23 05:01 keyurkadam

The module.inline.clearformat API is clearing attributes of “inline” tags only. And you’ve got div tags it looks like?

carlcs avatar Jan 24 '23 09:01 carlcs

okay so how can i clear div tag?

keyurkadam avatar Jan 24 '23 11:01 keyurkadam

Good question @keyurkadam. What’s your goal, convert the div to a p or h2 tag?

carlcs avatar Jan 24 '23 17:01 carlcs

The goal is to add a div tag after a user clicks "Special Heading" and to remove it after they click "clearStyles". is it possible?

keyurkadam avatar Jan 25 '23 03:01 keyurkadam

You can try the module.block.clearformat API if you want to clear block formatting.

https://imperavi.com/redactor/docs/api-modules/#s-clearformat

Or you setup multiple formatting options with module.block.format to switch between them. This should be basically identical as adding them to the default Formatting dropdown using the formattingAdd setting.

https://imperavi.com/redactor/docs/api-modules/#s-format https://imperavi.com/redactor/docs/settings/formatting/#s-formattingadd

carlcs avatar Jan 25 '23 13:01 carlcs

I’ve just added an dropdown for link styles to the example config file, that you might want to take inspiration from for your download button.

https://github.com/carlcs/craft-redactorcustomstyles/blob/393d283cebd46d3e7191e39958d35326e39b6c50/_examples/redactor/Example.json#L45-L63

carlcs avatar Jan 25 '23 14:01 carlcs

@carlcs sorry but not working. i have also tried your json but still "clear style" and "add class" not working. https://drive.google.com/file/d/1wFTGTEcXcYHZjtGw7jc0FHVN1QETYXG-/view

keyurkadam avatar Jan 26 '23 04:01 keyurkadam

@carlcs any update on this?

keyurkadam avatar Jan 30 '23 04:01 keyurkadam