顯示具有 HTML Editor 標籤的文章。 顯示所有文章
顯示具有 HTML Editor 標籤的文章。 顯示所有文章

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


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

[研究]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;
        }
    }
}





(完)

相關

2024年4月10日 星期三

[研究]ASP.NET, 夏日筆記 Summernote 1.0.3 WYSIWYG HTML Editor 試用 (MIT)

[研究]ASP.NET, 夏日筆記 Summernote 1.0.3 WYSIWYG HTML Editor 試用 (MIT)

2024-04-09

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

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

官方網站:https://summernote.org/

使用 MIT License 授權


範例:https://summernote.org/examples/

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

Summernote 相依套件 jQuery 和 Bootstrap 3.x ~5.x。

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>
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.7.0/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous" />

    <link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.js"></script>

    
</head>
<body>
    <form id="form1" runat="server">
        <textarea id="summernote" name="summernote" runat="server"
            style="width: 650px; height: 250px;"></textarea>
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
        <br />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </form>

    <script>
        $(document).ready(function () {
            $('#summernote').summernote({
                placeholder: 'Hello Bootstrap 4',
                height: 300,
                toolbar: [
                    ['fontname', ['fontname']],
                    ['fontsize', ['fontsize']],
                    ['style', ['bold', 'italic', 'underline', 'clear']],
                    ['font', ['strikethrough', 'superscript', 'subscript']],
                    ['color', ['color']],
                    ['para', ['ul', 'ol', 'paragraph']],
                    ['height', ['height']],
                    ['table', ['table']],
                    ['insert', ['link', 'picture', 'video']],
                    ['view', ['codeview']]
                ]
            });
        });
    </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)
        {
            Label1.Text = summernote.InnerText;
        }
    }
}




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

Summernote 相依套件 jQuery 和 Bootstrap 3.x ~5.x。

packages.config

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="bootstrap" version="5.3.3" targetFramework="net481" />
  <package id="FontAwesome" version="4.7.0" targetFramework="net481" />
  <package id="jQuery" version="3.7.1" targetFramework="net481" />
  <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="4.1.0" targetFramework="net481" />
  <package id="popper.js" version="1.16.1" targetFramework="net481" />
  <package id="summernote" version="1.0.3" targetFramework="net481" />
</packages>

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="Content/font-awesome.min.css" rel="stylesheet" />
    <script src="Scripts/jquery-3.7.1.min.js"></script>
    <link href="Content/bootstrap.css" rel="stylesheet" />
    <script src="Scripts/bootstrap.min.js"></script>
    <link href="Scripts/summernote/summernote.css" rel="stylesheet" />
    <script src="Scripts/summernote/summernote.min.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" TextMode="MultiLine" 
            Rows="10" Columns="80" runat="server"></asp:TextBox>
    </form>
    <script>
        $(document).ready(function () {
            $('#<%= TextBox1.ClientID %>').summernote();
        });
    </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)
        {
            Label1.Text = TextBox1.InnerText;
        }
    }
}





********************************************************************************
2024-10-24 補,相依的套件、.css 和 .js 都是必須的。

font-awesome.min.css 若缺失,toolbar 的按鈕圖示會不見,如下

summernote.css 若缺失,

bootstrap.css 若缺失,如下


jquery-3.7.1.min.js 或 bootstrap.min.js 或 summernote.min.js 若缺失

height: 300, 必須,否則高度會很扁,TextBox TextMode="MultiLine Rows="20" 控制不了高度。
高度可以再改。

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

Default.aspx 中,若在 DetailsView1 的 <EditItemTemplate> 中,DefaultMode="Edit" 必須設定。

ValidateRequest="false"  必須。

