How to hide toolbar and menubar in tinymce6 editor? - tinymce-6

In tinymce5 version we are using.
var tinyEditor;
tinymce.init(
{
selector: "textarea",
plugins: [
"advlist", "anchor", "autolink", "charmap", "code", "fullscreen",
"help", "image", "insertdatetime", "link", "lists", "media",
"preview", "searchreplace", "table", "visualblocks",
],
toolbar: "undo redo | styles | bold italic underline strikethrough,
setup : function(ed){
tinyEditor = ed;
}
});
Later on demand we hide menubar,statusbar as ..
tinyEditor.settings.menubar = false;
tinyEditor.settings.statusbar = false;
In Tinymce 6 version .settings attribute has been removed.

Related

How to make my vscode font slant like sublime?

I use the same font(Consolas) in VScode and sublime. But it looks different in the same place:
Here are my sublime settings:
{
"auto_complete_selector": "source,text",
"color_scheme": "Packages/Material Theme/schemes/Material-Theme-Darker.tmTheme",
"font_face": "Consolas",
"font_size": 12,
"ignored_packages":
[
],
"theme": "Default.sublime-theme"
}
Here are my vscode settings:
"materialTheme.accent": "Blue",
"editor.fontFamily": "Consolas, 'Courier New', monospace",
"editor.fontWeight": 520,
"editor.codeLensFontSize": 11,
"editor.fontSize": 15,
"editor.formatOnType": true,
"debug.console.fontFamily": "Cascadia Mono",
"python.showStartPage": false,
"workbench.editorAssociations": [
{
"viewType": "jupyter.notebook.ipynb",
"filenamePattern": "*.ipynb"
}
],
"explorer.confirmDelete": false,
"todo-tree.tree.showScanModeButton": true,
"editor.fontLigatures": true,
"editor.tokenColorCustomizations": {
"comments": "#7ea9eb"
My question is: How to make my vscode font slant like sublime?
According to the VS Code documentation, you can customize your theme color by using the editor.tokenColorCustomizations rule in your user settings:
Open your settings.json and add the following rule first (replace YOUR THEME NAME HERE with the name of your color theme):
"editor.tokenColorCustomizations": {
"[YOUR THEME NAME HERE]": {
"textMateRules": []
}
}
Open a Python file of your choice. Then, open Command Palette with Ctrl+Shift+P and run "Developer: Inspect Editor Tokens and Scopes"
Click on the keyword you wish make it italic. For example, we click on the class keyword to view its TextMate scopes. Copy the first TextMate scope ID as highlighted:
Go back to your settings.json. Inside the textMateRules array, insert a new object with the scope property being the TextMate scope ID you just copied.
"editor.tokenColorCustomizations": {
"[YOUR THEME NAME HERE]": {
"textMateRules": [
{
"scope": "storage.type.class.python",
"settings": {
"fontStyle": "italic"
}
}
]
}
}
Save your settings.json and you should see the class keyboard in italics
Note
You can append more objects in the textMateRules array to make the font italic for more keywords. For example:
"editor.tokenColorCustomizations": {
"[YOUR THEME NAME HERE]": {
"textMateRules": [
{
"scope": "variable.parameter.function.language.special.self.python",
"settings": {
"fontStyle": "italic"
}
},
{
"scope": "storage.type.class.python",
"settings": {
"fontStyle": "italic"
}
}
]
}
},

Using user-defined color in VS Code own Color Theme

In documentation of VS Code Extensions, it is mentioned that you can define your own color: https://code.visualstudio.com/api/references/contribution-points#contributes.colors
How can I use this color in the Color Theme I create?
For example, I have the following in package.json
"contributes": {
"themes": [
{
"label": "My Color Theme",
"uiTheme": "vs-dark",
"path": "./themes/my-color-theme.json"
}
],
"colors": [
{
"id": "color.gold",
"description": "Gold",
"defaults": {
"dark": "#FFB71B",
"light": "#FFB71B",
"highContrast": "#FFB71B"
}
}
]
}
And the following in my-color-theme.json (I would like to use "gold" for one of the item but it does not work):
{
"name": "My Color Theme",
"type": "dark",
"colors": {
"editor.background": "#000000",
"editor.foreground": "#FFFFFF",
"sideBarTitle.foreground": "color.gold",
},
...
}
Thanks
Color entries can only contain color values of the form #RGB, #RGBA, #RRGGBB or #RRGGBBAA, nothing else. No other color format (hsl etc.) or named color is supported. Hence "sideBarTitle.foreground": "color.gold" is an invalid entry.

Working example to custom-format a column title/header?

I have a formatter that works for column data, using column parameter formatter. Using the same formatter with column parameter titleformatter, I get the error noted below. Also, I don't understand why HTML in title parameter text seems not to work for <b> ... </b> but does work for other things (e.g., <i> ... </i>. A working custom formatter example would help. (I don't see this in Tabulator documentation.) See this montage combining a column header and row header screenshot with common cell text---'bold' in the row looks bolder to me.
Cell text comparison screenshot montage
I've tried emulating some posted sample code, but I get the same error as reported by #dagroj in his comment to #Oli Folkerd's answer (to the question) about titleformatter --- viz. tabulator.min.js:2 Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'. (Mentioning that here because I don't yet have the reputation to comment there.)
Here is a rendering of my CPT, without the titleformatter.
Corresponding table constructor:
"columnVertAlign": "bottom",
"height": "100%",
"layout": "fitColumns",
"columns": [
{
"title": "<i> absolute_T<--T (noisyAnd)</i>",
"columns": [
{
"title": "<b> NotCorrAnd_EffectiveHyp</b>",
"field": "label",
"align": "right",
"headerSort": false
}
]
},
{
"title": "NotB_EffectiveHyp",
"columns": [
{
"title": "<b>T</B>",
"field": "true",
"align": "center",
"headerSort": false
},
{
"title": "<i>F</i>",
"field": "false",
"align": "center",
"headerSort": false
}
]
},
{
"title": "<b> Belief </b>",
"columns": [
{
"title": "odds",
"field": "odds",
"align": "center",
"headerSort": false
},
{
"title": "log<sub>2</sub> odds",
"field": "log2odds",
"align": "center",
"headerSort": false
}
]
}
]
}
Formatter:
function truthFormatter(cell, formatterParams, onRendered) {
var cellValue = cell.getValue();
var cellElement = cell.getElement();
if (cellValue == "T") {
cellElement.style.backgroundColor = "#0000B3";
cellElement.style.color = "#FFFFFF";
cellElement.style.textAlign = "center";
cellElement.style.fontWeight = "bold";
}
else if (cellValue == "F") {
cellElement.style.backgroundColor = "#B30000";
cellElement.style.color = "#FFFFFF";
cellElement.style.textAlign = "center";
cellElement.style.fontWeight = "bold";
}
else cellElement.style.color = "#000000";
return cell.getValue();
}
Column headers are by default styled to be bold, so adding a bold or strong tag will not make them any bolder. On a side not you are using a mix of lowercase and uppercase "b" in your tags
If you are getting that error it means that your formatter is not returning a valid value, it must either be a string/number or a DOM element of type Node.

