admin管理员组

文章数量:1125027

<font style="background-color: rgb(255, 255, 0);" color="#ff0000">Write something</font>

Above tag generated by Summernote; the color property came outside of the style attribute. How can I fix this issue?" anyone found same problem that iam facing if you found let me know it will help me lot

<font style="background-color: rgb(255, 255, 0);" color="#ff0000">Write something</font>

Above tag generated by Summernote; the color property came outside of the style attribute. How can I fix this issue?" anyone found same problem that iam facing if you found let me know it will help me lot

Share Improve this question edited 2 days ago user28570838 asked 2 days ago user28570838user28570838 11 bronze badge New contributor user28570838 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. 1
  • color is a valid attribute in a <font> tag. What issue are you having? Is the font colour not showing red? – Musa Commented yesterday
Add a comment  | 

1 Answer 1

Reset to default 0

using <span> with a style attribute instead of <font> tags is more modern and widely supported you could override summernote's default behavior for formatting and ensure it generates <span> instead of <font>.

$('#summernote').summernote({
  toolbar: [
    ['style', ['bold', 'italic', 'underline', 'clear']],
    ['color', ['color']],
    ['para', ['ul', 'ol', 'paragraph']],
  ],
  popover: {
    color: [
      ['red', 'green', 'blue'],  
      ['#800000', '#013220', '#00008B'],  
    ],
  },
  callbacks: {
    onChange: function(contents) {
      // replacing <font> tag with <span> tag

      const fixedContents = contents.replace(
        /<font([^>]*?)color="([^"]*?)"/g,
        '<span$1 style="color:$2;"'
      ).replace(/<\/font>/g, '</span>');
      console.log(fixedContents);            // for debugging
    },
  },
});

本文标签: djangofont Tag issue in summer noteStack Overflow