<%@ 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="Content/font-awesome.min.css" rel="stylesheet" />
    <link href="Scripts/summernote/summernote.css" rel="stylesheet" />
    <script type="text/javascript" src="Scripts/jquery-3.7.1.min.js"></script>
    <link href="Content/bootstrap.css" rel="stylesheet" />
    <script type="text/javascript" src="Scripts/bootstrap.min.js"></script>
    <script type="text/javascript" src="Scripts/summernote/summernote.min.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine" Rows="10" Columns="80"></asp:TextBox><br />

        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:MyDBConnectionString %>" 
            DeleteCommand="DELETE FROM [MyTable] WHERE [SN] = @SN" 
            InsertCommand="INSERT INTO [MyTable] ([Field1], [Field2]) VALUES (@Field1, @Field2)" 
            SelectCommand="SELECT * FROM [MyTable]" 
            UpdateCommand="UPDATE [MyTable] SET [Field1] = @Field1, [Field2] = @Field2 WHERE [SN] = @SN">
            <DeleteParameters>
                <asp:Parameter Name="SN" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="Field1" Type="String" />
                <asp:Parameter Name="Field2" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="Field1" Type="String" />
                <asp:Parameter Name="Field2" Type="String" />
                <asp:Parameter Name="SN" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <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") %>' 
                            TextMode="MultiLine" Rows="20" Columns="80" ></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 () {
            $('#TextBox2').summernote({
                placeholder: 'Hello World',
                height: 200,
                toolbar: [
                    ['fontname', ['fontname']],
                    ['fontsize', ['fontsize']],
                    ['style', ['bold', 'italic', 'underline', 'clear']],
                    ['font', ['strikethrough', 'superscript', 'subscript']],
                    ['color', ['color']],
                    ['para', ['ul', 'ol', 'paragraph']],
                    ['height', ['height']],
                    ['table', ['table']],
                    ['insert', ['link', 'picture', 'video']],
                    ['view', ['codeview']]
                ]
            });

            var textBox = $('#<%= DetailsView1.FindControl("TextBox1").ClientID %>');
            textBox.summernote(
                {
                    height: 150
                }
            );
        });
    </script>
</body>
</html>





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

2024-10-24 補,白色底

<script type="text/javascript">
        $(document).ready(function () {
            var textBox = $('#<%= DetailsView1.FindControl("TextBox_NewsContent").ClientID %>');
            textBox.summernote({
                placeholder: '請輸入內容...',
                tabsize: 2,
                height: 150
            });
            // Set background color to white
            $('.note-editable').css('background-color', 'white');
        });
    </script>


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

2024-10-25 補,使用 MasterPage.master 並設定 CSS Class 的狀況

<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="Content/font-awesome.min.css" rel="stylesheet" />
    <link href="Scripts/summernote/summernote.css" rel="stylesheet" />
    <script type="text/javascript" src="Scripts/jquery-3.7.1.min.js"></script>
    <link href="Content/bootstrap.css" rel="stylesheet" />
    <script type="text/javascript" src="Scripts/bootstrap.min.js"></script>
    <script type="text/javascript" src="Scripts/summernote/summernote.min.js"></script>

    <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>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>

在 .aspx 中
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Rows="10" Columns="80"
   CssClass="summernoteCssClass" Text='<%# Bind("HTMLContent") %>'></asp:TextBox>
<span style="color:red">註:「HTML內容」欄位,按下右上角【&lt;/&gt;】按鈕,可以檢視 HTML 原始碼。</span><br />


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

2024-10-25 補,預設按下 Code View 按鈕 (但敝人測試無效)

<script>
    $(document).ready(function() {
        $('#summernote').summernote({
            height: 300, // 設置編輯器的高度
            codeviewFilter: false, // 禁用 Code View 過濾
            codeviewIframeFilter: true, // 啟用 iframe 過濾
            callbacks: {
                onInit: function() {
                    // 初始化後,直接進入 Code View 模式
                    $(this).summernote('codeview.toggle');
                }
            }
        });
    });
</script>


********************************************************************************
2024-10-30 補,優先順序

ChatGPT 說:

在 ASP.NET WebForms 應用程式中,調整 CSS 和 JavaScript 檔案的加載順序有助於避免依賴問題並優化載入速度。以下是建議的優先順序,考量依賴關係和常見的優化順序:

<!-- 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>

排序說明:
  • CSS:將 bootstrap.css 放在最前,這樣其他 CSS(如 Font Awesome 和 Summernote)可以根據 Bootstrap 設定進行增補和覆蓋。
  • JavaScript:將 jquery 放在最前,因為 bootstrap.min.js 和 summernote.min.js 都依賴於 jquery。
  • Custom JavaScript:將自訂的 JavaScript 放在最後,這樣能確保所有庫已載入並可供使用。

(完)

相關


[研究]ASP.NET,NuGet ckeditor WYSIWYG HTML Editor從 4.22 升級到 4.23 或 4.24 後 toolbar 不見了,為什麼 ?

[研究]ASP.NET,NuGet ckeditor WYSIWYG HTML Editor從 4.22 升級到 4.23 或 4.24 後 toolbar 不見了,為什麼 ?

2024-04-10

Copilot

根據您提供的信息,您在升級 CKEditor 從版本 4.22 到 4.23 或 4.24 後發現工具欄(toolbar)不見了。讓我為您解釋一下可能的原因。

1.版本更新通知:自 CKEditor 版本 4.22.0 開始,引入了檢查編輯器版本的新配置選項。這個檢查可以在 CKEditor 配置中禁用,方法是在管理界面的高級編輯器配置部分添加以下設置:config.versionCheck = false;。這將禁用警告,因為它會阻止編輯器檢查自己的版本,但不會修復編輯器的版本。

