顯示具有 WYSIWYG 標籤的文章。 顯示所有文章
顯示具有 WYSIWYG 標籤的文章。 顯示所有文章

2024年11月4日 星期一

[研究]ASP.NET,WebForm, 設定 Quill 2.0.0 WYSIWYG 的 toolbar 顯示全部按鈕及 Source

[研究]ASP.NET,WebForm, 設定 Quill 2.0.0 WYSIWYG 的 toolbar 顯示全部按鈕及 Source

2024-11-04

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

********************************************************************************

Quill - Your powerful rich text editor
https://quilljs.com/

Quill - Documentation
https://quilljs.com/docs/quickstart

Quill - Documentation - Toolbar Module
https://quilljs.com/docs/modules/toolbar

********************************************************************************

參考

https://quilljs.com/docs/modules/toolbar

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" 
    Inherits="WebApplication1.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <link href="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.snow.css" rel="stylesheet" />
    <script src="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.js"></script>
</head>
<body>
     <form id="form1" runat="server">
        <div>
            <asp:TextBox ID="TextBox1" TextMode="MultiLine" Rows="10" Columns="40" runat="server"></asp:TextBox><br />
            <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" /><br />
            <asp:Literal ID="Literal1" runat="server"></asp:Literal>
        </div>
    </form>
    <script type="text/javascript">
        var quill = new Quill('#TextBox1', {
            theme: 'snow',
            modules: {
                toolbar: [
                    ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
                    ['blockquote', 'code-block'],
                    ['link', 'image', 'video', 'formula'],

                    [{ 'header': 1 }, { 'header': 2 }],               // custom button values
                    [{ 'list': 'ordered' }, { 'list': 'bullet' }, { 'list': 'check' }],
                    [{ 'script': 'sub' }, { 'script': 'super' }],      // superscript/subscript
                    [{ 'indent': '-1' }, { 'indent': '+1' }],          // outdent/indent
                    [{ 'direction': 'rtl' }],                         // text direction

                    [{ 'size': ['small', false, 'large', 'huge'] }],  // custom dropdown
                    [{ 'header': [1, 2, 3, 4, 5, 6, false] }],

                    [{ 'color': [] }, { 'background': [] }],          // dropdown with defaults from theme
                    [{ 'font': [] }],
                    [{ 'align': [] }],

                    ['clean']                                         // remove formatting button
                ]
            }
        });
    </script>
</html>



Default.aspx.cs

using System;

namespace WebApplication1
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string quillContent = Request.Form["editor"];
            Response.Write("<script>alert('" + quillContent + "')</script>");
            Literal1.Text = TextBox1.Text;
        }
    }
}

有問題,版面很奇怪


表示 HTML Source Code 的 </> 按鈕按下也沒用,Rows 和 Columms 拿掉也怪

要用 <div id="editor"></div> 才行;下面都不行

<asp:TextBox ID="editor" runat="server"></asp:TextBox>

<asp:TextBox ID="editor" TextMode="MultiLine" runat="server"></asp:TextBox>

(完)

相關

[研究]ASP.NET,WebForm,試用Quill 2.0.0 WYSIWYG HTML editor 套件 (BSD)
https://shaurong.blogspot.com/2024/04/aspnetwebformquill-200-wysiwyg-html.html

[研究]ASP.NET,WebForm, 設定 Quill 2.0.0 WYSIWYG 的 toolbar 顯示全部按鈕及 Source
https://shaurong.blogspot.com/2024/11/aspnetwebform-quill-200-wysiwyg-toolbar.html


[研究]summernote-lite.min.js, summernote.min.js, summernote-bs4.min.js, summernote-bs5.min.js 比較試用

[研究]summernote-lite.min.js, summernote.min.js, summernote-bs4.min.js, summernote-bs5.min.js 比較試用

2024-11-04

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

********************************************************************************

以 libman 安裝 summernote 0.91 版

********************************************************************************

比較

版本適用 Bootstrap 版本是否需要 jQuery是否需要 Bootstrap說明
summernote-lite.min.js不依賴 Bootstrap輕量版本,無需 Bootstrap,內建樣式。
summernote.min.js無需特定版本通用版本,可搭配其他框架或自定樣式。
summernote-bs4.min.jsBootstrap 4專為 Bootstrap 4 設計,樣式適配 Bootstrap 4。
summernote-bs5.min.jsBootstrap 5專為 Bootstrap 5 設計,提供相容的樣式與結構。

使用建議 
  • 若已使用 Bootstrap,選擇與之相應的版本 (summernote-bs4.min.js 或 summernote-bs5.min.js)。 
  • 若未使用 Bootstrap,summernote-lite.min.js 為最佳選擇。

********************************************************************************

summernote-lite.min.js 版

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
    Inherits="WebApplication1.Default" ValidateRequest="false" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="lib/summernote/summernote-lite.min.css" rel="stylesheet" />
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <script type="text/javascript" src="lib/summernote/summernote-lite.min.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </form>
    <script type="text/javascript">
        $('#TextBox1').summernote({
            placeholder: 'Hello',
            tabsize: 2,
            height: 120
        });
    </script>
