mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	markdown: Add support for spoilers.
This adds support for a "spoiler" syntax in Zulip's markdown, which can be used to hide content that one doesn't want to be immediately visible without a click. We use our own spoiler block syntax inspired by Zulip's existing quote and math block markdown extensions, rather than requiring a token on every line, as is present in some other markdown spoiler implementations. Fixes #5802. Co-authored-by: Dylan Nugent <dylnuge@gmail.com>
This commit is contained in:
		@@ -153,6 +153,19 @@ exports.update_elements = (content) => {
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    content.find('div.spoiler-header').each(function () {
 | 
			
		||||
        // If a spoiler block has no header content, it should have a default header
 | 
			
		||||
        // We do this client side to allow for i18n by the client
 | 
			
		||||
        if ($.trim($(this).html()).length === 0) {
 | 
			
		||||
            $(this).append(`<p>${i18n.t('Spoiler')}</p>`);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Add the expand/collapse button to spoiler blocks
 | 
			
		||||
        const toggle_button_html = '<a class="spoiler-button" aria-expanded="false"><span class="spoiler-arrow"></span></a>';
 | 
			
		||||
        $(this).prepend(toggle_button_html);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // Display emoji (including realm emoji) as text if
 | 
			
		||||
    // page_params.emojiset is 'text'.
 | 
			
		||||
    if (page_params.emojiset === 'text') {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user