MCPcopy
hub / github.com/Bistutu/FluentRead / removeTriggerSymbols

Function removeTriggerSymbols

entrypoints/content.ts:779–806  ·  view source on GitHub ↗

* 根据触发方式去除末尾的触发符号

(text: string, triggerType: string)

Source from the content-addressed store, hash-verified

777 * 根据触发方式去除末尾的触发符号
778 */
779function removeTriggerSymbols(text: string, triggerType: string): string {
780 if (!text || triggerType === 'disabled' || triggerType === 'ctrl_enter') {
781 return text;
782 }
783
784 let triggerSymbol = '';
785 switch (triggerType) {
786 case 'triple_space':
787 triggerSymbol = ' ';
788 break;
789 case 'triple_equal':
790 triggerSymbol = '=';
791 break;
792 case 'triple_dash':
793 triggerSymbol = '-';
794 break;
795 default:
796 return text;
797 }
798
799 // 去除末尾所有的触发符号
800 let cleanedText = text;
801 while (cleanedText.endsWith(triggerSymbol)) {
802 cleanedText = cleanedText.slice(0, -1);
803 }
804
805 return cleanedText.trim();
806}
807
808/**
809 * 设置输入框中的文本

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected