Config TinyMCE, TinyMCErte by a external config JSON-File - tinymce

In MODX Revo, TinyMCErte I try to configure the PlugIn via the key tinymcerte.external_config. The config-File has to be valid JSON.
Here is my block, it is ignored.
I want TinyMCE not to convert special characters like german umlaute (öäü) and of cource & should stay & and not &
tinymce.init({
forced_root_block : false,
entity_encoding : "raw"
})

TinyMCE Rich Text Editor (Ver. 1.1.1) is reading the external config file.
the path could be e.g. ../assets/components/tinymcerte/ext-config.json, but it would be advisible to store it in a non web accesible place.
Although this github-entry implies that it reads external config files vom core-path, assets-path and base-path I was not able to get it to work.
the content of the external config file has to be valid JSON:
{
"forced_root_block" : false,
"entity_encoding" : "raw"
}
The keys must be wrapped in "", in contrast to "native" TinyMCE settings (but not sure on this one...)

I did not managed to get the external config file working. I tried an absolute link and a relative. The file did not load anyway.
I edited the file tinymcerte.js in
assets\components\tinymcerte\js\mgr
after this in line 60
tinymce.init(this.cfg);
I put in my configuration before closing the }:
tinymce.init({
selector: "#ta",
schema: 'html5',
element_format : 'xhtml',
forced_root_block : false,
entity_encoding : 'raw'
})
Nevertheless the next update of the extra will destroy this fiddle.

The configuration is connected from the side of php. Therefore, the absolute and relative paths do not work.
Use this kinds of location:
"{base_path}/file.cfg"
"{core_path}/file.cfg"
"{assets_path}/file.cfg"

Related

Getting "Invalid prettier configuration file detected" error

I am getting following errors whenever I am trying to format my .ts or .html file using alt + shift + f
I have set prettier as the default formatter.
I have checked all the possible solutions from these posts.
Prettier: invalid configuration file even though the file is straight from the docs
prettier configuration error, prettier not working
https://linuxpip.org/vscode-prettier-not-working/
https://github.com/prettier/prettier-vscode/issues/1292
Also, I confirmed that the file prettier.config.js with following content does exist in my root directory
module.exports = {
tabWidth: 2,
semi: true,
singleQuote: true,
bracketSpacing: true,
printWidth: 100,
endOfLine: 'auto',
trailingComma: 'all',
};
Also, I have set the prettier as default formatter in my settings.json file
The problem is that is not giving any information of what the problem is with the config file.
And it says that See log for details. but I am not sure where to look for the logs
Any help?

Requiring config.js file in VSCode extension with absolute path (e.g. "C:\...") does not work

