diff --git a/packages/editor/src/lib/index.css b/packages/editor/src/lib/index.css index 294d073..b9af820 100644 --- a/packages/editor/src/lib/index.css +++ b/packages/editor/src/lib/index.css @@ -74,7 +74,7 @@ padding: 0.5rem 1rem; text-align: left; transition-duration: 100ms; - transition-property: color background-color; + transition-property: color, background-color; background-color: var(--tiptap-object-bg); color: var(--tiptap-object-fg); } diff --git a/packages/util/src/Repository.ts b/packages/util/src/Repository.ts index 20a4276..e12de1c 100644 --- a/packages/util/src/Repository.ts +++ b/packages/util/src/Repository.ts @@ -125,7 +125,7 @@ export class Repository extends Emitter { const applied = this._applyAnyFilter(originalFilter) const filter = applied?.filter || originalFilter const events = applied ? this._getEvents(applied!.ids) : this.dump() - const sorted = shouldSort ? sortBy((e: E) => -e.created_at, events) : events + const sorted = this._sortEvents(shouldSort && Boolean(filter.limit), events) const chunk: E[] = [] for (const event of sorted) { @@ -145,7 +145,10 @@ export class Repository extends Emitter { result.push(chunk) } - return uniq(flatten(result)) + // Only re-sort if we had multiple filters, or if our single filter wasn't sorted + const shouldSortAll = shouldSort && (filters.length > 1 || !filters[0]?.limit) + + return this._sortEvents(shouldSortAll, uniq(flatten(result))) } publish = (event: E, {shouldNotify = true} = {}): boolean => { @@ -229,6 +232,9 @@ export class Repository extends Emitter { // Utilities + _sortEvents = (shouldSort: boolean, events: E[]) => + shouldSort ? sortBy(e => -e.created_at, events) : events + _updateIndex = (m: Map, k: K, add?: E, remove?: E) => { let a = m.get(k) || []