https://stackoverflow.com/questions/77958924/ckeditor-update-notification

https://ckeditor.com/cke4/release/CKEditor-4.2.2

https://forum.xwiki.org/t/cke-editor-warning-4-22-1-version-not-secure/14020/4

2.長期支持版本(LTS):CKEditor 4.23.0 引入了LTS(“長期支持”)版本,可在商業條款下使用(“擴展支持模型”)4。如果您已經購買了CKEditor 4 LTS的擴展支持模型,請閱讀CKEditor 4 LTS密鑰激活指南45。

CKEditor 4 已經進入了 EOS(終止支持)
https://ckeditor.com/cke4/release/CKEditor-4.23.0-LTS
https://ckeditor.com/cke4/release-notes

總之,您可以通過禁用版本檢查來解決工具欄不見的問題,但請注意,這不會直接修復編輯器的版本。如果您希望使用最新的LTS版本,請參考相關文檔以進行升級。

https://ckeditor.com/ckeditor-4/download/

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

CKEditor 4.23.0 LTS 是付費版本 ?

Copilot

根據我所知,CKEditor 4.23.0 LTS 是 付費版本。它是 長期支持(LTS) 版本,可在商業條款下使用。如果您已經購買了 CKEditor 4 LTS 的擴展支持模型,您可以使用相應的密鑰來激活它 。

請注意,CKEditor 4 LTS 的擴展支持模型僅適用於已購買的用戶,並且提供了更長時間的技術支持和更新。如果您需要使用長期支持版本,請參考相關文檔以獲取更多信息。

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

CKEditor 4.23.0 有免費的、非 LTS 版本?

Copilot

根據我所知,CKEditor 4.23.0 是 付費版本。它是 長期支持(LTS) 版本,可在商業條款下使用。如果您已經購買了 CKEditor 4 LTS 的擴展支持模型,您可以使用相應的密鑰來激活它 123.

CKEditor 4 的 LTS 版本自 4.23.0 版本起引入,並且只能在商業條款下使用。如果您需要免費版本,您可以考慮使用 CKEditor 5,它是 CKEditor 的最新版本,具有更多功能和改進。CKEditor 5 提供了更現代的編輯體驗,並且在技術上更加先進 14。

請注意,CKEditor 4 的 LTS 版本提供了更長時間的技術支持和更新,並且對安全漏洞和第三方 API 變更提供了保護。如果您需要使用長期支持版本,請參考相關文檔以獲取更多信息。

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

(完)


2024年4月7日 星期日

[研究]NuGet 為何不提供 ckeditor v5?

[研究]NuGet 為何不提供 ckeditor v5?

2024-04-07

NuGet 為何不提供 ckeditor v5 ?

ChatGPT

NuGet 是用於在 .NET 平台上管理和共享程式庫的套件管理器,而 CKEditor 是一個流行的用於實現所見即所得(WYSIWYG)編輯器的 JavaScript 程式庫。目前,CKEditor v5 的原始碼通常是透過 npm(Node Package Manager)來安裝和管理的,而不是 NuGet。因此,NuGet 不會提供 CKEditor v5 的套件。

通常來說,NuGet 主要專注於提供 .NET 平台上的程式庫和工具,而不是用於 JavaScript 的工具。所以,如果您想在 .NET 專案中使用 CKEditor v5,您需要透過其他方式(例如,直接從 npm 安裝,然後透過打包工具將其整合到您的 .NET 專案中)來管理和使用它。

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

NuGet 為何不提供 ckeditor v5 ?

Copilot

NuGet 是一個方便的套件管理工具,但是它的套件庫並不包含 CKEditor 5 的最新版本。目前,CKEditor 5 只能在 GPL copyleft 授權(或商業授權)下使用。如果你的專案是開源的且使用了不相容 GPL 授權的其他開源項目,你可以申請使用 Free for Open Source 計劃,以便使用 CKEditor 5。然而,如果你仍然想使用 CKEditor 5,你可以直接從它的下載頁面使用它的 CDN。以下是一個在 ASP.NET 專案中使用 CKEditor 5 的範例:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>CKEditor 5 – Classic editor</title>
    <script src="https://cdn.ckeditor.com/ckeditor5/12.0.0/classic/ckeditor.js"></script>
</head>
<body>
    <h1>Classic editor</h1>
    <asp:TextBox ID="txtarea" runat="server" ClientIDMode="Static"></asp:TextBox>
    <script>
        ClassicEditor
            .create(document.querySelector('#txtarea'))
            .catch(error => {
                console.error(error);
            });
    </script>
