RocketChat / feature-requests

This repository is used to track Rocket.Chat feature requests and discussions. Click here to open a new feature request.
21 stars 9 forks source link

Show messages as plain text #20

Open frafu opened 6 years ago

frafu commented 6 years ago

We are using rocket chat in our dev team and we are copy/pasting code snippets, logfile snippes, xml, json and so on. This is plain text and in this use case it sucks that the blanks are stripped away.

Is there any possibility to change the rendering to plain text with a fixed width font style? I played around with css settings, but it seems, that the text that is displayed is not exactly the same I pasted in to the chat input field. So, just adding "white-space: pre;" does not help.

Any idea?

vynmera commented 6 years ago

just wrap your code in ``` tags

frafu commented 6 years ago

is there a way to have this as default input mode?

frafu commented 6 years ago

Or is it possible to add a custom javascript that hooks to the "send message" button and wraps the message in this quotes?

frafu commented 6 years ago

Now, I am using this script in the "custom script for logged in users:"

$('textarea[name="msg"]').bind('paste', function () {
    setTimeout(function() {
        $('textarea[name="msg"]').val("```" + $('textarea[name="msg"]').val() + "```")
     }, 10);
})

Works well in the web client - but it is ignored in the linux client "Rocket.Chat+" Any idea why?

UPDATE: it works only in google chrome - not in firefox

frafu commented 6 years ago

NOW, I have a working (but maybe dirty) solution. It capture the ctrl-v event and add three backticks around the text in the msg textarea. So, whenever I paste some text into the msg area, it is automatically quoted. Works for me.

This is the code in "custom script for logged in users":

var pasteControl = false
$(document).ready(function () {
    //console.log("START")
    $(document).on('keydown', function (e) {
        //console.log(e.which)
        if (e.which == 17) {
            pasteControl = true
        }
        if (e.which == 86 && pasteControl == true) {
            //console.log("PASTE")
            setTimeout(function () {
                if ($('textarea[name="msg"]').val().trim() != "" && !$('textarea[name="msg"]').val().trim().startsWith("```")) {
                    $('textarea[name="msg"]').val("```" + $('textarea[name="msg"]').val() + "```")
                }
            }, 10);

        }

    });

    $(document).on('keyup', function (e) {
        if (e.which == 17) {
            pasteControl = false
        }
    });
});
frafu commented 6 years ago

Oh, no. Works only in the Linux Client. Not in the Windows Client. :-(

reetp commented 6 years ago

Duplicate or very similar to https://github.com/RocketChat/Rocket.Chat/issues/11772

timkinnane commented 5 years ago

Use triple back ticks to render code blocks. Markdown syntax... "code"

On Sun., 17 Feb. 2019, 2:37 pm frafu, notifications@github.com wrote:

We are using rocket chat in our dev team and we are copy/pasting code snippets, logfile snippes, xml, json and so on. This is plain text and in this use case it sucks that the blanks are stripped away.

Is there any possibility to change the rendering to plain text with a fixed width font style? I played around with css settings, but it seems, that the text that is displayed is not exactly the same I pasted in to the chat input field. So, just adding "white-space: pre;" does not help.

Any idea?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/RocketChat/feature-requests/issues/20, or mute the thread https://github.com/notifications/unsubscribe-auth/ABsTKyFBhNEbiHH1U86EWmKvkszDorsiks5vOM5lgaJpZM4a_V5x .

RichardKirk commented 3 years ago

The three back ticks does not seem to work for me on Safari (Big Sur). This is useful for quoting formatted output to terminals.