mirror of
https://github.com/nocodb/nocodb.git
synced 2026-05-01 05:26:53 +00:00
* feat: static button type * fix: swagger * fix: style corrections * feat: webhook trigger * fix: disables * feat: Button icons fix: row Delete failing * fix: expanded-form ux fix: disable buttons in forms fix: update PlainCell button handling fix: webhook delete, active change handling * fix: disable case * fix: disable case * fix: update Button styles * fix: refactor min/max with limit for columns fix: disable filter, groupby for Button Field fix: disable aggregation for Buttons * fix: hide button field in Filters * fix: fields menu corrections fix: update menu corrections * fix: rebase * feat: support webhook creation from ButtonOptions * fix: sort related tests * fix: keep webhook modal open * fix: ui fixes * fix: icon duplicate * fix: syntax highlighing for handlebar fix: disable mascot fix: truncate selected webhook * fix: sort disable tooltip * test: button playwright test * fix: button column duplication * fix: add error fix: column options * fix: EditOrAddProvider.vue * fix: add invalid configuration * fix: ux corrections * fix: ux corrections * fix: error handling fix: clear single query cache on hook delete * fix: include button type in api * fix: update overlay styles fix: webhook update * fix: formula placeholder * fix: playwright tests * fix: playwright tests * feat: refactor formula input * fix: added more spacing * fix: no icon text * fix: lint * fix: handle invalid url * fix: handle sort by for button causes issue when button used as lookup * fix: button field position * docs: button field * fix: tooltip correction * fix: link * fix: add btn href * fix: handle some edge cases * fix: handle some edge cases * fix: update font color * fix: add manual trigger docs * fix: sqlite BaseModel fix * docs: button share view info * fix: rebase * fix: reduce height and added resize support fix: added tooltip if label overflow * fix: manual hook disable state * docs: manual trigger details in webhook page * fix: chevron grey shade to 500 * docs: sample payload for manual trigger * fix: style update * fix: pr review comments * fix: pr review changes * fix: reactivity issue * fix: reactivity issue * fix: filter enabled on button * fix: reload meta on webhook change * fix: error handling in formula filter * fix: handle url error --------- Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com>
85 lines
2.4 KiB
TypeScript
85 lines
2.4 KiB
TypeScript
import type { Input as AntInput } from 'ant-design-vue'
|
|
import { formulas } from 'nocodb-sdk'
|
|
|
|
const formulaList = Object.keys(formulas)
|
|
|
|
// ref : https://stackoverflow.com/a/11077016
|
|
function insertAtCursor(myField: typeof AntInput, myValue: string, len = 0, b = 0) {
|
|
// MOZILLA and others
|
|
if (myField.selectionStart || myField.selectionStart === 0) {
|
|
const startPos = myField.selectionStart
|
|
const endPos = myField.selectionEnd
|
|
myField.value = myField.value.substring(0, startPos - len) + myValue + myField.value.substring(endPos, myField.value.length)
|
|
const pos = +startPos - len + myValue.length - b
|
|
// https://stackoverflow.com/a/4302688
|
|
if (myField.setSelectionRange) {
|
|
myField.focus()
|
|
myField.setSelectionRange(pos, pos)
|
|
} else if (myField.createTextRange) {
|
|
const range = myField.createTextRange()
|
|
range.collapse(true)
|
|
range.moveEnd('character', pos)
|
|
range.moveStart('character', pos)
|
|
range.select()
|
|
}
|
|
} else {
|
|
myField.value += myValue
|
|
}
|
|
return myField.value
|
|
}
|
|
|
|
function ReturnWord(text: string, caretPos: number) {
|
|
const preText = text.substring(0, caretPos)
|
|
if (preText.indexOf(' ') > 0) {
|
|
const words = preText.split(' ')
|
|
return words[words.length - 1] // return last word
|
|
} else {
|
|
return preText
|
|
}
|
|
}
|
|
|
|
function getWordUntilCaret(ctrl: typeof AntInput) {
|
|
const caretPos = GetCaretPosition(ctrl)
|
|
const word = ReturnWord(ctrl.value, caretPos)
|
|
return word || ''
|
|
}
|
|
|
|
function GetCaretPosition(ctrl: typeof AntInput) {
|
|
let CaretPos = 0
|
|
if (ctrl.selectionStart || ctrl.selectionStart === 0) {
|
|
CaretPos = ctrl.selectionStart
|
|
}
|
|
return CaretPos
|
|
}
|
|
|
|
// Function to check if cursor is inside Strings
|
|
function isCursorInsideString(text: string, offset: number) {
|
|
let inSingleQuoteString = false
|
|
let inDoubleQuoteString = false
|
|
let escapeNextChar = false
|
|
|
|
for (let i = 0; i < offset; i++) {
|
|
const char = text[i]
|
|
|
|
if (escapeNextChar) {
|
|
escapeNextChar = false
|
|
continue
|
|
}
|
|
|
|
if (char === '\\') {
|
|
escapeNextChar = true
|
|
continue
|
|
}
|
|
|
|
if (char === "'" && !inDoubleQuoteString) {
|
|
inSingleQuoteString = !inSingleQuoteString
|
|
} else if (char === '"' && !inSingleQuoteString) {
|
|
inDoubleQuoteString = !inDoubleQuoteString
|
|
}
|
|
}
|
|
|
|
return inDoubleQuoteString || inSingleQuoteString
|
|
}
|
|
|
|
export { formulaList, formulas, getWordUntilCaret, insertAtCursor, isCursorInsideString }
|