- 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/
这是工具栏布局的 XML... 我正在使用支持库将工具栏用作我的操作栏。我在 onCreate 中这样做了... Toolbar mToolbar = (Toolbar)getLayoutInf
是否有任何属性/配置表明工具栏在向右溢出时应滚动到最后一项?我有一个垂直工具栏。它应该滚动到右侧的最后一项 我的配置如下: var toolbar = Ext.create('Ext.toolbar.
我使用 toolbar.Template() 和 Toolbar.Excel() 但 toolbar.excel() 不显示,只是 toolbar.Template() 显示。 .Excel(exce
我试图将 justify-content:center 放在工具栏内容的中心。在定位工具栏时,我可以看到扩展的元素,其中之一是 md-toolbar-row 给 justify-content:cen
我有一个toolbar.xml: 我的另一个 Activity 布局有一个包含标签: 我已经在我的扩展 AppCompatActivity 的 Activity 中实现了它: Toolbar
这是主要 Activity ,如 您可以清楚地看到 import android.support.v7.widget.Toolbar; 已经存在。 package app.com.example.an
我正在使用 TabLayout 折叠 ToolbarLayout,除了向上滚动时我的选项卡没有卡在工具栏下方之外,一切正常。 下面是我的代码:
有人可以向我解释一下它们之间的区别以及为什么它们不能互换吗? 导入 android.widget.Toolbar 会导致编译错误,而导入 android.support.v7.widget.Toolb
我收到这个错误 Caused by: java.lang.ClassCastException: android.support.v7.widget.Toolbar cannot be cast t
我正在寻找一种干净的方法来调整 Material-UI AppBar 后面的内容的偏移量。 我认为 theme.mixins.toolbar 会自动适应,但事实并非如此。 (使用这里描述的主题密度 P
我试过很多方法。但没有工作。期待这样的风格 ion-toolbar { contain: none; .toolbar-container { overflow: vi
我想在 md-toolbar 中使用 mf-tabs,我使用 Sithdown 在 https://github.com/angular/material/issues/1076 中提供的解决方案 它
Django 1.10 django-debug-toolbar == 1.5 新项目(我刚刚安装了Django)。尝试安装Django调试工具栏。 文档:https://django-debug-t
我正在升级我之前制作的一款游戏的用户界面,并且正朝着 Google 的 Material Design 方向发展。作为代码升级的一部分,我将向后兼容性支持库 android-support-v7-ap
您好,我是 Xamarin 的新手,我试图在 MainActivity 的 OnCreate() 中找到一个 View ,但找不到它(?)并且返回为 null。 protected override
是否可以将SAS脚本或宏分配给基本SAS中的工具栏按钮?即可以'dm'宏或sas脚本吗? 最佳答案 当然。这是一种方法: 转到“工具”->“自定义”。 选择“自定义”选项卡 通过单击“添加工具”(最左
我创建了一个简单的ALV网格,并用数据填充了网格,现在在选择屏幕之后显示了该网格。我没有使用自定义容器,而是以全屏显示网格。 是否有ALV网格对象的属性,该属性使工具栏具有通常位于网格顶部的按钮过滤器
我想为我的网站制作一个像谷歌工具栏这样的浏览器工具栏。它应该与所有流行的浏览器兼容。 我应该使用哪种语言来制作它?我可以使用任何示例/指南吗? 最佳答案 对于 Firefox,从这里开始:https:
我新下载了一个 jupyter 并尝试使用它。 但是,使用我的 mac 和 windows 计算机, 我在 jupyter 中看不到工具栏。 我尝试搜索以解决此问题,并尝试在 Mac 和 window
我在我的应用程序中使用工具栏。它应该如下所示: 但是,有时候,工具栏背景是错误的!我不知道为什么会这样...... 这是我的布局: ...... 这是我的工具栏: 帮助!有什么想法吗? 设备
我是一名优秀的程序员,十分优秀!