<p>If it helps, here is my complete full.json file found in config/redactor/ folder.</p>
<pre><code>{
    &quot;buttons&quot;: [&quot;html&quot;,&quot;undo&quot;,&quot;format&quot;,&quot;bold&quot;,&quot;lists&quot;,&quot;link&quot;],
    &quot;plugins&quot;: [&quot;fullscreen&quot;,&quot;table&quot;],
    &quot;toolbarFixed&quot;: true,
    &quot;buttonsTextLabeled&quot;: true,
    &quot;minHeight&quot;:&quot;100px&quot;,
    &quot;formatting&quot;: [&quot;p&quot;],
    &quot;formattingAdd&quot;: {
        &quot;heading&quot;: {
            &quot;title&quot;: &quot;Heading&quot;,
            &quot;api&quot;: &quot;module.block.format&quot;,
            &quot;args&quot;: {
                &quot;tag&quot;: &quot;h2&quot;
            }
        },
        &quot;sub-heading&quot;: {
            &quot;title&quot;: &quot;Sub-Heading&quot;,
            &quot;api&quot;: &quot;module.block.format&quot;,
            &quot;args&quot;: {
                &quot;tag&quot;: &quot;h3&quot;
            }
        },
        &quot;blockquote&quot;: {
            &quot;title&quot;: &quot;Quote&quot;,
            &quot;api&quot;: &quot;module.block.format&quot;,
            &quot;args&quot;: {
                &quot;tag&quot;: &quot;blockquote&quot;
            }
        }
    }   
}
</code></pre>

CC BY-SA 4.0
2023-09-01T22:21:41.433Z
Thanks, Paul
You config file does not set a data attribute, does it? I had the hunch that the args part might work but writing
```"args": { "data-cursor": "projekt-link" } ```
still does not add a data attribute. Did I miss something in your code?
Moritz
CC BY-SA 4.0
2023-09-02T07:47:09.243Z
Sorry Moritz, I missunderstood the significance of the data-attribute part of your question. I thought the problem might have been the whole structure of your json file as you only shared part of it.
Paul Frost
CC BY-SA 4.0
2023-09-02T09:16:13.080Z
Thanks for sharing anyway! No, everything works just fine, only the data attribute is ignored. Cheers to you.
Moritz
CC BY-SA 4.0
2023-08-31T14:14:06.920Z
2023-08-31T14:14:06.920Z
Paul Frost
<p>According to <a href="https://imperavi.com/redactor/docs/settings/formatting/#s-formattingadd" rel="nofollow noreferrer">redactor’s documentation</a> it should be possible to add a data attribute to a block format. The code below works except from the data-cursor part (the block is styled italic and receives the project__link class).</p>
<p>I checked: The data attribute is already missing in the backend after assigning the block format.</p>
<p>Does someone have experience in adding data attributes to redactor text? Thanks for your help!</p>
<pre><code>{
    &quot;link&quot;: {
      &quot;title&quot;: &quot;Link&quot;,
      &quot;api&quot;: &quot;module.block.format&quot;,
      &quot;args&quot;: {
        &quot;tag&quot;: &quot;p&quot;,
        &quot;attr&quot;: {
          &quot;class&quot;: &quot;project__link&quot;,
          &quot;data-cursor&quot;: &quot;project-link&quot;
        },
        &quot;style&quot;: {
          &quot;font-style&quot;: &quot;italic&quot;
        }
      }
    }
  }
}
</code></pre>

<redactor>
Redactor: Assign data attribute
# Redactor: Assign data attribute

(Asked by: username_0 on 2023-08-30)

According to redactor’s documentation it should be possible to add a data attribute to a block format. The code below works except from the data-cursor part (the block is styled italic and receives the project__link class).
I checked: The data attribute is already missing in the backend after assigning the block format.
Does someone have experience in adding data attributes to redactor text? Thanks for your help!
{
    "link": {
      "title": "Link",
      "api": "module.block.format",
      "args": {
        "tag": "p",
        "attr": {
          "class": "project__link",
          "data-cursor": "project-link"
        },
        "style": {
          "font-style": "italic"
        }
      }
    }
  }
}

**Tags:** redactor

---

## 1 answers

### Answer by username_1 on 2023-08-31. Score: 1

If it helps, here is my complete full.json file found in config/redactor/ folder.
{
    "buttons": ["html","undo","format","bold","lists","link"],
    "plugins": ["fullscreen","table"],
    "toolbarFixed": true,
    "buttonsTextLabeled": true,
    "minHeight":"100px",
    "formatting": ["p"],
    "formattingAdd": {
        "heading": {
            "title": "Heading",
            "api": "module.block.format",
            "args": {
                "tag": "h2"
            }
        },
        "sub-heading": {
            "title": "Sub-Heading",
            "api": "module.block.format",
            "args": {
                "tag": "h3"
            }
        },
        "blockquote": {
            "title": "Quote",
            "api": "module.block.format",
            "args": {
                "tag": "blockquote"
            }
        }
    }   
}

> **Comments:**
> **username_0**: Thanks, Paul You config file does not set a data attribute, does it? I had the hunch that the args part might work but writing ```"args": { "data-cursor": "projekt-link" } ``` still does not add a data attribute. Did I miss something in your code?  
> **username_1**: Sorry Moritz, I missunderstood the significance of the data-attribute part of your question. I thought the problem might have been the whole structure of your json file as you only shared part of it.  
> **username_0**: Thanks for sharing anyway! No, everything works just fine, only the data attribute is ignored. Cheers to you.  

---