</body>
</html>



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

(完)

[研究]ASP.NET,WebForm,試用ckeditor 5 WYSIWYG HTML Editor

[研究]ASP.NET,WebForm,試用ckeditor 5 WYSIWYG HTML Editor

2024-04-07

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

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

說明:https://cdn.ckeditor.com/ckeditor5/41.2.1/classic/

https://ckeditor.com/docs/ckeditor5/latest/installation/getting-started/configuration.html#toolbar-setup

各種toolbar畫面:https://ckeditor.com/docs/ckeditor5/latest/installation/getting-started/quick-start-other.html

下面範例,只有classic出現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>
    <script src="https://cdn.ckeditor.com/ckeditor5/41.2.1/classic/ckeditor.js"></script>
    <%--<script src="https://cdn.ckeditor.com/ckeditor5/41.2.1/balloon/ckeditor.js"></script>--%>
    <%--<script src="https://cdn.ckeditor.com/ckeditor5/41.2.1/balloon-block/ckeditor.js"></script>--%>
    <%--<script src="https://cdn.ckeditor.com/ckeditor5/41.2.1/inline/ckeditor.js"></script>--%>
    <%--<script src="https://cdn.ckeditor.com/ckeditor5/41.2.1/decoupled-document/ckeditor.js"></script>--%>
</head>
<body>
    <form id="form1" runat="server">
<asp:TextBox ID="txtarea" runat="server" ClientIDMode="Static"></asp:TextBox>

    </form>
        <script>
            ClassicEditor.create(document.querySelector('#txtarea'))
                .catch(error => {
                    console.error(error);
                });
        </script>
</body>
</html>



結果


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

2024-04-08補測試

<%@ 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/ckeditor/contents.css" rel="stylesheet" />
    <script type="text/javascript" src="Scripts/ckeditor/ckeditor.js"></script>--%>
    <script type="text/javascript" src="https://cdn.ckeditor.com/ckeditor5/24.0.0/classic/ckeditor.js"></script>
    <%--<script type="text/javascript" src="https://cdn.ckeditor.com/4.24.0/full/ckeditor.js"></script>--%>
    <%--<script type="text/javascript"src="https://cdn.ckeditor.com/4.24.0-lts/standard/ckeditor.js"></script>--%>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" TextMode="MultiLine" runat="server"></asp:TextBox>
    </form>
    <%-- CDN v5.24.0 成功;CDN full 或 standard v4.24.0 都沒有 toolbar--%>
    <script type="text/javascript">
        ClassicEditor
            .create(document.querySelector('#<%= TextBox1.ClientID %>'));
        <%--ClassicEditor
            .create(document.querySelector('#<%= TextBox1.ClientID %>'))
            .catch(error => {
                console.error(error);
            });--%>
    </script>
    <%--不管 CDN v5.24.0 或 CDN v4.24.0,下面都沒有 toolbar
    <script type="text/javascript">
        CKEDITOR.replace('TextBox1');
    </script>--%>
</body>
</html>


(完)

相關

[研究][ASP.NET] TinyMCE 7.0.0 WYSIWYG HTML Editor 試用 (GPL2+)

[研究][ASP.NET] TinyMCE 7.0.0 WYSIWYG HTML Editor 試用 (GPL2+)

2024-04-07, 2024-04-20 更新

注意,TinyMCE Open Source 版是 GPL2+ 授權,不是 MIT。

https://www.tiny.cloud/pricing/


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

