mirror of
https://github.com/docmost/docmost.git
synced 2026-05-20 16:44:05 +08:00
d2629afff2
* feat: add heading extension with unique ID support and scroll functionality * Added unique id for heading * remove baseUrl heading storage * move heading to extensions package * WIP * support anchors in mentions * enhance scrolling functionality * nodeId function * fix nanoid import * Bring unique-id extension local * fixes * fix internal link scroll in public pages * add unique id server side * rename mention anchor to anchorId * capture first anchorId on paste --------- Co-authored-by: Romik <40670677+RomikMakavana@users.noreply.github.com>
16 lines
374 B
TypeScript
16 lines
374 B
TypeScript
/**
|
|
* Removes duplicated values within an array.
|
|
* Supports numbers, strings and objects.
|
|
*/
|
|
export function removeDuplicates<T>(array: T[], by = JSON.stringify): T[] {
|
|
const seen: Record<any, any> = {}
|
|
|
|
return array.filter(item => {
|
|
const key = by(item)
|
|
|
|
return Object.prototype.hasOwnProperty.call(seen, key)
|
|
? false
|
|
: (seen[key] = true)
|
|
})
|
|
}
|