sharepointに付属のテキストエディタを使用する2

35324 ワード

まずは参考記事リンク
http://kb.cnblogs.com/a/1222221/
パラシュート:SharePointコンテンツエディタのファイルアップロードについて
まず最初のリンクのいくつかを写しましょう...
Sharepointに付属のエディタの2種類のスタイル.1つ目はFullHtml、2つ目はCompatible
image   image
Sharepointコントロールの直接呼び出し:SharePointのリッチテキストエディタコントロール
<%@ Register Tagprefix="SharePoint"Namespace="Microsoft.SharePoint.WebControls"Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>

 
<%@ Register Tagprefix="SharePointPublish"Namespace="Microsoft.SharePoint.Publishing.WebControls"Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>

 
<%@ Page Language="C#" %>

<%@ Assembly Name="Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Import Namespace="Microsoft.SharePoint" %>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



<script runat="server">

    protected void Page_Load(object sender, EventArgs e)

    {         }

</script>



<%--  sharepoint   JS       init.js browseris       , init.js       --%>

<script type="text/javascript" language="javascript" src="/_layouts/1033/INIT.js"></script>

<script type="text/javascript" language="javascript" src="/_layouts/1033/form.js"></script>



<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

    <title></title>

</head>

<body>

    <form id="form1" runat="server">

    

    <div>

        <!--              -->

        <textarea name="txtTextArea1" rows="6" cols="60" id="txtTextArea1" title="Please Input"

            style="border: 1px solid blue"></textarea>

            <p></p>

        <asp:TextBox ID="TextBox1" runat="server" style="width:300px;"></asp:TextBox>



        <script language="javascript" type="text/javascript">

            RTE_ConvertTextAreaToRichEdit("txtTextArea1", false, false, "", "1033", null, null, null, null, null, "Compatible", "\u002f", null, null, null, null);

            //         ,    <%=TextBox1.ClientID%>, 1033:   ,2052              ,[Compatible,FullHtml]

            RTE_ConvertTextAreaToRichEdit("<%=TextBox1.ClientID%>", true, false, "", "1033", null, null, null, null, null, "FullHtml", "\u002f", null, null, null, null);      

        </script>

    </div>

    </form>

</body>

</html>


txtTextTextArea 1の効果図:RTE_ConvertTextAreaToRichEdit("txtTextArea1", false, false, "", "1033", null, null, null, null,null, "Compatible", "\u002f", null, null, null, null);
1
TextBox 1の効果図:RTE_ConvertTextAreaToRichEdit("<%=TextBox1.ClientID%>", true, false, "", "1033", null, null, null,null, null, "FullHtml", "\u002f", null, null, null, null);
2
 
彼のパラメータを比較すると、2番目のパラメータと後ろの[Compatible,FullHtml]は、2番目のパラメータがfalseの場合、彼のアップロード画像機能はBrowseの方法を使用することができます!しかし、上の文章は保存できないと言っていますが、これはまだテストしていません.
上のもののスタイルはあまりきれいではありません.文字列内のスタイルは効果がないので、他のパラメータで設定できると思います.RTE_を見てください.ConvertTextAreaToRichEdit関数は知ることができて、研究を待っています...[もしあなたが知っているならば、私に教えてください、ありがとうございます]
 
