I am working with Quill Editor. Its been nice so far. My question is that is there any way to make Quill Editor go full-screen (sort of distraction free mode) by a button in the toolbar?
If not than how can I proceed to implement this on my own?
To go fullscreen I think it is easiest to use a library, for example screenfull.js - https://github.com/sindresorhus/screenfull.js/
As for adding custom buttons to the Quill toolbar, I have found two ways.
Method 1:
At least simple buttons can be added directly through the toolbar options. Something like this:
http://codepen.io/nik10110/pen/PbyNoW
<div id="editor"></div>
<style>
#editor {
height: 375px;
}
.ql-omega:after {
content: "Ω";
}
</style>
<script type="text/javascript">
var toolbarOptions = [
[{ 'font': [] }],
['bold', 'italic', 'underline'],
['blockquote', 'code-block'],
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
[{ 'align': [] }],
['omega']
];
var quill = new Quill('#editor', {
modules: {
toolbar: toolbarOptions
},
theme: 'snow'
});
var customButton = document.querySelector('.ql-omega');
customButton.addEventListener('click', function() {
if (screenfull.enabled) {
console.log('requesting fullscreen');
screenfull.request();
} else {
console.log('Screenfull not enabled');
}
});
</script>
Method 2:
Set the toolbar to use custom Html rather than specifying the buttons through javascript. The official documentation ( http://quilljs.com/docs/modules/toolbar/ ) is quite detailed for this.
Here's a tweaked code sample from there:
<div id="toolbar">
<!-- Add buttons as you would before -->
<button class="ql-bold"></button>
<button class="ql-italic"></button>
<!-- But you can also add your own -->
<button id="toggle-fullscreen"></button>
</div>
<div id="editor"></div>
<script type="text/javascript">
var quill = new Quill('#editor', {
modules: {
toolbar: '#toolbar'
}
});
var customButton = document.querySelector('#toggle-fullscreen');
customButton.addEventListener('click', function() {
if (screenfull.enabled) {
console.log('requesting fullscreen');
screenfull.request();
} else {
console.log('Screenfull not enabled');
}
});
</script>
Related
I would like to use the Froala WYSIWYG HTML Editor with Ext JS Classic Application. Could you show me how to add the Froala Editor to my Classic Application?
Here is how you could add it to your Ext JS 7 Classic application.
Directions
Two things need to be done in order to use the Froala Editor in classic.
1. Import the javascript resources to your application
2. Initialize the Froala editor with a TextArea
HTML Source
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!-- Include Editor style. -->
<link href='https://cdn.jsdelivr.net/npm/froala-editor#3.0.6/css/froala_editor.pkgd.min.css' rel='stylesheet' type='text/css' />
<!-- Include JS file. -->
<script type='text/javascript' src='https://cdn.jsdelivr.net/npm/froala-editor#3.0.6/js/froala_editor.pkgd.min.js'></script>
</head>
<body>
</body>
</html>
Javascript Source
Ext.application({
name: 'Ext JS 7 Classic & Froala Example for Modern & Classic Themes',
// You get a Froala license with the Ext JS enterprise edition.
// Email Froala support to get your license.
// https://wysiwyg-editor.froala.help/hc/en-us
launch: function () {
var editor;
var htmlValue = '<p>The Froala Editor is a lightweight WYSIWYG HTML Editor written in Javascript that enables rich text editing capabilities for your applications.</p><p><br></p><p><img src="https://www.sencha.com/wp-content/uploads/2015/03/built-in-support-for-rpc-requestfactory-and-json.png" style="width: 300px;" class="fr-fic fr-dib fr-fil"></p>';
var displayHtml = function () {
var htmlContent = editor.html.get();
Ext.Msg.alert('Status', htmlContent);
}
// Once the panel is ready, render the Froala HTML Editor
var renderEditor = function () {
editor = new FroalaEditor('#my-froala-editor-id1', {}, function () {
// Call the method inside the initialized event.
editor.html.set(htmlValue);
});
}
Ext.create('Ext.panel.Panel', {
renderTo: Ext.getBody(),
fullscreen: true,
margin: 20,
items: [{
xtype: 'panel',
padding: 0,
items: [{
xtype: 'textareafield',
id: 'my-froala-editor-id1',
width: '100%',
height: 400,
// Fix editor bottom clipping from panel margin...
margin: '0 0 80 0'
}],
listeners: {
boxready: renderEditor, // classic listener
painted: renderEditor, // modern listener
}
}, {
xtype: 'button',
text: 'Display HTML',
margin: '5 0 10 0',
handler: displayHtml, // classic listener
listeners: {
tap: displayHtml, // modern listener
}
}]
});
}
});
Sencha Fiddle Example
Tryout the code here:
https://fiddle.sencha.com/#view/editor&fiddle/30hl
is there any way to change button style (colvis, copy, print, excel) in angularjs datatables.
vm.dtOptions = DTOptionsBuilder.newOptions().withButtons([
'colvis',
'copy',
'print',
'excel'
]);
Only way I can do this is directly in source code, but this is not good way.
here is solution with jquery, but this doesn't have any effect in DOM
$('#myTable').DataTable( {
buttons: {
buttons: [
{ extend: 'copy', className: 'copyButton' },
{ extend: 'excel', className: 'excelButton' }
]
}
} );
css
.copyButton {
background-color: red
}
.excelButton{
background-color: red
}
Thank you
Simply replace a button identifier with a literal and add className :
.withButtons([
'colvis',
{ extend: 'copy', className: 'copyButton' },
'print',
{ extend: 'excel', className: 'excelButton' }
]);
This works for a "clean" setup, but you are probably including all default stylesheets there is.
DataTables use by default an <a> tag and style it to look like a button through a .dt-button class which have a lot of pseudo class styling for :hover and so on. This makes it complicated to change for example the background, you'll need additional hackish CSS.
Also, DataTables itself already injects unique classes for each button type like .buttons-excel which you could take benefit of.
I will suggest you completely reset the default behaviour through the dom option:
.withButtons({
dom: {
button: {
tag: 'button',
className: ''
}
},
buttons: [
'colvis',
'copy',
'print',
'excel'
]
})
Now you can style for example .buttons-excel nicely from scratch :
.buttons-excel {
background-color: red;
color: white;
border: 1px outset;
}
.buttons-excel:hover {
background-color: pink;
}
If you are working with the bootstrap 4 taste of DataTables the buttons automatically have class btn-secondary.
Using the dom option you lose the bootstrap design altogether.
You can however add classes like so:
myTable = $('#myTableId').DataTable({
buttons: [
{ extend: 'colvis', className: 'btn-outline-secondary' },
{ extend: 'excel', className: 'btn-outline-secondary' }
]});
But for me this didn't change the button design because the btn-secondary was still there. So I removed it manually afterwords.
setTimeout(function () {
$oTable.buttons().container().addClass('ml-2').appendTo('#myTableId_length'); //attach buttons to table length choser
$oTable.buttons().container().find('.btn').removeClass('btn-secondary'); //remove class btn secondary
}, 500);
This is wrapped in a time-out to make sure, everything has been rendered before.
I hope this will help others too as there isn't a lot of documentation about this exactly.
I want to use a RTE (rich text editor) within a macro I've created to handle page sections.
I have successfully rendered the RTE within the macro. I can select my macroRte from the macro parameters panel. It even renders where I edit the values of my page section. I have attributed the alias of "macroRte" to the parameter.
However, it is not storing the values. Each time I press submit it is wiping the content.
I'm no Angular expert but i think that's the problem. Code below. Thank you.
View
<div ng-controller="CustomSectionEditController" class="umb-editor umb-rte">
<umb-editor model="macroRte">
<div ng-model="model.value">{{model.value}}</div>
</umb-editor>
Controller
angular.module("umbraco").controller("CustomSectionEditController", function ($scope) {
$scope.macroRte = {
label: 'bodyText',
description: 'Load some stuff here',
view: 'rte',
config: {
editor: {
toolbar: ["code", "undo", "redo", "cut", "styleselect", "bold", "italic", "alignleft", "aligncenter", "alignright", "bullist", "numlist", "link", "umbmediapicker", "table", "umbembeddialog"],
stylesheets: ["rte"],
dimensions: { height: 400 },
valueType:"STRING"
}
}
};
});
Render
#inherits Umbraco.Web.Macros.PartialViewMacroPage
<div class="lh-text">
#Model.MacroParameters["macroRte"];
</div>
Any ideas? :)
using this, https://github.com/engern/Umbraco-custom-macro-parameters/tree/master/App_Plugins/MacroRichText - I was able to solve my problem.
The view needs to be changed to the following
<div ng-controller="CustomSectionEditController">
<ng-form>
<umb-editor model="macroRte"></umb-editor>
</ng-form>
</div>
The controller needed the following code (add under view
value: $scope.model.value,
and an additional scope control
$scope.$watch("macroRte.value", function (newValue, oldValue) {
$scope.model.value = newValue;
});
The controller now looks like this
angular.module("umbraco").controller("CustomSectionEditController", function ($scope) {
$scope.macroRte = {
label: 'bodyText',
description: 'Load some stuff here',
view: 'rte',
value: $scope.model.value,
config: {
editor: {
toolbar: ["code", "undo", "redo", "cut", "styleselect", "bold", "italic", "alignleft", "aligncenter", "alignright", "bullist", "numlist", "link", "umbmediapicker", "table", "umbembeddialog"],
stylesheets: ["rte"],
dimensions: { height: 400 },
valueType:"STRING"
}
}
},
$scope.$watch("macroRte.value", function (newValue, oldValue) {
$scope.model.value = newValue;
});
});
I hope this help others.
Is there a way I can create paper-card heading dynamically using some property inside custom element? Following is what I tried but didn't work. Probably this is not the way to achieve what I want:( I googled for a couple of hours but ended up with nothing!
Custom Element
<script>
(function () {
'use strict';
Polymer({
is: 'nearest-customers',
properties: {
customers: {
type: Array,
value: [],
notify: true
},
cardViewMaxRecords: {
type: Number,
notify: true
},
showFullCustomerList: {
type: Boolean,
value: false,
notify: true
},
headingContent: {
type: String,
value: 'Custom card heading'
}
},
ready: function () {
this.heading.textContent = this.headingContent
},
});
})();
</script>
HTML
<nearest-customers id="nearestCustomers" card-view-max-records="3"></nearest-customers>
...
...
...
<script type="text/javascript">
window.addEventListener('WebComponentsReady', function (e) {
var nearestCustomers = document.querySelector("#nearestCustomers");
nearestCustomers.headingContent= "<a href='someurl'><iron-icon icon='fa:arrow-left'></iron-icon></a> This is a new content";
}
</script>
My objective is to put an iron-icon before the heading text and the icon can be used as a link to somewhere.
Thanks in advance
I'm sure there's a better way, but I just added the styles and structure:
<div class="header paper-card">
<div class="title-text paper-card">
<iron-icon icon="book"></iron-icon> Reading List
</div>
</div>
I'm using Angularjs with highcharts-ng library and I want to have a highchart directive with the ability to export the chart (showing the export button) and another without that option (not showing the export button) but I have not managed to disable (hide) the button using the configuration object. How can I do that?
Here is the snippet
var app = angular.module('app', ['highcharts-ng']);
app.directive('myChart', function(){
return {
restrict: 'E',
scope: {},
template: '<highchart config="chartConfig"></highchart>',
link: function(scope, element, attrs) {
scope.chartConfig = {
options: {
exporting: {
enabled: false
}
}
};
}
};
});
<div ng-app="app">
<my-chart></my-chart>
<div>
<script src="http://code.jquery.com/jquery-2.1.3.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="https://code.angularjs.org/1.3.0/angular.js"></script>
<script src="https://rawgit.com/pablojim/highcharts-ng/0.0.7/src/highcharts-ng.js"></script>
<script src="http://code.highcharts.com/highcharts-more.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
Even if a disable the export property
var HighChartChartModel = {
options: {
exporting: {
enabled: false
},
chart: {
type: 'bar'
}
},
This will work
Here is the right way to do this in highcharts-ng:
options: {
chart: {
type: 'bar'
},
exporting: {
enabled: false
}
},
Note that exporting is at the same level as chart.
I got the same problem, and since the regular options somehow don't work, I just hide it with some CSS and javascript (jQuery) where needed.
$('.highcharts-button').css('display': 'none');
looks like a bug in highcharts-ng.
if you simply don't include the exporting.js you won't get that button.
a working fiddle here