源代码编辑器使您可以编辑帮助中心的文章和内容块的 HTML 源代码。这使您可以自定义帮助中心的内容并设置其样式,而这是标准的所见即所得编辑器无法做到的。
编辑文章源代码
您可以使用文章源代码编辑器编辑文章的 HTML,从而自定义帮助中心文章。
- 在 帮助中心 或 知识管理中,创建或编辑文章或内容块。
- 在文章或内容块中,单击源代码图标 (
)。
- 在源代码编辑器中,创建或编辑您要使用的源代码。有关受支持元素的列表,请参阅 帮助中心文章支持的 HTML。
- 单击 应用 保存编辑并关闭源代码视图。
清理文章源代码中的样式
当您将内容从 HTML 页面复制粘贴到帮助文章中时,可能会带来不需要的样式,使文章源代码变得杂乱无章,并影响帮助中心的一致性。您可以使用源代码编辑器中的清理样式按钮,去除对文章编辑器工作不必要的内联样式。清除样式按钮不会影响 CSS 类 或 主题,也不会影响文章编辑器所需的内联样式(例如,前景和背景字体,表格单元格的高度和宽度)。
- 在帮助中心或 知识管理中,创建或编辑文章或内容块。
- 在文章或内容块中,单击源代码图标 (
)。
源代码编辑器随即打开,显示所有代码和内联样式。
- 在源代码编辑器中,单击 清理样式。
不受支持的内联样式将从源代码视图中移除。
- 单击 应用 保存编辑并关闭源代码视图。
- 单击 保存 以保存更改。
编辑源代码时的重要注意事项
空的 HTML 容器元素
Zendesk 会自动移除大多数空白容器元素,例如 i
或 span
更新。这些元素通常必须包含要呈现的内容。Zendesk 无法移除空白 p
标签。取而代之的是,Zendesk 会插入
作为元素的内容。例如:
<p> </p>
不安全的 HTML
默认情况下,Zendesk 认为以下 HTML 元素不安全。
applet, button, embed, form, input, object, script, textarea, style
处理文章中不安全的 HTML
对于文章,源代码编辑器不会移除不安全的 HTML 元素或不受支持的 HTML 属性。相反,它们被排除在用于呈现帮助中心文章的 HTTP 响应中。因此,文章可能无法如预期呈现。
允许文章中出现不安全的 HTML
您可以覆盖默认设置,允许帮助中心文章中出现不安全的 HTML。
警告:进行此更改将使潜在的恶意代码在用户在浏览器中打开文章时被执行。
允许 HTTP 响应中出现不安全的 HTML
- 在 知识管理员中,单击 设置 图标 (
)。
- 在 安全下,选择 显示不安全内容 选项。
- 单击更新。
处理内容块中的不安全 HTML
对于内容块,源代码编辑器会移除不安全的 HTML 元素和不受支持的属性。不安全元素内的内容将放置在 p
元素如 未知 HTML中所述。
未知 HTML
不受支持的 HTML 元素将被视为未知元素。根据您编辑的是内容块还是帮助中心文章,对不受支持的 HTML 的处理方式有所不同。
如果您正在编辑内容块,HTML 块会识别不受支持的内容,并将其包装在 HTML 块中。您可以单击内容块编辑器中的 HTML 块以打开仅显示该块代码的源代码编辑器。您可以使用此聚焦视图来操作选定内容的 HTML,而无需滚动查看整个内容块的源代码。请参阅使用 HTML 块编辑内容块中的代码。
mytag
元素。<mytag>Hello world!</mytag>
在用于呈现帮助中心的HTTP 响应中, mytag
元素已移除。其内容将放在 p
元素。
<p>Hello world!</p>
帮助文章中的 HTML 样式
在可能的情况下,Zendesk 建议 class
属性和相关 CSS 类,以设置帮助中心文章中的 HTML 样式。CSS 类应在帮助中心主题中定义。有关更多信息,请参阅自定义帮助中心主题。
为帮助中心主题创建 CSS 规则时,请避免使用嵌套选择器,例如 div.container > p > img
更新。此类规则难以维护,可能会针对意外的元素。相反,使用直接为类设置样式的选择器,例如 .container-image
更新。然后使用 将该类直接添加到受影响的 HTML 元素 class
元素。例如:<img
class="container-image" ...>
避免使用 style
属性以应用内联样式到 HTML 元素。内联样式难以维护,并可能导致样式不一致。
翻译免责声明:本文章使用自动翻译软件翻译,以便您了解基本内容。 我们已采取合理措施提供准确翻译,但不保证翻译准确性
如对翻译准确性有任何疑问,请以文章的英语版本为准。
22 条评论
John Jarvie
Hello,
During the initial migration to Zendesk, embedded code from the previous HC provider was included in the articles. It doesn't impact the functionality, but I would like to avoid future problems. Is there a way of searching for and stripping all of that code automatically? It is a long manual process because I have to get into the code of each article individually.
0
David Bjorgen
8001833167258 you'll need to navigate to the “Security” section in your Guide settings and make sure the “Display unsafe content” option is checked.
0
Oleksandr Nebylytsia
Hi.
I see <script> as unsafe HTML elements. But how can i implement Schema markup with Json-LD script? It is totally safe script which i need to make my articles more accesible for Google.
0
Paolo
Currently, the options in the editor are fixed. If you can't find the specific option you need for your article, you can always add it in the source code or theme code. Providing this feedback would be really helpful for us to improve our product.
I suggest creating a new post in the General Product Feedback topic in our community. This way, you can connect with other users who might have similar needs and explore potential workarounds together. Engaging in discussions with a lot of users can catch the attention of our product managers during roadmap planning. Thank you.
Best,
Paolo | Technical Support Engineer | Zendesk
0
Felix Tilgner
Hi, I was wondering if it is possible to add custom options to the WYSIWYG editor?
I have certain elements that I want to use consistent formatting, which is not available via the editor. For this purpose, I have created custom classes in the CSS style file, but I am not able to use these classes without having to open the source code every time.
0
David Bjorgen
1265139235370 you can wrap Font Awesome in <span> tags instead of <i> tags. In certain cases, such as tables, empty <span> tags are removed, so you have to add a non-breaking space ( ) inside the <span>.
1
Alan Blair
Does anyone know of any workarounds/resolutions to this?
0
David Bjorgen
The "safe" list is missing a few semantic HTML elements:
1
Gorka Cardona-Lauridsen
5240986373786 take a look at Welcome to WhatsApp in Zendesk Support.
If you can't find what you need there you should contact our support using the chat in the bottom right corner.

1
Stefano Volpe
Hi! Are safe tags and attributes for tickets the same as the ones listed here? Or perhaps there are two different lists for those altogether?
0
登录再写评论。