</body>
</html>

結果

********************************************************************************

summernote.min.js 版

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
    Inherits="WebApplication1.Default" ValidateRequest="false" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="lib/summernote/summernote.min.css" rel="stylesheet" />
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <script type="text/javascript" src="lib/summernote/summernote.min.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </form>
    <script type="text/javascript">
        $('#TextBox1').summernote({
            placeholder: 'Hello',
            tabsize: 2,
            height: 120
        });
    </script>
</body>
</html>



結果

********************************************************************************

summernote-bs4.min.js版

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
    Inherits="WebApplication1.Default" ValidateRequest="false" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.2/css/bootstrap.min.css" />
    <link href="lib/summernote/summernote-bs4.min.css" rel="stylesheet" />
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.2/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="lib/summernote/summernote-bs4.min.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </form>
    <script type="text/javascript">
        $('#TextBox1').summernote({
            placeholder: 'Hello',
            tabsize: 2,
            height: 120
        });
    </script>
</body>
</html>


結果


********************************************************************************

summernote-bs5.min.js版

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
    Inherits="WebApplication1.Default" ValidateRequest="false" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
<%--    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.2/css/bootstrap.min.css" />
    <link href="lib/summernote/summernote-bs4.min.css" rel="stylesheet" />
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.2/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="lib/summernote/summernote-bs4.min.js"></script>--%>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/css/bootstrap.min.css" />
    <link href="lib/summernote/summernote-bs5.min.css" rel="stylesheet" />
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="lib/summernote/summernote-bs5.min.js"></script>

    <%--<link href="lib/summernote/summernote.min.css" rel="stylesheet" />
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <script type="text/javascript" src="lib/summernote/summernote.min.js"></script>--%>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </form>
    <script type="text/javascript">
        $('#TextBox1').summernote({
            placeholder: 'Hello',
            tabsize: 2,
            height: 120
        });
    </script>
</body>
</html>



結果


********************************************************************************

好像只有 lite 版正常,原因不明,待研究。

(完)

相關

[研究]summernote-lite.min.js, summernote.min.js, summernote-bs4.min.js, summernote-bs5.min.js 比較試用
https://shaurong.blogspot.com/2024/11/summernote-liteminjs-summernoteminjs.html

[研究]ASP.NET, SummerNote 1.0.3 與 Bootstrap 3.4.1, 4.6.2, 5.3.3 相容測試
https://shaurong.blogspot.com/2024/10/aspnet-summernote-103-bootstrap-341-462.html

[研究]ASP.NET, 夏日筆記 Summernote 1.0.3 WYSIWYG HTML Editor 試用 (MIT)
https://shaurong.blogspot.com/2024/04/aspnetsummernote-wysiwyg-html-editor.html

[研究]SummerNote 0.9.0官方下載免 Bootstrap 版試用
https://shaurong.blogspot.com/2024/11/summernote-090-bootstrap.html

[研究]SummerNote 用 NuGet 1.0.3、0.8.10, 官方 Compiled 0.9.0, Source Code 0.9.1, libman 0.9.1 安裝差異比較
https://shaurong.blogspot.com/2024/11/summernote-nuget-libman.html


2024年11月1日 星期五

[研究]SummerNote 用 NuGet 1.0.3、0.8.10, 官方 Compiled 0.9.0, Source Code 0.9.1, libman 0.9.1 安裝差異比較

[研究]SummerNote 用 NuGet 1.0.3、0.8.10, 官方 Compiled 0.9.0, Source Code 0.9.1, libman 0.9.1 安裝差異比較

2024-11-01

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

********************************************************************************

下圖,NuGet安裝 1.0.3版




下圖,NuGet 的 SummerNote 實際上是某人使用官方 0.6.9 版改出來的,比官方 0.9.0 或 0.9.1 差很多了,且 0.9.0 以下版本已經有弱點。


********************************************************************************

下圖,官方下載 0.9.0 Compiled 版 (編譯版)

https://summernote.org/getting-started/






********************************************************************************

下圖,官方下載 0.9.1 Source Code 版 (原始程式碼版,沒有 .css,有 .scss )

https://summernote.org/getting-started/




********************************************************************************
GitHub 版,到 0.9.1

https://github.com/summernote/summernote/releases/tag/v0.9.1

********************************************************************************

下圖,libman 安裝 0.9.1版

********************************************************************************

NuGet SummerNote 0.8.10 版


********************************************************************************

Summernote : Vulnerability Statistics
https://www.cvedetails.com/vendor/32951/Summernote.html

Cross-site Scripting (XSS)
Affecting summernote package, versions <0.9.0
https://security.snyk.io/vuln/SNYK-JS-SUMMERNOTE-7251013

0.9.0版以下有弱點。

********************************************************************************

安裝結果差異很大,NuGet 提供的 1.0.3 版可能最不像官方版,也不知它使用官方哪一版本去改的。

