pdfmake API? Is there a list of styles, fonts, capabilities? - css

I'm using pdfmake. I want to format a document and they have good examples on github and in their playground but I was wondering if they featured all capabilities therein. I get the feeling that their may be additional properties like switching fonts, adding different style elements or underlining - things not expressly shared in the examples. Maybe what you see is what you get and that is all but I went over the github page pretty throughly and did not find a more detailed list of capabilities. It seems hella similar to html but it doesn't seem to have the same styling capabilities of html/css, if there is something more could someone please point it out.

Here you go.. At least, uncommented below styles are supported. I tried it myself.
['font',
'fontSize',
'bold',
'italics',
'alignment',
'color',
'columnGap',
'fillColor',
'decoration',
'decorationStyle',
'decorationColor',
'background',
'lineHeight'
//'tableCellPadding'
// 'cellBorder',
// 'headerCellBorder',
// 'oddRowCellBorder',
// 'evenRowCellBorder',
// 'tableBorder'
]
You could use the above styles, as below.
var dd = {
content: [
{
text: 'This is a header, using header style',
style: 'header'
}
],
styles: {
header: {
fontSize: 18,
bold: true,
background: '#ff1'
}
}
}

You can use margin also as shown below.
// margin: [left, top, right, bottom]
{ text: 'sample', margin: [ 5, 2, 10, 20 ] },
// margin: [horizontal, vertical]
{ text: 'another text', margin: [5, 2] },
// margin: equalLeftTopRightBottom
{ text: 'last one', margin: 5 }
It is from the docs Here.

Update: 27/5/2020 from Github's anwer
Extending #Romo 's answer:
[
'font',
'fontSize',
'bold',
'italics',
'alignment',
'color',
'columnGap',
'fillColor',
'decoration',
'decorationStyle',
'decorationColor',
'background',
'lineHeight'
'listType' // <=== Added
]
It accepts several options:
'none', 'upper-roman', 'circle', 'square'

Related

ExtJS 7.x Modern Grid Selection Bug On Layout Animation