Visual Studio 2019 + ASP.NET + WebForm ( WebApplication)

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>
    <script src="scripts/tinymce/tinymce.min.js"></script>
    <script>
        tinymce.init({
            selector: '#TextBox1'
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" 
            Rows="5" Columns="20"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" />
    </form>
</body>
</html>



Upgrade 按鈕會跳到下面網址
https://www.tiny.cloud/tinymce-self-hosted-premium-features/?utm_campaign=self_hosted_upgrade_promo&utm_source=tiny&utm_medium=referral


********************************************************************************
TinyMCE 7.0.0 WYSIWYG HTML Editor 可以商業 免費使用 ?
ChatGPT
TinyMCE 7.0.0 是一款開源的富文本編輯器,它基於LGPL協議發布,這意味著你可以在商業專案中免費使用它。 LGPL授權讓你在自己的專案中使用和修改這個軟體,而不需要公開原始碼或以其他方式將你的程式碼也授權為開源。 所以,如果你打算將TinyMCE 7.0.0 整合到商業項目中,你可以放心使用而不必支付費用。
********************************************************************************
TinyMCE 7.0.0 WYSIWYG HTML Editor 可以商業 免費使用 ?
Copilot
TinyMCE 7.0.0 是一個功能豐富的所見即所得(WYSIWYG)HTML編輯器,允許用戶在友好的界面中創建格式化的內容。這個版本根據GPL第2版或更高版本進行授權123。如果您是自托管用戶,您可以選擇在GPL下使用它,或者通過Tiny驗證您的付費許可證。
********************************************************************************

顯示 Upgrade 按鈕以外所有按鈕 ( 就是不要顯示 menubar)
NuGet 安裝 TinyMEC 7.0.1

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>
 <script src="scripts/tinymce/tinymce.min.js"></script>
    <script>
        tinymce.init({
            selector: '#TextBox1',
            //toolbar: 'undo redo | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link unlink | image media | code',
            menubar: false // Hide the menu bar
        });
    </script>

</head>
<body>
      <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" 
            Rows="5" Columns="20"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" />
    </form>
</body>
</html>






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

(完)

2023年10月17日 星期二

[研究]NuGet 上 WYSIWYG HTML editor 套件下載排名

[研究]NuGet 上 WYSIWYG HTML editor 套件下載排名

2023-10-17

因為 ckeditor 升級到 23.0.0 後,toolbar (工具列、按鈕選單、選單功能表) 不見,因為 ckeditor 4 已經 EOL,LTS版要 key

CKEditor 4 reaches its End of Life (EOL) in June 2023
https://ckeditor.com/blog/ckeditor-4-end-of-life/

NuGet 沒有 ckeditor 5,考慮其他替代方案,下載排名最高是 TinyMCE

https://www.nuget.org/packages?q=WYSIWYG+HTML+editor&prerel=true&sortby=totalDownloads-desc


TinyMCE 有免費版和付費版
https://www.tiny.cloud/pricing/

[研究][ASP.NET] TinyMCE 5.4.2 WYSIWYG HTML Editor 試用

https://shaurong.blogspot.com/2020/09/aspnet-tinymce-542.html


之後是 jHtmlArea,待研究

https://github.com/crpietschmann/jHtmlArea

(完)

2023年10月16日 星期一

[研究][ASP.NET] ckeditor-full v4.23.0 按鈕選單 toolbar 不見了 (NuGet安裝)

[研究][ASP.NET] ckeditor-full v4.23.0 按鈕選單 toolbar 不見了 (NuGet安裝)

2023-10-16

因為某方案使用 ckeditor 22.1.0 升級 23.0.0 後,按鈕不見了,故測試一下。

參考

[研究][ASP.NET][JavaScript] ckeditor-full v4.9.2 試用(NuGet安裝)
http://shaurong.blogspot.com/2018/06/aspnetjavascript-ckeditor-full-v492.html

發現按鈕真的不見了。

(完)

參考

[研究][ASP.NET][JavaScript] ckeditor-full v4.9.2 試用(NuGet安裝)
http://shaurong.blogspot.com/2018/06/aspnetjavascript-ckeditor-full-v492.html

[研究]CKEditor 4 生命週期結束 (June 30, 2023)
https://shaurong.blogspot.com/2023/07/ckeditor-4-june-30-2023.html

2023年7月11日 星期二

[研究]CKEditor 4 生命週期結束 (June 30, 2023)

[研究]CKEditor 4 生命週期結束 (June 30, 2023)

2023-07-11

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

2023-10-16 補,官方有

CKEditor LTS (Long-term support) package v4.23.0-lts | 24-08-2023

https://ckeditor.com/ckeditor-4/download/

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

https://ckeditor.com/ckeditor-4/ 

CKEditor 4 End-of-Life June 30, 2023.


https://ckeditor.com/ckeditor-4/download/

4.22.1 最新,4.21.0前一版


NVD弱點資料庫

cpe:2.3:a:ckeditor:ckeditor:4.21.0:*:*:*:*:*:*:*

https://nvd.nist.gov/vuln/search/results?adv_search=true&isCpeNameSearch=tru

e&query=cpe%3A2.3%3Aa%3Ackeditor%3Ackeditor%3A4.21.0%3A*%3A*%3A*%3A*%3A*%3A*

%3A*

4.21.0 NVD 沒弱點


https://nvd.nist.gov/vuln/search/results?adv_search=true&isCpeNameSearch=tru

e&query=cpe%3A2.3%3Aa%3Ackeditor%3Ackeditor%3A4.20.2%3A*%3A*%3A*%3A*%3A*%3A*

%3A* 

4.20.2 NVD 有弱點

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

NuGet 目前 ckeditor-full 只提供 4.22.1

(完)