NuGet 的 SummerNote 0.8.10 版比較像官方的舊版,此版疑似沒有 summernote-bs5.js 和 summernote-bs5.css。

(完)

相關

[研究]ASP.NET, SummerNote 1.0.3 與 Bootstrap 3.4.1, 4.6.2, 5.3.3 相容測試
https://shaurong.blogspot.com/2024/10/aspnet-summernote-103-bootstrap-341-462.html

[研究]ASP.NET, 夏日筆記 Summernote 1.0.3 WYSIWYG HTML Editor 試用 (MIT)
https://shaurong.blogspot.com/2024/04/aspnetsummernote-wysiwyg-html-editor.html

[研究]SummerNote 0.9.0官方下載免 Bootstrap 版試用
https://shaurong.blogspot.com/2024/11/summernote-090-bootstrap.html

[研究]SummerNote 用 NuGet 1.0.3、0.8.10, 官方 Compiled 0.9.0, Source Code 0.9.1, libman 0.9.1 安裝差異比較
https://shaurong.blogspot.com/2024/11/summernote-nuget-libman.html

[研究]SummerNote 0.9.0官方下載免 Bootstrap 版 ( SummerNote 0.9.0 Lite版) 試用

[研究]SummerNote 0.9.0官方下載免 Bootstrap 版 ( SummerNote 0.9.0 Lite版) 試用

2024-10-31

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

********************************************************************************

https://summernote.org/getting-started/#download-source-code


參考程式 Without Bootstrap (lite)
You can use Summernote without Bootstrap using summernote-lite.js and summernote-lite.css.
https://summernote.org/getting-started/

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
    Inherits="WebApplication1.Default" ValidateRequest="false" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
        <script src="https://code.jquery.com/jquery-3.7.1.slim.min.js"></script>
    <link href="MyPackages/summernote-0.9.0-dist/summernote-lite.css" rel="stylesheet" />
    <script src="MyPackages/summernote-0.9.0-dist/summernote-lite.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </form>
    <script>
        $('#TextBox1').summernote({
        placeholder: 'Hello stand alone ui',
        tabsize: 2,
        height: 120,
        toolbar: [
          ['style', ['style']],
          ['font', ['bold', 'underline', 'clear']],
          ['color', ['color']],
          ['para', ['ul', 'ol', 'paragraph']],
          ['table', ['table']],
          ['insert', ['link', 'picture', 'video']],
          ['view', ['fullscreen', 'codeview', 'help']]
        ]
      });
    </script>
</body>
</html>



Default.aspx.cs

using System;

namespace WebApplication1
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}

結果


感覺狀況有些混亂,因為 NuGet 並沒有 0.9.0版,NuGet 版本安裝了也沒 summernote-lite.js 和 summernote-lite.css,NuGet 至少是 1.0.0版,最新 1.0.3版。



下圖,Visual Studio 2019畫面

********************************************************************************
Summernote 套件在 NuGet 至少 1.0.0 版,在 https://summernote.org  只有到 0.9.0 版,兩者關係 ?

Copilot

這可能是因為 NuGet 和 Summernote 的維護者是不同的團隊,他們各自更新和發布版本。NuGet 上的版本可能包含了一些額外的功能或修復,而官方網站上的版本則是官方維護的最新穩定版本。

(完)

相關

[研究]ASP.NET, SummerNote 1.0.3 與 Bootstrap 3.4.1, 4.6.2, 5.3.3 相容測試
https://shaurong.blogspot.com/2024/10/aspnet-summernote-103-bootstrap-341-462.html

[研究]ASP.NET, 夏日筆記 Summernote 1.0.3 WYSIWYG HTML Editor 試用 (MIT)
https://shaurong.blogspot.com/2024/04/aspnetsummernote-wysiwyg-html-editor.html

[研究]SummerNote 0.9.0官方下載免 Bootstrap 版試用
https://shaurong.blogspot.com/2024/11/summernote-090-bootstrap.html


[研究]ASP.NET, 顯示 jHtmlArea 1.0.0 WYSIWYG HTML editor 全部按鈕及 Source (PD授權)

[研究]ASP.NET, 顯示 jHtmlArea 1.0.0 WYSIWYG HTML editor 全部按鈕及 Source (PD授權)

2024-11-01

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

********************************************************************************

jHtmlArea GitHub
https://github.com/crpietschmann/jHtmlArea

jHtmlArea Documentation
https://github.com/crpietschmann/jHtmlArea/wiki

所有按鈕  (ChatGPT 亂寫,實際請參考此網頁)
https://github.com/crpietschmann/jHtmlArea/wiki/Configure-jHtmlArea-Toolbar-Buttons

Add Custom jHtmlArea Toolbar Button
https://github.com/crpietschmann/jHtmlArea/wiki/Add-Custom-jHtmlArea-Toolbar-Button

[研究]ASP.NET,WebForm,試用 jHtmlArea 1.0.0 WYSIWYG HTML editor 套件 (PD授權)
https://shaurong.blogspot.com/2024/04/aspnetwebform-jhtmlarea-100-wysiwyg.html

