How to add a picture in the Texteditor (Inputfield)

Started by Draffi, September 28, 2013, 07:44:32 AM

Previous topic - Next topic

Draffi

Hi!

I want to ask, if somebody have an idea or code snippet, for how to show a picture inside the texteditor (i mean not inside the BBC-Button, i mean the main input area, where are you typing the text...)

Thank you!

emanuele



Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Draffi

Exactly. A background for the Textarea-Inputwindow.

(I want to make a PNG-Picture, with 50% Transparency, no background, only some words:
1. Respect the members
2. Respect the rules
3. We all are human
4. ...
)

Saw this in another SMF-Forum. When you click inside the Texteditor, the Picture is gone and you see the cursor and you can start to write a posting...

margarett

According to my firebug, the text area is this:

<textarea id="message" class="editor" style="height: 175px;" tabindex="2" onchange="storeCaret(this);" onkeyup="storeCaret(this);" onclick="storeCaret(this);" onselect="storeCaret(this);" cols="600" rows="12" name="message"></textarea>

So I see a "editor" class, that comes from editor.css.
It should be possible to do so using some new rules to make a semi-transparent background:
http://www.w3schools.com/css/css_image_transparency.asp
http://stackoverflow.com/questions/4183948/css-set-background-image-with-opacity
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Arantor

There are two different ways the editor can be used, one in regular mode and one in WYSIWYG - and the WYSIWYG mode is quite a bit different in terms of handling (it doesn't use a textarea at all, but an iframe with contenteditable... and it's different again in 2.1)

I really don't know if there will be a problem trying to use this in WYSIWYG mode thinking about it.

margarett

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

emanuele

The new (2.1) editor should be easy to customize with css, I remember the old editor (2.0) is able to grab some styles from the "normal" editor, though I don't remember exactly which.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Draffi

Thank you for your replies.

It should looks like this (see Attachment)

(taken from www.biology-forums.com)


margarett

Now I missed what you mean, sorry.

That's a forums index, there is no text area there.
Did you look at my reply? Can you try those tips or do you need further help?
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

IchBin™

.editor, .rich_editor {
    background-image('path/to/image.png');
}
IchBin™        TinyPortal

Antechinus

What he said. Although you would also want to add this to make the image vanish on focus:

.editor:focus, .rich_editor:focus {
    background-image: none;
}

Arantor

Does that work with the rich editor too? Didn't think it'd work properly with the contenteditable iframe. (But that's why I leave the CSS to people who know it better than I do ;D)

Antechinus

Dunno. Haven't tried it. I assumed IchBin had the basics right. :D

Anyway, if it doesn't work it'll be an easy fix. It's just a matter of basic targeting.

Tomy Tran


Draffi

Quote.editor, .rich_editor {
    background-image('path/to/image.png');
}

was putting my pic into the directory called "style", but not working.

.editor, .rich_editor {
   background-image: url(../images/style/editor.png);
}


Any suggestions more, please?


Antechinus


Draffi

i put in the index.css the following

.editor, .rich_editor {
   background-image: url(../images/style/editor.png);
}

IchBin™

The code I posted should work for the non-wysiwyg mode. Clicking to toggle into the wysiwyg mode requires altering the javascript though. Looks like for the rich editor you have to add it to the editor.js file to add it into the iframe.

Search for:
                // Set the frame padding/margin inside the editor.
                this.oFrameDocument.body.style.padding = '1px';
                this.oFrameDocument.body.style.margin = '0';


Add this line after:
                this.oFrameDocument.body.style.background = 'url(' + smf_images_url + '/editor.png)';
IchBin™        TinyPortal

Draffi

Thank you!

The picture is showing up.

But it is repeating (in my case three times) and furthermore it would be better, if the picture disappear, when you start to enter text (click inside).

Do you think it is possible?

margarett

Did you try this?
Quote from: Antechinus on September 29, 2013, 07:39:34 PM
What he said. Although you would also want to add this to make the image vanish on focus:

.editor:focus, .rich_editor:focus {
    background-image: none;
}

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Advertisement: