Html 文本区域转 svg 文本

发布于 2024-12-27 22:30:47 字数 2467 浏览 0 评论 0原文

是否可以将 html 中的文本区域中的文本转换为 svg 文本?文本区域具有格式化文本,即粗体、斜体、项目符号等。这是使用 jwysiwyg 库创建的。我附上代码:

`

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Example: Resizable - jWYSIWYG</title>
<link rel="stylesheet" type="text/css" href="../lib/blueprint/screen.css" media="screen, projection" />
<link rel="stylesheet" type="text/css" href="../lib/blueprint/print.css" media="print" />
<!--[if lt IE 8]><link rel="stylesheet" href="../lib/blueprint/ie.css" type="text/css" media="screen, projection" /><![endif]-->
<link rel="stylesheet" href="../../jquery.wysiwyg.css" type="text/css"/>
<link type="text/css" href="../lib/ui/jquery.ui.all.css" rel="stylesheet"/>
<script type="text/javascript" src="../lib/jquery.js"></script>
<script type="text/javascript" src="../../jquery.wysiwyg.js"></script>
<script type="text/javascript" src="../lib/ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../lib/ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../lib/ui/jquery.ui.mouse.js"></script>
<script type="text/javascript" src="../lib/ui/jquery.ui.resizable.js"></script>
<script type="text/javascript" src="../../controls/wysiwyg.image.js"></script>
<script type="text/javascript" src="../../controls/wysiwyg.link.js"></script>
<script type="text/javascript" src="../../controls/wysiwyg.table.js"></script>
<script type="text/javascript">
(function ($) {
    $(document).ready(function () {
        $('#wysiwyg').wysiwyg({
            resizeOptions: {},

            controls: {
                html: { visible: true }
            }
        });
    });
})(jQuery);
</script>
</head>
<body><div class="container">
    <h1>jWYSIWYG</h1>
    <h2>Example: Resizable</h2>
    <textarea id="wysiwyg" rows="5" cols="47"></textarea>

    <hr/>
    <a href="index.html">Index</a>
</div></body>
</html>

`

此参考页面是@ http://akzhan.github.com/jwysiwyg /

Is is possible to convert the text in a textarea in html to a svg text? The text area has formatted text i.e. bold, italics, bullets etc. This was created using jwysiwyg library. I am attaching the code:

`

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Example: Resizable - jWYSIWYG</title>
<link rel="stylesheet" type="text/css" href="../lib/blueprint/screen.css" media="screen, projection" />
<link rel="stylesheet" type="text/css" href="../lib/blueprint/print.css" media="print" />
<!--[if lt IE 8]><link rel="stylesheet" href="../lib/blueprint/ie.css" type="text/css" media="screen, projection" /><![endif]-->
<link rel="stylesheet" href="../../jquery.wysiwyg.css" type="text/css"/>
<link type="text/css" href="../lib/ui/jquery.ui.all.css" rel="stylesheet"/>
<script type="text/javascript" src="../lib/jquery.js"></script>
<script type="text/javascript" src="../../jquery.wysiwyg.js"></script>
<script type="text/javascript" src="../lib/ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../lib/ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../lib/ui/jquery.ui.mouse.js"></script>
<script type="text/javascript" src="../lib/ui/jquery.ui.resizable.js"></script>
<script type="text/javascript" src="../../controls/wysiwyg.image.js"></script>
<script type="text/javascript" src="../../controls/wysiwyg.link.js"></script>
<script type="text/javascript" src="../../controls/wysiwyg.table.js"></script>
<script type="text/javascript">
(function ($) {
    $(document).ready(function () {
        $('#wysiwyg').wysiwyg({
            resizeOptions: {},

            controls: {
                html: { visible: true }
            }
        });
    });
})(jQuery);
</script>
</head>
<body><div class="container">
    <h1>jWYSIWYG</h1>
    <h2>Example: Resizable</h2>
    <textarea id="wysiwyg" rows="5" cols="47"></textarea>

    <hr/>
    <a href="index.html">Index</a>
</div></body>
</html>

`

The reference page for this is @ http://akzhan.github.com/jwysiwyg/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

守护在此方 2025-01-03 22:30:47

您必须使用 tspan 分割 svg 中的各个部分。你可以在这里使用 css 。

<text x="382" y="238">
  <tspan >This text</tspan>
  <tspan style="font-weight:bold">is bold</tspan>
  <tspan> and this is normal</tspan>
</text>

此外,Highcharts 渲染器可以自动为您执行此操作:

http://www.highcharts.com/ref/# renderer

我自己经常使用它。

You have to split various sections in your svg with a tspan. You can just use css here.

<text x="382" y="238">
  <tspan >This text</tspan>
  <tspan style="font-weight:bold">is bold</tspan>
  <tspan> and this is normal</tspan>
</text>

Also, Highcharts renderer can do this for you automatically:

http://www.highcharts.com/ref/#renderer

I use this a lot myself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文