如何在 Dreamweaver 中创建自定义插入菜单项?
我需要创建一个插入一些专有标记的菜单项,例如
<###LoginForm###>
我的 CMS 使用的代码标记。
我发现这非常困难 - 从逻辑上讲,根据文档,我应该能够通过在 Program Files 的 Dreamweaver 文件夹中的 configuration/Menus 中编辑 menus.xml 来完成此操作。但这并没有按预期工作。我尝试复制插入 HR 标签的项目,替换我的“标签”,但没有插入任何内容。
在configuration/objects/common中有一些文件,在XML中引用,这些文件似乎包含可插入的代码块,即有一个HR.htm,看起来应该插入
,但它插入了
当实际菜单项在 XHTML 中使用时,它们是否已过时?
我非常希望有人给我一个万无一失的方法来创建一个菜单,该菜单允许我插入我自己的类似标签的代码片段,如上所述。
I need to create a menu item which inserts some proprietary markup, e.g. a code marker like
<###LoginForm###>
as used by my CMS.
I'm finding it very hard -- logically, and according to documentation, I should be able to do it by editing menus.xml in configuration/Menus in Dreamweaver's folder in Program Files. But this doesn't work as expected. I tried to copy the item which inserts an HR tag, substituting my "tag", but nothing is inserted.
There are files in configuration/objects/common, referenced in the XML, which seem to contain insertable chunks of code, i.e. there's an HR.htm which looks like it should insert <HR>
but it inserts <hr />
when the actual menu item is used in XHTML, so are they obsolete?
I would very much like someone to give me a foolproof recipe to create a menu which would allow me to insert my own tag-like code snippets as above.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建 Dreamweaver 扩展/插件的文档需要大量改进。您可能阅读了如何添加菜单项,但它可能没有说明您应该在属性值中包含什么内容才能准确地执行您想要的操作。尝试复制其他东西是一个很好的起点,但有些东西的实际工作方式可能存在一些“魔力”。
如果这是一段代码,为什么不使用“代码片段”面板(“窗口”->“代码片段”)?您甚至可以选择为各个片段分配键盘快捷键?
对于对象(插入菜单和插入栏用于向页面添加代码),内置标签(例如 HR)将标签的 XHTML 兼容版本插入到具有 XHTML 文档类型的文档中。这是设计使然,是 Dreamweaver 的内部设计。
如果您将以下菜单项添加到 HR 条目上方的 menus.xml 中:
注意:我不再使用文件属性,而是使用允许运行 JavaScript 代码的命令属性,在本例中:
它获取对文档的引用,查找文档中的选择偏移量,并将选择内容替换为您的代码块。
我没有以各种可能的方式对此进行测试,但它适用于纯 HTML 和 XHTML 文档。
The documentation for creating Dreamweaver extensions/addons could use a great deal of improvement. You maybe read how to add a menu item, but it probably didn't say what you should include in the attribute values to do exactly what you wanted. Trying to copy something else is a good starting point, but there can be some "magic" with how some things actually work.
If this is a snippet of code, why not use the Snippets panel (Window -> Snippet)? You even have the option assigning a keyboard shortcut to individual snippets?
As for objects (which the Insert menu and Insert bar are used to add code to the page), the built-in tags, such as HR, insert the XHTML compatible versions of the tag into documents with an XHTML doctype. This is by design, and is internal to Dreamweaver.
If you added the following menu item to menus.xml above the HR entry:
Note: I moved away from the file attribute and instead used the command attribute which allows running of JavaScript code, in this case:
which gets a reference to the document, finds the selection offsets within the document and replaces the selection with your code chunk.
I've not tested this in every possible way, but works for me in a plain HTML and XHTML documents.
我在尝试不同的事情时也遇到了问题:添加另一个菜单选项来插入已经包含可访问性属性 role="presentation" 的表,因为我编写了电子邮件代码。尽管我通过复制现有代码来插入表,然后替换 ids 并使用我想要的修改引用所涉及文件的版本(Table.htm 和 TableCommands.htm),在 menus.xml 中创建了一个新块,但它从未出现在 DW 的菜单上。我查找了对插入表选项 id 的调用,但在搜索中出现的 menus.xml 中唯一的其他位置现在有新条目的 id,但仍然没有发生任何事情。所以,我只能认为菜单的另一个组件需要更新,但我不知道涉及什么文件。
I also had a problem while trying a different thing: to add another menu option to insert a table already containing the accessibility attribute role="presentation", because I code emails. Although I created a new block in menus.xml by duplicating the existing code to insert a table and then replacing the ids and referencing my version of the files involved (Table.htm and TableCommands.htm) with the modification I wanted, it never appeared on DW's menu. I looked for calls to the insert Table option's id, but the only other place in menus.xml that came up on a search has the new entry's id now and still nothing happened. So, I can only think there's another component of the menu that needs to be updated and I don't know what file is involved.