fix(frontend): Attempt to resolve TypeError in RichTextInput.svelte
Fixes an issue where `ue.getWordAtDocPos is not a function` would be thrown in `MessageInput.svelte`. The error was caused by a timing issue where the `getWordAtDocPos` method on the `RichTextInput` component was not available when called from an event handler within the same component. This change refactors the code to pass the `getWordAtDocPos` function as a callback prop from `RichTextInput` to `MessageInput`, ensuring it's available when needed.
This commit is contained in:
@@ -74,15 +74,15 @@ const readPngChunks = (data) => {
|
||||
|
||||
if (!isValidPng) throw new Error('Invalid PNG file');
|
||||
|
||||
let chunks = [];
|
||||
const chunks = [];
|
||||
let offset = 8; // Skip PNG signature
|
||||
|
||||
while (offset < data.length) {
|
||||
let length =
|
||||
const length =
|
||||
(data[offset] << 24) | (data[offset + 1] << 16) | (data[offset + 2] << 8) | data[offset + 3];
|
||||
let type = String.fromCharCode.apply(null, data.slice(offset + 4, offset + 8));
|
||||
let chunkData = data.slice(offset + 8, offset + 8 + length);
|
||||
let crc =
|
||||
const type = String.fromCharCode.apply(null, data.slice(offset + 4, offset + 8));
|
||||
const chunkData = data.slice(offset + 8, offset + 8 + length);
|
||||
const crc =
|
||||
(data[offset + 8 + length] << 24) |
|
||||
(data[offset + 8 + length + 1] << 16) |
|
||||
(data[offset + 8 + length + 2] << 8) |
|
||||
|
||||
@@ -23,8 +23,8 @@ const ALLOWED_SURROUNDING_CHARS =
|
||||
// const inlineRule = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:?!。,:]|$)/;
|
||||
// const blockRule = /^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;
|
||||
|
||||
let inlinePatterns = [];
|
||||
let blockPatterns = [];
|
||||
const inlinePatterns = [];
|
||||
const blockPatterns = [];
|
||||
|
||||
function escapeRegex(string) {
|
||||
return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
||||
@@ -69,7 +69,7 @@ export default function (options = {}) {
|
||||
}
|
||||
|
||||
function katexStart(src, displayMode: boolean) {
|
||||
let ruleReg = displayMode ? blockRule : inlineRule;
|
||||
const ruleReg = displayMode ? blockRule : inlineRule;
|
||||
|
||||
let indexSrc = src;
|
||||
|
||||
@@ -78,7 +78,7 @@ function katexStart(src, displayMode: boolean) {
|
||||
let startIndex = -1;
|
||||
let startDelimiter = '';
|
||||
let endDelimiter = '';
|
||||
for (let delimiter of DELIMITER_LIST) {
|
||||
for (const delimiter of DELIMITER_LIST) {
|
||||
if (delimiter.display !== displayMode) {
|
||||
continue;
|
||||
}
|
||||
@@ -115,8 +115,8 @@ function katexStart(src, displayMode: boolean) {
|
||||
}
|
||||
|
||||
function katexTokenizer(src, tokens, displayMode: boolean) {
|
||||
let ruleReg = displayMode ? blockRule : inlineRule;
|
||||
let type = displayMode ? 'blockKatex' : 'inlineKatex';
|
||||
const ruleReg = displayMode ? blockRule : inlineRule;
|
||||
const type = displayMode ? 'blockKatex' : 'inlineKatex';
|
||||
|
||||
const match = src.match(ruleReg);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user