WinHtmlEditor/Common/HTMLEditHelper.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System.Runtime.InteropServices;
using mshtml;

namespace WinHtmlEditor
{
    #region HTMLEditHelper class
    public static class HTMLEditHelper
    {
        private static IHTMLDocument2 _mPDoc2;

        public static IHTMLDocument2 DOMDocument
        {
            get { return _mPDoc2; }
            set { _mPDoc2 = value; }
        }

        #region Table specific

        /// <summary>
        /// The currently selected text/controls will be replaced by the given HTML code.
        /// If nothing is selected, the HTML code is inserted at the cursor position
        /// </summary>
        /// <param name="sHtml"></param>
        /// <returns></returns>
        public static bool PasteIntoSelection(string sHtml)
        {
            if (_mPDoc2.IsNull())
                return false;
            var sel = _mPDoc2.selection as IHTMLSelectionObject;
            if (sel.IsNull())
                return false;
            var range = sel.createRange() as IHTMLTxtRange;
            if (range.IsNull())
                return false;
            //none
            //text
            //control
            if ((!sel.EventType.IsNullOrEmpty()) &&
                (sel.EventType == "control"))
            {
                var ctlrange = range as IHTMLControlRange;
                if (!ctlrange.IsNull()) //Control(s) selected
                {
                    int ctls = ctlrange.length;
                    for (int i = 0; i < ctls; i++)
                    {
                        //Remove all selected controls
                        IHTMLElement elem = ctlrange.item(i);
                        if (!elem.IsNull())
                        {
                            RemoveNode(elem, true);
                        }
                    }
                    // Now get the textrange after deleting all selected controls
                    range = sel.createRange() as IHTMLTxtRange;
                }
            }

            if (!range.IsNull())
            {
后面还有 62 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。