[研究]ASP.NET, jHtmlArea 1.0.0 的 toolbar 有時出現 TextArea 或 TextBox 左邊之解決
https://shaurong.blogspot.com/2024/11/aspnet-jhtmlarea-100-toolbar-textarea.html

********************************************************************************

jHtmlArea 相依 jQuery >= 1.3.2,測試 jQuery 3.7.1 可用。

packages.config

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="jHtmlArea" version="1.0" targetFramework="net48" />
  <package id="jQuery" version="3.7.1" targetFramework="net48" />
  <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="4.1.0" targetFramework="net48" />
</packages>

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
    Inherits="WebApplication1.Default" ValidateRequest="false" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script type="text/javascript" src="Scripts/jquery-3.7.1.min.js"></script>
    <link href="Content/jHtmlArea/jHtmlArea.css" rel="stylesheet" />
    <script type="text/javascript" src="Scripts/jHtmlArea.min.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" TextMode="MultiLine" Rows="10" Columns="130" runat="server"></asp:TextBox>
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /><br />
        <asp:Literal ID="Literal1" runat="server"></asp:Literal><br />
        <asp:Label ID="Label1" runat="server"></asp:Label>
    </form>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#TextBox1").htmlarea({
                toolbar: [
                    ["html",
                    "|",
                    "bold",
                    "italic",
                    "underline",
                    "strikethrough",
                    "p",
                    "h1",
                    "h2",
                    "h3",
                    "h4",
                    "h5",
                    "h6",
                    "image",
                    "link",
                    "unlink",
                    "orderedList",
                    "unorderedList",
                    "superscript",
                    "subscript",
                    "indent",
                    "outdent",
                    "justifyleft",
                    "justifycenter",
                    "justifyright",
                    "increasefontsize",
                    "decreasefontsize",
                    "forecolor",
                    "horizontalrule"]

                ],
                loaded: function () {
                    //this.toggleHtmlEditor("bold"); // 將粗體按鈕設置為按下狀態
                    //this.toggleView(); // 切換到 HTML 編輯視圖; 無效
                }
            });
        });

        editor.htmlarea("insertHtml", "<p>Initial content</p>"); // 設置初始內容
        setTimeout(function () {
            $(".jHtmlArea .toolset button[name=html]").addClass("active");//無效
        }, 0);
    </script>
</body>
</html>



Default.aspx.cs

using System;

namespace WebApplication1
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string content = TextBox1.Text;
            // 在此處處理編輯器的內容
            Literal1.Text = content;
            Label1.Text = content;
        }
    }
}

實際測試,Columns="120" 時 toolbar 位置還正常,Columns="130" 就會異常。

********************************************************************************

2024-11-04補

註:NuGet 目前只提供 1.0.0,但官方到 1.0.1,1.0.1解決了toolbar和填寫框寬度不一致問題

https://github.com/crpietschmann/jHtmlArea

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
    Inherits="WebApplication1.Default" ValidateRequest="false" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>

    <!-- jHtmlArea Compontent -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/crpietschmann/jHtmlArea@v1.0.1/dist/css/jHtmlArea.css">
    <script src="https://cdn.jsdelivr.net/gh/crpietschmann/jHtmlArea@1.0.1/dist/js/jHtmlArea.min.js"></script>

    <!-- jHtmlArea Color Picker Menu -->
    <%--<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/crpietschmann/jHtmlArea@v1.0.1/dist/css/jHtmlArea.ColorPickerMenu.css">
    <script src="https://cdn.jsdelivr.net/gh/crpietschmann/jHtmlArea@1.0.1/dist/js/jHtmlArea.ColorPickerMenu.min.js"></script>--%>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" TextMode="MultiLine" Rows="10" Columns="100" runat="server"></asp:TextBox>
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /><br />
        <asp:Literal ID="Literal1" runat="server"></asp:Literal><br />
        <asp:Label ID="Label1" runat="server"></asp:Label>
    </form>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#TextBox1").htmlarea({
                toolbar: [
                    ["html",
                        "|",
                        "bold",
                        "italic",
                        "underline",
                        "strikethrough",
                        "p",
                        "h1",
                        "h2",
                        "h3",
                        "h4",
                        "h5",
                        "h6",
                        "image",
                        "link",
                        "unlink",
                        "orderedList",
                        "unorderedList",
                        "superscript",
                        "subscript",
                        "indent",
                        "outdent",
                        "justifyleft",
                        "justifycenter",
                        "justifyright",
                        "increasefontsize",
                        "decreasefontsize",
                        "forecolor",
                        "horizontalrule"]

                ],
                loaded: function () {
                    //this.toggleHtmlEditor("bold"); // 將粗體按鈕設置為按下狀態
                    //this.toggleView(); // 切換到 HTML 編輯視圖; 無效
                }
            });
        });

        editor.htmlarea("insertHtml", "<p>Initial content</p>"); // 設置初始內容
        setTimeout(function () {
            $(".jHtmlArea .toolset button[name=html]").addClass("active");//無效
        }, 0);
    </script>
