deployment fix
This commit is contained in:
parent
2528ad4726
commit
04f6fe5192
|
|
@ -65,44 +65,42 @@ export function usePinnedToView(editor: Editor | null, shapeId: string | undefin
|
||||||
|
|
||||||
// Bring the shape to the front by manually setting index
|
// Bring the shape to the front by manually setting index
|
||||||
// Note: sendToFront doesn't exist in this version of tldraw, so we use manual index setting
|
// Note: sendToFront doesn't exist in this version of tldraw, so we use manual index setting
|
||||||
try {
|
// Try to set a safe index value
|
||||||
// Try to set a safe index value
|
// Use conservative values that are known to work (a1, a2, b1, etc.)
|
||||||
// Use conservative values that are known to work (a1, a2, b1, etc.)
|
let newIndex: string = 'a2' // Safe default
|
||||||
let newIndex: string = 'a2' // Safe default
|
|
||||||
|
// Try to find a valid index higher than existing ones
|
||||||
// Try to find a valid index higher than existing ones
|
const allIndices = allShapes
|
||||||
const allIndices = allShapes
|
.map(s => s.index)
|
||||||
.map(s => s.index)
|
.filter((idx): idx is string => typeof idx === 'string' && /^[a-z]\d+$/.test(idx))
|
||||||
.filter((idx): idx is string => typeof idx === 'string' && /^[a-z]\d+$/.test(idx))
|
.sort()
|
||||||
.sort()
|
|
||||||
|
if (allIndices.length > 0) {
|
||||||
if (allIndices.length > 0) {
|
const highest = allIndices[allIndices.length - 1]
|
||||||
const highest = allIndices[allIndices.length - 1]
|
const match = highest.match(/^([a-z])(\d+)$/)
|
||||||
const match = highest.match(/^([a-z])(\d+)$/)
|
if (match) {
|
||||||
if (match) {
|
const letter = match[1]
|
||||||
const letter = match[1]
|
const num = parseInt(match[2], 10)
|
||||||
const num = parseInt(match[2], 10)
|
// Increment number, or move to next letter if number gets too high
|
||||||
// Increment number, or move to next letter if number gets too high
|
if (num < 100) {
|
||||||
if (num < 100) {
|
newIndex = `${letter}${num + 1}`
|
||||||
newIndex = `${letter}${num + 1}`
|
} else if (letter < 'y') {
|
||||||
} else if (letter < 'y') {
|
const nextLetter = String.fromCharCode(letter.charCodeAt(0) + 1)
|
||||||
const nextLetter = String.fromCharCode(letter.charCodeAt(0) + 1)
|
newIndex = `${nextLetter}1`
|
||||||
newIndex = `${nextLetter}1`
|
} else {
|
||||||
} else {
|
// Use a safe value if we're running out of letters
|
||||||
// Use a safe value if we're running out of letters
|
newIndex = 'a2'
|
||||||
newIndex = 'a2'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Validate before using
|
|
||||||
if (/^[a-z]\d+$/.test(newIndex)) {
|
// Validate before using
|
||||||
editor.updateShape({
|
if (/^[a-z]\d+$/.test(newIndex)) {
|
||||||
id: shapeId as TLShapeId,
|
editor.updateShape({
|
||||||
type: shape.type,
|
id: shapeId as TLShapeId,
|
||||||
index: newIndex as any,
|
type: shape.type,
|
||||||
})
|
index: newIndex as any,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error bringing pinned shape to front:', error)
|
console.error('Error bringing pinned shape to front:', error)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue