mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 19:57:52 +01:00
common: make imports esm compatible
This commit is contained in:
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { describe, test } from "vitest";
|
||||
import { PathTree } from "../src/utils/path-tree";
|
||||
import { PathTree } from "../src/utils/path-tree.js";
|
||||
|
||||
test("adding duplicate path should make it unique", (t) => {
|
||||
const tree = new PathTree();
|
||||
|
||||
@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export * from "./resolved-item";
|
||||
export * from "./resolved-item.js";
|
||||
|
||||
@@ -21,7 +21,7 @@ import { ItemMap, ItemType } from "@notesnook/core";
|
||||
import {
|
||||
ResolvedItemOptions,
|
||||
useResolvedItem
|
||||
} from "../hooks/use-resolved-item";
|
||||
} from "../hooks/use-resolved-item.js";
|
||||
|
||||
type ResolvedItemProps<TItemType extends ItemType> =
|
||||
ResolvedItemOptions<TItemType> & {
|
||||
|
||||
@@ -17,6 +17,6 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import Database from "@notesnook/core/dist/api/index";
|
||||
import { Database } from "@notesnook/core";
|
||||
|
||||
export const database = new Database();
|
||||
|
||||
@@ -17,6 +17,6 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export * from "./use-time-ago";
|
||||
export * from "./use-promise";
|
||||
export * from "./use-resolved-item";
|
||||
export * from "./use-time-ago.js";
|
||||
export * from "./use-promise.js";
|
||||
export * from "./use-resolved-item.js";
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ItemMap, ItemType, VirtualizedGrouping } from "@notesnook/core";
|
||||
import { resolveItems } from "../utils/resolve-items";
|
||||
import { resolveItems } from "../utils/resolve-items.js";
|
||||
import { useDeferredValue, useEffect, useState, useTransition } from "react";
|
||||
|
||||
export type ResolvedItemOptions<TItemType extends ItemType> = {
|
||||
|
||||
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export * from "./database";
|
||||
export * from "./utils";
|
||||
export * from "./hooks";
|
||||
export * from "./components";
|
||||
export * from "./database.js";
|
||||
export * from "./utils/index.js";
|
||||
export * from "./hooks/index.js";
|
||||
export * from "./components/index.js";
|
||||
|
||||
20
packages/common/src/utils/dataurl.ts
Normal file
20
packages/common/src/utils/dataurl.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2023 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export { DataURL } from "@notesnook/core";
|
||||
@@ -17,14 +17,15 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { database } from "../database.js";
|
||||
import {
|
||||
FormatDateOptions,
|
||||
TimeFormat,
|
||||
formatReminderTime,
|
||||
HistorySession,
|
||||
Reminder,
|
||||
FormatDateOptions,
|
||||
formatDate
|
||||
} from "@notesnook/core/dist/utils/date";
|
||||
import { database } from "../database";
|
||||
import { formatReminderTime } from "@notesnook/core/dist/collections/reminders";
|
||||
import { HistorySession, Reminder } from "@notesnook/core/dist/types";
|
||||
} from "@notesnook/core";
|
||||
|
||||
export function getFormattedDate(
|
||||
date: string | number | Date,
|
||||
@@ -53,3 +54,5 @@ export function getFormattedHistorySessionDate(session: HistorySession) {
|
||||
fromDate !== toDate ? `${toDate}, ` : ""
|
||||
}${toTime}`;
|
||||
}
|
||||
|
||||
export { formatDate };
|
||||
@@ -17,17 +17,23 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Attachment, Note, parseInternalLink } from "@notesnook/core";
|
||||
import { FilteredSelector } from "@notesnook/core/dist/database/sql-collection";
|
||||
import { CHECK_IDS, checkIsUserPremium } from "@notesnook/core/dist/common";
|
||||
import { isImage, isWebClip } from "@notesnook/core/dist/utils/filename";
|
||||
import { sanitizeFilename } from "./file";
|
||||
import { database } from "../database";
|
||||
import {
|
||||
Attachment,
|
||||
Note,
|
||||
parseInternalLink,
|
||||
getContentFromData,
|
||||
ResolveInternalLink,
|
||||
isImage,
|
||||
isWebClip,
|
||||
CHECK_IDS,
|
||||
checkIsUserPremium,
|
||||
FilteredSelector,
|
||||
EMPTY_CONTENT
|
||||
} from "@notesnook/core";
|
||||
import { sanitizeFilename } from "./file.js";
|
||||
import { database } from "../database.js";
|
||||
import { join, relative } from "pathe";
|
||||
import { EMPTY_CONTENT } from "@notesnook/core/dist/collections/content";
|
||||
import { getContentFromData } from "@notesnook/core/dist/content-types";
|
||||
import { PathTree } from "./path-tree";
|
||||
import { ResolveInternalLink } from "@notesnook/core/dist/content-types/tiptap";
|
||||
import { PathTree } from "./path-tree.js";
|
||||
|
||||
const FORMAT_TO_EXT = {
|
||||
pdf: "pdf",
|
||||
|
||||
@@ -17,12 +17,13 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export * from "./file";
|
||||
export * from "./number";
|
||||
export * from "./time";
|
||||
export * from "./debounce";
|
||||
export * from "./random";
|
||||
export * from "./string";
|
||||
export * from "./resolve-items";
|
||||
export * from "./migrate-toolbar";
|
||||
export * from "./export-notes";
|
||||
export * from "./file.js";
|
||||
export * from "./number.js";
|
||||
export * from "./date-time.js";
|
||||
export * from "./debounce.js";
|
||||
export * from "./random.js";
|
||||
export * from "./string.js";
|
||||
export * from "./resolve-items.js";
|
||||
export * from "./migrate-toolbar.js";
|
||||
export * from "./export-notes.js";
|
||||
export * from "./dataurl.js";
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ToolbarConfig, ToolbarConfigPlatforms } from "@notesnook/core";
|
||||
import { database } from "../database";
|
||||
import { database } from "../database.js";
|
||||
|
||||
export const CURRENT_TOOLBAR_VERSION = 2;
|
||||
export async function migrateToolbar(
|
||||
|
||||
@@ -17,9 +17,15 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Color, Item, Reminder, Notebook, Tag } from "@notesnook/core";
|
||||
import { database as db } from "../database";
|
||||
import { getUpcomingReminder } from "@notesnook/core/dist/collections/reminders";
|
||||
import {
|
||||
Color,
|
||||
Item,
|
||||
Reminder,
|
||||
Notebook,
|
||||
Tag,
|
||||
getUpcomingReminder
|
||||
} from "@notesnook/core";
|
||||
import { database as db } from "../database.js";
|
||||
|
||||
type WithDateEdited<T> = { items: T[]; dateEdited: number };
|
||||
export type NotebooksWithDateEdited = WithDateEdited<Notebook>;
|
||||
|
||||
Reference in New Issue
Block a user