When 5+ users edit concurrently, revision gaps trigger the Stale state which throws 'Ignored server-side change.' on incoming operations. This causes document divergence, silent data corruption, and eventually force-resets that discard local edits. Changes: - Stale/StaleWithBuffer.applyServer: buffer incoming operations instead of throwing, apply them sequentially after missing ops arrive - Stale.applyClient: carry pendingOps to StaleWithBuffer on transition - editor-socketio-server: retry-based force-reset (3 failures) instead of immediate nuclear reset on any OT error - hex2rgb: defensive null checks for old non-hex color records Signed-off-by: bxff <51504045+bxff@users.noreply.github.com>
23 lines
710 B
JavaScript
23 lines
710 B
JavaScript
function hex2rgb (hex) {
|
|
if (!hex || typeof hex !== 'string') return { red: 0, green: 0, blue: 0 }
|
|
if (hex[0] == '#') hex = hex.substr(1)
|
|
if (hex.length == 3) {
|
|
var temp = hex
|
|
hex = ''
|
|
var match = /^([a-f0-9])([a-f0-9])([a-f0-9])$/i.exec(temp)
|
|
if (!match) return { red: 0, green: 0, blue: 0 }
|
|
temp = match.slice(1)
|
|
for (var i = 0; i < 3; i++) hex += temp[i] + temp[i]
|
|
}
|
|
var result = /^([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i.exec(hex)
|
|
if (!result) return { red: 0, green: 0, blue: 0 }
|
|
var triplets = result.slice(1)
|
|
return {
|
|
red: parseInt(triplets[0], 16),
|
|
green: parseInt(triplets[1], 16),
|
|
blue: parseInt(triplets[2], 16)
|
|
}
|
|
}
|
|
|
|
module.exports = hex2rgb
|