update
This commit is contained in:
@ -374,27 +374,25 @@ export class DeesInputWysiwyg extends DeesInputBase<string> {
|
||||
this.blurTimeout = null;
|
||||
}
|
||||
|
||||
if (block.type !== 'divider') {
|
||||
const prevSelectedId = this.selectedBlockId;
|
||||
this.selectedBlockId = block.id;
|
||||
const prevSelectedId = this.selectedBlockId;
|
||||
this.selectedBlockId = block.id;
|
||||
|
||||
// Only update selection UI if it changed
|
||||
if (prevSelectedId !== block.id) {
|
||||
// Update the previous block's selection state
|
||||
if (prevSelectedId) {
|
||||
const prevWrapper = this.shadowRoot?.querySelector(`[data-block-id="${prevSelectedId}"]`);
|
||||
const prevBlockComponent = prevWrapper?.querySelector('dees-wysiwyg-block') as any;
|
||||
if (prevBlockComponent) {
|
||||
prevBlockComponent.isSelected = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Only update selection UI if it changed
|
||||
if (prevSelectedId !== block.id) {
|
||||
// Update the previous block's selection state
|
||||
if (prevSelectedId) {
|
||||
const prevWrapper = this.shadowRoot?.querySelector(`[data-block-id="${prevSelectedId}"]`);
|
||||
const prevBlockComponent = prevWrapper?.querySelector('dees-wysiwyg-block') as any;
|
||||
if (prevBlockComponent) {
|
||||
prevBlockComponent.isSelected = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Update the new block's selection state
|
||||
const wrapper = this.shadowRoot?.querySelector(`[data-block-id="${block.id}"]`);
|
||||
const blockComponent = wrapper?.querySelector('dees-wysiwyg-block') as any;
|
||||
if (blockComponent) {
|
||||
blockComponent.isSelected = true;
|
||||
}
|
||||
// Update the new block's selection state
|
||||
const wrapper = this.shadowRoot?.querySelector(`[data-block-id="${block.id}"]`);
|
||||
const blockComponent = wrapper?.querySelector('dees-wysiwyg-block') as any;
|
||||
if (blockComponent) {
|
||||
blockComponent.isSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -451,9 +449,7 @@ export class DeesInputWysiwyg extends DeesInputBase<string> {
|
||||
// Focus last block if clicking on empty editor area
|
||||
if (target.classList.contains('editor-content')) {
|
||||
const lastBlock = this.blocks[this.blocks.length - 1];
|
||||
if (lastBlock.type !== 'divider') {
|
||||
this.blockOperations.focusBlock(lastBlock.id, 'end');
|
||||
}
|
||||
this.blockOperations.focusBlock(lastBlock.id, lastBlock.type === 'divider' || lastBlock.type === 'image' ? undefined : 'end');
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user