</body>
</html>



Columns="80" 約比 toolbar 略大一點。

********************************************************************************

(完)

相關

[研究]ASP.NET,WebForm,試用 jHtmlArea 1.0.0 WYSIWYG HTML editor 套件 (PD授權)
https://shaurong.blogspot.com/2024/04/aspnetwebform-jhtmlarea-100-wysiwyg.html

[研究]ASP.NET, jHtmlArea 1.0.0 的 toolbar 有時出現 TextArea 或 TextBox 左邊之解決
https://shaurong.blogspot.com/2024/11/aspnet-jhtmlarea-100-toolbar-textarea.html

[研究]ASP.NET, 顯示 jHtmlArea 1.0.0 WYSIWYG HTML editor 全部按鈕及 Source (PD授權)
https://shaurong.blogspot.com/2024/11/aspnet-jhtmlarea-100-wysiwyg-html.html

[研究]ASP.NET, jHtmlArea 1.0.0 的 toolbar 有時出現 TextArea 或 TextBox 左邊之解決

[研究]ASP.NET, jHtmlArea 1.0.0 的 toolbar 有時出現 TextArea 或 TextBox 左邊之解決

2024-10-31

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

********************************************************************************

[研究]ASP.NET,WebForm,試用 jHtmlArea 1.0.0 WYSIWYG HTML editor 套件 (PD授權)
https://shaurong.blogspot.com/2024/04/aspnetwebform-jhtmlarea-100-wysiwyg.html

********************************************************************************

Default.aspx 之中

<asp:TextBox ID="TextBox1" TextMode="MultiLine" Rows="10" Columns="80" runat="server"></asp:TextBox>

若 Columns="80"

若 Columns="90"

也就是 Columns 值大到某種程度,toolbar 顯示位置就會異常。

(完)

相關

[研究]ASP.NET,WebForm,試用 jHtmlArea 1.0.0 WYSIWYG HTML editor 套件 (PD授權)
https://shaurong.blogspot.com/2024/04/aspnetwebform-jhtmlarea-100-wysiwyg.html

[研究]ASP.NET, jHtmlArea 1.0.0 的 toolbar 有時出現 TextArea 或 TextBox 左邊之解決
https://shaurong.blogspot.com/2024/11/aspnet-jhtmlarea-100-toolbar-textarea.html




2024年10月30日 星期三

[研究]ASP.NET, SummerNote 1.0.3 與 Bootstrap 3.4.1, 4.6.2, 5.3.3 相容測試

[研究]ASP.NET, SummerNote 1.0.3 與 Bootstrap 3.4.1, 4.6.2, 5.3.3 相容測試

2024-10-30

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

********************************************************************************

[研究]ASP.NET, 夏日筆記 Summernote 1.0.3 WYSIWYG HTML Editor 試用 (MIT)
https://shaurong.blogspot.com/2024/04/aspnetsummernote-wysiwyg-html-editor.html

********************************************************************************

NuGet 安裝 jQuery, bootstrap, summernote 等。

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" 
    Inherits="WebApplication1.Default"  ValidateRequest="false"  %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>

    <!-- CSS Files -->
<link href="Content/bootstrap.css" rel="stylesheet" />
<link href="Content/font-awesome.min.css" rel="stylesheet" />
<link href="Scripts/summernote/summernote.css" rel="stylesheet" />

<!-- JavaScript Files -->
<script type="text/javascript" src="Scripts/jquery-3.7.1.min.js"></script>
<script type="text/javascript" src="Scripts/bootstrap.min.js"></script>
<script type="text/javascript" src="Scripts/summernote/summernote.min.js"></script>
<!-- Custom JavaScript -->
<script type="text/javascript">
    $(document).ready(function () {
        $(".summernoteCssClass").summernote({
            placeholder: '請輸入內容...',
            tabsize: 2,
            height: 200
        });
        // Set background color to white
        $('.note-editable').css('background-color', 'white');
    });
</script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" CssClass="summernoteCssClass" runat="server"></asp:TextBox>
    </form>
</body>
</html>



Default.aspx.cs

using System;

namespace WebApplication1
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}



【使用 Bootstrap 3.4.1 結果】


【使用 Bootstrap 4.6.2 結果】

【使用 Bootstrap 5.3.3 結果】

也就是 NuGet 說明只相依 FontAwesome >= 4.2.0,實際上不只。

官方網站
https://summernote.org/
說需要 Supports Bootstrap: 3.x.x to 5.x.x,但實際 4.6.2不行。

(完)

相關

2024年4月21日 星期日

[研究]在 CKEditor 5 中添加「View Source」按鈕

[研究]在 CKEditor 5 中添加「View Source」按鈕

2024-04-19

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

********************************************************************************

ckeditor v5 支援 View Code 或 View Source 按鈕 ?

ChatGPT

