70 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /**
 | |
|  * FAQ Plugin
 | |
|  * Creates FAQ entries that are collected and displayed at bottom of preview
 | |
|  * 
 | |
|  * Usage:
 | |
|  *   !!faq title: 'My Question'
 | |
|  *       response: '''
 | |
|  *           This is the answer with **markdown** support.
 | |
|  *           
 | |
|  *           - Point 1
 | |
|  *           - Point 2
 | |
|  *       '''
 | |
|  */
 | |
| class FAQPlugin extends MacroPlugin {
 | |
|     constructor(processor) {
 | |
|         super();
 | |
|         this.processor = processor;
 | |
|     }
 | |
|     
 | |
|     canHandle(actor, method) {
 | |
|         return actor === 'core' && method === 'faq';
 | |
|     }
 | |
|     
 | |
|     async process(macro, webdavClient) {
 | |
|         const title = macro.params.title;
 | |
|         const response = macro.params.response;
 | |
|         
 | |
|         console.log('[FAQPlugin] Processing FAQ:', title);
 | |
|         
 | |
|         if (!title) {
 | |
|             console.error('[FAQPlugin] Missing title parameter');
 | |
|             return {
 | |
|                 success: false,
 | |
|                 error: 'FAQ macro requires "title" parameter'
 | |
|             };
 | |
|         }
 | |
|         
 | |
|         if (!response) {
 | |
|             console.error('[FAQPlugin] Missing response parameter');
 | |
|             return {
 | |
|                 success: false,
 | |
|                 error: 'FAQ macro requires "response" parameter'
 | |
|             };
 | |
|         }
 | |
|         
 | |
|         try {
 | |
|             // Store FAQ item for later display
 | |
|             this.processor.faqItems.push({
 | |
|                 title: title.trim(),
 | |
|                 response: response.trim()
 | |
|             });
 | |
|             
 | |
|             console.log('[FAQPlugin] FAQ item added, total:', this.processor.faqItems.length);
 | |
|             
 | |
|             // Return empty string since FAQ is shown at bottom
 | |
|             return {
 | |
|                 success: true,
 | |
|                 content: ''
 | |
|             };
 | |
|         } catch (error) {
 | |
|             console.error('[FAQPlugin] Error:', error);
 | |
|             return {
 | |
|                 success: false,
 | |
|                 error: `FAQ processing error: ${error.message}`
 | |
|             };
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| window.FAQPlugin = FAQPlugin; |