update
This commit is contained in:
@ -120,7 +120,8 @@ export class WysiwygKeyboardHandler {
|
||||
const blockOps = this.component.blockOperations;
|
||||
|
||||
// For non-editable blocks, create a new paragraph after
|
||||
if (block.type === 'divider' || block.type === 'image') {
|
||||
const nonEditableTypes = ['divider', 'image', 'youtube', 'markdown', 'html', 'attachment'];
|
||||
if (nonEditableTypes.includes(block.type)) {
|
||||
e.preventDefault();
|
||||
const newBlock = blockOps.createBlock();
|
||||
await blockOps.insertBlockAfter(block, newBlock);
|
||||
@ -145,59 +146,33 @@ export class WysiwygKeyboardHandler {
|
||||
// Split content at cursor position
|
||||
e.preventDefault();
|
||||
|
||||
console.log('Enter key pressed in block:', {
|
||||
blockId: block.id,
|
||||
blockType: block.type,
|
||||
blockContent: block.content,
|
||||
blockContentLength: block.content?.length || 0,
|
||||
eventTarget: e.target,
|
||||
eventTargetTagName: (e.target as HTMLElement).tagName
|
||||
});
|
||||
|
||||
// Get the block component - need to search in the wysiwyg component's shadow DOM
|
||||
const blockWrapper = this.component.shadowRoot?.querySelector(`[data-block-id="${block.id}"]`);
|
||||
console.log('Found block wrapper:', blockWrapper);
|
||||
|
||||
const blockComponent = blockWrapper?.querySelector('dees-wysiwyg-block') as any;
|
||||
console.log('Found block component:', blockComponent, 'has getSplitContent:', !!blockComponent?.getSplitContent);
|
||||
|
||||
if (blockComponent && blockComponent.getSplitContent) {
|
||||
console.log('Calling getSplitContent...');
|
||||
const splitContent = blockComponent.getSplitContent();
|
||||
|
||||
console.log('Enter key split content result:', {
|
||||
hasSplitContent: !!splitContent,
|
||||
beforeLength: splitContent?.before?.length || 0,
|
||||
afterLength: splitContent?.after?.length || 0,
|
||||
splitContent
|
||||
});
|
||||
|
||||
if (splitContent) {
|
||||
console.log('Updating current block with before content...');
|
||||
// Update current block with content before cursor
|
||||
blockComponent.setContent(splitContent.before);
|
||||
block.content = splitContent.before;
|
||||
|
||||
console.log('Creating new block with after content...');
|
||||
// Create new block with content after cursor
|
||||
const newBlock = blockOps.createBlock('paragraph', splitContent.after);
|
||||
|
||||
console.log('Inserting new block...');
|
||||
// Insert the new block
|
||||
await blockOps.insertBlockAfter(block, newBlock);
|
||||
|
||||
// Update the value after both blocks are set
|
||||
this.component.updateValue();
|
||||
console.log('Enter key handling complete');
|
||||
} else {
|
||||
// Fallback - just create empty block
|
||||
console.log('No split content returned, creating empty block');
|
||||
const newBlock = blockOps.createBlock();
|
||||
await blockOps.insertBlockAfter(block, newBlock);
|
||||
}
|
||||
} else {
|
||||
// No block component or method, just create empty block
|
||||
console.log('No getSplitContent method, creating empty block');
|
||||
const newBlock = blockOps.createBlock();
|
||||
await blockOps.insertBlockAfter(block, newBlock);
|
||||
}
|
||||
|
Reference in New Issue
Block a user