CKEditor 5 是一個先進的 WYSIWYG 編輯器,它提供了一個稱為「Source Editing」的功能,允許使用者切換到 HTML 源代碼視圖。然而,相對於 CKEditor 4,CKEditor 5 不再直接提供名為「View Code」或「View Source」的按鈕。相反,它提供了一個 API,你可以使用它來自定義和添加按鈕或其他 UI 元素來實現此功能。

要實現類似的功能,你可以通過 CKEditor 5 提供的 API 添加自定義按鈕,然後使用該按鈕觸發切換到 HTML 源代碼視圖的操作。這需要一些 JavaScript 編程,但CKEditor 5 的文檔提供了很好的指導和範例來幫助你完成這項任務。

********************************************************************************

CKEditor 5 - Source Editing Feature

https://ckeditor.com/docs/ckeditor5/latest/features/source-editing.html

註:敝人聞了 ChatGPT 和 Copilot 多次,得到的 Code 實際測試,都失敗,故提供官方的說明。

********************************************************************************

(完)

相關

2024年4月20日 星期六

[研究]ASP.NET,WebForm,試用 jHtmlArea 1.0.0 WYSIWYG HTML editor 套件 (PD授權)

[研究]ASP.NET,WebForm,試用 jHtmlArea 1.0.0 WYSIWYG HTML editor 套件 (PD授權)

2024-04-19

Awesome WYSIWYG EDITORS
https://github.com/JefMari/awesome-wysiwyg-editors

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

1.0.0 版是 2023-08-24 釋出,相依 jQuery >= 1.3.2

********************************************************************************

授權

https://github.com/JefMari/awesome-wysiwyg-editors?tab=readme-ov-file#license


https://creativecommons.org/publicdomain/zero/1.0/


********************************************************************************


********************************************************************************

NuGet 安裝 jHtmlArea 套件,jQuery 可安裝或用 CDN 的

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication3.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
   <%-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>--%>
    <script src="Scripts/jquery-1.4.1.min.js"></script>
    <%--<link href="Content/jHtmlArea/jHtmlArea.Editor.css" rel="stylesheet" />不是,黑底,一堆黑點--%>
    <%--<link href="Content/jHtmlArea/jHtmlArea.ColorPickerMenu.css" rel="stylesheet" />不是,白底,一堆黑點--%>
    <link href="Content/jHtmlArea/jHtmlArea.css" rel="stylesheet" />
    <script src="Scripts/jHtmlArea.min.js"></script>

    
</head>
<body>
    <form id="form1" runat="server">
        <textarea id="editor" runat="server" style="width: 100%; height: 500px;"></textarea>
        <br />
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
    </form>

    <script type="text/javascript">
        //$(function () {
        //    $("textarea").htmlarea({
        //        toolbar: ["html", "|",
        //            "forecolor",  // <-- Add the "forecolor" Toolbar Button
        //            "|", "bold", "italic", "underline", "|", "h1", "h2", "h3", "|", "link", "unlink"] // Overrides/Specifies the Toolbar buttons to show
        //    });
        //});

        $(document).ready(function () {
            $("#editor").htmlarea({
                toolbar: [
                    ["bold", "italic", "underline", "strikethrough"],
                    ["p", "h1", "h2", "h3", "h4", "h5", "h6"],
                    ["link", "unlink", "image"],
                    ["html"] // 添加 HTML 按鈕到工具欄
                ],
                loaded: function () {
                    //this.toggleHtmlEditor("bold"); // 將粗體按鈕設置為按下狀態
                    //this.toggleView(); // 切換到 HTML 編輯視圖; 無效
                }
            });
        });

        editor.htmlarea("insertHtml", "<p>Initial content</p>"); // 設置初始內容

        // 將 HTML 按鈕設置為按下狀態
        //setTimeout(function () {
        //    editor.htmlarea("toggleHtmlEditor", "html");    //無效
        //}, 0);

        // 使用 execute 方法模擬點擊 HTML 按鈕
        //setTimeout(function () {
        //    editor.htmlarea("execute", "html");//無效
//}, 0); // 使用 jQuery 將 HTML 按鈕設置為按下狀態 setTimeout(function () { $(".jHtmlArea .toolset button[name=html]").addClass("active");//無效
}, 0); </script> </body> </html>

Default.aspx.cs

using System;
namespace WebApplication3
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string content = editor.Value;
            // 在此處處理編輯器的內容
        }
    }
}

 下圖,toolbar會在TextArea左邊,原因不明,待解決

