Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Matergi/editorjs-color-picker
Text Color Picker Tool for Editor.js 2.0
https://github.com/Matergi/editorjs-color-picker
Last synced: about 1 month ago
JSON representation
Text Color Picker Tool for Editor.js 2.0
- Host: GitHub
- URL: https://github.com/Matergi/editorjs-color-picker
- Owner: Matergi
- License: mit
- Created: 2024-10-04T11:41:36.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-29T14:52:30.000Z (3 months ago)
- Last Synced: 2024-10-29T15:56:19.146Z (3 months ago)
- Language: TypeScript
- Homepage:
- Size: 52.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-editorjs - editorjs-color-picker - Color Picker Tool (Tools / Block Tools)
README
# Color Picker Tool for Editor.js
https://github.com/user-attachments/assets/780b3856-26d8-44af-95d7-9c703211fcd4
## Installation
Get the package
```shell
yarn add editorjs-color-picker
```## Usage
Add a new Tool to the `tools` property of the Editor.js initial config.
```javascript
import ColorPicker from 'editorjs-color-picker';const editor = new EditorJS({
...tools: {
...
ColorPicker: {
class: ColorPicker,
},
}...
});
```If you don't want the text to retain its colors every time you copy and paste it into the editor, you can use the `ColorPickerWithoutSanitize` class.
```javascript
import { ColorPickerWithoutSanitize } from 'editorjs-color-picker';const editor = new EditorJS({
...tools: {
...
ColorPicker: {
class: ColorPickerWithoutSanitize,
},
}...
});
```## Config Params
The Paragraph Tool supports these configuration parameters:
| Field | Type | Description |
| ------- | ---------- | --------------------------------------------------- |
| colors | `string[]` | (there are default colors) Array of colors you want |
| columns | `number` | (default: `7`) Number of columns to display |## Issues with Copy and Paste
If you copy and paste text with a different background color, it adopts the style of the ``.
The only solution I’ve found so far, without modifying the paragraph component and its onPaste handler, is to apply this style.
For now, I’m only attaching it here without adding it to the library, as it might interfere with other plugins.
So, anyone interested should try applying this style:```css
.ce-paragraph span {
background-color: unset !important;
}
```
If anyone finds a more elegant solution, can open a PR, and we’ll fix it.