aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/midas
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/midas
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/midas')
-rw-r--r--files/zh-cn/midas/index.html324
-rw-r--r--files/zh-cn/midas/security_preferences/index.html111
2 files changed, 435 insertions, 0 deletions
diff --git a/files/zh-cn/midas/index.html b/files/zh-cn/midas/index.html
new file mode 100644
index 0000000000..f463b504de
--- /dev/null
+++ b/files/zh-cn/midas/index.html
@@ -0,0 +1,324 @@
+---
+title: Midas 所见即所得编辑功能
+slug: Midas
+translation_of: Mozilla/Projects/Midas
+---
+<h2 id="Introduction" name="Introduction">简介</h2>
+<p>Midas是一个Gecko内建的富文本编辑器的代号。Midas可以通过JS激活。当Midas可用时,文档将变成用户可编辑状态。Midas的脚本是基于IE所支持的<a href="http://msdn.microsoft.com/zh-CN/library/ms533049.aspx" title="http://msdn.microsoft.com/zh-CN/library/ms533049.aspx">DHTML commands</a>。IE中通过设置文档对象的designMode属性让整个文档变成可编辑状态;这也是Gecko中的Midas采用的调用方式。IE也支持让某个特定元素进入可编辑状态,只要在钙元素上使用contentEditable属性;从FireFox3开始,Gecko也支持使用contentEditable。只要调用了Midas,就可以使用document文档对象的一些方法相关方法。</p>
+<h2 id="Properties" name="Properties">属性</h2>
+<dl>
+ <dt>
+ <a href="/zh-CN/Midas/designMode" title="zh-CN/Midas/designMode">document.designMode</a></dt>
+ <dd>
+ 将该属性设置为“on”,该文档将可编辑。</dd>
+</dl>
+<h2 id="Notes" name="Notes">注意</h2>
+<p>整个文档变为可编辑状态后,开发者常将此文档载入iframe框架,然后在父文档中编写代码。根据标准,iframe元素拥有contentDocument属性引用其内联框架的document对象,同样还有contentWindow属性可以引用内联框架的window对象。</p>
+<p>除了内建的命令意外,通过操纵<a href="/zh-CN/DOM/Selection" title="/zh-CN/DOM/Selection">Selection</a>和<a href="/zh-CN/DOM/range" title="/zh-CN/DOM/range">range</a>对象可以实现更高级的编辑功能。编辑文档的时候用到这些对象可以提高编辑器的友好性。</p>
+<h2 id="Examples" name="Examples">案例</h2>
+<p>该示例代码展示了最基本的代码结构:</p>
+<pre>&lt;html&gt;
+ &lt;head&gt;
+ &lt;title&gt;Simple Edit Box&lt;/title&gt;
+ &lt;/head&gt;
+ &lt;body&gt;
+ &lt;iframe
+ id="MidasForm"
+ src="about:blank"
+ onload="this.contentDocument.designMode='on';"
+ &gt;&lt;/iframe&gt;
+ &lt;/body&gt;
+&lt;/html&gt;
+</pre>
+<h2 id="Methods" name="Methods">方法</h2>
+<dl>
+ <dt>
+ <a href="/zh-CN/Document.execCommand" title="zh-CN/Document.execCommand">document.execCommand</a></dt>
+ <dd>
+ 执行给定的命令。</dd>
+ <dt>
+ <a href="/zh-CN/Document.queryCommandEnabled" title="zh-CN/Document.queryCommandEnabled">document.queryCommandEnabled</a></dt>
+ <dd>
+ 文档在当前状态下是否可以执行给定的命令。</dd>
+ <dt>
+ <a href="/zh-CN/Document.queryCommandIndeterm" title="zh-CN/Document.queryCommandIndeterm">document.queryCommandIndeterm</a></dt>
+ <dd>
+ <span style="color: rgb(68, 68, 68); font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 22.390625px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; background-color: rgb(255, 255, 255); display: inline !important; float: none;">检测当前选定的内容是否处于不确定的状态。</span></dd>
+ <dt>
+ <a href="/zh-CN/Document.queryCommandState" title="zh-CN/Document.queryCommandState">document.queryCommandState</a></dt>
+ <dd>
+ 检测给出的命令是否已在当前选择的内容上执行。</dd>
+ <dt>
+ <a href="/zh-CN/Document.queryCommandValue" title="zh-CN/Document.queryCommandValue">document.queryCommandValue</a></dt>
+ <dd>
+ 检测给定命令操作的当前文档、范围或选定内容的当前值。</dd>
+</dl>
+<h2 id="Supported_Commands" name="Supported_Commands">支持的命令</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td class="header">Command</td>
+ <td class="header">Value</td>
+ <td class="header">Description</td>
+ </tr>
+ <tr>
+ <td>backcolor</td>
+ <td>
+ <p>颜色代码</p>
+ </td>
+ <td>
+ <p>设置文档背景色。</p>
+ </td>
+ </tr>
+ <tr>
+ <td>bold</td>
+ <td> </td>
+ <td>
+ <p>如果没有选中文本,将在光标处插入一个标志位。</p>
+ <p>如果选中了一段文本并且该文本内容已经是粗体,那么这些粗体样式会被移除。否则,所有文本都会从普通状态变为粗体。</p>
+ </td>
+ </tr>
+ <tr>
+ <td>contentReadOnly</td>
+ <td> </td>
+ <td>
+ <p>该命令可以让编辑器变为只读状态(true)或可编辑状态(false)。当页面需要进行其他活动(比如保存编辑状态,利用AJAX向服务器提交数据)的时候,该命令会很有用。</p>
+ </td>
+ </tr>
+ <tr>
+ <td>copy</td>
+ <td> </td>
+ <td>
+ <p>如果选择了一段文本,该命令可以将其内容拷贝到剪贴板。如果没有选中文本,什么也不会发生。</p>
+ <p>note: this command won't work without setting a pref or using signed JS. See: <a class="external" href="http://www.mozilla.org/editor/midasdemo/securityprefs.html">more about security preferences</a></p>
+ <p>note: the shortcut key will automatically trigger this command (typically accel-C) with or without the signed JS or any code on the page to handle it.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>createlink</td>
+ <td>A URI.</td>
+ <td>This command will not do anything if no selection is made. If there is a selection, a link will be inserted around the selection with the url parameter as the href of the link.</td>
+ </tr>
+ <tr>
+ <td>cut</td>
+ <td> </td>
+ <td>If there is a selection, this command will copy the selection to the clipboard and remove the selection from the edit control. If there isn't a selection, nothing will happen.
+ <p>note: this command won't work without setting a pref or using signed JS. See: <a class="external" href="http://www.mozilla.org/editor/midasdemo/securityprefs.html">more about security preferences</a></p>
+ <p>note: the shortcut key will automatically trigger this command (typically accel-X) with or without the signed JS or any code on the page to handle it.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>decreasefontsize</td>
+ <td> </td>
+ <td>This command will add a &lt;small&gt; tag around selection or at insertion point.</td>
+ </tr>
+ <tr>
+ <td>delete</td>
+ <td> </td>
+ <td>This command will delete all text and objects that are selected. If no text is selected it deletes one character to the right. This is similar to the <em>Delete</em> button on the keyboard.</td>
+ </tr>
+ <tr>
+ <td>fontname</td>
+ <td>A font name</td>
+ <td>This command will set the font face for a selection or at the insertion point if there is no selection.
+ <p>The given string is such as would be used in the "face" attribute of the font tag, i.e., a comma-separated list of font names.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>fontsize</td>
+ <td>A number</td>
+ <td>This command will set the fontsize for a selection or at the insertion point if there is no selection.
+ <p>The given number is such as would be used in the "size" attribute of the font tag.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>forecolor</td>
+ <td>A color code</td>
+ <td>This command will set the text color of the selection or at the insertion point.</td>
+ </tr>
+ <tr>
+ <td>formatblock</td>
+ <td>H1, H2, H3, H4, H5, H6, P, DIV, ADDRESS, BLOCKQUOTE (more?)</td>
+ <td>The selection surrounded by the given block element.</td>
+ </tr>
+ <tr>
+ <td>heading</td>
+ <td>H1, H2, H3, H4, H5, H6</td>
+ <td>Selected block will be formatted as the given type of heading.</td>
+ </tr>
+ <tr>
+ <td>hilitecolor</td>
+ <td>A color code</td>
+ <td>This command will set the hilite color of the selection or at the insertion point. It only works with styleWithCSS enabled.</td>
+ </tr>
+ <tr>
+ <td>increasefontsize</td>
+ <td> </td>
+ <td>This command will add a &lt;big&gt; tag around selection or at insertion point.</td>
+ </tr>
+ <tr>
+ <td>indent</td>
+ <td> </td>
+ <td>Indent the block where the caret is located. If the caret is inside a list, that item becomes a sub-item one level deeper.</td>
+ </tr>
+ <tr>
+ <td>insertbronreturn</td>
+ <td>true/false</td>
+ <td>Selects whether pressing return inside a paragraph creates another paragraph or just inserts a &lt;br&gt; tag.</td>
+ </tr>
+ <tr>
+ <td>inserthorizontalrule</td>
+ <td>null/string (when string is the Line's id)</td>
+ <td>This command will insert a horizontal rule (line) at the insertion point.
+ <p>Does it delete the selection? Yes!</p>
+ </td>
+ </tr>
+ <tr>
+ <td>inserthtml</td>
+ <td>A string.</td>
+ <td>This command will insert the given html into the &lt;body&gt; in place of the current selection or at the caret location.
+ <p>The given string is the HTML to insert.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>insertimage</td>
+ <td>A URI.</td>
+ <td>This command will insert an image (referenced by the given url) at the insertion point.</td>
+ </tr>
+ <tr>
+ <td>insertorderedlist</td>
+ <td> </td>
+ <td>Depends on the selection. If the caret is not inside a non-LI block, that block becomes the first LI and an OL. If the caret is inside a bulleted item, the bulleted item becomes a numbered item.</td>
+ </tr>
+ <tr>
+ <td>insertunorderedlist</td>
+ <td> </td>
+ <td>Depends on the selection. If the caret is not inside a non-LI block, that block becomes the first LI and UL. If the caret is inside a numbered item, the numbered item becomes a bulleted item.</td>
+ </tr>
+ <tr>
+ <td>insertparagraph</td>
+ <td> </td>
+ <td>Inserts a new paragraph.</td>
+ </tr>
+ <tr>
+ <td>italic</td>
+ <td> </td>
+ <td>If there is no selection, the insertion point will set italic for subsequently typed characters.
+ <p>If there is a selection and all of the characters are already italic, the italic will be removed. Otherwise, all selected characters will become italic.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>justifycenter</td>
+ <td> </td>
+ <td>Center-aligns the current block.</td>
+ </tr>
+ <tr>
+ <td>justifyfull</td>
+ <td> </td>
+ <td>Fully-justifies the current block.</td>
+ </tr>
+ <tr>
+ <td>justifyleft</td>
+ <td> </td>
+ <td>Left-aligns the current block.</td>
+ </tr>
+ <tr>
+ <td>justifyright</td>
+ <td> </td>
+ <td>Right aligns the current block.</td>
+ </tr>
+ <tr>
+ <td>outdent</td>
+ <td> </td>
+ <td>Outdent the block where the caret is located. If the block is not indented prior to calling outdent, nothing will happen.
+ <p>If the caret is in a list item, the item will bump up a level in the list or break out of the list entirely.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>paste</td>
+ <td> </td>
+ <td>This command will paste the contents of the clipboard at the location of the caret. If there is a selection, it will be deleted prior to the insertion of the clipboard's contents.
+ <p>note: this command won't work without setting a pref or using signed JS. user_pref("capability.policy.policynames", "allowclipboard"); user_pref("capability.policy.allowclipboard.Clipboard.paste", "allAccess"); See: <a class="external" href="http://www.mozilla.org/editor/midasdemo/securityprefs.html">more about security preferences</a></p>
+ <p>note: the shortcut key will automatically trigger this command (typically accel-V) with or without the signed JS or any code on the page to handle it.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>redo</td>
+ <td> </td>
+ <td>This command will redo the previous undo action. If undo was not the most recent action, this command will have no effect.
+ <p>note: the shortcut key will automatically trigger this command (typically accel-shift-Z)</p>
+ </td>
+ </tr>
+ <tr>
+ <td>removeformat</td>
+ <td> </td>
+ <td>Removes inline formatting from the current selection.</td>
+ </tr>
+ <tr>
+ <td>selectall</td>
+ <td> </td>
+ <td>This command will select all of the contents within the editable area.
+ <p>note: the shortcut key will automatically trigger this command (typically accel-A)</p>
+ </td>
+ </tr>
+ <tr>
+ <td>strikethrough</td>
+ <td> </td>
+ <td>If there is no selection, the insertion point will set strikethrough for subsequently typed characters.
+ <p>If there is a selection and all of the characters are already striked, the strikethrough will be removed. Otherwise, all selected characters will have a line drawn through them.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>styleWithCSS</td>
+ <td> </td>
+ <td>This command is used for toggling the format of generated content. By default (at least today), this is true. An example of the differences is that the "bold" command will generate &lt;b&gt; if the styleWithCSS command is false and generate css style attribute if the styleWithCSS command is true.</td>
+ </tr>
+ <tr>
+ <td>subscript</td>
+ <td> </td>
+ <td>If there is no selection, the insertion point will set subscript for subsequently typed characters.
+ <p>If there is a selection and all of the characters are already subscripted, the subscript will be removed. Otherwise, all selected characters will be drawn slightly lower than normal text.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>superscript</td>
+ <td> </td>
+ <td>If there is no selection, the insertion point will set superscript for subsequently typed characters.
+ <p>If there is a selection and all of the characters are already superscripted, the superscript will be removed. Otherwise, all selected characters will be drawn slightly higher than normal text.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>underline</td>
+ <td> </td>
+ <td>If there is no selection, the insertion point will set underline for subsequently typed characters.
+ <p>If there is a selection and all of the characters are already underlined, the underline will be removed. Otherwise, all selected characters will become underlined.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>undo</td>
+ <td> </td>
+ <td>This command will undo the previous action. If no action has occurred in the document, then this command will have no effect.
+ <p>note: the shortcut key will automatically trigger this command (typically accel-Z)</p>
+ </td>
+ </tr>
+ <tr>
+ <td>unlink</td>
+ <td> </td>
+ <td>If the insertion point is within a link or if the current selection contains a link, the link will be removed and the text will remain.</td>
+ </tr>
+ <tr>
+ <td colspan="3">{{ Deprecated_header() }}</td>
+ </tr>
+ <tr>
+ <td>readonly</td>
+ <td> </td>
+ <td>This command has been replaced with contentReadOnly. It takes the same values as contentReadOnly, but the meaning of true and false are inversed.</td>
+ </tr>
+ <tr>
+ <td>useCSS</td>
+ <td> </td>
+ <td>This command has been replaced with styleWithCSS. It takes the same values as styleWithCSS, but the meaning of true and false are inversed.</td>
+ </tr>
+ </tbody>
+</table>
+<p> </p>
diff --git a/files/zh-cn/midas/security_preferences/index.html b/files/zh-cn/midas/security_preferences/index.html
new file mode 100644
index 0000000000..be9edc27a0
--- /dev/null
+++ b/files/zh-cn/midas/security_preferences/index.html
@@ -0,0 +1,111 @@
+---
+title: Midas editor module security preferences
+slug: Midas/Security_preferences
+translation_of: Mozilla/Projects/Midas/Security_preferences
+---
+<div class="note">
+<p><strong>Note:</strong> If you've reached this page from a message box in Firefox or another Mozilla product, try using keyboard shortcuts for the Cut, Copy, and Paste commands:</p>
+
+<p>注意:如果你从火狐信息邮箱,或者火狐的其他产品有到达这个页面,试着使用键盘快捷键,剪切,复制,黏贴命令。</p>
+
+<ul>
+ <li>Copy: Ctrl+C or Ctrl+Insert (command+C on Mac)</li>
+ <li>复制:Ctrl+C 或者 Ctrl+Insert (命令+C在Mac系统)</li>
+ <li>Paste: Ctrl+V or Shift+Insert (command+V on Mac)</li>
+ <li>黏贴:Ctrl+V 或者 Shift+Insert (命令+V 在Mac系统)</li>
+ <li>Cut: Ctrl+X or Shift+Delete (command+X on Mac)</li>
+ <li>剪切:Ctrl+X 或者 Shift+Delete (命令+X 在Mac系统)</li>
+</ul>
+
+<p>The information on the rest of this page is for Web developers and advanced users. Please do not try to modify this page.</p>
+
+<p>这个网页剩余的信息是为了网页开发者好和高级的用户。请不要试着修改这个页面。</p>
+
+<p> </p>
+</div>
+
+<p>To protect users' private information, unprivileged scripts cannot invoke the Cut, Copy, and Paste commands in Midas, which is Mozilla's rich text editor component.</p>
+
+<p>在Midas中为了保护用户的私有信息,没有权限的脚本 不能调用剪切,复制和黏贴命令,那个是火狐强大的文本编辑组件。</p>
+
+<p>This means that the corresponding buttons on the <a href="http://www-archive.mozilla.org/editor/midasdemo/" title="http://www-archive.mozilla.org/editor/midasdemo/">Mozilla Rich Text Editing demo page</a> will not work. To enable these functions, you must modify your browser preferences.</p>
+
+<p>这个意味着那个符号命令的按钮在火狐强大文本编辑演示页面不能够工作。为了启动这个功能,你可以修改浏览器的首选项。</p>
+
+<div class="warning">
+<p><strong>Warning:</strong> Changing these preferences can leave your browser insecure, especially if you grant permission to untrusted sites.</p>
+
+<p>警告:改变这个首选项可能不安全的离开你的浏览器,尤其如果你获得允许为了不真实的网站。</p>
+
+<p>Only change these settings as needed to try the demo above and to test your own add-on or Firefox-internal code, and be sure to restore the default settings when you're done!</p>
+
+<p>仅仅改变这些设置如需要试着演示上面的和测试你拥有的添加在或者火狐内部的代码,当你做的时候确保恢复默认的设置。</p>
+</div>
+
+<h2 id="Changing_the_preferences_in_Firefox">Changing the preferences in Firefox</h2>
+
+<p>在火狐中改变首选项。</p>
+
+<ol>
+ <li>Quit Firefox. If you have Quick Launch running (on Windows, this is an icon in the toolbar), quit that too.</li>
+ <li>退出火狐。如果你有快速的开始运行(在windows,这是一个图标在那个工具池里),也退出。</li>
+ <li><a class="external" href="http://support.mozilla.com/en-US/kb/Profiles">Find your Firefox profile directory</a>.</li>
+ <li>找到你的火狐资料目录</li>
+ <li>Open the <code class="filename">user.js</code> file from that directory in a text editor. If there's no <code>user.js</code> file, create one.</li>
+ <li>打开那个user.js文件从在文本编辑器的目录。如果没有user.js文件,创建一个。</li>
+ <li>Add these lines to <code class="filename">user.js</code>:</li>
+ <li>在user.js中添加下面这些行。</li>
+ <li>
+ <pre class="code">user_pref("capability.policy.policynames", "allowclipboard");
+user_pref("capability.policy.allowclipboard.sites", "https://www-archive.mozilla.org");
+user_pref("capability.policy.allowclipboard.Clipboard.cutcopy", "allAccess");
+user_pref("capability.policy.allowclipboard.Clipboard.paste", "allAccess");
+</pre>
+ </li>
+ <li>Change the URL <span class="external"><code class="url">https://www.mozilla.org</code></span> to the site for which you want to enable this function.</li>
+ <li>改变那个URL <span class="external"><code class="url">https://www.mozilla.org</code> 这个网站,你想要使用这个功能。</span></li>
+ <li>Save the file and restart Firefox. The Clipboard buttons in the demo, or similar buttons on the sites you listed, should now function.</li>
+ <li>保存这个文件和重启火狐。那在演示中的剪切板按钮或者在网站中你列表类似的按钮,应该有现在的功能。</li>
+</ol>
+
+<div class="note">
+<p><strong>Note:</strong> The preference is site as well as protocol specific. For example:</p>
+
+<p>注意;那个首选项网址也是特定协议。例如</p>
+
+<pre>user_pref("capability.policy.allowclipboard.sites", "http://www-archive.mozilla.org")
+</pre>
+
+<p>is not the same as:</p>
+
+<p>不是相同的和下面的</p>
+
+<pre>user_pref("capability.policy.allowclipboard.sites", "https://www-archive.mozilla.org")
+</pre>
+
+<p>This is because the first uses <a href="/en-US/docs/HTTP" title="/en-US/docs/HTTP">HTTP</a> while the second uses HTTPS.</p>
+
+<p>这是因为第一个使用HTTP 然而第二个使用HTTPS</p>
+
+<p>If you want to allow multiple URLs to access the Paste operation, separate the URLs with a space. For example:</p>
+
+<p>如果你想要允许多条URL访问那个黏贴操作,使用独立的URL的一个空间。例如:</p>
+
+<pre>user_pref("capability.policy.allowclipboard.sites", "https://www-archive.mozilla.org https://developer.mozilla.org")
+</pre>
+</div>
+
+<p>Again, keep in mind the security risks involved here and be sure to remove permission to access the clipboard once you no longer need it enabled.</p>
+
+<p>再次说明,牢记那个安全危机在这里涉及的,和确保移除允许访问那个剪切板一旦你不在需要启动它。</p>
+
+<h2 id="See_also">See also</h2>
+
+<p>另见:</p>
+
+<ul>
+ <li id="For_more_information_about_security_policies.2C_see_this_article_about_Configurable_Security_Policies.">For more information about security policies, see this article about <a href="http://www.mozilla.org/projects/security/components/ConfigPolicy.html" title="http://www.mozilla.org/projects/security/components/ConfigPolicy.html">Configurable Security Policies</a>.</li>
+ <li>更多的信息关于安全政策看这篇文章关于配置安全政策。</li>
+ <li><a href="/en-US/docs/Web/Security/CSP">CSP</a> and <a href="/en-US/docs/Web/Security/CSP/CSP_policy_directives">Policy Directives</a>.</li>
+ <li>CSP和政策指令。</li>
+</ul>