Skip to content

Commit

Permalink
Merge pull request #51 from kommitters/v1.1
Browse files Browse the repository at this point in the history
Prepare v1.1.2 release
  • Loading branch information
MarioRodriguezS authored Jan 19, 2022
2 parents 0fef278 + 56b670e commit 286a644
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.1.2 (18.01.2022)
* set the plugin to recognize any editor Id

## 1.1.1 (07.12.2021)
* Reduce the gif size

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@ const editor = EditorJS({
underline: true,
backgroundColor: '#154360',
textColor: '#FDFEFE',
holder: 'editorId',
}
}
}
});
```
Select some text, click on the tooltip button in the inline-tools bar, and type the tooltip in the input, when the key enter is pressed, the tooltip will be created.

**Note:** Use the holder field to indicate the EditorJS Id passed in the div tag, by default the holder field is 'editorjs'.

## Config Params

| Field | Type | Description |
Expand All @@ -58,6 +61,7 @@ Select some text, click on the tooltip button in the inline-tools bar, and type
| underline | `{ underline: boolean }` | You could add underline text decoration to the text wrapped by the tooltip
| backgroundColor | `{ backgroundColor: string }` | You could choose the tooltip color, you could pass hexadecimal colors or string colors
| textColor | `{ textColor: string }` | You could choose the tooltip text color, you could pass hexadecimal colors or string colors
| holder | `{ holder: string }` | If your EditorJS Id passed in the Editor tag is different from 'editorjs', use the holder field.

## Output data

Expand Down
2 changes: 1 addition & 1 deletion dist/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "editorjs-tooltip",
"version": "1.1.1",
"version": "1.1.2",
"keywords": [
"tool",
"tooltip",
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default class Tooltip {
this.underline = config.underline ? config.underline : false;
this.backgroundColor = config.backgroundColor;
this.textColor = config.textColor;
this.editorId = config.holder ? config.holder : 'editorjs';

this.tag = 'SPAN';

Expand Down Expand Up @@ -130,7 +131,7 @@ export default class Tooltip {
* Observe if some tooltip span is inserted and create the respective tooltip
*/
tooltipsObserver() {
const holder = document.getElementById('editorjs');
const holder = document.getElementById(this.editorId);
const observer = new MutationObserver((mutationList) => {
mutationList.forEach((mutation) => {
if (mutation.type === 'childList'
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const config = {
underline: true,
backgroundColor: 'blue',
textColor: 'white',
holder: 'editorjs2',
};

/**
Expand Down
19 changes: 14 additions & 5 deletions test/tooltip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ describe('Tooltip', () => {
let tooltip;
beforeEach(() => {
document.body.innerHTML = `<div id= "editorjs"><span id="tooltip">Tooltip text</span></div>
<div class= "ct tooltip-color ct--right ct--shown">
<div class= "ct__content tooltip-text-color">tooltip</div></div>`;
<div class= "ct tooltip-color ct--right ct--shown">
<div class= "ct__content tooltip-text-color">tooltip</div></div>`;
});

describe('validates panel components', () => {
Expand Down Expand Up @@ -41,14 +41,23 @@ describe('Tooltip', () => {
});
});

describe('validates tooltip position', () => {
describe('validates config parameters', () => {
beforeEach(() => {
document.body.innerHTML = `<div id= "editorjs2"><span id="tooltip">Tooltip text</span></div>
<div class= "ct tooltip-color ct--right ct--shown">
<div class= "ct__content tooltip-text-color">tooltip</div></div>`;
});

it('validates position', () => {
tooltip = createTooltipRightPosition();
expect(tooltip.tooltipLocation).toBe('right');
});
});

describe('validates tooltip background color and underline decoration', () => {
it('validates holder', () => {
tooltip = createTooltipRightPosition();
expect(tooltip.editorId).toBe('editorjs2');
});

it('validates color and underline decoration', () => {
tooltip = createTooltipRightPosition();

Expand Down

0 comments on commit 286a644

Please sign in to comment.