modxcms / fred

The friendly front-end editor for visual, drag-and-drop content building in MODX CMS
https://fred.modx.com
MIT License
57 stars 25 forks source link

FRED Not saving links #490

Closed DmitryFX closed 5 months ago

DmitryFX commented 11 months ago

I have an element with custom RTE config to easily edit links.

image

{
  "theme": "modern",
  "inline": true,
  "menubar": "link",
  "plugins": "link",
  "toolbar": "link",
  "forced_root_block": "",
  "allow_unsafe_link_target": true,
  "target_list": [
    {
      "title": "В той же вкладке",
      "value": "_self"
    },
    {
      "title": "В новой вкладке ",
      "value": "_blank"
    }
  ]
}

The link attributes are updated, when closing RTE editor:

<a href="https://avan.ru" class="btn btn_simple js-tabs__tab is-active mce-content-body mce-edit-focus" data-fred-name="link_adress" data-fred-rte="true" data-fred-rte-config="Fred_RTE_Link" data-fred-editable="true" contenteditable="true" id="mce_3" style="position: relative;" spellcheck="false" data-mce-href="https://avan.ru" target="_self">ЧТО ВЗЯТЬ С СОБОЙ</a>

But not saved after saving the page and refreshing or viewing it in the regular web context. Href attr is switched back to default empty state:

<a href="" class="btn btn_simple js-tabs__tab is-active">ЧТО ВЗЯТЬ С СОБОЙ</a>
matdave commented 5 months ago

You can't put data-fred-name="link_adress" and data-fred-rte="true" on an anchor as that will trigger two different behaviors. You would need to do one or the other.

If you want the link to be fully editable with MCE, how I will generally set that up is something like

<span data-fred-name="link" data-fred-rte="true" data-fred-rte-config="cta"><a href="example.com">Insert Link</a></span>

Then I will set the CTA RTE Config up like this example:

{
  "theme": "inlite",
  "inline": true,
  "plugins": "link contextmenu code",
  "selection_toolbar": "bold italic | link | code",
  "valid_elements": "a[href|target|class],br,strong,em,span"
}