********************************************************************************
2024-10-24 再測

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" 
    Inherits="WebApplication1.Default" ValidateRequest="false" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script type="text/javascript" src="Scripts/jquery-3.7.1.min.js"></script>
    <link href="Content/jHtmlArea/jHtmlArea.css" rel="stylesheet" />
    <script type="text/javascript" src="Scripts/jHtmlArea.min.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" TextMode="MultiLine" Rows="10" Columns="40" runat="server"></asp:TextBox>
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /><br />
        <asp:Literal ID="Literal1" runat="server"></asp:Literal><br />
        <asp:Label ID="Label1" runat="server"></asp:Label>
    </form>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#TextBox1").htmlarea({
                toolbar: [
                    ["bold", "italic", "underline", "strikethrough"],
                    ["p", "h1", "h2", "h3", "h4", "h5", "h6"],
                    ["link", "unlink", "image"],
                    ["html"] // 添加 HTML 按鈕到工具欄
                ],
                loaded: function () {
                    //this.toggleHtmlEditor("bold"); // 將粗體按鈕設置為按下狀態
                    //this.toggleView(); // 切換到 HTML 編輯視圖; 無效
                }
            });
        });

        editor.htmlarea("insertHtml", "<p>Initial content</p>"); // 設置初始內容
        setTimeout(function () {
            $(".jHtmlArea .toolset button[name=html]").addClass("active");//無效
        }, 0);
    </script>
</body>
</html>



Default.aspx.cs

using System;

namespace WebApplication1
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string content = TextBox1.Text;
            // 在此處處理編輯器的內容
            Literal1.Text = content;
            Label1.Text = content;
        }
    }
}





(完)

相關

[研究]ASP.NET,WebForm,試用Froala 4.2.0 WYSIWYG HTML editor 套件

[研究]ASP.NET,WebForm,試用Froala 4.2.0 WYSIWYG HTML editor 套件

2024-04-20

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

官方網站:https://froala.com/wysiwyg-editor/

Pricing (價格):https://cart.froala.com/。Free Trial 只提供 自架服務 (Self-Hosted)

範例:https://froala.com/wysiwyg-editor/docs/overview/

https://froala.com/wysiwyg-editor/examples/

********************************************************************************

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/froala-editor/4.2.0/css/froala_editor.pkgd.min.css" rel="stylesheet" />
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <textarea id="editor" runat="server"></textarea><br />
            <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
        </div>
    </form>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/froala-editor/4.2.0/js/froala_editor.pkgd.min.js"></script>
    <script> 
        var editor = new FroalaEditor('#editor');
    </script>
</body>
</html>


Default.aspx.cs

using System;

namespace WebApplication1
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string quillContent = Request.Form["editor"];
            Response.Write("<script>alert('" + quillContent + "')</script>");
        }
    }
}






********************************************************************************
Froala 4.2.0 WYSIWYG HTML editor 可免費使用 ? 可免費商用使用 ?

ChatGPT

Froala Editor 4.2.0是一款商業產品,提供了免費版本和付費版本。 免費版本包含了基本功能,而付費版本則提供了更多高級功能和技術支援。

根據Froala的官方授權協議,免費版本主要適用於個人專案、非商業專案以及非營利組織。 如果你的專案是商業用途或是為獲利目的,那麼你可能需要購買Froala Editor的許可證。 商業許可證的價格取決於你的專案規模和需要的功能。

在任何情況下,建議在使用Froala Editor之前查看其最新的許可協議,以確保你的使用符合其規定。 你可以在Froala的官方網站上找到最新的授權資訊和購買選項。

********************************************************************************
下圖,NuGet安裝版

下圖,F5執行index.html會出錯





嚴重性 程式碼 說明 專案 檔案 隱藏項目狀態
錯誤 Build:索引簽章參數類型必須為 'string' 或 'number'。 WebApplication2 C:\CodeTemp\WebApplication2\WebApplication2\Scripts\froala-editor\index.d.ts 1534
錯誤 Build:索引簽章參數類型必須為 'string' 或 'number'。 WebApplication2 C:\CodeTemp\WebApplication2\WebApplication2\Scripts\froala-editor\index.d.ts 1535
警告 元素 'html' 需要有結束標記。 WebApplication2 C:\CodeTemp\WebApplication2\WebApplication2\Scripts\froala-editor\index.html 2


NuGet的 Froala 4.2.0 安裝版有問題,無法使用。

********************************************************************************

(完)

相關

[研究]ASP.NET,WebForm,試用Quill 2.0.0 WYSIWYG HTML editor 套件 (BSD)

[研究]ASP.NET,WebForm,試用Quill 2.0.0 WYSIWYG HTML editor 套件 (BSD)

2024-04-20、2024-11-04更新

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

官方網站:https://quilljs.com/

https://github.com/quilljs/quill/releases

目前最新2.0.0,2024-04-17釋出。

2024-11-01補,NuGet 沒看到 Quill 2.0.0。

https://www.nuget.org/packages/Quill/1.0.0-beta.1


********************************************************************************

註:NuGet另外有一個名稱很像的 Quill Delta

Quill Delta to HTML Converter 套件主要是用於將 Quill 編輯器的 Delta 格式(Quill 的內部數據格式)轉換成 HTML 格式的文本。這在將 Quill 編輯器中的內容儲存到資料庫或將其顯示於網頁時尤其有用。

