MCPcopy Create free account
hub / github.com/dailydotdev/apps / getLinkReplacement

Function getLinkReplacement

packages/shared/src/lib/markdown.ts:98–112  ·  view source on GitHub ↗
(
  type,
  { word, url, selection: [start] },
)

Source from the content-addressed store, hash-verified

96};
97
98export const getLinkReplacement: GetReplacementFn = (
99 type,
100 { word, url, selection: [start] },
101) => {
102 const urlReplacement = url ?? urlText;
103 const replacement = getUrlText(word, urlReplacement);
104
105 if (type === CursorType.Isolated) {
106 const offset = start + 1;
107 return { replacement, offset: [offset, offset] };
108 }
109
110 const end = start + replacement.length - 1;
111 return { replacement, offset: [end - urlReplacement.length, end] };
112};
113
114export const getStyleReplacement = (wrapper: string): GetReplacementFn => {
115 return (type: CursorType, { word, selection: [start] }) => {

Callers 1

onLinkPasteCommandFunction · 0.90

Calls 1

getUrlTextFunction · 0.85

Tested by

no test coverage detected