Convert angular view into image for clipboard - angularjs

I would like to render a view from an Angular directive into an image so that a user could right click on it, and copy it to clipboard. Basically I have a directive that compiles information into a nice Bootstrap scaffold with styling and would like to be able to right click, copy to clipboard, and paste into a document as a img type.
Imagine:
<div class="fancyCss">
<MyCustomHeaderDirective2 dataVal="foo"></MyCustomHeaderDirective2>
<MyCustomBodyDirective2>
<div class="row">
<- Content ->
</MyCustomBodyDirective2>
</div>
So On the page they load up the correct 'foo', see the fancy table, right click, and voila, jpg of table in your clipboard. Currently the process is render, get out snipping tool, click and drag,copy, paste.
For clarity: IS this possible? Does a library exist for this? Most importantly, how do I implement this with an angular directive?

If you are looking for pure client side solution:https://html2canvas.hertzen.com/
Alternatively for more customisable and foolproof solution, you can pass your DOM with inline styling to the server side and render it using phantomJS. Take a snapshot, save it as an image and send back to client.

There is a library available
http://hertzen.com/experiments/jsfeedback/
http://html2canvas.hertzen.com/
How it works
It capturing the html dom content and pasting inside a canvas
In Canvas you can convert the content to image format

Related

Wagtail: How to render the blocks dynamically on Admin panel?

In wagtail, I need to make a Struct/Stream Block
There is a dropdown on the top of the block(Image/Video)
If editor choose Image, VideoChooserBlock should be hidden.
And if editor choose Video, ImageChooserBlock should be hidden.
class MyBlock(StruckBlock):
category = ChoiceBlock(choices=(("image", "image"),("video", "video")))
image = ImageChooserBlock()
video = videoChooserBlock()
Here, editor should be able to choose only image or video depending on category.
Any help is appriciated.
Thanks
You may find it useful to review the code of wagtail-link-block which does something similar.
Main files to focus on:
blocks.py for displaying fields conditionally based on a ChoiceBlock
static/link_block/link_block.js and static/link_block/link_block.css to handle the DOM manipulation and styling with JavaScript and CSS
wagtail_hooks.py to insert JS and CSS

Can not write text at left align after adding Image with a caption in Froala editors

Steps to reproduce the issue::
Open the froala editor on https://www.froala.com/wysiwyg-editor.
Remove everything in the editor.
Insert an image.
Add a caption to the image.
Click outside the image and try to type.
Issue: After adding image caption, If write any text then it always written inside the image area[blue color]
Video:
In Froala: https://github.com/froala/wysiwyg-editor/issues/2597#issuecomment-386163085
Can anyone help me?
If you look at your browser's dom inspector you will see that erasing the content and adding the image leaves you with one element wrapping the image and caption, and therefore no-where else to set focus to continue typing. The quickinsert feature also fails to show as there are no block boundaries to trigger it.
Froala Editor offers a decent events API, and there is a workaround via the 'image.inserted' event which fires when an image element is added into the editor. The code below listens for this event and inserts a new para element immediately after Froala's wrapping elements around the image. When typed, your caption text is part of Froala's wrapper around the image, leaving this new para ready to accept focus and let you type into it.
$('#yourselector').on('froalaEditor.image.inserted', function (e, editor, $img, response) {
$img.after("<p>Type something here</p>"); // insert a new para or div here
});
Note the downside of the simple workaround is that you get extra content injected, but the benefit hopefully outweighs that for your use-case.
This is a plain JS solution which hopefully you can adapt for your environment.
I have previously failed to add JS snippets for Froala to SO so provide this codepen working example.
Is this what you are looking for? The text is after the image caption and not inside the image area [blue bordered].

angularjs pdf viewer - select text of pdf

I use this directive to view pdfs:
PDF Viewer
and it really works fine. The only thing I would need is also to select text in PDF. Is there a possibiliy to do this or is it not doable?
Actually I am not sure if I am right but is it an image or is it the real pdf which is shown?
It is not possible to do this. If you inspect the HTML you will see the PDF is rendered in a canvas element. So it is an image that is shown rather than an actual PDF.

linking two articles using an image

I am trying to link an image within an article to another article but when clicked all I get is a larger version of the image opening top of page. Tried amending html img src, used JCE editor to create links, created a hidden menu item and copied syntax, all to no avail. Any ideas please?
Thanks
I think what you are trying to do is this:
<img src="http://placehold.it/350x150">
Just wrap your image in an anchor tag with it pointing to the site you want to go to.

Appgyver: How to use Ionic Icons or images in super-navbar?

I am trying to use navigation images on left as well right of <super-navbar> but it is stated in the official documentation, that only text is supported in super-navbar buttons. But there must be some way around to do this. Below is my code, where I want to place images instead of text:
<super-navbar>
<super-navbar-button side="left" id="hamburger" onclick="supersonic.ui.drawers.open()">Menu</super-navbar-button>
<super-navbar-title>MyApp</super-navbar-title>
<super-navbar-button side="right">Search</super-navbar-button>
</super-navbar>
Instead of "menu" text I want to have hamburger type icon or png image at least. Same for search text.
Thanks.
This can be accomplished right now by removing the <super-navbar> section and writing your own html header.
If you look in the layout file for your project there is an import statement as you mentioned:
<link rel="import" href="/components/supersonic/components/import.html">
There is a section that states:
* #name super-navbar-button
* When used inside theelement, creates a button that will be displayed on the navigation bar. Only text content is supported for the button title.
Support for icons has been requested. You can subscribe to their github to get notifications of issues. https://github.com/AppGyver/steroids
One work around to be able to keep using <super-navbar> and have icons is to use something like this which will render as ≡
<super-navbar-button ng-click="toggleMenuDrawer()">
≡
</super-navbar-button>
They have a good forum on Muut as well. This issue is most likely related to trying to add icons in the <super-navbar>. I experienced a disappearing navbar after trying to add markup: <i class="icon super-search"></i>
It works in the main content area, but makes the navbar behave differently when nested in a <super> element.

Resources