How to trigger click on a button

I've this page. I need to trigger a click on the BUY NOW button on this page using AngularJS.
I've tried these ways to click on this "BUY NOW" in content script(myscript.js) but does not work:
angular.element($('ul form button:contains("BUY NOW")').get(0)).triggerHandler('click');
$('ul form button:contains("BUY NOW")').get(0).click();
$('ul form button:contains("BUY NOW")').get(0).dispatchEvent(new MouseEvent('click', {
'view': window,
'bubbles': true,
'cancelable': true
}));
The manifest.json looks like this:
"content_scripts": [
{
"run_at": "document_end",
"all_frames": false,
"matches": ["*://www.flipkart.com/*"],
"css": [ "jqueryui/jquery-ui.css", "js/slidenavi/sidenavi-right.css","main.css", "js/bootstrap-switch-master/dist/css/bootstrap3/bootstrap-switch.min.css"],
"js": ["jquery-2.1.4.min.js", "jqueryui/jquery-ui.min.js","js/angular.min.js", "js/jquery.cookie.js", "jqueryui/jquery-ui.min.js","js/slidenavi/SideNavi.js", "client_server_common.js", "user-selections.js",
"jquery.countdown.min.js", "js/bootstrap-switch-master/dist/js/bootstrap-switch.min.js", "js/cryptojs/rollups/md5.js", "common.js",
"myscript.js"
]
}
],
What is the way to make it work?
Try with this code; it simulates a mouse left click on the element by a quick succession of mousedown, mouseup and click events fired in the center of the button:
var simulateMouseEvent = function(element, eventName, coordX, coordY) {
element.dispatchEvent(new MouseEvent(eventName, {
view: window,
bubbles: true,
cancelable: true,
clientX: coordX,
clientY: coordY,
button: 0
}));
};
var theButton = document.querySelector('ul form button');
var box = theButton.getBoundingClientRect(),
coordX = box.left + (box.right - box.left) / 2,
coordY = box.top + (box.bottom - box.top) / 2;
simulateMouseEvent (theButton, "mousedown", coordX, coordY);
simulateMouseEvent (theButton, "mouseup", coordX, coordY);
simulateMouseEvent (theButton, "click", coordX, coordY);
What about Vanilla JS, noone prohibited?
Such as "onlick/click"?
function ae(a,b,c) {
if (a.addEventListener)
a.addEventListener (b,c,false);
else if (a.attachEvent)
a.attachEvent ('on'+b,c);
}
function re(a,b,c) {
if (a.removeEventListener)
a.removeEventListener (b,c,false);
if (a.detachEvent)
a.detachEvent ('on'+b,c);
}

Render context menu depending on selection

I want to display a different menu option depending on whether a number or text is selected.
I've tried playing with content scripts but I can't get them to work in gmail which is where I need it to work. Here is what I have, it works on sites other than gmail (is it a https thing?)
Background.html
<script src="driver.js"></script>
content_script.js
document.addEventListener("mousedown", function(event){
if(event.button == 2) {
var selection = window.getSelection().toString();
chrome.extension.sendRequest({cmd: selection});
}
}, true);
driver.js
chrome.extension.onRequest.addListener(function(request) {
alert(request.cmd);
});
manifest.json
{
"name": "Context Menu Search",
"description": "Opens the selected text as keyword in a new window",
"version": "0.1",
"permissions": ["contextMenus"],
"content_scripts": [
{
"matches": ["http://*/*","https://*/*"],
"js": ["content_script.js"]
}
],
"background_page": "background.html"
}
Selection type changes context menu using chrome extension
You will have to set a listener for mouse down. There is no other way to get the selected text before the menu is created.
See this SO question:
chrome extension context menus, how to display a menu item only when there is no selection?
Here is part of the code the rest is at the link.
document.addEventListener("mousedown", function(event){
//right click
if(event.button == 2) {
if(window.getSelection().toString()) {
chrome.extension.sendRequest({cmd: "createSelectionMenu"});
} else {
chrome.extension.sendRequest({cmd: "createRegularMenu"});
}
}
}, true);

Resources