【问题标题】:PHP rich text editor initializable with html [closed]可使用 html 初始化的 PHP 富文本编辑器 [关闭]
【发布时间】:2015-10-26 07:01:58
【问题描述】:

您好,我的网站需要富文本编辑器,它可以将我的 html 文件作为开始时的输入。有人可以推荐我那种免费的 php 可竞争的富文本编辑器,我可以用我预先创建的 html 进行初始化,我需要从中获取输出(word 或 excel 或 pdf 等)

【问题讨论】:

  • 比较 TinyMCE 和 ckEditor。它们都被广泛使用。我使用 ckEditor。

标签: php html richtextbox rich-text-editor


【解决方案1】:

使用TinyMCE文本编辑器

<?php
 $allowedTags='<p><strong><em><u><h1><h2><h3><h4><h5><h6><img>';
 $allowedTags.='<li><ol><ul><span><div><br><ins><del>';  
// Should use some proper HTML filtering here.
  if($_POST['elm1']!='') {
    $sHeader = '<h1>Ah, content is king.</h1>';
    $sContent = strip_tags(stripslashes($_POST['elm1']),$allowedTags);
} else {
    $sHeader = '<h1>Nothing submitted yet</h1>';
    $sContent = '<p>Start typing...</p>';
    $sContent.= '<p><img width="107" height="108" border="0" src="/mediawiki/images/badge.png"';
    $sContent.= 'alt="TinyMCE button"/>This rover has crossed over</p>';
  }
?>
<html>
<head>
<title>My test editor - with tinyMCE and PHP</title>
<script language="javascript" type="text/javascript" src="/js/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
  tinyMCE.init({
    theme : "advanced",
    mode: "exact",
    elements : "elm1",
    theme_advanced_toolbar_location : "top",
    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,"
    + "justifyleft,justifycenter,justifyright,justifyfull,formatselect,"
    + "bullist,numlist,outdent,indent",
    theme_advanced_buttons2 : "link,unlink,anchor,image,separator,"
    +"undo,redo,cleanup,code,separator,sub,sup,charmap",
    theme_advanced_buttons3 : "",
    height:"350px",
    width:"600px"
});

</script>
</head>
<body>
 <?php echo $sHeader;?>
 <h2>Sample using TinyMCE and PHP</h2>
 <form method="post" action="<?=$_SERVER['REQUEST_URI']?>">
  <textarea id="elm1" name="elm1" rows="15" cols="80"><?php echo $sContent;?></textarea>
<br />
<input type="submit" name="save" value="Submit" />
<input type="reset" name="reset" value="Reset" />
</form>
</body>
</html>

Download editor

【讨论】:

  • 它应该对我有好处,但没有定义 elm1?
  • 对不起,请使用 isset($_POST['elm1']) @Furkan
  • 我可以使用编辑器上的按钮获得 msword 输出吗?
  • 或者我应该为 html 到 msword 使用其他不同的库吗?
  • 你需要额外的库。它会给你html响应
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-06
  • 2011-10-17
相关资源
最近更新 更多