- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试实现一个报告编辑器,其中在使用多个 Summernote WYSIWYG 编辑器部分时仅显示一个工具栏。我想出了一个解决方案,其中第一部分是完整的编辑器,另一部分处于空中模式。
这是我正在使用的 HTML 代码:
<h1>Report Editor</h1>
<h2>Findings</h2>
<summernote id="findings" class="summernote focused" ng-model="summernoteText" config="options" on-blur="reportCtrl.blur(evt)"></summernote>
<h2>Conclusions</h2>
<summernote id="conclusions" class="summernote" ng-model="summernoteText1" config="options" airmode on-blur="reportCtrl.blur(evt)"></summernote>
<h3>Findings Preview</h3>
<div class="sectionPreview">{{ summernoteText | notEmpty }}</div>
这是 Controller :
var module = angular.module('risReportControllers', ['summernote']);
module
.controller('ReportController', ['$route', '$scope', '$log',
function ($route, $scope, $log) {
$scope.summernoteText = "<p>Hi! I'm section #1!</p><p>Pick a car: <select name=\"cars\"> <option value=\"volvo\">Volvo</option> <option value=\"saab\">Saab</option> <option value=\"fiat\">Fiat</option> <option value=\"audi\">Audi</option> </select> and you could win!</p>";
$scope.summernoteText1 = "<p>Ooops, I did #2.</p>";
$scope.options = {
height: 150,
minHeight: null,
toolbar: [
['style', ['bold', 'italic', 'underline', 'clear']],
['color', ['color']],
['table', ['table']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']],
['view', ['fullscreen', 'codeview']]
],
};
this.blur = function (event) {
$log.debug("blur(event='" + event + "'");
var parentElement = angular.element(event.currentTarget.parentElement.parentElement);
$log.debug("parentElement = '" + parentElement + "'");
};
}]);
这是我所看到的屏幕截图:
我需要弄清楚如何更改模糊函数中的 parentElement
以使该部分恢复为 airmode
。我有什么想法可以做到这一点吗?
最佳答案
我想出了一个更好的方法来做到这一点,现在使用 Bootstrap 进行样式设置。我不再使用 Summernote 中的“airmode”。相反,我有可点击的 div,点击时会激活或销毁 Summernote 编辑器。如果单击另一个部分,则所有其他编辑器都会被销毁(如果它们处于事件状态)。
HTML
<div class="container">
<h1>Summernote Editor</h1>
<div ng-repeat="section in reportCtrl.sections">
<div class="panel panel-info">
<div class="panel-heading"> {{ section.heading }}</div>
<div id="section_{{$index}}" class="panel-body" ng-bind-html="section.body" ng-click="section.onClick($index)"></div>
</div>
</div>
<button type="button" class="btn btn-primary pull-right" ng-click="reportCtrl.destroyEditors()">Close All</button>
</div>
JS
var module = angular.module('risReportControllers', ['summernote']);
module
.controller('ReportController', ['$route', '$scope', '$log', '$sce', 'ModelFetchService',
function ($route, $scope, $log, $sce, ModelFetchService) {
var reportCtrl = this;
reportCtrl.sections = [];
// This fetches a fake report from the reports folder and populates the sections[] array.
ModelFetchService.get({reportId: 'report'}, function (file) {
for (var i in file.report) {
var section = file.report[i];
reportCtrl.sections.push({
heading: section.heading,
body: $sce.trustAsHtml(section.body),
isEditable: false,
onClick: function (i) {
reportCtrl.activateEditor(i);
}
});
}
});
const SECTION_ID_PREFIX = '#section_';
/**
* Renders the editor for the section with the given id value and turns off editing for all other sections.
*
* @param sectionId the html id of the section to edit.
*/
reportCtrl.activateEditor = function (sectionIndex) {
var section = reportCtrl.sections[sectionIndex];
activateEditor(sectionIndex);
// Destroy the editor an all other sections but this one.
for (var i in reportCtrl.sections) {
if (i != sectionIndex) {
destroyEditor(i);
}
}
};
/**
* Destroys the editor for all sections.
*/
reportCtrl.destroyEditors = function () {
for (var i in reportCtrl.sections) {
destroyEditor(i);
}
};
/**
* Actives the editor in the section with the given sectionIndex (if it is not already active).
*
* @param sectionIndex the numerical index of the section in the reportCtrl's sections array
*/
var activateEditor = function (sectionIndex) {
var section = reportCtrl.sections[sectionIndex];
if (!section.isEditable) {
section.isEditable = true;
$log.debug("activateEditor(sectionIndex='" + sectionIndex + "')");
const sectionId = SECTION_ID_PREFIX + sectionIndex;
var element = angular.element(sectionId);
element.summernote({
minHeight: 150,
toolbar: [
['style', ['bold', 'italic', 'underline']],
['para', ['ul', 'ol']],
]
});
}
};
/**
* Destroys the editor in the given section (if the editor is active).
*
* @param sectionIndex the numerical index of the section in the reportCtrl's sections array.
*/
var destroyEditor = function (sectionIndex) {
var section = reportCtrl.sections[sectionIndex];
if (section.isEditable) {
section.isEditable = false;
$log.debug("destroyEditor(sectionIndex='" + sectionIndex + "')");
const sectionId = SECTION_ID_PREFIX + sectionIndex;
var element = angular.element(sectionId);
section.body = $sce.trustAsHtml(element.code());
element.destroy();
// You have to add the onClick method back because it is destroyed by the summernote integration.
element.on('click', function () {
section.onClick(sectionIndex);
});
}
};
}]);
请注意,在 reportCtrl
的序言中,我添加了对 ModelFetchService
的调用,该调用会获取 json 文件并将其插入 sections[]
数组中。我的 html 中的 ng-repeat 使用它来创建部分。
屏幕截图
关于javascript - 如何在airmode 和toolbar 模式之间切换summernote 编辑器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32587641/
我想像 wordpress 的 css 管理器一样为我的网站制作 css 管理器。我想在 textarea 中打开 css 文件,这样我就可以编辑它,而不是在按下提交按钮后,应该保存 css 文件中的
我不知道这是一个有效的问题。我见过大多数插件和对话框定义的 CKEditor 示例都使用变量“editor”。我想知道它是什么以及它的值来自哪里。 例如 CKEDITOR.plugins.add( '
如果你希望极认真地学习和使用 XML,那么一定想要找一款称手的 XML 编辑器 XML 是基于文本的 XML是基于文本的标记语言 XML可被类似记事本这样的简单的文本编辑器来创建和编辑 不过在
有没有人成功地将 Summernote 编辑器与 Meteor 一起使用? 见 http://hackerwins.github.io/summernote/ 我在我的模板中包含了以下 div:
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
如何使文本默认从右向左对齐(p:editor)。 当前使用 primefaces 3.0.M2-SNAPSHOT。现在无法更新到新版本吗? 这是阿拉伯语版本应用程序所必需的。 谢谢 最佳答案 在 we
如何启动或安装 Eclipse XSD 编辑器? 根据this看来它应该开箱即用。我创建了 XMLExamples 项目,当我打开 Catalogue.xsd 时,Eclipse 将其视为文本文件。如
我爱wysihtml5但我找不到任何关于向元素添加类这样简单的文档。 基本上我正在寻找的是一种允许 blockquote 元素有 2 种不同变体的方法: blockquote.pull-leftblo
我真的很想要一个在 Django 中实现文本编辑器的清晰直接的示例,就像提议的 pagedown 或 markdownx 一样。我无法在 Django 2.0 中使用这些解决方案中的任何一个,并且我找
是否有支持 REPL 和大括号匹配的 ClojureCLR 编辑器?我找到了一个将对 ClojureCLR 的支持添加到 Visual Studio 的项目:vsClojure ,但无法构建它。还有其
GWT 的编辑器框架非常好用,它不仅可以用于编辑POJO,还可以用于只读显示。 但是,我并不完全确定进行内联编辑的最佳做法是什么。 假设我有一个 PersonProxy 并且我有一对 Presente
我对 primefaces 编辑器的第一个问题是它不接受来自 Chrome 和资源管理器中的 MS word 文档的文本,但在 Firefox 中工作正常。有没有办法让它直接接受来自 MS word
我使用 Prototype JS 作为主要 JS 库,并且我已将最后一个 RedactorJS 与 jQuery 以无冲突模式集成,但我无法启动如下功能: jQuery('#redactor').re
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 5年前关闭。 Improve thi
我正在 Laravel 项目上使用 redactor 作为文本编辑器。 每当编辑器位于页面上并初始化时,每当我单击任意位置时都会收到此错误。 Uncaught TypeError: $(...).cl
我在带有 jQuery .show("slide") 动画的界面设计中使用tinyMCE 时遇到问题。由于表单的复杂性,它像向导一样被分为多个页面,但它不使用下一步和后退按钮。相反,它使用部分名称
如何制作像 wufoo.com 表单编辑器中那样的拖放式编辑器 最佳答案 通常客户端应用程序是使用某种客户端框架构建的。比较流行的是(排名不分先后): GWT YUI jQuery 首先检查这些内容,
已关闭。此问题旨在寻求有关书籍、工具、软件库等的建议。不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以
有人建议我使用具有语法错误检查和调试功能的 Javascript 编辑器吗? Eclipse IDE 有可用的插件吗?或者您可以建议最适合错误检查和调试的任何编辑器。 提前致谢。 最佳答案 您可以安装
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
我是一名优秀的程序员,十分优秀!