mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
fc01deeefd
* chore(deps-dev): bump oxlint-tsgolint from 0.14.2 to 0.22.1 Bumps [oxlint-tsgolint](https://github.com/oxc-project/tsgolint) from 0.14.2 to 0.22.1. - [Release notes](https://github.com/oxc-project/tsgolint/releases) - [Commits](https://github.com/oxc-project/tsgolint/compare/v0.14.2...v0.22.1) --- updated-dependencies: - dependency-name: oxlint-tsgolint dependency-version: 0.22.1 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * chore: Switch tsconfig to bundler resolution for tsgolint 0.22.1 oxlint-tsgolint 0.22.1 removed support for moduleResolution=node10 (the alias for "node"). Switch to "bundler" with resolvePackageJsonExports disabled so packages whose exports field omits a types condition still resolve. Update markdown-it type imports to sub-paths since the package's .d.mts entry only re-exports a subset of named types. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix: Resolve type-aware lint errors caught by tsgolint 0.22.1 oxlint-tsgolint 0.22.1 catches several await-thenable, no-floating-promises, and no-meaningless-void-operator cases the prior 0.14.2 missed: - Drop redundant inner `await` from Promise.all([await x, await y]) call sites so the array entries are real Promises rather than already-resolved values. - Replace Promise.all wrappers around synchronous presenters (presentEvent, presentTemplate, presentPublicTeam) with plain map / direct calls. - Wrap non-promise branches of ternaries inside Promise.all with Promise.resolve so the array remains thenable across both arms. - Add `void` to the unawaited provider.connect() in the auth-failed retry chain, and remove `void` from the disconnect() call which returns void. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tom Moor <tom@getoutline.com> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
78 lines
2.2 KiB
TypeScript
78 lines
2.2 KiB
TypeScript
import type MarkdownIt from "markdown-it";
|
|
import type StateInline from "markdown-it/lib/rules_inline/state_inline.mjs";
|
|
import { full as emojiPlugin } from "markdown-it-emoji";
|
|
import { isUUID } from "validator";
|
|
import { nameToEmoji } from "../lib/emoji";
|
|
|
|
type Options = {
|
|
emoji: boolean;
|
|
};
|
|
|
|
/**
|
|
* Custom markdown-it inline rule to parse UUID-based custom emojis in the format :uuid:
|
|
* This catches custom emoji UUID patterns that the standard emoji plugin doesn't recognize.
|
|
*
|
|
* @param state - The markdown-it state object for inline parsing.
|
|
* @param silent - When true, only checks if the rule matches without creating tokens.
|
|
* @returns True if the rule matched and processed content, false otherwise.
|
|
*/
|
|
function customEmojiRule(state: StateInline, silent: boolean) {
|
|
const start = state.pos;
|
|
const max = state.posMax;
|
|
|
|
// Must start with a colon
|
|
if (state.src.charCodeAt(start) !== 0x3a /* : */) {
|
|
return false;
|
|
}
|
|
|
|
// Find the closing colon
|
|
let pos = start + 1;
|
|
while (pos < max && state.src.charCodeAt(pos) !== 0x3a /* : */) {
|
|
pos++;
|
|
}
|
|
|
|
// No closing colon found
|
|
if (pos >= max) {
|
|
return false;
|
|
}
|
|
|
|
// Extract the content between colons
|
|
const content = state.src.slice(start + 1, pos);
|
|
|
|
// Check if it's a valid UUID (any version)
|
|
if (!isUUID(content)) {
|
|
return false;
|
|
}
|
|
|
|
// If we're in silent mode (checking if rule matches), just return true
|
|
if (!silent) {
|
|
const token = state.push("emoji", "", 0);
|
|
token.markup = content;
|
|
token.content = content;
|
|
}
|
|
|
|
state.pos = pos + 1;
|
|
return true;
|
|
}
|
|
|
|
export default function emoji(md: MarkdownIt) {
|
|
// Ideally this would be an empty object, but due to a bug in markdown-it-emoji
|
|
// passing an empty object results in newlines becoming emojis. Until this is
|
|
// fixed at least one key is required. See:
|
|
// https://github.com/markdown-it/markdown-it-emoji/issues/46
|
|
const noMapping = {
|
|
no_name_mapping: "💯",
|
|
};
|
|
|
|
// Add the custom emoji rule first so it can catch UUID patterns
|
|
md.inline.ruler.push("custom_emoji", customEmojiRule);
|
|
|
|
// Apply the standard emoji plugin to handle regular emoji names
|
|
emojiPlugin(md, {
|
|
defs: (md.options as Options).emoji === false ? noMapping : nameToEmoji,
|
|
shortcuts: {},
|
|
});
|
|
|
|
return md;
|
|
}
|