Skip to content

Commit

Permalink
fix(parser): mediaList now only includes png resouces
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenlx committed Aug 22, 2021
1 parent 8809f81 commit c7e242d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"author": "AidenLx",
"license": "MIT",
"devDependencies": {
"@alx-plugins/marginnote": "^1.7.3",
"@alx-plugins/marginnote": "^1.7.4",
"@release-it/bumper": "^3.0.1",
"@release-it/conventional-changelog": "^3.3.0",
"@rollup/plugin-commonjs": "^20.0.0",
Expand Down
8 changes: 5 additions & 3 deletions src/modules/parser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MbBook } from "@alx-plugins/marginnote";
import { excerptPic_video, MbBook } from "@alx-plugins/marginnote";

import PopupRecorder from "./PopupRecorder";
import { item, MNMark, node, ReturnBody, selection } from "./return";
Expand All @@ -24,15 +24,17 @@ const process = (node: node, rec: PopupRecorder, book?: MbBook): ReturnBody => {
} else {
const data = scanObject(node, 2);
const { last, sendTime } = getLastAndSendTime(data);
const videoId = (data.excerptPic as excerptPic_video)?.video;
const mediaList = [];
const mediaIds = node.mediaList?.split("-");
const mediaIds = node.mediaList?.split("-").filter((id) => id !== videoId);
if (mediaIds && mediaIds.length > 1) {
for (const id of mediaIds) {
if (!id) continue; // escape empty string
const mediaData = Database.sharedInstance()
.getMediaByHash(id)
?.base64Encoding();
if (mediaData && !mediaData.startsWith("W3sicGFn"))
// only export png, cannot find way to process stroke properly for now
if (mediaData && mediaData.startsWith("iVBORw0K"))
mediaList.push({ id, data: mediaData });
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const isMbBookNote = (obj: any): obj is MbBookNote => {
);
};

export const scanObject = (obj: any, depth = 1): any => {
export const scanObject = <T>(obj: T, depth = 1): T => {
const scan = (obj: any, dive?: boolean, accu: number = 0): any => {
if (typeof obj !== "undefined" && obj !== null) {
let out: any = {};
Expand Down

0 comments on commit c7e242d

Please sign in to comment.