How to set default Style at current position in CKEditor..? - javascript

How to set the some default CKEditor styles(Presented in Styles combo box) at the current position through javascript.?
For example if the cursor in one position, i have to set the 'Marker: Yellow' style for that position after typing any character it should change to Yellow. Is it Possible?

I'm not sure if I understood you, but isn't you just want to exec command applying (or removing) e.g. bold style? If yes you can do this by:
editor.execCommand('bold');
If you've got empty selection (caret) placed somewhere in the text, before executing this command, editor will create empty <strong>^</strong> element, so when user starts to type, the text will be bolded.
Update
Styles are applied in a little bit different way.
var style = new CKEDITOR.style(
{ name: 'Blue Title', element: 'h3', styles: { 'color': 'Blue' } });
style.apply(editor.document);
That will apply Blue Title style to the current selection. You can find other styles definitions in _source/plugins/styles/styles/default.js (http://dev.ckeditor.com/browser/CKEditor/trunk/_source/plugins/styles/styles/default.js) or you can get them in the code:
editor.getStylesSet(function(stylesDefinitions) {
// stylesDefinitions is an array
});

Related

Add new line/blank div/padding in VueJS h (hyperscript) functions

I'm working on a project using VueJS's h() functions and all the content I need to include needs to be inside one of these. I'm trying to add content to a div by appending additional h('divs') to it, but need a way to space them (and the text inside them) out.
I've tried using '\n' and '< / br>', both with and without quotes, to add new lines, but this doesn't work - with quotes it gets included as text, and without it says there's an unexpected '<'. I've also tried to add padding inside style tags, following the example in the documentation:
h('div', {style: { margin: 100, padding:100 } })
but this doesn't do anything. How can I space out the h() function divs and the text inside?
You can add CSS styles to the style property of the h() function to control the spacing of the divs and the text inside them. To add padding, you can use the padding property with a CSS length value in pixels, ems, or any other valid CSS unit.
Here's an example:
h('div', {
style: {
padding: '20px'
}
}, [
h('div', 'This is the first div'),
h('div', 'This is the second div'),
h('div', 'This is the third div')
])
This will add 20 pixels of padding to each of the divs inside the main div, spacing them out vertically. You can adjust the padding value as needed to control the amount of space between the divs.
Hope this is helpful.

ExtJS 6 Charts -- change title color

I have a chart with a title like so:
{
xtype:"cartesian",
axes:[{
type:"numeric",
position:"bottom",
fields:"ABC",
title:"BLAH",
....
...
}]
}
previously in with ext 4 I was using css to style the tspan el
tspan{
fill:"#fff";
}
but in ext6 the same doesnt work nor can I inspect the tspan element like I was able to in ext 4.
I also tried:
title:"<font color='#fff'><BLAH></font>"
this did not work and in place of the title it shows the above font tag
how can I change my chart title to white?
thx
If given a String, the 'text' attribute of the title sprite will be set, otherwise the style will be set.
use the config style to set the text color, just add
style: {
color: #fff
}
you can read more here http://docs.sencha.com/extjs/5.1/5.1.2-apidocs/#!/api/Ext.chart.axis.Axis
same on ext 6

After a background color change with Javascript the :hover don't change the color

I have a long form with many fields. Some of the fields get their data from separate DIV, where there are other more specific fields.
Every field, along with its label, is included into a separate block. To highlight the fields there is a CSS :hover for their class.
The CSS :hoveron the fields blocks works smoothly, and also the onmouseover and onmouseout over the many DIV passing data to them, using the following Javascript:
function LineOn(whichOne) {
document.getElementById(whichOne).style.backgroundColor = '#cf0';
}
function LineOff(whichOne) {
document.getElementById(whichOne).style.backgroundColor = '#fff';
}
But, after the execution of the Javascript, the hover stops to work (i.e. the block remains white), without reporting any console error or message.
This happens both with Firefox 36.0.3 and with Chrome 39.0.2171.71, running on a Slackware current release.
Is there a sort of hierarchy giving to the background color set with Javascript the priority over the one defined in the <style> section?
Yes, styles defined directly in the element's style property overrides any value set in CSS, unless that style has !important on it.
CSS specificity http://www.w3.org/wiki/CSS/Training/Priority_level_of_selector
The priority level of the selector is decided in Point of combination of selectors.
style attribute = a
number of ID attributes in the selector = b
number of other attributes and pseudo-classes in the selector = c
number of element names and pseudo-elements in the selector = d
That's one good reason not to set styles attributes; set a CSS class instead yet.

InDesign: Changing default Cell Style

I am trying to change the default document settings for a batch of InDesign documents – that is, the styles, swatches etc. that are 'active' (marked blue) in an open document with nothing selected.
But I have a hard time figuring out how to change the default cell style.
Stroke swatch, Paragraph style and Character style are simple:
app.activeDocument.pageItemDefaults.strokeColor = "Black";
app.activeDocument.textDefaults.appliedParagraphStyle = app.activeDocument.paragraphStyles.item ("[Basic Paragraph]");
app.activeDocument.textDefaults.appliedCharacterStyle = app.activeDocument.characterStyles.item ("[None]");
Cell style, however, is not so easily accessed, even though it is really just a simple mouse-click for a user. There is no 'appliedCellStyle' property.
How can I do this?
I think defalut cell style is "None", though selected other cell style in GUI
if you want apply default cell style as "None", there are no need to do.
when create a table without applying table style, the cells are always applyied 'None'.
please try this code.
var table = app.activeDocument.textFrames.add().tables.add();
alert(table.cells.firstItem().appliedCellStyle.name);
thank you
mg

Indesign CS6, Javascript

I am a javascript beginner. I am working in indesign CS6. I have assigned paragraph and character styles to all the fonts being used throughout my document. Using character styles I have changed the color of some type to be purple. The purple text is being used to call specific attention to that text. However I want to be able to toggle on and off the purple text. When I toggle off the purple I want the text to change to gray. I do need to be able to change it back to purple as well. Is there anyway to do this using script?
Thank you!
You can create a dedicated swatch and change its color components to fit your taste.
All references e.g. from within styles will follow.
// assuming the swatch is already created
var swatch = app.activeDocument.swatches.itemByName("purple");
swatch.properties = {model:1886548851, space:1129142603, colorValue:[0, 0, 0, 30]};
The following script changes the internal color setting of the specified character style, from a 'purple'-named swatch to a 'grey'-names swatch, and vice-versa.
var myDoc = app.activeDocument;
var charStyle = myDoc.characterStyles.item('My Character Style');
var purple = myDoc.colors.item('purple');
var grey = myDoc.colors.item('grey');
if (charStyle.fillColor == purple)
charStyle.fillColor = grey;
else charStyle.fillColor = purple;
If it's set to Purple then it changes to Grey, and if it's set to Grey it changes to Purple.
(change the swatch names and character style to suit your needs)
you can try this :
http://forum.jquery.com/topic/toggle-change-row-color
try to create a class for your "purple text" , and add/remove the class to change the colors.
there is a similar question at this link :
How do you toggle links to stay a certain color until clicked again

Categories

Resources