Remove debug output
This commit is contained in:
@@ -4,6 +4,7 @@ Copyright (c) 2025 trading_peter
|
||||
This program is available under Apache License Version 2.0
|
||||
*/
|
||||
|
||||
import './tp-rtb-emoji-suggestion.js';
|
||||
import { LitElement, html, css } from 'lit';
|
||||
import { Editor } from '@tiptap/core';
|
||||
import Document from '@tiptap/extension-document';
|
||||
@@ -13,9 +14,6 @@ import HardBreak from '@tiptap/extension-hard-break';
|
||||
import { UndoRedo } from '@tiptap/extensions';
|
||||
import Mention from '@tiptap/extension-mention';
|
||||
import { MenuPositioner } from './menu-positioner.js';
|
||||
import './tp-rtb-emoji-suggestion.js';
|
||||
|
||||
|
||||
import { FormElement } from '@tp/helpers/form-element.js';
|
||||
|
||||
class TpRichTextBox extends FormElement(LitElement) {
|
||||
@@ -324,20 +322,63 @@ class TpRichTextBox extends FormElement(LitElement) {
|
||||
// If we have suggestions, add a single Mention extension with all suggestions
|
||||
if (suggestions.length > 0) {
|
||||
this.extensions.push(
|
||||
Mention.configure({
|
||||
Mention.extend({
|
||||
addAttributes() {
|
||||
return {
|
||||
...this.parent?.(),
|
||||
subtype: {
|
||||
default: null,
|
||||
parseHTML: element => {
|
||||
const subtype = element.getAttribute('data-subtype');
|
||||
if (subtype) return subtype;
|
||||
|
||||
// Infer from class or other attributes for backward compatibility
|
||||
if (element.classList.contains('command-mention')) return 'command';
|
||||
if (element.classList.contains('user-mention')) return 'user';
|
||||
if (element.getAttribute('data-mention-suggestion-char') === '/') return 'command';
|
||||
if (element.getAttribute('data-mention-suggestion-char') === '@') return 'user';
|
||||
|
||||
return null;
|
||||
},
|
||||
renderHTML: attributes => {
|
||||
if (!attributes.subtype) {
|
||||
return {}
|
||||
}
|
||||
return {
|
||||
'data-subtype': attributes.subtype,
|
||||
}
|
||||
},
|
||||
},
|
||||
date: {
|
||||
default: null,
|
||||
parseHTML: element => element.getAttribute('data-date'),
|
||||
renderHTML: attributes => {
|
||||
if (!attributes.date) {
|
||||
return {}
|
||||
}
|
||||
return {
|
||||
'data-date': attributes.date,
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}).configure({
|
||||
suggestions: suggestions,
|
||||
renderHTML({ options, node, suggestion }) {
|
||||
renderHTML({ options, node }) {
|
||||
const subtype = node.attrs.subtype;
|
||||
const suggestion = suggestions.find(s => s.suggestionType === subtype);
|
||||
|
||||
if (suggestion && suggestion.renderHTML) {
|
||||
return suggestion.renderHTML({ options, node, suggestion });
|
||||
}
|
||||
|
||||
console.warn('No renderHTML defined for mention suggestion. Using default rendering.');
|
||||
|
||||
return [
|
||||
'span',
|
||||
{
|
||||
'data-type': 'mention',
|
||||
contenteditable: 'false'
|
||||
contenteditable: 'false',
|
||||
'data-subtype': subtype
|
||||
},
|
||||
node.attrs.label || node.attrs.id
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user