Blockquotes

Last post 06-02-2004, 7:25 AM by mgoodson. 4 replies.
Sort Posts: Previous Next
  •  05-28-2004, 9:42 AM 895

    Blockquotes

    Hi, I really need users to be able to mark up text with <blockquote> tags, and avoid them nesting these within <p>'s.

     

    Is there a way to customize the paragraph dropdown list to add a new item 'blockquote' which will nest the selected text in <blockquote>'s, in the same way that heading tags are currently added ?

     

    thanks

     

    marc

     

     

  •  05-28-2004, 10:12 AM 899 in reply to 895

    Re: Blockquotes

    Marc,

     

    You can create a custome button which use execCommand('FormatBlock', true, '<blockquote>');  I will add this request to the new version as well. It's much easier.


    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  05-28-2004, 11:43 AM 901 in reply to 899

    Re: Blockquotes

    Thanks for your quick reply,

     

    sorry I must be missing something in the documentation but:-

     

    I register a new button with the control

     

    and add the onclick attribute to be

     

    myNewImage.Attributes.Add("onclick", "_Format('myRichTextBox','blockquotes');")

     

    then in the _Format javascript function I am adding a new case/switch

    case "blockquotes":

    editor.document.execCommand('FormatBlock', true, '<blockquote>');

    break;

     

    but nothing happens when I click it

    am I doing something stupid ?

     

    regards

     

    marc

     

     

  •  06-01-2004, 11:11 AM 909 in reply to 901

    Re: Blockquotes

    marc,

     
    You didn't miss anything.
     
    I made a test as well. It looks like the following code doesn't work at all:
     
    document.execCommand('FormatBlock', true, '<blockquote>');
     
     
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  06-02-2004, 7:25 AM 911 in reply to 909

    Re: Blockquotes

    Hi Adam

     
    Yes for some reason it seems not to work, it could be that the .execCommand('Indent') is meant to replace it, this inserts <blockquote>s however it includes some inline style attributes,  and also nests <p> tags, which is specifically what I'm trying to avoid ! ie like this
     
    <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
    <P>Test</P></BLOCKQUOTE>
     
    as I'm trying to quickly get this up and running, I've gone for a bit of a dodgy workaround, on the basis that I don't need to use <ADDRESS> tags, I use .execCommand('FormatBlock', false, '<ADDRESS>') then use regex's to replace the <ADDRESS> tags with <BLOCKQUOTES>
     
    can you think of a better way ?
     
    my code below:-
     
     

    function doBlockQuotes(EditorID) {

    var editor = document.getElementById(EditorID);

    checkRange(EditorID);

    // ideally we want to use .execCommand('FormatBlock',false,'<BLOCKQUOTE>') but it does not work :-(

    // So since we are NEVER (famous last words) going to use the <ADDRESS> block functionality, but want our blockquote button to work like that

    // we first change the block into <ADDRESS> tags, using the FormatBlock functionality of the execCommand

    editor.document.execCommand('FormatBlock',false,'<ADDRESS>');

    // then sneakily we use regex's to replace <ADDRESS> tags with <BLOCKQUOTE> tags

    editor.innerHTML = editor.innerHTML.replace(/<(\/?)ADDRESS>/gi, "<$1BLOCKQUOTE>");

    // then we tidy any extra <BLOCKQUOTES> that have been unhelpfully added.

    editor.innerHTML = editor.innerHTML.replace(/<BLOCKQUOTE>\s*?<BLOCKQUOTE>/gi, "<BLOCKQUOTE>");

    editor.innerHTML = editor.innerHTML.replace(/<\/BLOCKQUOTE>\s*?<\/BLOCKQUOTE>/gi, "<\/BLOCKQUOTE>");

    editor.innerHTML = editor.innerHTML.replace(/<BLOCKQUOTE>\s*?<\/BLOCKQUOTE>/gi, "");

    }

    function unBlockQuotes(EditorID) {

    checkRange(EditorID);

    // well you'd think that selecting normal from the paragraph menu would revert the <blockquotes> back into <p>'s

    // it does if you try it twice (once to insert <p>'s inside the <blockquotes>, the 2nd time, removing the <blockquotes>)

    // that may be liveable with if not

    var editor = document.getElementById(EditorID);

    // change the formatBlock to be normal paragraphs

    editor.document.execCommand('FormatBlock',false,'<P>');

    // use regexs to tidy up nested <P> tags inside <blockquotes>

    editor.innerHTML = editor.innerHTML.replace(/<BLOCKQUOTE>\s*?<P>/gi,"<P>");

    editor.innerHTML = editor.innerHTML.replace(/<\/P>s*?<\/BLOCKQUOTE>/gi,"<\/P>");

    editor.innerHTML = editor.innerHTML.replace(/<BLOCKQUOTE>\s*?<\/BLOCKQUOTE>/gi, "");

    }
     
    and a couple of toolbar images
     
     
    regards
     
     
    marc
     
     
     
     
View as RSS news feed in XML