paste a picture to the notebook worksheet

21 views
Skip to first unread message

lmc70

unread,
Apr 9, 2009, 3:46:43 PM4/9/09
to sage-support
Hello,

Is it possible to paste a picture, like a snapshot of a pdf file, on
the notebook worksheet?

Thank you,
lmc



mark mcclure

unread,
Apr 9, 2009, 10:08:41 PM4/9/09
to sage-support
On Apr 9, 3:46 pm, lmc70 <limingche...@gmail.com> wrote:
> Is it possible to paste a picture, like a snapshot of a pdf file, on
> the notebook worksheet?

I haven't figured out how to insert a PDF file, but you can insert
a PNG image, or any other image type that your browser will
display easy enough. To do so, access the TinyMCE code
editor by shift-clicking between cells. A small word processor
looking window will appear right in the notebook, complete
with toolbars. The 'insert/edit image' button is on the right
side of the bottom toolbar. You must specify the image by
URL but you should be able to use an image stored with
your sage worksheets easily enough.

Mark McClure

lmc70

unread,
Apr 10, 2009, 12:05:04 AM4/10/09
to sage-support
Thank you, Mark,

You actually answered my question. I don't want to insert a whole pdf
file into the notebook, instead, only part of a pdf file, like a free
body diagram etc. I take a snapshot photo picture to the part of the
pdf I want to insert and save it as a image then insert into the
notebook. To get this done, I also learned some instructions from
another thread talking about TinyMCE, they gave a lot of details on
how to insert the image, but never mention how to bring up the TinyMCE
texteditor, so I cannot figure out how to do it until you told me
shift-clicking.

The inserted image looks good. It will be even better if the image
can also be put into a cell just beside the related texts.

Thanks again,
lmc

Rob Beezer

unread,
Apr 10, 2009, 12:11:51 AM4/10/09
to sage-support
Once in a worksheet, there is a blue "Edit" button near the top, on
the right. Click this and you can type in raw HTML between cells
(which are delimted by triple braces).

The TinyMCE approach works and builds something like:
<p><img src="http://nowhere.com/foto.png" alt="" /></p>
which you could just type in as raw HTML if you wished.

On Apr 9, 7:08 pm, mark mcclure <mcmcc...@unca.edu> wrote:
> You must specify the image by
> URL but you should be able to use an image stored with
> your sage worksheets easily enough.

For an image stored locally, I've tried various combinations of using
TinyMCE and raw HTML with "file://" and "localhost:8000//" type URLs,
to various locations (near worksheets, or elsewhere), but with no
luck.

Rob

William Stein

unread,
Apr 10, 2009, 12:53:48 AM4/10/09
to sage-s...@googlegroups.com

If you do Data --> Upload File, then upload the file foo.png,
you can use <img src="foo.png">

William

Rob Beezer

unread,
Apr 10, 2009, 1:20:05 AM4/10/09
to sage-support
On Apr 9, 9:53 pm, William Stein <wst...@gmail.com> wrote:
> If you do Data --> Upload File, then upload the file foo.png,
> you can use <img src="foo.png">

Thanks, William. That does the trick.

So after uploading an image, you can just use the TinyMCE image-insert
tool, where all you need to do is put in the file name by itself into
the URL field. The image gets stored into the data subdirectory of
the worksheet, and after doing the upload there is an explanation
about a variable available in the worksheet named DATA that contains
the full pathname to this location.

William Stein

unread,
Apr 10, 2009, 1:25:55 AM4/10/09
to sage-s...@googlegroups.com

Yep. It's particularly good because then if you download the
worksheet and upload it somewhere else, the image will definitely be
there and work, even if you aren't online, etc.

William

Pat LeSmithe

unread,
Apr 10, 2009, 2:35:46 AM4/10/09
to sage-s...@googlegroups.com, sage-...@googlegroups.com
Rob Beezer wrote:
> Once in a worksheet, there is a blue "Edit" button near the top, on
> the right. Click this and you can type in raw HTML between cells
> (which are delimted by triple braces).
>
> The TinyMCE approach works and builds something like:
> <p><img src="http://nowhere.com/foto.png" alt="" /></p>
> which you could just type in as raw HTML if you wished.

There's also TinyMCE's style / CSS plug-in and toolbar button, which
might be useful in other situations:

http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/style

To activate them, backup and edit

SAGE_ROOT/local/lib/python2.5/site-packages/sage/server/notebook/notebook.py

or the devel equivalent. Starting around line 1800, in tinyMCE.init(),
replace

plugins: "table,searchreplace,safari,paste,autosave",

with

plugins: "table,searchreplace,safari,paste,autosave,style",

This enables the plug-in. To display the toolbar button, replace

link,image,unlink",

with

link,image,unlink,styleprops",

To keep TinyMCE from deactivating any *manually* inserted <style>
elements (e.g., via "Edit"), add

extended_valid_elements: "style",

after

theme_advanced_resizing : true,

In the attached screenshot, the style toolbar button is the one with two
"A"s on it.


By the way, the other "new" toolbar button in the snapshot brings up
TinyMCE's fullpage editor:

http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullpage

To enable this, too, use

plugins: "table,searchreplace,safari,paste,autosave,style,fullpage",

and

link,image,unlink,styleprops,fullpage",

Apparently, the style plugin edits only the style="" attribute of the
selected elements, but the fullpage plugin has wider scope.

It may be possible to blend these into a worksheet-specific tab or
plug-in, e.g., to change the background color of an input cell. Perhaps
double-clicking on a plot can pop up another plug-in, for editing axes,
labels, etc. I'm sure there are other possibilities!

It seems the TinyMCE developers have already done a lot of the work. Of
course, there's "some" layout work and wiring to do. If we're not
fastidious about the widget layout, perhaps we can generate much of the
boilerplate code from lists of the names and types of "the stuff that
needs setting" and Python scripts. This might make it easier to make
changes.

Or so I think. It'd be great to get input, particularly from the
JavaScript experts. Does anyone have experience developing custom
plug-ins for TinyMCE?

I've cc'd this reply to sage-devel.


> On Apr 9, 7:08 pm, mark mcclure <mcmcc...@unca.edu> wrote:
>> You must specify the image by
>> URL but you should be able to use an image stored with
>> your sage worksheets easily enough.
>
> For an image stored locally, I've tried various combinations of using
> TinyMCE and raw HTML with "file://" and "localhost:8000//" type URLs,
> to various locations (near worksheets, or elsewhere), but with no
> luck.

http://wiki.moxiecode.com/index.php/TinyMCE:FAQ#How_can_I_upload_image_files_from_my_local_computer.3F

?

styleplug.png
Reply all
Reply to author
Forward
0 new messages