Quill 本身是一款 WYSIWYG 編輯器,Delta 是其內部資料結構,用於記錄使用者輸入的格式化文本和操作,因此 Quill Delta to HTML Converter 可以將這些格式轉換成 HTML 以便瀏覽器識別。簡單來說,這個套件並不是編輯器本身,而是 Quill 編輯器的輔助工具,幫助將其內容轉為標準 HTML 格式便於顯示。

********************************************************************************

BSD 授權 License
https://quilljs.com/docs/modules/clipboard#matchers
Quill is developed and maintained by Slab. It is permissively licensed under BSD. Use it freely in personal or commercial projects!

********************************************************************************

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>

    <link href="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.snow.css" rel="stylesheet" />
    <script src="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <div id="editor"></div>
            <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
        </div>
    </form>

    <script>
        var quill = new Quill('#editor', {
            theme: 'snow'
        });
    </script>
</body>
</html>



Default.aspx.cs

using System;

namespace WebApplication1
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string quillContent = Request.Form["editor"];
            Response.Write("<script>alert('" + quillContent + "')</script>");
        }
    }
}




實際測試功能有問題

下圖,彈出對話盒視窗應該顯示輸入內容,沒有。

下圖,填寫框變大,按鈕到最下方去了。



暫時不知如何處理。

(完)

相關

[研究]ASP.NET,WebForm,試用Quill 2.0.0 WYSIWYG HTML editor 套件 (BSD)
https://shaurong.blogspot.com/2024/04/aspnetwebformquill-200-wysiwyg-html.html

[研究]ASP.NET,WebForm, 設定 Quill 2.0.0 WYSIWYG 的 toolbar 顯示全部按鈕及 Source
https://shaurong.blogspot.com/2024/11/aspnetwebform-quill-200-wysiwyg-toolbar.html


2024年4月19日 星期五

[研究]ASP.NET, WebForm, 試用 Trumbowyg 1.0.1 WYSIWYG JavaScript editor 套件 (MIT)

[研究]ASP.NET, WebForm, 試用 Trumbowyg 1.0.1 WYSIWYG JavaScript editor 套件

2024-04-19

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

********************************************************************************

Trumbowyg 1.0.1 於 2017/10/28 釋出,無相依套件
https://github.com/jitbit/TrumbowygNuget

授權 License 是 MIT
https://github.com/jitbit/TrumbowygNuget/blob/master/LICENSE

********************************************************************************

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" 
    CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <link href="Scripts/trumbowyg/trumbowyg.min.css" rel="stylesheet" />
    <script type="text/jscript" src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <script type="text/jscript" src="Scripts/trumbowyg/trumbowyg.min.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
    </form>

    <script type="text/javascript">
        $(document).ready(function () {
            $('#<%= TextBox1.ClientID %>').trumbowyg();
        });
    </script>
</body>
</html>



Default.aspx.cs

using System;

namespace WebApplication1
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string content = TextBox1.Text;
        }
    }
}





感覺怪怪的,每輸入一個英文字母,滑鼠焦點就離開文字區域,每點一下才能輸入一個英文字幕。

********************************************************************************

2024-10-24 再測

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" 
    Inherits="WebApplication1.Default" ValidateRequest="false" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <link href="Scripts/trumbowyg/trumbowyg.min.css" rel="stylesheet" />
    <script type="text/javascript" src="Scripts/jquery-3.7.1.min.js"></script>
    <script type="text/javascript" src="Scripts/trumbowyg/trumbowyg.min.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" TextMode="MultiLine" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" style="height: 21px" />
    </form>

    <script type="text/javascript">
        $(document).ready(function () {
            $('#<%= TextBox1.ClientID %>').trumbowyg();
        });
    </script>
</body>
</html>



Default.aspx.cs

using System;

namespace WebApplication1
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string content = TextBox1.Text;
        }
    }
}




********************************************************************************
2024-10-24 補

Default.aspx 如果在 DetailsView 的 <EditItemTemplate> 中,要設定 DefaultMode="Edit"

<asp:DetailsView ID="DetailsView1" runat="server" 
             DefaultMode="Edit"
            AutoGenerateRows="False" DataKeyNames="SN" DataSourceID="SqlDataSource1">
            <Fields>
                <asp:BoundField DataField="SN" HeaderText="SN" InsertVisible="False" ReadOnly="True" SortExpression="SN" />
                <asp:TemplateField HeaderText="Field1" SortExpression="Field1">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Field1") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Field1") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("Field1") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="Field2" HeaderText="Field2" SortExpression="Field2" />
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" />
            </Fields>
        </asp:DetailsView>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" style="height: 21px" />
    </form>

    <script type="text/javascript">
        $(document).ready(function () {
            <%--$('#<%= TextBox1.ClientID %>').trumbowyg();--%>
            var textBox = $('#<%= DetailsView1.FindControl("TextBox1").ClientID %>');
            //if (textBox.length > 0) {
            //    textBox.trumbowyg();
            //}
            textBox.trumbowyg();
        });
    </script>

感覺怪怪的,每輸入一個英文字母,滑鼠焦點就離開文字區域,每點一下才能輸入一個英文字幕。


(完)

相關