Skip to content

Commit

Permalink
Fixed Remove anchor element when set black text color. #936
Browse files Browse the repository at this point in the history
Issue: #936
  • Loading branch information
xdan committed Feb 13, 2023
1 parent d45058a commit ea0055d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

- [Wrong new empty paragraph location when cursor is set after a table and <Enter> key is pressed #953](https://github.com/xdan/jodit/issues/953)
- The PluginSystem module has been refactored: now asynchronous plugins do not block the initialization of the editor and it is ready to work without them.
- [Remove anchor element when set black text color. #936](https://github.com/xdan/jodit/issues/936)

## 3.24.4

Expand Down
1 change: 1 addition & 0 deletions src/core/selection/style/api/toggle-attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function toggleAttributes(
mode: CommitMode,
dry: boolean = false
): CommitMode {
debugger
if (!dry && commitStyle.isApplied(elm, tak)) {
return mode;
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/selection/style/apply-style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ export function ApplyStyle(jodit: IJodit, cs: ICommitStyle): void {
IStyleTransactionValue
>(states.START, transactions);
state.element = font.value;
// machine.disableSilent();
machine.disableSilent();

while (machine.getState() !== states.END) {
state = machine.dispatch('exec', state);
// console.log(machine.getState(), state);
console.log(machine.getState(), state);
}
// console.log('-------------------');
console.log('-------------------');

font = gen.next();
}
Expand Down
30 changes: 29 additions & 1 deletion src/core/selection/style/style.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

const { Dom } = Jodit.modules;

describe('Apply style', () => {
describe.only('Apply style', () => {
describe('Test Style module', function () {
let editor;

Expand All @@ -20,6 +20,34 @@ describe('Apply style', () => {

describe('Base apply', () => {
[
[
'<p><a href="https://xdsoft.net/jodit/">|https://xdsoft.net/jodit/|</a></p>',
{
attributes: {
style: { color: '#000000' }
}
},
// https://github.com/xdan/jodit/issues/936
'<p><a href="https://xdsoft.net/jodit/">|https://xdsoft.net/jodit/|</a></p>'
],
[
'<p><a href="https://xdsoft.net/jodit/" style="color:#000001">|https://xdsoft.net/jodit/|</a></p>',
{
attributes: {
style: { color: '#000001' }
}
},
'<p><a href="https://xdsoft.net/jodit/">|https://xdsoft.net/jodit/|</a></p>'
],
[
'<p><a href="https://xdsoft.net/jodit/">|https://xdsoft.net/jodit/|</a></p>',
{
attributes: {
style: { color: '#000001' }
}
},
'<p><a href="https://xdsoft.net/jodit/" style="color:#000001">|https://xdsoft.net/jodit/|</a></p>'
],
[
'<p><strong>|test</strong> pop <strong>test|</strong></p>',
{
Expand Down
5 changes: 5 additions & 0 deletions src/core/selection/style/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ export const transactions: IStyleTransactions = {
return { ...value, next: states.CHANGE };
}

// Apply same color for anchor https://github.com/xdan/jodit/issues/936
if (!Dom.isTag(element, style.element)) {
return { ...value, next: states.END };
}

return { ...value, next: states.UNWRAP };
}
},
Expand Down

0 comments on commit ea0055d

Please sign in to comment.