How to fix it? I found a bug on layout card animation using grid component;
What happens?
When you configure the layout for the "card" type and animation for "slide", "cover" etc... the line selection (record) stops working, when hovering over the record and clicking, the css of check gives bug.
When you change the layout to "card" simply, the grid selection works normally.
I'm using Windows 10, Edge browser;
See the bug on Sencha Fiddle
It is only the grid, dataview does not appear to have the same problem.
Not getting the error on firefox.
Also only with Material theme because it is related to Fashion. I could not figure out how to import Fashion in the sencha fiddle so I could not add to your fiddle.
I found that if you unchecked ANY color in chrome devtools the problem goes away for one animation. So i messed around with resetting the colors and that seems to work. You have to change a color wait 10 milliseconds and change it back. You can change ANY color. I am changing the hovered-background-color but it can be anyone of the predefined colors. I change it just one shade and it is only for 10 milliseconds. It will only work with colors in the format of #11111.
I have not figured out what is causing the problem but I have a huge hack of a work around. I am sure this can be improved... also did not test much at all. Feel free to post any improvements, or if you figure out the underlying problem.
items: [{
xtype: "grid",
ui: 'default',
listeners: {
show: function() {
let cssVariables = Fashion.css.getVariables();
let oldColor = cssVariables['hovered-background-color'];
newColor = parseInt(oldColor, 16);
newColor = '#' + (((newColor & 0x0000FF) + 1) | ((((newColor >> 8) & 0x00FF) + 1) << 8) | (((newColor >> 16) + 1) << 16)).toString(16);
cssVariables['hovered-background-color'] = newColor;
Fashion.css.setVariables(cssVariables);
Ext.defer(function() {
cssVariables['hovered-background-color'] = oldColor;
Fashion.css.setVariables(cssVariables);
}, 10);
}
},
title: 'Simpsons',
store: {
fields: ['name', 'email', 'phone'],
data: [
{ 'name': 'Lisa', "email":"lisa#simpsons.com", "phone":"555-111-1224" },
{ 'name': 'Bart', "email":"bart#simpsons.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"home#simpsons.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"marge#simpsons.com", "phone":"555-222-1254" }
]
},
columns: [
{ text: 'Name', dataIndex: 'name', width: 200 },
{ text: 'Email', dataIndex: 'email', width: 250 },
{ text: 'Phone', dataIndex: 'phone', width: 120, flex: 1 }
]
}, {

How to set CSS configuration of MathJax 2.7.8 to change text-color of equations globally

I'm using mathjax in a project and I've been trying to change the colors of all math. I am loading the following configuration file:
window.MathJax = {
jax: ['input/TeX', 'output/HTML-CSS'],
extensions: ['tex2jax.js'],
displayAlign: 'center',
TeX: {
extensions: ['AMSmath.js', 'AMSsymbols.js', 'AMScd.js'],
Macros: {
e: '{\\textrm{e}}',
R: '{\\mathbb{R}}', // this is working!
Z: '{\\mathbb Z}',
KK: '{\\mathbb{K}}'
}
},
tex2jax: {
inlineMath: [
['$', '$'],
['\\(', '\\)']
],
displayMath: [
['$$', '$$'],
['\\[', '\\]']
],
processEscapes: true
},
'HTML-CSS': {
fonts: ['TeX'],
styles: {
scale: 110,
'.MathJax': { padding: '1em 0.1em', color: 'green ! important' }, //Not working
'.MathJax_Display': { 'text-align': 'center' }
}
},
showProcessingMessages: false,
menuSettings: { zoom: 'Double-Click', mpContext: true, mpMouse: true }
}
Everything is apparently working but the HTML-CCS:styles part is not working. I couldn't find a proper reference for this, and I don't know if this version of MathJax (2.7.8) is using a different format.
In this project I'm using nuxt and vuetify, I don't know if this is the problem, but I turn off vuetify and still the styles are not applied to the math display.
Thanks very much for any help,
Milton.
The scale: 110 parameter is not a CSS declaration, so should not be in the styles block (but rather in the HTML-CSS block directly). I suspect that that may be causing the styles not to be generated properly. Try moving the scale up one level and see if that helps.
Note that the HTML-CSS output jax is the slowest one available. You might consider switching to the CommonHTML output jax instead.
I finally found what was the problem. Apparently the new versions of Mathjax changed the name of the CSS classes. The following configuration now works:
Update: Now I'm facing a different problem...that configuration only works in developing mode, when deploy the mathjax css is not working...in that case I think it is the vuetify css. :-(
Update: Now it is working, also in deployed mode. I was loading Mathjax with a the pre-configuration ?config=TeX-AMS-MML_SVG. When I load it without that pre-configuration it works. I don't know why.
window.MathJax = {
jax: ['input/TeX', 'output/CommonHTML'],
extensions: ['tex2jax.js', 'Safe.js'],
styles: {
'.mjx-chtml': { padding: '0.1em 0.1em' }, //new names of the selectors, working!
'.MJXc-display, .mjx-chtml': { color: 'green' }
},
displayAlign: 'center',
TeX: {
extensions: ['AMSmath.js', 'AMSsymbols.js', 'AMScd.js'],
Macros: {
e: '{\\textrm{e}}',
R: '{\\mathbb{R}}',
Z: '{\\mathbb Z}',
KK: '{\\mathbb{K}}'
}
},
tex2jax: {
inlineMath: [
['$', '$'],
['\\(', '\\)']
],
displayMath: [
['$$', '$$'],
['\\[', '\\]']
],
processEscapes: true
},
CommonHTML: {
scale: 105,
linebreaks: { automatic: true }
},
showProcessingMessages: false,
menuSettings: { zoom: 'None', mpContext: true, mpMouse: true }
}
Note that styles are in the core configurations, outside the CommonHTML item.
Thanks for the help!
Milton.

Create custom settings for custom Gutenberg block

I created custom Gutenberg block for social links but I would need to add input fields where user can paste the url to that social profile. Here is where I would like to put the field (same as paragraph block has alignment settings there for example):
This is my code for the block:
const { registerBlockType } = window.wp.blocks;
const { __ } = window.wp.i18n;
const { BlockControls, AlignmentToolbar} = window.wp.editor;
registerBlockType('social-block/social', {
title: __('Social'),
icon: 'smiley',
category: 'common',
attributes: {
content: {type: 'string'},
color: {type: 'string'}
},
edit: function (props) {
return React.createElement(
"div",
{style: {
display: 'flex',
justifyContent: 'center'
}},
// facebook
React.createElement(
'a',
{
'href': '',
'rel': 'noopener noreferrer',
'target': '_blank'
},
React.createElement(
'svg',
{
'xmlns': "http://www.w3.org/2000/svg",
'xmlns:xlink': "http://www.w3.org/1999/xlink",
'viewBox': "0 0 24 24",
'fill': "currentColor",
'width': "48px",
'height':"48px"
},
React.createElement(
'path',
{
'fill-rule': "evenodd",
'd': "M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm3-11.762h-1.703V9.2c0-.39.278-.48.474-.48h1.202V7.005L13.318 7c-1.838 0-2.255 1.278-2.255 2.096v1.142H10v1.765h1.063V17h2.234v-4.997h1.508L15 10.238z"
}
)
),
),
}
});
I tried implementing https://developer.wordpress.org/block-editor/tutorials/block-tutorial/block-controls-toolbars-and-inspector/ but its not the behavior that I need, anyone has a suggestion where to look or what to do?
First of all I will recommend you to use the ES6 syntax as it will make your code a lot easier. For ES6 whenever you see any code in WordPress docs then you can choose ESNEXT tab from top of snippet that will then shows you ES6 code.
Now your answer. Gutenberg provides us two kind of controls BlockControl and InspectorControl both of these provides you the way to manipulate your block but the difference is that BlockControl is a toolbar that appears on top of block (its the same link that you shared) while InspectorControls serves as a sidebar setting option the thing that you wanted to do. Here is the actual documentation of Inspector Controls and here is one working example from Image block of Gutenberg core.

How can I use a custom gif loader for Lists in Sencha Touch?

When you use the Ext.dataview.List in Sencha, it automatically inserts a nice loading spinner while the data is loading. That's all fine and dandy, but I'd like to know how to use a custom loader .gif.
I've looked around and think I need to change the loadmask but not positive cause I'm new to this. See this link.
Below is the code for one of my Lists. I'm hoping to be able to add the code suggested to one place so that all lists are affected and have the new spinner.
{
xtype: 'list',
height: '',
id: 'categoryList',
itemId: '',
width: '100%',
scrollable: false,
emptyText: '<div class="pdtsListHtml" style="margin-top:30%">Product List Empty</div>',
itemTpl: [
'<div ><div class="pdtsListHtml" style="display:inline;">{navigationElementItemName} ({navigationElementItemRecordCounts})</div><div style="display:inline;float:right;margin-right:5px;"><img src="resources/image/arrow.png" width="11" height="11"></div></div>'
],
store: 'productListStore',
allowDeselect: true,
onItemDisclosure: false
}
Here's a fiddle that shows you an example list with a loading mask that uses a gif.
Basically you should define your own Ext.LoadMask subclass and use it on the list:
Ext.define("Test.MyLoadMask", {
extend: "Ext.LoadMask",
alias: "widget.myloadmask",
getTemplate: function() {
var prefix = Ext.baseCSSPrefix;
return [
{
reference: 'innerElement',
cls: prefix + 'mask-inner',
children: [
{
reference: 'indicatorElement',
cls: prefix + 'loading-spinner-outer',
children: [
{ tag: 'img', src: "http://example.com/my-spinner.gif" }
]
},
{
reference: 'messageElement'
}
]
}
];
}
});
Then you should define an applyMasked on your lists that modifies the xtype and sets it to myloadmask instead of loadmask.

Yahoo.widget.Editor - How to configure font size of text

I am using the YUI Rich Text Editor (YAHOO.widget.Editor), and I got it working fine, except for one thing. I cannot figure out how to configure the font size of the text that I type in the editor box (input type="textarea"). I want that text to be 150%. I know that I need a CSS rule of the form:
some-YUI-related-selector {
font-size: 150%;
}
but I cannot figure out the identity of "some-YUI-related-selector".
I'd appreciate any help I can get.
Thanks, Jay
More information:
I want my web to display large fonts, so I used a CSS style for the div in question as follows:
div.newsform {
font-size:120%;
}
div.newsform input {
font-size:120%;
}
input#newsgoals {
font-size:150%;
}
The HTML page snippet in question is:
<div class="newsform">
<p>Some text</p>
<form>
<input type="text" name="sname" style="width:353px"/>
<input type="textarea" id="newsgoals" name="newsgoals" ></input><br/>
<input type="submit" value="Add" />
</form>
</div>
I bind the YUI Editor in a Javascript snippet at the bottom of the web page as follows:
<script>
var myNewSEditor = new YAHOO.widget.Editor('newsgoals', {
height: '300px',
width: '440px',
dompath: false,
animate: true,
css: YAHOO.widget.SimpleEditor.prototype._defaultCSS, // + 'html { font-size:130%; }',
// { css: YAHOO.widget.SimpleEditor.prototype._defaultCSS + 'ADD MYY CSS HERE' }
toolbar: {
titlebar: 'Write Your Goals Here',
buttons: [
{ group: 'textstyle', // label: 'Font Style',
buttons: [
{ type: 'push', label: 'Bold', value: 'bold' },
{ type: 'push', label: 'Italic', value: 'italic' },
{ type: 'push', label: 'Underline', value: 'underline' },
{ type: 'separator' },
{ type: 'select', label: 'Arial', value: 'fontname', disabled: true,
menu: [
{ text: 'Arial', checked: true },
{ text: 'Arial Black' },
{ text: 'Comic Sans MS' },
{ text: 'Courier New' },
{ text: 'Lucida Console' },
{ text: 'Tahoma' },
{ text: 'Times New Roman' },
{ text: 'Trebuchet MS' },
{ text: 'Verdana' }
]
},
{ type: 'spin', label: '22', value: 'fontsize', range: [ 9, 75 ], disabled: true },
{ type: 'separator' },
{ type: 'color', label: 'Font Color', value: 'forecolor', disabled: true },
{ type: 'push', label: 'HTML Link CTRL + SHIFT + L', value: 'createlink', disabled: true }
]
}
]
}
});
myNewSEditor.render();
</script>
The everything inside the div (class="newsform") renders the fonts at 120% large except the YUI Editor, which continues to render very small. If I used the web page without the YUI editor, the text area (input#newsgoals) renders properly at 150%.
I was able to configure colours and font sizes in the tool bar of the YUI Editor, but not in the text area box.
I even tried configuring the 'css:" attribute in the toolbar and then adding my CSS rule to _defaultCSS (as per the YUI Editor documents), but it didn't work.
Jay,
Dav Glass, the author of this component, provides great help to his users over at the YUI Library forums: http://yuilibrary.com/forum/
If you don't get an answer here, definitely try posting over there.
-Eric
Woohoo! Thanks Eric Miraglia. The pointer to Dav Glass' forum got me where I needed to go.
For some reason, I had found the css: configuration parameter which was correct, but I had done something else wrong and that caused it to fail. The correct answer is to put the following line where I have the css: when I call "new Yahoo.widget.Editor()" :
css: YAHOO.widget.SimpleEditor.prototype._defaultCSS + 'body { font-size:130%; background-color:red;color:white;}'
That was enough to get the font-size and editor background changed to what I want.

Resources