Skip to content

Commit

Permalink
Merge pull request #1705 from hLinx/hotfix_3.5.x
Browse files Browse the repository at this point in the history
Hotfix 3.5.x
  • Loading branch information
hLinx authored Feb 1, 2023
2 parents 62e8b8a + bdd1ffa commit cff6a3c
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 147 deletions.
15 changes: 8 additions & 7 deletions src/frontend/src/components/ace-editor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
SQL: 'sql',
};
const LOCAL_STORAGE_KEY = 'ace_editor_history';

const escapeHTML = str => str.replace(/&/g, '&').replace(/"/g, '"')
.replace(/'/g, ''')
.replace(/</g, '&#60;');
Expand All @@ -167,7 +167,7 @@
temp.value = value;
return temp.value;
};

export default {
name: 'AceEditor',
components: {
Expand Down Expand Up @@ -382,6 +382,7 @@
},
beforeDestroy () {
this.handleExitFullScreen();
this.$store.commit('setScriptCheckError', null);
},
mounted () {
this.initEditor();
Expand Down Expand Up @@ -420,7 +421,7 @@
return result;
}, {});
this.defaultScriptMap = Object.assign({}, DefaultScript, customScriptMap);

// 只读或有传入值默认脚本使用prop.value
// 其它情况使用脚本编辑器提供的默认值
this.content = this.readonly || this.value
Expand Down Expand Up @@ -457,7 +458,7 @@
editor.setShowPrintMargin(false);
editor.$blockScrolling = Infinity;
editor.setReadOnly(this.readonly);

editor.on('change', () => {
this.content = editor.getValue();
const content = Base64.encode(this.content);
Expand All @@ -479,12 +480,12 @@
});
// 先保存 editor 在设置 value
this.editor = editor;

this.$once('hook:beforeDestroy', () => {
editor.destroy();
editor.container.remove();
});

this.watchEditAction();

const $handler = document.querySelector(`#${this.selfId}`);
Expand Down Expand Up @@ -576,7 +577,7 @@
if (target.type !== 'textarea') {
return;
}

if ([
'Escape',
'Meta',
Expand Down
20 changes: 11 additions & 9 deletions src/frontend/src/components/jb-edit/input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@
</div>
</template>
<template v-else>
<div class="edit-value-box" :class="{ 'edit-error': !!error }" @click.stop="">
<div
class="edit-value-box"
:class="{ 'edit-error': !!error }"
@click.stop="">
<bk-input
ref="input"
:value="newVal"
Expand Down Expand Up @@ -174,7 +177,7 @@
resolve();
}
});

const allPromise = this.rules.map(rule => checkValidator(rule, this.newVal));
this.isValidatoring = true;
return Promise.all(allPromise).finally(() => {
Expand Down Expand Up @@ -256,16 +259,15 @@
* @param {Object} event dom 事件
*/
handleHideEdit (event) {
const eventPath = event.composedPath();
if (this.isValidatoring || this.error) {
return;
}
if (event.path && event.path.length > 0) {
// eslint-disable-next-line no-plusplus
for (let i = 0; i < event.path.length; i++) {
const target = event.path[i];
if (target.className === 'jb-edit-input') {
return;
}
// eslint-disable-next-line no-plusplus
for (let i = 0; i < eventPath.length; i++) {
const target = eventPath[i];
if (target.className === 'jb-edit-input') {
return;
}
}
this.isEditing = false;
Expand Down
19 changes: 9 additions & 10 deletions src/frontend/src/components/jb-edit/select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
resolve();
}
});

const allPromise = this.rules.map(rule => checkValidator(rule, this.localValue));
this.isValidatoring = true;
return Promise.all(allPromise).finally(() => {
Expand Down Expand Up @@ -300,17 +300,16 @@
* @param {Object} event dom 事件
*/
handleHideEdit (event) {
const eventPath = event.composedPath();
if (this.isValidatoring || this.error) {
return;
}
if (event.path && event.path.length > 0) {
// eslint-disable-next-line no-plusplus
for (let i = 0; i < event.path.length; i++) {
const target = event.path[i];
if (target.className === 'jb-edit-select'
|| target.className === 'tippy-content') {
return;
}
// eslint-disable-next-line no-plusplus
for (let i = 0; i < eventPath.length; i++) {
const target = eventPath[i];
if (target.className === 'jb-edit-select'
|| target.className === 'tippy-content') {
return;
}
}
this.isEditing = false;
Expand All @@ -331,7 +330,7 @@
this.triggerChange();
}
},

},
};
</script>
Expand Down
25 changes: 12 additions & 13 deletions src/frontend/src/components/jb-edit/tag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,20 @@
document.body.removeEventListener('click', this.hideEdit);
});
},

methods: {
/**
* @desc 触发标签修改操作
*/
triggerRemote () {
this.isEditing = false;

if (isEqual(this.memoValue, this.localValue)) {
return;
}

this.isLoading = true;

this.remoteHander({
[this.field]: this.localValue.map(({ id }) => ({ id })),
}).then(() => {
Expand All @@ -187,17 +187,16 @@
*/
hideEdit (event) {
if (!this.isEditing) return;
if (event.path && event.path.length > 0) {
// eslint-disable-next-line no-plusplus
for (let i = 0; i < event.path.length; i++) {
const target = event.path[i];
if (/tippy-popper/.test(target.className)
|| /job-tag-create-dialog/.test(target.className)) {
return;
}
const eventPath = event.composedPath();
// eslint-disable-next-line no-plusplus
for (let i = 0; i < eventPath.length; i++) {
const target = eventPath[i];
if (/tippy-popper/.test(target.className)
|| /job-tag-create-dialog/.test(target.className)) {
return;
}
}

this.triggerRemote();
},
/**
Expand Down
21 changes: 10 additions & 11 deletions src/frontend/src/components/jb-edit/textarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,15 @@
$el.style.wordBreak = 'keep-all';
$el.style.whiteSpace = 'pre';
}

this.$refs.valueTextBox.appendChild($el);

const lineHeight = 24;
const maxLine = 3;
const maxHeight = lineHeight * maxLine;
let realHeight = 0;
let realLength = 1;

const calcLength = () => {
const text = this.newVal.slice(0, realLength);
$el.innerText = `${text} 展开展开`;
Expand Down Expand Up @@ -287,13 +287,12 @@
* @desc 退出编辑状态
*/
handleHideInput (event) {
if (event.path && event.path.length > 0) {
// eslint-disable-next-line no-plusplus
for (let i = 0; i < event.path.length; i++) {
const target = event.path[i];
if (target.className === 'jb-edit-textarea') {
return;
}
const eventPath = event.composedPath();
// eslint-disable-next-line no-plusplus
for (let i = 0; i < eventPath.length; i++) {
const target = eventPath[i];
if (target.className === 'jb-edit-textarea') {
return;
}
}
this.isEditing = false;
Expand Down Expand Up @@ -366,7 +365,7 @@

&:hover {
.edit-action {
opacity: 1;
opacity: 100%;
transform: scale(1);
}
}
Expand Down Expand Up @@ -398,7 +397,7 @@
padding: 4px 15px 4px 2px;
color: #979ba5;
cursor: pointer;
opacity: 0;
opacity: 0%;
transform: scale(0);
transition: 0.15s;
transform-origin: left center;
Expand Down
Loading

0 comments on commit cff6a3c

Please sign in to comment.