How to upload Image from desktop in CKEditor in Angular 6 - angular6

I have tried lots of things but I could not find any solution for that, How can I upload an image from the desktop in CK Editor in Angular 6. How can I configure that?

You need to write some code to insert images or links to images from your server path.
Try that:
<ckbutton [name]="'imageExplorer'"
[command]="'openImageExplorer'"
(click)="openImageExplorer($event)"
[icon]="'./images/Icon.png'"
[label]="'Open image explorer'"
[toolbar]="'insert,1'">
</ckbutton>
Config File:
this.ckeConfig = {
height: 400,
language: "en",
allowedContent: true,
toolbar: [
{ name: "clipboard", items: ["Cut", "Copy", "Paste", "PasteText", "PasteFromWord", "-", "Undo", "Redo"] },
{ name: "links", items: ["Link", "Unlink", "Anchor"] },
{ name: "insert", items: ["Image", "Table", "HorizontalRule", "SpecialChar", "Iframe", "imageExplorer"] }
]
};
In your dialog window insert the link:
onAddImage() {
try
{
let link = this.ckeditor.instance.document.createElement("img");
link.setAttribute("alt", "Image");
link.setAttribute("src", "./Images/test.png");
this.ckeditor.instance.insertElement(link);
}
catch(error)
{
console.log((<Error>error).message);
}
this.showFiles = false;
}
For Documentation
Hope it helps thanks.

Related

NUXTJS | Error on loading css / layout the first call

I am playing as a newbie with Nuxtjs. I bought an html template to transform it as Nuxtjs project. The template, there are several css to display out a good layout.
There are issues on loading a page.vue as first call but if I reload it, the layout/css are displayed correctly.
My tries were:
- Adding css: [ ... ] at nuxt.config.js as global.
- Added css as script injected into the page.vue as follow:
export default {
head () {
return {
link: [
{ rel: 'stylesheet', type: 'text/css', href: './css/animate.css' },
{ rel: 'stylesheet', type: 'text/css', href: './css/et-line.css' },
],
}
}
}
I appreciate your clues & tricks.
Put your css files to assets or static folder. More info about the difference you could find in the doc: https://nuxtjs.org/guide/assets#static
Plug it in nuxt.config.js as so:
css: ["~assets/main.css"] or css: ["~/static/static.css"]
Rebuild the project

How to display timestamped data with PrimeFaces and ChartJs?

