[英]JavaScript WYSIWYG Rich Text Editor
What is the basic method of styling text inside input boxes? 在输入框内设置文本样式的基本方法是什么? Can you show me the most simple example of how to change text color separately?
你能告诉我一个如何分别改变文字颜色的最简单的例子吗?
Very simply: 非常简单:
window.document.designMode = “On”;
document.execCommand(‘ForeColor’, false, ‘red’);
For more detail: 有关详细信息:
http://shakthydoss.com/javascript/html-rich-text-editor/ http://shakthydoss.com/javascript/html-rich-text-editor/
and then 然后
http://shakthydoss.com/javascript/stxe-html-rich-text-editor/ http://shakthydoss.com/javascript/stxe-html-rich-text-editor/
There are 4 approaches you can adopt 您可以采用4种方法
insertHtml
to preview div. insertHtml
以预览div。 Trix uses the same approach but programmatically. Example 例
angular.module("myApp", [])
.directive("click", function () {
return {
restrict: "A",
link: function (scope, element, attrs) {
element.bind("click", function () {
scope.$evalAsync(attrs.click);
});
}
};
})
.controller("Example", function ($scope) {
$scope.supported = function (cmd) {
var css = !!document.queryCommandSupported(cmd.cmd) ? "btn-succes" : "btn-error"
return css
};
$scope.icon = function (cmd) {
return (typeof cmd.icon !== "undefined") ? "fa fa-" + cmd.icon : "";
};
$scope.doCommand = function (cmd) {
if ($scope.supported(cmd) === "btn-error") {
alert("execCommand(“" + cmd.cmd + "”)\nis not supported in your browser");
return;
}
val = (typeof cmd.val !== "undefined") ? prompt("Value for " + cmd.cmd + "?", cmd.val) : "";
document.execCommand(cmd.cmd, false, (cmd.val || ""));
}
$scope.commands = commands;
$scope.tags = [
'Bootstrap', 'AngularJS', 'execCommand'
]
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.