I am developing the Argdown VSCode extension. The Argdown parser can be configured using either argdown.config.json files or argdown.config.js files exporting a config object. Using Javascript files is the easiest way to allow users to add custom plugins to the Argdown parser.
If the user tells the parser to use a Javascript file, the file is loaded using import-fresh, (which uses node's require, but deletes the cached version.
Using the Argdown commandline tool (#argdown/cli) this works fine, but in the VSCode extension the module of the config file can not be found. The extension is using absolute file paths to require the config module (e.g. "C:\Users\my-username\projects\my-argdown-project\argdown.config.js"). These paths work with import-fresh outside of the VScode extension.
Is there a security restriction for VSCode extensions that does not allow to require modules with absolute file paths? Or is there some other reason why this does not work?
This was not related to VSCode. The problem was caused by bundling up import-fresh with webpack. I thought that webpack would ignore dynamic imports, but it did not.
I was lucky: Since last month, webpack supports "magic comments" for require (not only for import). So I can use:
require(/* webpackIgnore: true */ file);
You have to activate magic comments support in your webpack config:
module.exports = {
parser: {
javascript: {
commonjsMagicComments: true,
},
},
}
Now the next question is how to add the magic comments to the import-fresh package. For that I used the string-replace-loader:
module.exports = {
module: {
rules: {
{
enforce: "pre",
test: /import-fresh[\/\\]index\.js/,
loader: "string-replace-loader",
options: {
search:
"return parent === undefined ? require(filePath) : parent.require(filePath);",
replace:
"return parent === undefined ? require(/* webpackIgnore: true */ filePath) : parent.require(/* webpackIgnore: true */ filePath);",
},
},
}
}
}
After that, I could load the argdown.config.js files again, even after bundling everything with webpack.

Hashed file names using Rollup

I am fairly new to bundlers and rollup specifically. What is the best way to conditionally hash file names in rollup.config.js when building for production, while at the same time saving the index.html to reference the new .css and .js hashed versions?
I see this in the docs, but I guess I don't know how to conditionally set these options based on dev/prod settings?
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/build/bundle.js'
// entryFileNames : 'bundle[hash].js
},
or is using rollup-plugin-hash a better solution?
still not sure what the best practice would be for updating the index.html
(and what does the manifest file option provide?)
You can use a plugin like #rollup/plugin-html to generate a html file that references the hashed filenames.
It is also possible to use the rollup-plugin-manifest to generate a JSON file that will contain these hashed filenames.
This is useful when you can't generate the HTML using rollup for some reason.
Since the Rollup config file is just Javascript, you can include some if statements that return different results based on the dev/prod settings.
const isProduction = process.env.NODE_ENV === 'production';
export default {
output: {
sourcemap: true,
format: 'iife',
name: 'app',
entryFileName: isProduction ? 'bundle[hash].js' : 'public/build/bundle.js',
dir: './',
}
};

Need help to complete installation of linter-stylelint for Atom

I am really sorry for this newbie question but I can't see how solve that...
I installed linter-stylelint and tried to configure it like it's said there:
https://atom.io/packages/linter-stylelint
So:
- I placed a stylelint.config.js file in my project.
- In the settings, I checked Use standard
- But can't see what I have to do to "Add a stylelint section in your package.json"
On my Mac I see the file:
/Users/eric/node_modules/stylelint-config-standard
But I don't know what code do I have to insert inside...
By the way, when I try to use linter-stylelint in a css file I get the error message:
Unable to parse stylelint configuration
Unexpected token :
In my stylelint.config.js, I have the following code for now:
{
"extends": "stylelint-config-standard"
"rules" {
"no-unsupported-browser-features": [ true, { "severity": "warning" }]
}
}
Thanks if you can help me!
;)
Paul
So: - I placed a stylelint.config.js file in my project. - In the settings, I checked Use standard
According to the docs you reference, you should either place a stylelint.config.js file or check "Use standard".
I get the error message Unable to parse stylelint configuration Unexpected token :
This is because the JSON of your configuration file is invalid. It is missing both a comma and a colon. Use a service like JSONLint to validate JSON. Your fixed config is:
{
"extends": "stylelint-config-standard",
"rules": {
"no-unsupported-browser-features": [true, {
"severity": "warning"
}]
}
}
Even though this config is valid JSON, it won't work because the no-unsupported-browser-features rule is no longer built into stylelint. It is, however, available as a plugin. You'll need to follow the plugin's instructions if you wish to use it.
I am really sorry for this newbie question
It's fine. We are all newbies in the beginning! As you're just getting started with stylelint, I suggest you remove the stylelint.config.js file and ensure the "Use Standard" box is checked. This is likely the quickest way to get going. Once you are more comfortable with the tool, you can investigate creating your own configuration file for your specific needs.

TSLint Config in VS Code

I'm trying to configure the max line length (among other settings) for TS Lint in VS code but no matter what changes I make it doesn't 'take'.
So, the first strange thing is that VS code's TS Lint error for max line length says I've exceeded the 140 character limit but in the various config files I've found it only ever mentions 120 characters as the default.
I've changed this to 200 characters, disabled / enabled the extension but still get the 140 character warning. Does anyone know where and how to configure this setting? The documentation online is clear enough but I don't appear to have a tslint.json file and within the node_modules => tslint => lib => rules folder the setting is 120 and changing it makes no difference.
Edit 2020-09-30
Microsoft deprectaded the old plugin and released a newer, completely rewritten version with additional features here.
For the new plugin the setting "tslint.enable": true does not exists and is not needed anymore.
Original Answer
You need to create a tslint.json (in your workspace root) and set something like this to disable the maximum line length:
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"max-line-length": [false]
},
"rulesDirectory": []
}
Furthermore, ensure that the following options are set in the in the vscode user settings (settings.json):
"tslint.configFile": "./path/to/tslint/relative/from/workspaceroot/tslint.json",
"tslint.enable": true
The tslint.configFile option can be empty if the file is in the root directory of your workspace.
Further rules can be found here.