mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: upsert tag based content (#816)
* feat: upsert tag based content * chore: update
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import { isNumber, last, toLower } from "lodash";
|
||||
import { isNumber, last, toLower, uniq } from "lodash";
|
||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { getMatchedNodes } from "../labs/marked";
|
||||
import { deleteMemoResource, upsertMemoResource } from "../helpers/api";
|
||||
import { TAB_SPACE_WIDTH, UNKNOWN_ID, VISIBILITY_SELECTOR_ITEMS } from "../helpers/consts";
|
||||
import { useEditorStore, useLocationStore, useMemoStore, useResourceStore, useTagStore, useUserStore } from "../store/module";
|
||||
@ -326,6 +327,13 @@ const MemoEditor = () => {
|
||||
toastHelper.error(error.response.data.message);
|
||||
}
|
||||
|
||||
// Upsert tag based with content.
|
||||
const matchedNodes = getMatchedNodes(content);
|
||||
const tagNameList = uniq(matchedNodes.filter((node) => node.parserName === "tag").map((node) => node.matchedContent.slice(1)));
|
||||
for (const tagName of tagNameList) {
|
||||
await tagStore.upsertTag(tagName);
|
||||
}
|
||||
|
||||
setState((state) => {
|
||||
return {
|
||||
...state,
|
||||
|
Reference in New Issue
Block a user