Since the public 7.0 release of PrimeFaces includes ChartJs, I thought I'd give it a try.
It works fine, however so far I have not been able to properly display data with values changing over time in a line chart.
chart.js has cartesian time axes for this purpose, however in PrimeFaces , only CartesianLinearAxes is available.
Feeding date objects (instead of String labels) to ChartData simply results in no x-axis being drawn.
Am I missing something or did they just skip this functionality when including chart.js in Primefaces?
OK great questions.
First, PF knows they did not implement time yet but there is an open ticket: https://github.com/primefaces/primefaces/issues/4564
Second, have no fear you can use the Extender feature to make it work. Here is an example we used.
In your Java model for your chart set the Extender feature on.
chartModel.setExtender("chartExtender");
In your XHTML add this JavaScript code function to match when you set in #1 Java bean.
function chartExtender() {
//copy the config options into a variable
var options = $.extend(true, {}, this.cfg.config);
options = {
//remove the legend
legend: {
display: false
},
scales: {
xAxes: [{
display: true,
type: "time",
time: {
parser: 'h:mm:ss a',
tooltipFormat: 'h:mm:ss a',
unit: 'hour',
displayFormats: {
'hour': 'h:mm:ss a'
}
}
}],
yAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Your Y Axis',
fontSize: 13,
}
}]
}
};
//merge all options into the main chart options
$.extend(true, this.cfg.config, options);
};
You can see the different time formats available from ChartsJS using MomentJS.
Just a complement to do the extender works, use this.cfg.config.options = {...
for exemple:
function extName() {
this.cfg.config.options = {
legend: {
display: false
}
};
};

How to add header and footer in pdf using jquery datatable

I am unable to add a header and footer in my PDF using jQuery DataTables with TableTools extension. Can anyone give me any idea?
This is my code:
var oTable;
var line1Value,line2Value;
var myVar = "<img src='../macro/$proj/images/images.jpg' alt='myImage' title='myImage'/>"
\$(document).ready(function(){
oTable=\$('#PdfTable').DataTable({
"scrollY":"500px",
"scrollCollapse": true,
"paging":false,
dom: 'T<"clear">lfrtip',
tableTools: {
"sSwfPath": "../macro/$proj/js/Pdfjs/copy_csv_xls_pdf.swf",
"aButtons": [
"copy",
"csv",
"xls",
{
"sExtends": "pdf",
'sTitle': "Benchmark Report",
"sPdfOrientation": "landscape"
},
"print"
]
}
});
});
This is not possible.
It requires changing the swf action script file ('copy_csv_xls_pdf.swf' or 'flashExport.swf').
TableTools uses the AlivePDF library ( http://alivepdf.bytearray.org ) for creating PDFs. The AS3 code used by TableTools is here: https://github.com/DataTables/TableTools/blob/master/media/as3/ZeroClipboardPdf.as.
Source: https://datatables.net/forums/discussion/19049/customizing-pdf
You can use header and footer property like this
$("#example").DataTable({
header : true,
footer: true,
});
This way you can enable to print header and footer.

Creating Chrome extensions to hide DIV display:none; on a specific page

I'm trying to create my first Chrome extension.
It's basically an adblocker for specific elements, in this case - the Facebook comments section.
It works with the all_urls but not with that specific domain.
Manifest file:
{
"name": "My extension",
"version": "1.0",
"manifest_version": 2,
"content_scripts": [
{
"matches": ["http://visir.is/*"], //where your script should be injected
"css": ["style.css"] //the name of the file to be injected
}
]
}
style.css file:
.fbcomment {
display: none;
}
Any ideas how to correct "matches"?
I have tried *://visir.is/* as specified in https://developer.chrome.com/extensions/match_patterns but it only works with all_urls
Viktor,
You are on the wrong way. Your extension should work on Facebook site, and so the matches statement in the manifest must be exactly as the following:
"matches": ["https://www.facebook.com/*"]
Than you need to find all the comments in the timeline (most probably by css class), detect the presence of the target site address (//visir.is/) and then hide these comments.
Because the timeline dynamically load more posts you will also need to observe the new nodes and apply your function on them too (see the example from my Chrome extension below):
var obs = new MutationObserver(function (mutations, observer) {
for (var i = 0; i < mutations[0].addedNodes.length; i++) {
if (mutations[0].addedNodes[i].nodeType == 1) {
$(mutations[0].addedNodes[i]).find(".userContentWrapper").each(function () {
injectFBMButton($(this));
});
}
}
injectMainButton();
});
obs.observe(document.body, { childList: true, subtree: true, attributes: false, characterData: false });

How adding more links on the extension page action

I'm developing an extension page action that works only in a specific domain, can I add more than one link to the page action? My background.js is this.
it is possible to add more links in background.html for the extension page action?
//background.js
chrome.runtime.onInstalled.addListener(function() {
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([
{
conditions: [
new chrome.declarativeContent.PageStateMatcher({
pageUrl: { urlContains: 'www.exemple.com' },
})
],
actions: [ new chrome.declarativeContent.ShowPageAction() ]
}
]);
Yes, you can register a page action for multiple sites by adding multiple PageStateMatchers to the list of conditions.
chrome.runtime.onInstalled.addListener(function() {
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [
new chrome.declarativeContent.PageStateMatcher({
pageUrl: { hostSuffix: 'example.com' }
}),
new chrome.declarativeContent.PageStateMatcher({
pageUrl: { hostSuffix: 'example.net' }
}),
],
actions: [ new chrome.declarativeContent.ShowPageAction() ]
}]);
});
});
Note: I replaced urlContains with hostSuffix because you wanted to show the page action on certain domains, not on all pages whose URL contain the website's host (e.g. you probably don't want to match http://localhost/path/containing/www.example.com). See the documentation of the UrlFilter type for more ways to match pages.
With regular expressions you can match multiple domains with a single rule.
For example the following matches any Google search page in every country.
pageUrl: { urlMatches: '^(www\.)?(google.).*\/search\?', schemes: ['https'] },