3

当我将 Jodit 编辑器 (3.4.2) 放入 Bootstrap 模式 (4.3) 中时,弹出表单的任何 Jodit 工具栏项都不允许您在该表单上输入输入。例如,如果您单击图像工具栏图标,则会弹出一个表单供您输入 URL。该输入字段不会获得焦点以允许您输入任何内容。这些弹出表单上的按钮确实有效。

其他一切 Jodit-wise 似乎在模态中工作正常,而不是在选择工具栏图标时弹出的表单。当它不在 Bootstrap 模式中时,相同的 Jodit 配置在该页面上工作。

Jodit 设置的 z-index 比模态的要高得多。没有什么明显的输入字段被禁用。我认为可能需要在显示模式后创建编辑器,但这对问题没有影响。

HTML

<div>
    <div>
        Click on the image tool.  Can edit url input field.
    </div>
    <div id="editor1"></div>    

    <button onclick="$('#dialog').modal( 'show' );">
        Show modal with editor
    </button>
</div>
<div id="dialog" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
                </button>
            </div>

            <div class="modal-body">

                <div>
                    Click on the image tool.  Can't edit url input field.
                </div>
                <div id="editor2"></div>    

            </div>

        </div>
    </div>
</div>

JavaScript

var editor1 = new Jodit( '#editor1' );
var editor2 = new Jodit( '#editor2' );

示例:https ://jsfiddle.net/Lmqj2ybv/1/

4

1 回答 1

1

需要删除 tabindex="-1"

var editor1 = new Jodit( '#editor1' );
var editor2 = new Jodit( '#editor2' );
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jodit/3.4.26/jodit.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jodit/3.4.26/jodit.min.js"></script>
 <div>
         <div>
          Click on the image tool.  Can edit url input field.
          </div>
          <div id="editor1"></div>    

   <button onclick="$('#dialog').modal( 'show' );">
   Show modal with editor
   </button>
 </div>
 <div id="dialog" class="modal" role="dialog">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
      
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        
        <div class="modal-body">

          <div>
          Click on the image tool.  Can't edit url input field.
          </div>
          <div id="editor2"></div>    

        </div>
        
      </div>
    </div>
  </div>

于 2021-02-04T13:56:21.413 回答