mirror of
https://github.com/codex-team/editor.js
synced 2024-05-27 19:12:56 +02:00
comparison improved
This commit is contained in:
parent
dfbc53419f
commit
12c1e33d1d
|
@ -772,7 +772,7 @@ export default class Block extends EventsDispatcher<BlockEvents> {
|
|||
return toolboxItems.find((item) => {
|
||||
return Object.entries(item.data)
|
||||
.some(([propName, propValue]) => {
|
||||
return blockData[propName] && blockData[propName] === propValue;
|
||||
return blockData[propName] && _.equals(blockData[propName], propValue);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -352,7 +352,7 @@ export default class ConversionToolbar extends Module<ConversionToolbarNodes> {
|
|||
* @param entry2 - entry to compare with
|
||||
*/
|
||||
function isTheSameToolboxEntry(entry1, entry2): boolean {
|
||||
return entry1.icon + entry1.title === entry2.icon + entry2.title;
|
||||
return entry1.icon === entry2.icon && entry1.title === entry2.title;
|
||||
}
|
||||
|
||||
this.tools.forEach(tool => {
|
||||
|
|
|
@ -779,3 +779,21 @@ export const isIosDevice =
|
|||
window.navigator.platform &&
|
||||
(/iP(ad|hone|od)/.test(window.navigator.platform) ||
|
||||
(window.navigator.platform === 'MacIntel' && window.navigator.maxTouchPoints > 1));
|
||||
|
||||
/**
|
||||
* Compares two values with unknown type
|
||||
*
|
||||
* @param var1 - value to compare
|
||||
* @param var2 - value to compare with
|
||||
* @returns true if they are equal
|
||||
*/
|
||||
export function equals(var1: unknown, var2: unknown): boolean {
|
||||
const isVar1NonPrimitive = Array.isArray(var1) || isObject(var1);
|
||||
const isVar2NonPrimitive = Array.isArray(var2) || isObject(var2);
|
||||
|
||||
if (isVar1NonPrimitive || isVar2NonPrimitive) {
|
||||
return JSON.stringify(var1) === JSON.stringify(var2);
|
||||
}
|
||||
|
||||
return var1 === var2;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue