更新时间:2023-10-04 21:24:10
我的解决方案是在我的评论中使用评论系统,但在将页面内容提供给CKEditor之前,将它们转换为自定义HTML标记。然后,保存后,将它们转换回我的注释标签。
My solution to this was to use comments in my system, but before feeding the page content to CKEditor, convert them to custom HTML tags. Then, upon save, convert them back to my comment tags.
对于你的语法,这将是这样的PHP。将网页内容打印到textarea之前:
For your syntax that would be something like this in PHP. Before printing the page content to the textarea:
$content = str_replace(array('<!-- src -->','<!-- end src -->'),array('<protected>','</protected>'),$content);
保存结果内容之前:
$content = str_replace(array('<protected>','</protected>'),array('<!-- src -->','<!-- end src -->'),$content);
在CKEditor配置中:
In the CKEditor configuration:
protectedSource:[/<protected>[\s\S]*<\/protected>/g]
希望有帮助!