SharePoint InputformTextboxの幅を調整する方法
var name = "<%= ReportTextBox.ClientID %>";
(document.getElementById(name + "_toolbar")).style.width = "100%";
(document.getElementById(name + "_iframe")).style.width = "100%";
 
 
附:RTE_ConvertTextAreaToRichEditメソッドソースコード【C:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions12TEMPLATELAYOUTS1033FORM.js】
注意sharepointが中国語にインストールされている場合は、1033を2052に変更してください.
function RTE_ConvertTextAreaToRichEdit(

            strBaseElementID,

            fRestrictedMode,

            fAllowHyperlink,

            strDirection,

            strWebLocale,

            fSimpleTextOnly,

            fEditable,

            fUseDynamicHeightSizing,

            iMaxHeightSize,

            iMinHeightSize,

            strMode,

            urlWebRoot,

            strThemeUrl,

            strBodyClassName,

            fAllowRelativeLinks,

            strBaseUrl,

            fUseDynamicWidthSizing,

            iMaxWidthSize,

            iMinWidthSize,

            fEnforceAccessibilityMode,

            fPreserveScript,

            fHookUpEvents,

            fGenerateToolbar

            ) {

        ;

        if (!(browseris.ie5up && browseris.win32)) {

            return;

        }

        fEnforceAccessibilityMode = (fEnforceAccessibilityMode == null || fEnforceAccessibilityMode);

        if (IsAccessibilityFeatureEnabled() && fEnforceAccessibilityMode) {

            return;

        }

        fSimpleTextOnly = (fSimpleTextOnly != null && fSimpleTextOnly);

        fRestrictedMode = (fSimpleTextOnly) ? true : fRestrictedMode;

        fEditable = (null == fEditable) ? true : fEditable;

        fUseDynamicHeightSizing = (fUseDynamicHeightSizing != null && fUseDynamicHeightSizing);

        iMaxHeightSize = (null == iMaxHeightSize || iMaxHeightSize <= 0) ?

        g_iDefaultMaxHeightSize : iMaxHeightSize;

        iMinHeightSize = (null == iMinHeightSize || iMinHeightSize <= 0 || iMinHeightSize > iMaxHeightSize) ?

        g_iDefaultMinHeightSize : iMinHeightSize;

        fUseDynamicWidthSizing = (fUseDynamicWidthSizing != null && fUseDynamicWidthSizing);

        iMaxWidthSize = (null == iMaxWidthSize || iMaxWidthSize <= 0) ?

        g_iDefaultMaxWidthSize : iMaxWidthSize;

        iMinWidthSize = (null == iMinWidthSize || iMinWidthSize <= 0 || iMinWidthSize > iMaxWidthSize) ?

        g_iDefaultMinWidthSize : iMinWidthSize;

        fHookUpEvents = (null == fHookUpEvents || fHookUpEvents);

        fGenerateToolbar = (null == fGenerateToolbar || fGenerateToolbar);

        if (strMode != "FullHtml")

            strMode = "Compatible";

        if (null == strBodyClassName) {

            strBodyClassName = "ms-formbody";

        }

        aSettings = new Array();

        RTE_InitializeExtendedRichTextSupport(strBaseElementID);

        var variables = RTE_GetEditorInstanceVariables(strBaseElementID);

        var fFullHtml = false;

        if (strMode == "FullHtml") {

            fFullHtml = true;

            fAllowHyperlink = false;

            variables.overrides.GetToolBarDefinition = RTE_FullHtmlToolBarDefinitionFactory(

                fEnforceAccessibilityMode);

            aSettings.fRestrictedMode = true;

            aSettings.fAllowHyperlink = false;

            aSettings.fIsVisible = true;

        }

        else {

            aSettings.fRestrictedMode = fRestrictedMode;

            aSettings.fAllowHyperlink = fAllowHyperlink;

            aSettings.fIsVisible = !fSimpleTextOnly;

        }

        aSettings.urlWebRoot = (urlWebRoot == null || urlWebRoot == "/") ?

        "" : urlWebRoot;

        aSettings.fAllowRelativeLinks = (fAllowRelativeLinks == null) ? false : fAllowRelativeLinks;

        aSettings.fPreserveScript = (fPreserveScript == null) ? false : fPreserveScript;

        variables.aSettings = aSettings;

        var elemTextArea = RTE_GetEditorTextArea(strBaseElementID);

        var strHtmlToEdit = elemTextArea.innerText;

        if ((null == strHtmlToEdit) || (0 == strHtmlToEdit.length)) {

            strHtmlToEdit = "<div></div>";

        }

        g_elemRTELastTextAreaConverted = elemTextArea;

        window.attachEvent("onload",

        new Function(

            "RTE_TextAreaWindow_OnLoad('" + strBaseElementID + "');"));

        var aHtmlToAppend = new Array();

        if (fGenerateToolbar) {

            aHtmlToAppend.push(RTE_GenerateToolBarHtmlFromSettings(

            strBaseElementID, strWebLocale, elemTextArea, aSettings));

        }

        aHtmlToAppend.push(RTE_GenerateIFrameEditorHtml(

        strBaseElementID, elemTextArea, fRestrictedMode, fAllowHyperlink));

        var strHtmlToAppend = aHtmlToAppend.join("");

        elemTextArea.insertAdjacentHTML("afterEnd", strHtmlToAppend);

        if (fHookUpEvents) {

            elemTextArea.onfocus = new Function("RTE_TextArea_OnFocus('" + strBaseElementID + "')");

            elemTextArea.style.display = "none";

            variables.onBeforeUnloadFunc = new Function(

                "RTE_TransferIFrameContentsToTextArea('" + strBaseElementID + "');");

            window.attachEvent("onbeforeunload", variables.onBeforeUnloadFunc);

            var findForm = elemTextArea;

            while (findForm.tagName != "FORM" && findForm.tagName != "WINDOW") {

                findForm = findForm.parentElement;

            }

            findForm.attachEvent("onsubmit",

            new Function(

                "RTE_TransferIFrameContentsToTextArea('" + strBaseElementID + "');"));

        }

        var aEditorHtml = new Array();

        aEditorHtml.push("<html><head>");

        if (null != strBaseUrl && true == fAllowRelativeLinks) {

            aEditorHtml.push("<base href=\"");

            aEditorHtml.push(strBaseUrl);

            aEditorHtml.push("\"/>");

        }

        aEditorHtml.push("<link rel=\"stylesheet\" type=\"text/css\" href=\"");

        aEditorHtml.push(RTE_GetServerRelativeStylesheetUrl("core.css", strWebLocale));

        aEditorHtml.push("\">");

        if (null != strThemeUrl) {

            aEditorHtml.push("<link rel=\"stylesheet\" type=\"text/css\" href=\"");

            aEditorHtml.push(strThemeUrl);

            aEditorHtml.push("\">");

        }

        aEditorHtml.push("</head><body class=\"");

        aEditorHtml.push(strBodyClassName);

        aEditorHtml.push("\" style=\"background-color: white;border:none;\"></body></html>");

        var strEditorHtml = aEditorHtml.join("");

        var docEditor = RTE_GetEditorDocument(strBaseElementID);

        docEditor.designMode = (fEditable ? "on" : "off");

        docEditor = RTE_GetEditorDocument(strBaseElementID);

        docEditor.open("text/html", "replace");

        docEditor.write(strEditorHtml);

        docEditor.close();

        docEditor.body.scroll = "yes";

        docEditor.body.wordWrap = false;

        docEditor.body.contentEditable = true;

        docEditor.body.innerHTML = strEditorHtml;

        if (fHookUpEvents) {

            RTE_EventHookUp(strBaseElementID);

        }

        if (fRestrictedMode) {

            docEditor.body.ondragenter = new Function("RTE_OnDragEnter(this);");

            docEditor.body.ondragover = new Function("RTE_OnDragOver(this);");

            docEditor.body.ondragdrop = new Function("RTE_OnDrop(this);");

        }

        if (strDirection != "" &&

        strDirection != "None") {

            docEditor.dir = strDirection;

        }

        else {

            docEditor.dir = document.dir;

        }

        if (fRestrictedMode && !fFullHtml) {

            docEditor.body.setAttribute(

            g_strRTERestrictedModeAttributeName, "true");

            docEditor.body.onpaste = new Function("RTE_OnPaste_Restricted('" + strBaseElementID + "', this);");

        }

        if (fSimpleTextOnly) {

            docEditor.body.setAttribute(

            g_strRTESimpleTextOnlyAttributeName, "true");

        }

        if (fUseDynamicHeightSizing || fUseDynamicWidthSizing) {

            var strFuncCall = "";

            if (fUseDynamicHeightSizing) {

                docEditor.body.style.wordWrap = "break-word";

                docEditor.body.setAttribute(g_strRTEUseDynamicHeightSizing, "true");

                docEditor.body.setAttribute(

                g_strRTEMinHeightSizeAttributeName, iMinHeightSize);

                docEditor.body.setAttribute(

                g_strRTEMaxHeightSizeAttributeName, iMaxHeightSize);

                strFuncCall = "RTE_DocEditor_AdjustHeight('" + strBaseElementID + "');";

            }

            if (fUseDynamicWidthSizing) {

                docEditor.body.style.wordWrap = "normal";

                docEditor.body.setAttribute(g_strRTEUseDynamicWidthSizing, "true");

                docEditor.body.setAttribute(

                g_strRTEMaxWidthSizeAttributeName, iMaxHeightSize);

                docEditor.body.setAttribute(

                g_strRTEMinWidthSizeAttributeName, iMinHeightSize);

                strFuncCall += "RTE_DocEditor_AdjustWidth('" + strBaseElementID + "');";

            }

            var ifmEditor = RTE_GetEditorIFrame(strBaseElementID);

            docEditor.attachEvent(

            "onkeydown",

            new Function(

            strFuncCall));

            ifmEditor.attachEvent(

            "onscroll",

            new Function(

            strFuncCall));

            window.attachEvent(

             "onload",

             new Function(

            strFuncCall));

            if (fHookUpEvents) {

                if (fUseDynamicHeightSizing) {

                    RTE_DocEditor_AdjustHeight(strBaseElementID);

                }

                if (fUseDynamicWidthSizing) {

                    RTE_DocEditor_AdjustWidth(strBaseElementID);

                }

            }

        }

        if (fAllowHyperlink) {

            docEditor.body.setAttribute(

            g_strRTEAllowHyperlinkAttributeName, "true");

        }

        docEditor.body.setAttribute(

        g_strRTEBaseElementIDAttributeName, strBaseElementID);

        docEditor.body.setAttribute(

        g_strRTEWebLocaleAttributeName, strWebLocale);

        g_rgstrRTEAllEditorsInThePage[g_rgstrRTEAllEditorsInThePage.length] = strBaseElementID;

        if (fGenerateToolbar) {

            RTE_DisableToolBar(strBaseElementID);

            var ifmEditorObj = RTE_GetEditorElement(strBaseElementID);

            ifmEditorObj.tabIndex = elemTextArea.tabIndex;

            RTE_ToolBarMnemonicInitialization(strBaseElementID);

        }

    }
 
 : sharepoint mysite  edit profile          ,     Portal.css         ,           !