Skip to content

Commit

Permalink
AI Proofread: MD5 correct text
Browse files Browse the repository at this point in the history
  • Loading branch information
renatoagds committed Jul 16, 2024
1 parent 532a456 commit ea11111
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import { applyFormat } from '@wordpress/rich-text';
import md5 from 'crypto-js/md5';
/**
* Types
*/
Expand All @@ -26,11 +27,13 @@ const applyHighlightFormat = ( {
newContent = indexes.reduce(
(
acc: RichTextValue,
{ startIndex, endIndex }: { startIndex: number; endIndex: number }
{ startIndex, endIndex, text }: { startIndex: number; endIndex: number; text: string }
) => {
const currentAttr = { ...attributes, 'data-id': md5( text ) };

const format = {
type,
attributes,
attributes: currentAttr,
} as RichTextFormat;

return applyFormat( acc, format, startIndex, endIndex );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { select as globalSelect, useDispatch, useSelect } from '@wordpress/data'
import { __ } from '@wordpress/i18n';
import { registerFormatType, removeFormat, RichTextValue } from '@wordpress/rich-text';
import clsx from 'clsx';
import md5 from 'crypto-js/md5';
import React from 'react';
/**
* Internal dependencies
Expand Down Expand Up @@ -191,7 +190,6 @@ export function registerBreveHighlights() {
indexes: highlights,
attributes: {
'data-type': config.name,
'data-id': md5( text ),
'data-identifier': richTextIdentifier ?? 'none',
'data-block': blockClientId,
},
Expand Down

0 comments on commit ea11111

Please sign in to comment.