Compare commits

...

2 Commits

Author SHA1 Message Date
Kevin Jahns
8586806932 13.6.6 2023-06-25 19:10:34 +02:00
Kevin Jahns
981340139f skip iterating when there are no formatting items - replaces #547 2023-06-25 12:46:02 +02:00
4 changed files with 21 additions and 14 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "yjs",
"version": "13.6.5",
"version": "13.6.6",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "yjs",
"version": "13.6.5",
"version": "13.6.6",
"license": "MIT",
"dependencies": {
"lib0": "^0.2.74"

View File

@@ -1,6 +1,6 @@
{
"name": "yjs",
"version": "13.6.5",
"version": "13.6.6",
"description": "Shared Editing Library",
"main": "./dist/yjs.cjs",
"module": "./dist/yjs.mjs",

View File

@@ -1,6 +1,6 @@
import {
AbstractType, UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, Item, StructStore, Transaction // eslint-disable-line
YText, UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, Item, StructStore, Transaction // eslint-disable-line
} from '../internals.js'
import * as error from 'lib0/error'
@@ -47,28 +47,30 @@ export class ContentFormat {
}
/**
* @param {number} offset
* @param {number} _offset
* @return {ContentFormat}
*/
splice (offset) {
splice (_offset) {
throw error.methodUnimplemented()
}
/**
* @param {ContentFormat} right
* @param {ContentFormat} _right
* @return {boolean}
*/
mergeWith (right) {
mergeWith (_right) {
return false
}
/**
* @param {Transaction} transaction
* @param {Transaction} _transaction
* @param {Item} item
*/
integrate (transaction, item) {
integrate (_transaction, item) {
// @todo searchmarker are currently unsupported for rich text documents
/** @type {AbstractType<any>} */ (item.parent)._searchMarker = null
const p = /** @type {YText} */ (item.parent)
p._searchMarker = null
p._hasFormatting = true
}
/**

View File

@@ -505,7 +505,7 @@ export const cleanupYTextAfterTransaction = transaction => {
// cleanup in a new transaction
transact(doc, (t) => {
iterateDeletedStructs(transaction, transaction.deleteSet, item => {
if (item instanceof GC || needFullCleanup.has(/** @type {YText} */ (item.parent))) {
if (item instanceof GC || !(/** @type {YText} */ (item.parent)._hasFormatting) || needFullCleanup.has(/** @type {YText} */ (item.parent))) {
return
}
const parent = /** @type {YText} */ (item.parent)
@@ -859,9 +859,14 @@ export class YText extends AbstractType {
*/
this._pending = string !== undefined ? [() => this.insert(0, string)] : []
/**
* @type {Array<ArraySearchMarker>}
* @type {Array<ArraySearchMarker>|null}
*/
this._searchMarker = []
/**
* Whether this YText contains formatting attributes.
* This flag is updated when a formatting item is integrated (see ContentFormat.integrate)
*/
this._hasFormatting = false
}
/**
@@ -911,7 +916,7 @@ export class YText extends AbstractType {
const event = new YTextEvent(this, transaction, parentSubs)
callTypeObservers(this, transaction, event)
// If a remote change happened, we try to cleanup potential formatting duplicates.
if (!transaction.local) {
if (!transaction.local && this._hasFormatting) {
transaction._needFormattingCleanup = true
}
}