fix(codeblock): unable to save the selected language

This commit is contained in:
yanmao 2021-12-29 23:34:19 +08:00
parent 19021ffdd7
commit ac6a258da8
7 changed files with 12 additions and 11 deletions

View File

@ -113,7 +113,7 @@ class Engine implements EngineInterface {
// 查找父级样式 overflow 或者 overflow-y 为 auto 或者 scroll 的节点 // 查找父级样式 overflow 或者 overflow-y 为 auto 或者 scroll 的节点
const targetValues = ['auto', 'scroll']; const targetValues = ['auto', 'scroll'];
let parent = this.container.parent(); let parent = this.container.parent();
while (parent && parent.length > 0 && parent.name !== 'body') { while (!sn && parent && parent.length > 0 && parent.name !== 'body') {
if ( if (
targetValues.includes(parent.css('overflow')) || targetValues.includes(parent.css('overflow')) ||
targetValues.includes(parent.css('overflow-y')) targetValues.includes(parent.css('overflow-y'))

View File

@ -137,6 +137,12 @@ export interface EditorInterface {
* *
*/ */
clipboard: ClipboardInterface; clipboard: ClipboardInterface;
/**
*
* @param node
*/
setScrollNode(node: HTMLElement): void;
/** /**
* *
* @param eventType * @param eventType
@ -532,11 +538,6 @@ export interface EngineInterface extends EditorInterface {
* *
*/ */
isEmpty(): boolean; isEmpty(): boolean;
/**
*
* @param node
*/
setScrollNode(node: HTMLElement): void;
/** /**
* *
* @param ignoreCursor * @param ignoreCursor

View File

@ -115,7 +115,7 @@ class View implements ViewInterface {
// 查找父级样式 overflow 或者 overflow-y 为 auto 或者 scroll 的节点 // 查找父级样式 overflow 或者 overflow-y 为 auto 或者 scroll 的节点
const targetValues = ['auto', 'scroll']; const targetValues = ['auto', 'scroll'];
let parent = this.container.parent(); let parent = this.container.parent();
while (parent && parent.length > 0 && parent.name !== 'body') { while (!sn && parent && parent.length > 0 && parent.name !== 'body') {
if ( if (
targetValues.includes(parent.css('overflow')) || targetValues.includes(parent.css('overflow')) ||
targetValues.includes(parent.css('overflow-y')) targetValues.includes(parent.css('overflow-y'))

View File

@ -155,7 +155,7 @@ class CodeBlockEditor implements CodeBlockEditorInterface {
'readOnly', 'readOnly',
!isEngine(this.editor) || this.editor.readonly ? true : false, !isEngine(this.editor) || this.editor.readonly ? true : false,
); );
if (code !== undefined) this.save(); this.save();
} }
render(mode: string, value: string, options?: EditorConfiguration) { render(mode: string, value: string, options?: EditorConfiguration) {

View File

@ -174,7 +174,7 @@ class CodeBlcok<V extends CodeBlockValue = CodeBlockValue> extends Card<V> {
if (!this.codeEditor.container.inEditor()) { if (!this.codeEditor.container.inEditor()) {
this.codeEditor.container = $(this.codeEditor.renderTemplate()); this.codeEditor.container = $(this.codeEditor.renderTemplate());
this.mirror = undefined; this.mirror = undefined;
this.getCenter().append(this.codeEditor.container); this.getCenter().empty().append(this.codeEditor.container);
} }
const value = this.getValue(); const value = this.getValue();

View File

@ -156,7 +156,7 @@ class CodeBlockEditor implements CodeBlockEditorInterface {
'readOnly', 'readOnly',
!isEngine(this.editor) || this.editor.readonly ? true : false, !isEngine(this.editor) || this.editor.readonly ? true : false,
); );
if (code !== undefined) this.save(); this.save();
} }
render(mode: string, value: string, options?: EditorConfiguration) { render(mode: string, value: string, options?: EditorConfiguration) {

View File

@ -171,7 +171,7 @@ class CodeBlcok<V extends CodeBlockValue = CodeBlockValue> extends Card<V> {
if (!this.codeEditor.container.inEditor()) { if (!this.codeEditor.container.inEditor()) {
this.codeEditor.container = $(this.codeEditor.renderTemplate()); this.codeEditor.container = $(this.codeEditor.renderTemplate());
this.mirror = undefined; this.mirror = undefined;
this.getCenter().append(this.codeEditor.container); this.getCenter().empty().append(this.codeEditor.container);
} }
const value = this.getValue(); const value = this.getValue();