@dxos/plugin-markdown 0.7.5-main.9cb18ac → 0.7.5-main.9d2a38b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{MarkdownContainer-XY6NEUOA.mjs → MarkdownContainer-ARRY4I6S.mjs} +95 -46
- package/dist/lib/browser/MarkdownContainer-ARRY4I6S.mjs.map +7 -0
- package/dist/lib/browser/app-graph-serializer-HHWSLYIW.mjs +51 -0
- package/dist/lib/browser/app-graph-serializer-HHWSLYIW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-R4MG2DP2.mjs → chunk-ADAYSA5G.mjs} +20 -9
- package/dist/lib/browser/chunk-ADAYSA5G.mjs.map +7 -0
- package/dist/lib/browser/{chunk-6FIHBJRV.mjs → chunk-EMIIXXVX.mjs} +17 -12
- package/dist/lib/browser/chunk-EMIIXXVX.mjs.map +7 -0
- package/dist/lib/browser/chunk-FSAYVXSE.mjs +16 -0
- package/dist/lib/browser/chunk-FSAYVXSE.mjs.map +7 -0
- package/dist/lib/browser/{chunk-4X6YX3KU.mjs → chunk-YB2TJFNH.mjs} +3 -3
- package/dist/lib/browser/chunk-YB2TJFNH.mjs.map +7 -0
- package/dist/lib/browser/chunk-YPDWX3WI.mjs +47 -0
- package/dist/lib/browser/chunk-YPDWX3WI.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +100 -367
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-4KWMUMND.mjs +37 -0
- package/dist/lib/browser/intent-resolver-4KWMUMND.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-RL4CISJZ.mjs +152 -0
- package/dist/lib/browser/react-surface-RL4CISJZ.mjs.map +7 -0
- package/dist/lib/browser/settings-PTF73JDL.mjs +28 -0
- package/dist/lib/browser/settings-PTF73JDL.mjs.map +7 -0
- package/dist/lib/browser/state-DOVZP7XJ.mjs +37 -0
- package/dist/lib/browser/state-DOVZP7XJ.mjs.map +7 -0
- package/dist/lib/browser/thread-G4RS7NBZ.mjs +36 -0
- package/dist/lib/browser/thread-G4RS7NBZ.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -4
- package/dist/lib/node/{MarkdownContainer-EX6YDF6J.cjs → MarkdownContainer-TV6W64EN.cjs} +100 -53
- package/dist/lib/node/MarkdownContainer-TV6W64EN.cjs.map +7 -0
- package/dist/lib/node/app-graph-serializer-PJRST43Q.cjs +62 -0
- package/dist/lib/node/app-graph-serializer-PJRST43Q.cjs.map +7 -0
- package/dist/lib/node/{chunk-CQMXZ54Z.cjs → chunk-34WFGSZU.cjs} +21 -16
- package/dist/lib/node/chunk-34WFGSZU.cjs.map +7 -0
- package/dist/lib/node/chunk-7WZANRNS.cjs +64 -0
- package/dist/lib/node/chunk-7WZANRNS.cjs.map +7 -0
- package/dist/lib/node/{meta.cjs → chunk-G7WKHUGU.cjs} +13 -8
- package/dist/lib/node/chunk-G7WKHUGU.cjs.map +7 -0
- package/dist/lib/node/{chunk-PHHIPRJC.cjs → chunk-HTWAAR54.cjs} +7 -7
- package/dist/lib/node/chunk-HTWAAR54.cjs.map +7 -0
- package/dist/lib/node/{chunk-SXQAPZZU.cjs → chunk-UFFFUC6W.cjs} +37 -12
- package/dist/lib/node/chunk-UFFFUC6W.cjs.map +7 -0
- package/dist/lib/node/index.cjs +92 -366
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-QN25AFOP.cjs +50 -0
- package/dist/lib/node/intent-resolver-QN25AFOP.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-surface-RZ2XV56V.cjs +165 -0
- package/dist/lib/node/react-surface-RZ2XV56V.cjs.map +7 -0
- package/dist/lib/node/settings-BO5P5R4I.cjs +42 -0
- package/dist/lib/node/settings-BO5P5R4I.cjs.map +7 -0
- package/dist/lib/node/state-F26NQP7F.cjs +51 -0
- package/dist/lib/node/state-F26NQP7F.cjs.map +7 -0
- package/dist/lib/node/thread-THWQ67WS.cjs +52 -0
- package/dist/lib/node/thread-THWQ67WS.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +7 -7
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{MarkdownContainer-E7W623A7.mjs → MarkdownContainer-3ZHQTTMQ.mjs} +95 -46
- package/dist/lib/node-esm/MarkdownContainer-3ZHQTTMQ.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-serializer-JTHJUUS2.mjs +52 -0
- package/dist/lib/node-esm/app-graph-serializer-JTHJUUS2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-2GHK262V.mjs +17 -0
- package/dist/lib/node-esm/chunk-2GHK262V.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-BABK7FMW.mjs → chunk-AOKWCL3O.mjs} +3 -3
- package/dist/lib/node-esm/chunk-AOKWCL3O.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ZVFBKBSA.mjs → chunk-CDFNMFGT.mjs} +17 -12
- package/dist/lib/node-esm/chunk-CDFNMFGT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HLP536EW.mjs +48 -0
- package/dist/lib/node-esm/chunk-HLP536EW.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-Y76MM22C.mjs → chunk-Y5RSQVGH.mjs} +20 -9
- package/dist/lib/node-esm/chunk-Y5RSQVGH.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +100 -367
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-F7MQOTG7.mjs +38 -0
- package/dist/lib/node-esm/intent-resolver-F7MQOTG7.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-RRXHEW4R.mjs +153 -0
- package/dist/lib/node-esm/react-surface-RRXHEW4R.mjs.map +7 -0
- package/dist/lib/node-esm/settings-E7P5FQ3F.mjs +29 -0
- package/dist/lib/node-esm/settings-E7P5FQ3F.mjs.map +7 -0
- package/dist/lib/node-esm/state-HXSOQNOV.mjs +38 -0
- package/dist/lib/node-esm/state-HXSOQNOV.mjs.map +7 -0
- package/dist/lib/node-esm/thread-CYEXBXTW.mjs +37 -0
- package/dist/lib/node-esm/thread-CYEXBXTW.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +4 -4
- package/dist/types/src/MarkdownPlugin.d.ts +1 -3
- package/dist/types/src/MarkdownPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-serializer.d.ts +4 -0
- package/dist/types/src/capabilities/app-graph-serializer.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +12 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +16 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +4 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/capabilities/state.d.ts +11 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/thread.d.ts +6 -0
- package/dist/types/src/capabilities/thread.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownContainer.d.ts +1 -1
- package/dist/types/src/components/MarkdownContainer.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownEditor.d.ts +15 -0
- package/dist/types/src/components/MarkdownEditor.d.ts.map +1 -1
- package/dist/types/src/components/MarkdownEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar.stories.d.ts +2 -2
- package/dist/types/src/components/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/extensions.d.ts +2 -2
- package/dist/types/src/extensions.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +0 -7
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +12 -26
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +1 -5
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +32 -37
- package/src/MarkdownPlugin.tsx +79 -213
- package/src/capabilities/app-graph-serializer.ts +50 -0
- package/src/capabilities/capabilities.ts +20 -0
- package/src/capabilities/index.ts +14 -0
- package/src/capabilities/intent-resolver.ts +27 -0
- package/src/capabilities/react-surface.tsx +73 -0
- package/src/capabilities/settings.ts +25 -0
- package/src/capabilities/state.ts +31 -0
- package/src/capabilities/thread.ts +34 -0
- package/src/components/MarkdownContainer.tsx +6 -7
- package/src/components/MarkdownEditor.stories.tsx +16 -5
- package/src/components/MarkdownEditor.tsx +82 -48
- package/src/components/Toolbar.stories.tsx +16 -22
- package/src/extensions.tsx +13 -10
- package/src/index.ts +2 -5
- package/src/meta.ts +1 -1
- package/src/translations.ts +1 -0
- package/src/types/schema.ts +1 -5
- package/src/types/types.ts +16 -44
- package/src/util.tsx +2 -8
- package/dist/lib/browser/MarkdownContainer-XY6NEUOA.mjs.map +0 -7
- package/dist/lib/browser/chunk-4X6YX3KU.mjs.map +0 -7
- package/dist/lib/browser/chunk-6FIHBJRV.mjs.map +0 -7
- package/dist/lib/browser/chunk-R4MG2DP2.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/lib/node/MarkdownContainer-EX6YDF6J.cjs.map +0 -7
- package/dist/lib/node/chunk-CQMXZ54Z.cjs.map +0 -7
- package/dist/lib/node/chunk-PHHIPRJC.cjs.map +0 -7
- package/dist/lib/node/chunk-SXQAPZZU.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node-esm/MarkdownContainer-E7W623A7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BABK7FMW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y76MM22C.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZVFBKBSA.mjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
DocumentType
|
|
4
|
-
|
|
5
|
-
} from "./chunk-ZVFBKBSA.mjs";
|
|
3
|
+
DocumentType
|
|
4
|
+
} from "./chunk-CDFNMFGT.mjs";
|
|
6
5
|
|
|
7
6
|
// packages/plugins/plugin-markdown/src/util.tsx
|
|
8
7
|
import { debounce } from "@dxos/async";
|
|
9
8
|
import { create, createObject, isEchoObject, loadObjectReferences, makeRef } from "@dxos/react-client/echo";
|
|
9
|
+
import { TextType } from "@dxos/schema";
|
|
10
10
|
var isMarkdownProperties = (data) => isEchoObject(data) ? true : data && typeof data === "object" ? "title" in data && typeof data.title === "string" : false;
|
|
11
|
-
var markdownExtensionPlugins = (plugins) => {
|
|
12
|
-
return plugins.filter((plugin) => Boolean(plugin.provides?.markdown));
|
|
13
|
-
};
|
|
14
11
|
var nonTitleChars = /[^\w ]/g;
|
|
15
12
|
var getFallbackName = (content) => {
|
|
16
13
|
return content.substring(0, 31).split("\n")[0].replaceAll(nonTitleChars, "").trim();
|
|
@@ -43,11 +40,25 @@ var serializer = {
|
|
|
43
40
|
}
|
|
44
41
|
};
|
|
45
42
|
|
|
43
|
+
// packages/plugins/plugin-markdown/src/capabilities/index.ts
|
|
44
|
+
import { lazy } from "@dxos/app-framework";
|
|
45
|
+
var AppGraphSerializer = lazy(() => import("./app-graph-serializer-JTHJUUS2.mjs"));
|
|
46
|
+
var IntentResolver = lazy(() => import("./intent-resolver-F7MQOTG7.mjs"));
|
|
47
|
+
var ReactSurface = lazy(() => import("./react-surface-RRXHEW4R.mjs"));
|
|
48
|
+
var MarkdownSettings = lazy(() => import("./settings-E7P5FQ3F.mjs"));
|
|
49
|
+
var MarkdownState = lazy(() => import("./state-HXSOQNOV.mjs"));
|
|
50
|
+
var Thread = lazy(() => import("./thread-CYEXBXTW.mjs"));
|
|
51
|
+
|
|
46
52
|
export {
|
|
47
53
|
isMarkdownProperties,
|
|
48
|
-
markdownExtensionPlugins,
|
|
49
54
|
getFallbackName,
|
|
50
55
|
setFallbackName,
|
|
51
|
-
serializer
|
|
56
|
+
serializer,
|
|
57
|
+
AppGraphSerializer,
|
|
58
|
+
IntentResolver,
|
|
59
|
+
ReactSurface,
|
|
60
|
+
MarkdownSettings,
|
|
61
|
+
MarkdownState,
|
|
62
|
+
Thread
|
|
52
63
|
};
|
|
53
|
-
//# sourceMappingURL=chunk-
|
|
64
|
+
//# sourceMappingURL=chunk-Y5RSQVGH.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/util.tsx", "../../../src/capabilities/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { debounce } from '@dxos/async';\nimport { type TypedObjectSerializer } from '@dxos/plugin-space/types';\nimport { create, createObject, isEchoObject, loadObjectReferences, makeRef } from '@dxos/react-client/echo';\nimport { TextType } from '@dxos/schema';\n\nimport { DocumentType, type MarkdownProperties } from './types';\n\nexport const isMarkdownProperties = (data: unknown): data is MarkdownProperties =>\n isEchoObject(data)\n ? true\n : data && typeof data === 'object'\n ? 'title' in data && typeof data.title === 'string'\n : false;\n\nconst nonTitleChars = /[^\\w ]/g;\n\nexport const getFallbackName = (content: string) => {\n return content.substring(0, 31).split('\\n')[0].replaceAll(nonTitleChars, '').trim();\n};\n\nexport const setFallbackName = debounce((doc: DocumentType, content: string) => {\n const name = getFallbackName(content);\n if (doc.fallbackName !== name) {\n doc.fallbackName = name;\n }\n}, 200);\n\nexport const serializer: TypedObjectSerializer<DocumentType> = {\n serialize: async ({ object }): Promise<string> => {\n const content = await loadObjectReferences(object, (doc) => doc.content);\n return JSON.stringify({ name: object.name, fallbackName: object.fallbackName, content: content.target?.content });\n },\n\n deserialize: async ({ content: serialized }) => {\n const { name, fallbackName, content } = JSON.parse(serialized);\n return createObject(\n create(DocumentType, { name, fallbackName, content: makeRef(create(TextType, { content })), threads: [] }),\n );\n },\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { lazy } from '@dxos/app-framework';\n\nexport const AppGraphSerializer = lazy(() => import('./app-graph-serializer'));\nexport const IntentResolver = lazy(() => import('./intent-resolver'));\nexport const ReactSurface = lazy(() => import('./react-surface'));\nexport const MarkdownSettings = lazy(() => import('./settings'));\nexport const MarkdownState = lazy(() => import('./state'));\nexport const Thread = lazy(() => import('./thread'));\n\nexport * from './capabilities';\n"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,SAASA,gBAAgB;AAEzB,SAASC,QAAQC,cAAcC,cAAcC,sBAAsBC,eAAe;AAClF,SAASC,gBAAgB;AAIlB,IAAMC,uBAAuB,CAACC,SACnCC,aAAaD,IAAAA,IACT,OACAA,QAAQ,OAAOA,SAAS,WACtB,WAAWA,QAAQ,OAAOA,KAAKE,UAAU,WACzC;AAER,IAAMC,gBAAgB;AAEf,IAAMC,kBAAkB,CAACC,YAAAA;AAC9B,SAAOA,QAAQC,UAAU,GAAG,EAAA,EAAIC,MAAM,IAAA,EAAM,CAAA,EAAGC,WAAWL,eAAe,EAAA,EAAIM,KAAI;AACnF;AAEO,IAAMC,kBAAkBC,SAAS,CAACC,KAAmBP,YAAAA;AAC1D,QAAMQ,OAAOT,gBAAgBC,OAAAA;AAC7B,MAAIO,IAAIE,iBAAiBD,MAAM;AAC7BD,QAAIE,eAAeD;EACrB;AACF,GAAG,GAAA;AAEI,IAAME,aAAkD;EAC7DC,WAAW,OAAO,EAAEC,OAAM,MAAE;AAC1B,UAAMZ,UAAU,MAAMa,qBAAqBD,QAAQ,CAACL,QAAQA,IAAIP,OAAO;AACvE,WAAOc,KAAKC,UAAU;MAAEP,MAAMI,OAAOJ;MAAMC,cAAcG,OAAOH;MAAcT,SAASA,QAAQgB,QAAQhB;IAAQ,CAAA;EACjH;EAEAiB,aAAa,OAAO,EAAEjB,SAASkB,WAAU,MAAE;AACzC,UAAM,EAAEV,MAAMC,cAAcT,QAAO,IAAKc,KAAKK,MAAMD,UAAAA;AACnD,WAAOE,aACLC,OAAOC,cAAc;MAAEd;MAAMC;MAAcT,SAASuB,QAAQF,OAAOG,UAAU;QAAExB;MAAQ,CAAA,CAAA;MAAKyB,SAAS,CAAA;IAAG,CAAA,CAAA;EAE5G;AACF;;;ACvCA,SAASC,YAAY;AAEd,IAAMC,qBAAqBC,KAAK,MAAM,OAAO,qCAAA,CAAA;AAC7C,IAAMC,iBAAiBD,KAAK,MAAM,OAAO,gCAAA,CAAA;AACzC,IAAME,eAAeF,KAAK,MAAM,OAAO,8BAAA,CAAA;AACvC,IAAMG,mBAAmBH,KAAK,MAAM,OAAO,yBAAA,CAAA;AAC3C,IAAMI,gBAAgBJ,KAAK,MAAM,OAAO,sBAAA,CAAA;AACxC,IAAMK,SAASL,KAAK,MAAM,OAAO,uBAAA,CAAA;",
|
|
6
|
+
"names": ["debounce", "create", "createObject", "isEchoObject", "loadObjectReferences", "makeRef", "TextType", "isMarkdownProperties", "data", "isEchoObject", "title", "nonTitleChars", "getFallbackName", "content", "substring", "split", "replaceAll", "trim", "setFallbackName", "debounce", "doc", "name", "fallbackName", "serializer", "serialize", "object", "loadObjectReferences", "JSON", "stringify", "target", "deserialize", "serialized", "parse", "createObject", "create", "DocumentType", "makeRef", "TextType", "threads", "lazy", "AppGraphSerializer", "lazy", "IntentResolver", "ReactSurface", "MarkdownSettings", "MarkdownState", "Thread"]
|
|
7
|
+
}
|
|
@@ -1,390 +1,123 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
+
translations_default
|
|
4
|
+
} from "./chunk-HLP536EW.mjs";
|
|
5
|
+
import {
|
|
6
|
+
AppGraphSerializer,
|
|
7
|
+
IntentResolver,
|
|
8
|
+
MarkdownSettings,
|
|
9
|
+
MarkdownState,
|
|
10
|
+
ReactSurface,
|
|
11
|
+
Thread,
|
|
3
12
|
getFallbackName,
|
|
4
13
|
isMarkdownProperties,
|
|
5
|
-
markdownExtensionPlugins,
|
|
6
14
|
serializer,
|
|
7
15
|
setFallbackName
|
|
8
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-Y5RSQVGH.mjs";
|
|
9
17
|
import {
|
|
10
18
|
DocumentType,
|
|
11
|
-
MarkdownAction
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
MarkdownAction
|
|
20
|
+
} from "./chunk-CDFNMFGT.mjs";
|
|
21
|
+
import {
|
|
22
|
+
MarkdownCapabilities
|
|
23
|
+
} from "./chunk-2GHK262V.mjs";
|
|
15
24
|
import {
|
|
16
25
|
MARKDOWN_PLUGIN,
|
|
17
|
-
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
|
|
20
|
-
// packages/plugins/plugin-markdown/src/MarkdownPlugin.tsx
|
|
21
|
-
import { pipe } from "effect";
|
|
22
|
-
import React2 from "react";
|
|
23
|
-
import { parseIntentPlugin, resolvePlugin, createSurface, createResolver, createIntent, chain } from "@dxos/app-framework";
|
|
24
|
-
import { create, makeRef, RefArray } from "@dxos/live-object";
|
|
25
|
-
import { LocalStorageStore } from "@dxos/local-storage";
|
|
26
|
-
import { SpaceAction } from "@dxos/plugin-space";
|
|
27
|
-
import { CollectionType } from "@dxos/plugin-space/types";
|
|
28
|
-
import { createDocAccessor, fullyQualifiedId, getRangeFromCursor, isSpace } from "@dxos/react-client/echo";
|
|
29
|
-
import { translations as editorTranslations, createEditorStateStore } from "@dxos/react-ui-editor";
|
|
30
|
-
|
|
31
|
-
// packages/plugins/plugin-markdown/src/components/index.ts
|
|
32
|
-
import { lazy } from "react";
|
|
33
|
-
|
|
34
|
-
// packages/plugins/plugin-markdown/src/components/MarkdownSettings.tsx
|
|
35
|
-
import React from "react";
|
|
36
|
-
import { Input, Select, useTranslation } from "@dxos/react-ui";
|
|
37
|
-
import { EditorInputModes, EditorViewModes } from "@dxos/react-ui-editor";
|
|
38
|
-
import { DeprecatedFormInput } from "@dxos/react-ui-form";
|
|
39
|
-
var MarkdownSettings = ({ settings }) => {
|
|
40
|
-
const { t } = useTranslation(MARKDOWN_PLUGIN);
|
|
41
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DeprecatedFormInput, {
|
|
42
|
-
label: t("default view mode label")
|
|
43
|
-
}, /* @__PURE__ */ React.createElement(Select.Root, {
|
|
44
|
-
value: settings.defaultViewMode,
|
|
45
|
-
onValueChange: (value) => {
|
|
46
|
-
settings.defaultViewMode = value;
|
|
47
|
-
}
|
|
48
|
-
}, /* @__PURE__ */ React.createElement(Select.TriggerButton, null), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, EditorViewModes.map((mode) => /* @__PURE__ */ React.createElement(Select.Option, {
|
|
49
|
-
key: mode,
|
|
50
|
-
value: mode
|
|
51
|
-
}, t(`${mode} mode label`, {
|
|
52
|
-
ns: "react-ui-editor"
|
|
53
|
-
})))))))), /* @__PURE__ */ React.createElement(DeprecatedFormInput, {
|
|
54
|
-
label: t("editor input mode label")
|
|
55
|
-
}, /* @__PURE__ */ React.createElement(Select.Root, {
|
|
56
|
-
value: settings.editorInputMode ?? "default",
|
|
57
|
-
onValueChange: (value) => {
|
|
58
|
-
settings.editorInputMode = value;
|
|
59
|
-
}
|
|
60
|
-
}, /* @__PURE__ */ React.createElement(Select.TriggerButton, {
|
|
61
|
-
placeholder: t("select editor input mode placeholder")
|
|
62
|
-
}), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, EditorInputModes.map((mode) => /* @__PURE__ */ React.createElement(Select.Option, {
|
|
63
|
-
key: mode,
|
|
64
|
-
value: mode
|
|
65
|
-
}, t(`settings editor input mode ${mode} label`)))))))), /* @__PURE__ */ React.createElement(DeprecatedFormInput, {
|
|
66
|
-
label: t("settings toolbar label")
|
|
67
|
-
}, /* @__PURE__ */ React.createElement(Input.Switch, {
|
|
68
|
-
checked: settings.toolbar,
|
|
69
|
-
onCheckedChange: (checked) => settings.toolbar = !!checked
|
|
70
|
-
})), /* @__PURE__ */ React.createElement(DeprecatedFormInput, {
|
|
71
|
-
label: t("settings numbered headings label")
|
|
72
|
-
}, /* @__PURE__ */ React.createElement(Input.Switch, {
|
|
73
|
-
checked: settings.numberedHeadings,
|
|
74
|
-
onCheckedChange: (checked) => settings.numberedHeadings = !!checked
|
|
75
|
-
})), /* @__PURE__ */ React.createElement(DeprecatedFormInput, {
|
|
76
|
-
label: t("settings folding label")
|
|
77
|
-
}, /* @__PURE__ */ React.createElement(Input.Switch, {
|
|
78
|
-
checked: settings.folding,
|
|
79
|
-
onCheckedChange: (checked) => settings.folding = !!checked
|
|
80
|
-
})), /* @__PURE__ */ React.createElement(DeprecatedFormInput, {
|
|
81
|
-
label: t("settings experimental label")
|
|
82
|
-
}, /* @__PURE__ */ React.createElement(Input.Switch, {
|
|
83
|
-
checked: settings.experimental,
|
|
84
|
-
onCheckedChange: (checked) => settings.experimental = !!checked
|
|
85
|
-
})), /* @__PURE__ */ React.createElement(DeprecatedFormInput, {
|
|
86
|
-
label: t("settings debug label"),
|
|
87
|
-
secondary: settings.debug ? /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.TextArea, {
|
|
88
|
-
rows: 5,
|
|
89
|
-
value: settings.typewriter,
|
|
90
|
-
onChange: ({ target: { value } }) => settings.typewriter = value,
|
|
91
|
-
placeholder: t("settings debug placeholder")
|
|
92
|
-
})) : void 0
|
|
93
|
-
}, /* @__PURE__ */ React.createElement(Input.Switch, {
|
|
94
|
-
checked: settings.debug,
|
|
95
|
-
onCheckedChange: (checked) => settings.debug = !!checked
|
|
96
|
-
})));
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// packages/plugins/plugin-markdown/src/components/index.ts
|
|
100
|
-
var MarkdownContainer = lazy(() => import("./MarkdownContainer-E7W623A7.mjs"));
|
|
101
|
-
|
|
102
|
-
// packages/plugins/plugin-markdown/src/translations.ts
|
|
103
|
-
var translations_default = [
|
|
104
|
-
{
|
|
105
|
-
"en-US": {
|
|
106
|
-
[DocumentType.typename]: {
|
|
107
|
-
"typename label": "Document"
|
|
108
|
-
},
|
|
109
|
-
[MARKDOWN_PLUGIN]: {
|
|
110
|
-
"plugin name": "Editor",
|
|
111
|
-
"create stack section label": "Create document",
|
|
112
|
-
"document title placeholder": "New document",
|
|
113
|
-
"choose markdown from space dialog title": "Choose one or more documents to add",
|
|
114
|
-
// TODO(burdon): Style-guide for user-facing text (e.g., hints, questions, capitalization, etc.)
|
|
115
|
-
"empty choose markdown from space message": "None available; try creating a new one instead?",
|
|
116
|
-
"chooser done label": "Add selected",
|
|
117
|
-
"create document label": "Create document",
|
|
118
|
-
"editor placeholder": "",
|
|
119
|
-
"editor input mode label": "Editor input mode",
|
|
120
|
-
"select editor input mode placeholder": "Select editor input mode\u2026",
|
|
121
|
-
"settings editor input mode default label": "Default",
|
|
122
|
-
"settings editor input mode vim label": "Vim",
|
|
123
|
-
"settings editor input mode vscode label": "VS Code",
|
|
124
|
-
"settings toolbar label": "Show toolbar",
|
|
125
|
-
"settings numbered headings label": "Numbered headings",
|
|
126
|
-
"settings folding label": "Folding",
|
|
127
|
-
"settings experimental label": "Enable experimental features",
|
|
128
|
-
"settings debug label": "Enable debugging features",
|
|
129
|
-
"settings debug placeholder": "Typewriter script...",
|
|
130
|
-
"toggle view mode label": "Toggle read-only",
|
|
131
|
-
"default view mode label": "Default view mode"
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
];
|
|
26
|
+
meta
|
|
27
|
+
} from "./chunk-AOKWCL3O.mjs";
|
|
136
28
|
|
|
137
29
|
// packages/plugins/plugin-markdown/src/MarkdownPlugin.tsx
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
allowUndefined: true
|
|
168
|
-
})
|
|
169
|
-
}).prop({
|
|
170
|
-
key: "experimental",
|
|
171
|
-
type: LocalStorageStore.bool({
|
|
172
|
-
allowUndefined: true
|
|
173
|
-
})
|
|
174
|
-
}).prop({
|
|
175
|
-
key: "debug",
|
|
176
|
-
type: LocalStorageStore.bool({
|
|
177
|
-
allowUndefined: true
|
|
178
|
-
})
|
|
179
|
-
}).prop({
|
|
180
|
-
key: "typewriter",
|
|
181
|
-
type: LocalStorageStore.string({
|
|
182
|
-
allowUndefined: true
|
|
183
|
-
})
|
|
184
|
-
}).prop({
|
|
185
|
-
key: "numberedHeadings",
|
|
186
|
-
type: LocalStorageStore.bool({
|
|
187
|
-
allowUndefined: true
|
|
188
|
-
})
|
|
189
|
-
}).prop({
|
|
190
|
-
key: "folding",
|
|
191
|
-
type: LocalStorageStore.bool({
|
|
192
|
-
allowUndefined: true
|
|
193
|
-
})
|
|
194
|
-
});
|
|
195
|
-
state.prop({
|
|
196
|
-
key: "viewMode",
|
|
197
|
-
type: LocalStorageStore.json()
|
|
198
|
-
});
|
|
199
|
-
markdownExtensionPlugins(plugins).forEach((plugin) => {
|
|
200
|
-
const { extensions } = plugin.provides.markdown;
|
|
201
|
-
state.values.extensionProviders?.push(extensions);
|
|
202
|
-
});
|
|
203
|
-
},
|
|
204
|
-
provides: {
|
|
205
|
-
settings: settings.values,
|
|
30
|
+
import { Capabilities, contributes, createIntent, defineModule, definePlugin, Events, oneOf } from "@dxos/app-framework";
|
|
31
|
+
import { RefArray } from "@dxos/live-object";
|
|
32
|
+
import { ClientCapabilities, ClientEvents } from "@dxos/plugin-client";
|
|
33
|
+
import { translations as editorTranslations } from "@dxos/react-ui-editor";
|
|
34
|
+
import { TextType } from "@dxos/schema";
|
|
35
|
+
var MarkdownPlugin = () => definePlugin(meta, [
|
|
36
|
+
defineModule({
|
|
37
|
+
id: `${meta.id}/module/settings`,
|
|
38
|
+
activatesOn: Events.SetupSettings,
|
|
39
|
+
activate: MarkdownSettings
|
|
40
|
+
}),
|
|
41
|
+
defineModule({
|
|
42
|
+
id: `${meta.id}/module/state`,
|
|
43
|
+
activatesOn: Events.Startup,
|
|
44
|
+
activate: MarkdownState
|
|
45
|
+
}),
|
|
46
|
+
defineModule({
|
|
47
|
+
id: `${meta.id}/module/translations`,
|
|
48
|
+
activatesOn: Events.SetupTranslations,
|
|
49
|
+
activate: () => contributes(Capabilities.Translations, [
|
|
50
|
+
...translations_default,
|
|
51
|
+
...editorTranslations
|
|
52
|
+
])
|
|
53
|
+
}),
|
|
54
|
+
defineModule({
|
|
55
|
+
id: `${meta.id}/module/metadata`,
|
|
56
|
+
activatesOn: oneOf(Events.Startup, Events.SetupAppGraph),
|
|
57
|
+
activate: () => contributes(Capabilities.Metadata, {
|
|
58
|
+
id: DocumentType.typename,
|
|
206
59
|
metadata: {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
{
|
|
214
|
-
ns: MARKDOWN_PLUGIN
|
|
215
|
-
}
|
|
216
|
-
],
|
|
217
|
-
icon: "ph--text-aa--regular",
|
|
218
|
-
graphProps: {
|
|
219
|
-
managesAutofocus: true
|
|
220
|
-
},
|
|
221
|
-
// TODO(wittjosiah): Move out of metadata.
|
|
222
|
-
loadReferences: async (doc) => await RefArray.loadAll([
|
|
223
|
-
doc.content,
|
|
224
|
-
...doc.threads
|
|
225
|
-
]),
|
|
226
|
-
serializer
|
|
60
|
+
createObject: (props) => createIntent(MarkdownAction.Create, props),
|
|
61
|
+
label: (object) => object instanceof DocumentType ? object.name || object.fallbackName : void 0,
|
|
62
|
+
placeholder: [
|
|
63
|
+
"document title placeholder",
|
|
64
|
+
{
|
|
65
|
+
ns: MARKDOWN_PLUGIN
|
|
227
66
|
}
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
translations: [
|
|
231
|
-
...translations_default,
|
|
232
|
-
...editorTranslations
|
|
233
|
-
],
|
|
234
|
-
echo: {
|
|
235
|
-
schema: [
|
|
236
|
-
DocumentType
|
|
237
67
|
],
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
return [
|
|
249
|
-
{
|
|
250
|
-
inputType: DocumentType.typename,
|
|
251
|
-
outputType: "text/markdown",
|
|
252
|
-
// Reconcile with metadata serializers.
|
|
253
|
-
serialize: async (node) => {
|
|
254
|
-
const doc = node.data;
|
|
255
|
-
const content = await doc.content.load();
|
|
256
|
-
return {
|
|
257
|
-
name: doc.name || doc.fallbackName || translations_default[0]["en-US"][MARKDOWN_PLUGIN]["document title placeholder"],
|
|
258
|
-
data: content.content,
|
|
259
|
-
type: "text/markdown"
|
|
260
|
-
};
|
|
261
|
-
},
|
|
262
|
-
deserialize: async (data, ancestors) => {
|
|
263
|
-
const space = ancestors.find(isSpace);
|
|
264
|
-
const target = ancestors.findLast((ancestor) => ancestor instanceof CollectionType) ?? space?.properties[CollectionType.typename]?.target;
|
|
265
|
-
if (!space || !target) {
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
const result = await dispatch(pipe(createIntent(MarkdownAction.Create, {
|
|
269
|
-
name: data.name,
|
|
270
|
-
content: data.data
|
|
271
|
-
}), chain(SpaceAction.AddObject, {
|
|
272
|
-
target
|
|
273
|
-
})));
|
|
274
|
-
return result.data?.object;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
];
|
|
278
|
-
}
|
|
279
|
-
},
|
|
280
|
-
thread: {
|
|
281
|
-
predicate: (obj) => obj instanceof DocumentType,
|
|
282
|
-
createSort: (doc) => {
|
|
283
|
-
const accessor = doc.content.target ? createDocAccessor(doc.content.target, [
|
|
284
|
-
"content"
|
|
285
|
-
]) : void 0;
|
|
286
|
-
if (!accessor) {
|
|
287
|
-
return (_) => 0;
|
|
288
|
-
}
|
|
289
|
-
const getStartPosition = (cursor) => {
|
|
290
|
-
const range = cursor ? getRangeFromCursor(accessor, cursor) : void 0;
|
|
291
|
-
return range?.start ?? Number.MAX_SAFE_INTEGER;
|
|
292
|
-
};
|
|
293
|
-
return (anchorA, anchorB) => {
|
|
294
|
-
if (anchorA === void 0 || anchorB === void 0) {
|
|
295
|
-
return 0;
|
|
296
|
-
}
|
|
297
|
-
const posA = getStartPosition(anchorA);
|
|
298
|
-
const posB = getStartPosition(anchorB);
|
|
299
|
-
return posA - posB;
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
},
|
|
303
|
-
surface: {
|
|
304
|
-
definitions: () => [
|
|
305
|
-
createSurface({
|
|
306
|
-
id: `${MARKDOWN_PLUGIN}/document`,
|
|
307
|
-
role: [
|
|
308
|
-
"article",
|
|
309
|
-
"section"
|
|
310
|
-
],
|
|
311
|
-
filter: (data) => data.subject instanceof DocumentType,
|
|
312
|
-
component: ({ data, role }) => /* @__PURE__ */ React2.createElement(MarkdownContainer, {
|
|
313
|
-
id: fullyQualifiedId(data.subject),
|
|
314
|
-
object: data.subject,
|
|
315
|
-
role,
|
|
316
|
-
settings: settings.values,
|
|
317
|
-
extensionProviders: state.values.extensionProviders,
|
|
318
|
-
viewMode: getViewMode(fullyQualifiedId(data.subject)),
|
|
319
|
-
editorStateStore,
|
|
320
|
-
onViewModeChange: setViewMode
|
|
321
|
-
})
|
|
322
|
-
}),
|
|
323
|
-
createSurface({
|
|
324
|
-
id: `${MARKDOWN_PLUGIN}/editor`,
|
|
325
|
-
role: [
|
|
326
|
-
"article",
|
|
327
|
-
"section"
|
|
328
|
-
],
|
|
329
|
-
filter: (data) => isEditorModel(data.subject),
|
|
330
|
-
component: ({ data, role }) => /* @__PURE__ */ React2.createElement(MarkdownContainer, {
|
|
331
|
-
id: data.subject.id,
|
|
332
|
-
object: data.subject,
|
|
333
|
-
role,
|
|
334
|
-
settings: settings.values,
|
|
335
|
-
extensionProviders: state.values.extensionProviders,
|
|
336
|
-
viewMode: getViewMode(data.subject.id),
|
|
337
|
-
editorStateStore,
|
|
338
|
-
onViewModeChange: setViewMode
|
|
339
|
-
})
|
|
340
|
-
}),
|
|
341
|
-
createSurface({
|
|
342
|
-
id: `${MARKDOWN_PLUGIN}/settings`,
|
|
343
|
-
role: "settings",
|
|
344
|
-
filter: (data) => data.subject === MARKDOWN_PLUGIN,
|
|
345
|
-
component: () => /* @__PURE__ */ React2.createElement(MarkdownSettings, {
|
|
346
|
-
settings: settings.values
|
|
347
|
-
})
|
|
348
|
-
})
|
|
349
|
-
]
|
|
350
|
-
},
|
|
351
|
-
intent: {
|
|
352
|
-
resolvers: () => [
|
|
353
|
-
createResolver(MarkdownAction.Create, ({ name, content }) => {
|
|
354
|
-
const doc = create(DocumentType, {
|
|
355
|
-
name,
|
|
356
|
-
content: makeRef(create(TextType, {
|
|
357
|
-
content: content ?? ""
|
|
358
|
-
})),
|
|
359
|
-
threads: []
|
|
360
|
-
});
|
|
361
|
-
return {
|
|
362
|
-
data: {
|
|
363
|
-
object: doc
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
}),
|
|
367
|
-
createResolver(MarkdownAction.SetViewMode, ({ id, viewMode }) => {
|
|
368
|
-
state.values.viewMode[id] = viewMode;
|
|
369
|
-
})
|
|
370
|
-
]
|
|
68
|
+
icon: "ph--text-aa--regular",
|
|
69
|
+
graphProps: {
|
|
70
|
+
managesAutofocus: true
|
|
71
|
+
},
|
|
72
|
+
// TODO(wittjosiah): Move out of metadata.
|
|
73
|
+
loadReferences: async (doc) => await RefArray.loadAll([
|
|
74
|
+
doc.content,
|
|
75
|
+
...doc.threads
|
|
76
|
+
]),
|
|
77
|
+
serializer
|
|
371
78
|
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
79
|
+
})
|
|
80
|
+
}),
|
|
81
|
+
defineModule({
|
|
82
|
+
id: `${meta.id}/module/schema`,
|
|
83
|
+
activatesOn: ClientEvents.SetupClient,
|
|
84
|
+
activate: () => [
|
|
85
|
+
contributes(ClientCapabilities.SystemSchema, [
|
|
86
|
+
TextType
|
|
87
|
+
]),
|
|
88
|
+
contributes(ClientCapabilities.Schema, [
|
|
89
|
+
DocumentType
|
|
90
|
+
])
|
|
91
|
+
]
|
|
92
|
+
}),
|
|
93
|
+
defineModule({
|
|
94
|
+
id: `${meta.id}/module/react-surface`,
|
|
95
|
+
activatesOn: Events.Startup,
|
|
96
|
+
activate: ReactSurface
|
|
97
|
+
}),
|
|
98
|
+
defineModule({
|
|
99
|
+
id: `${meta.id}/module/intent-resolver`,
|
|
100
|
+
activatesOn: Events.SetupIntents,
|
|
101
|
+
activate: IntentResolver
|
|
102
|
+
}),
|
|
103
|
+
defineModule({
|
|
104
|
+
id: `${meta.id}/module/app-graph-serializer`,
|
|
105
|
+
activatesOn: Events.Startup,
|
|
106
|
+
activate: AppGraphSerializer
|
|
107
|
+
}),
|
|
108
|
+
defineModule({
|
|
109
|
+
id: `${meta.id}/module/thread`,
|
|
110
|
+
activatesOn: Events.Startup,
|
|
111
|
+
activate: Thread
|
|
112
|
+
})
|
|
113
|
+
]);
|
|
378
114
|
export {
|
|
379
|
-
|
|
380
|
-
|
|
115
|
+
MARKDOWN_PLUGIN,
|
|
116
|
+
MarkdownCapabilities,
|
|
381
117
|
MarkdownPlugin,
|
|
382
|
-
TextType,
|
|
383
|
-
src_default as default,
|
|
384
118
|
getFallbackName,
|
|
385
|
-
isEditorModel,
|
|
386
119
|
isMarkdownProperties,
|
|
387
|
-
|
|
120
|
+
meta,
|
|
388
121
|
serializer,
|
|
389
122
|
setFallbackName
|
|
390
123
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/MarkdownPlugin.tsx"
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { pipe } from 'effect';\nimport React from 'react';\n\nimport {\n parseIntentPlugin,\n resolvePlugin,\n type PluginDefinition,\n createSurface,\n createResolver,\n createIntent,\n chain,\n} from '@dxos/app-framework';\nimport type { BaseObject } from '@dxos/echo-schema';\nimport { create, makeRef, RefArray } from '@dxos/live-object';\nimport { LocalStorageStore } from '@dxos/local-storage';\nimport { SpaceAction } from '@dxos/plugin-space';\nimport { CollectionType } from '@dxos/plugin-space/types';\nimport { createDocAccessor, fullyQualifiedId, getRangeFromCursor, isSpace } from '@dxos/react-client/echo';\nimport {\n type EditorInputMode,\n type EditorViewMode,\n translations as editorTranslations,\n createEditorStateStore,\n} from '@dxos/react-ui-editor';\n\nimport { MarkdownContainer, MarkdownSettings } from './components';\nimport meta, { MARKDOWN_PLUGIN } from './meta';\nimport translations from './translations';\nimport { DocumentType, isEditorModel, TextType } from './types';\nimport {\n type MarkdownPluginProvides,\n type MarkdownSettingsProps,\n MarkdownAction,\n type MarkdownPluginState,\n} from './types';\nimport { markdownExtensionPlugins, serializer } from './util';\n\nexport const MarkdownPlugin = (): PluginDefinition<MarkdownPluginProvides> => {\n const settings = new LocalStorageStore<MarkdownSettingsProps>(MARKDOWN_PLUGIN, {\n defaultViewMode: 'preview',\n toolbar: true,\n numberedHeadings: true,\n folding: true,\n experimental: false,\n });\n\n const editorStateStore = createEditorStateStore(`${MARKDOWN_PLUGIN}/editor`);\n\n const state = new LocalStorageStore<MarkdownPluginState>(MARKDOWN_PLUGIN, { extensionProviders: [], viewMode: {} });\n\n const getViewMode = (id: string) => (id && state.values.viewMode[id]) || settings.values.defaultViewMode;\n const setViewMode = (id: string, viewMode: EditorViewMode) => (state.values.viewMode[id] = viewMode);\n\n return {\n meta,\n ready: async ({ plugins }) => {\n settings\n .prop({ key: 'defaultViewMode', type: LocalStorageStore.enum<EditorViewMode>() })\n .prop({ key: 'editorInputMode', type: LocalStorageStore.enum<EditorInputMode>({ allowUndefined: true }) })\n .prop({ key: 'toolbar', type: LocalStorageStore.bool({ allowUndefined: true }) })\n .prop({ key: 'experimental', type: LocalStorageStore.bool({ allowUndefined: true }) })\n .prop({ key: 'debug', type: LocalStorageStore.bool({ allowUndefined: true }) })\n .prop({ key: 'typewriter', type: LocalStorageStore.string({ allowUndefined: true }) })\n .prop({ key: 'numberedHeadings', type: LocalStorageStore.bool({ allowUndefined: true }) })\n .prop({ key: 'folding', type: LocalStorageStore.bool({ allowUndefined: true }) });\n\n state.prop({ key: 'viewMode', type: LocalStorageStore.json<{ [key: string]: EditorViewMode }>() });\n\n markdownExtensionPlugins(plugins).forEach((plugin) => {\n const { extensions } = plugin.provides.markdown;\n state.values.extensionProviders?.push(extensions);\n });\n },\n provides: {\n settings: settings.values,\n metadata: {\n records: {\n [DocumentType.typename]: {\n createObject: (props: { name?: string }) => createIntent(MarkdownAction.Create, props),\n label: (object: any) => (object instanceof DocumentType ? object.name || object.fallbackName : undefined),\n placeholder: ['document title placeholder', { ns: MARKDOWN_PLUGIN }],\n icon: 'ph--text-aa--regular',\n graphProps: {\n managesAutofocus: true,\n },\n // TODO(wittjosiah): Move out of metadata.\n loadReferences: async (doc: DocumentType) =>\n await RefArray.loadAll<BaseObject>([doc.content, ...doc.threads]),\n serializer,\n },\n },\n },\n translations: [...translations, ...editorTranslations],\n echo: {\n schema: [DocumentType],\n system: [TextType],\n },\n graph: {\n serializer: (plugins) => {\n const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatchPromise;\n if (!dispatch) {\n return [];\n }\n\n return [\n {\n inputType: DocumentType.typename,\n outputType: 'text/markdown',\n // Reconcile with metadata serializers.\n serialize: async (node) => {\n const doc = node.data;\n const content = await doc.content.load();\n return {\n name:\n doc.name ||\n doc.fallbackName ||\n translations[0]['en-US'][MARKDOWN_PLUGIN]['document title placeholder'],\n data: content.content,\n type: 'text/markdown',\n };\n },\n deserialize: async (data, ancestors) => {\n const space = ancestors.find(isSpace);\n const target =\n ancestors.findLast((ancestor) => ancestor instanceof CollectionType) ??\n space?.properties[CollectionType.typename]?.target;\n if (!space || !target) {\n return;\n }\n\n const result = await dispatch(\n pipe(\n createIntent(MarkdownAction.Create, { name: data.name, content: data.data }),\n chain(SpaceAction.AddObject, { target }),\n ),\n );\n\n return result.data?.object;\n },\n },\n ];\n },\n },\n thread: {\n predicate: (obj) => obj instanceof DocumentType,\n createSort: (doc: DocumentType) => {\n const accessor = doc.content.target ? createDocAccessor(doc.content.target, ['content']) : undefined;\n if (!accessor) {\n return (_) => 0;\n }\n\n const getStartPosition = (cursor: string | undefined) => {\n const range = cursor ? getRangeFromCursor(accessor, cursor) : undefined;\n return range?.start ?? Number.MAX_SAFE_INTEGER;\n };\n\n return (anchorA: string | undefined, anchorB: string | undefined): number => {\n if (anchorA === undefined || anchorB === undefined) {\n return 0;\n }\n const posA = getStartPosition(anchorA);\n const posB = getStartPosition(anchorB);\n return posA - posB;\n };\n },\n },\n surface: {\n definitions: () => [\n createSurface({\n id: `${MARKDOWN_PLUGIN}/document`,\n role: ['article', 'section'],\n filter: (data): data is { subject: DocumentType } => data.subject instanceof DocumentType,\n component: ({ data, role }) => (\n <MarkdownContainer\n id={fullyQualifiedId(data.subject)}\n object={data.subject}\n role={role}\n settings={settings.values}\n extensionProviders={state.values.extensionProviders}\n viewMode={getViewMode(fullyQualifiedId(data.subject))}\n editorStateStore={editorStateStore}\n onViewModeChange={setViewMode}\n />\n ),\n }),\n createSurface({\n id: `${MARKDOWN_PLUGIN}/editor`,\n role: ['article', 'section'],\n filter: (data): data is { subject: { id: string; text: string } } => isEditorModel(data.subject),\n component: ({ data, role }) => (\n <MarkdownContainer\n id={data.subject.id}\n object={data.subject}\n role={role}\n settings={settings.values}\n extensionProviders={state.values.extensionProviders}\n viewMode={getViewMode(data.subject.id)}\n editorStateStore={editorStateStore}\n onViewModeChange={setViewMode}\n />\n ),\n }),\n createSurface({\n id: `${MARKDOWN_PLUGIN}/settings`,\n role: 'settings',\n filter: (data): data is any => data.subject === MARKDOWN_PLUGIN,\n component: () => <MarkdownSettings settings={settings.values} />,\n }),\n ],\n },\n intent: {\n resolvers: () => [\n createResolver(MarkdownAction.Create, ({ name, content }) => {\n const doc = create(DocumentType, {\n name,\n content: makeRef(create(TextType, { content: content ?? '' })),\n threads: [],\n });\n\n return { data: { object: doc } };\n }),\n createResolver(MarkdownAction.SetViewMode, ({ id, viewMode }) => {\n state.values.viewMode[id] = viewMode;\n }),\n ],\n },\n },\n };\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { lazy } from 'react';\n\nexport * from './MarkdownSettings';\n\nexport const MarkdownContainer = lazy(() => import('./MarkdownContainer'));\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Input, Select, useTranslation } from '@dxos/react-ui';\nimport { type EditorInputMode, EditorInputModes, type EditorViewMode, EditorViewModes } from '@dxos/react-ui-editor';\nimport { DeprecatedFormInput } from '@dxos/react-ui-form';\n\nimport { MARKDOWN_PLUGIN } from '../meta';\nimport { type MarkdownSettingsProps } from '../types';\n\nexport const MarkdownSettings = ({ settings }: { settings: MarkdownSettingsProps }) => {\n const { t } = useTranslation(MARKDOWN_PLUGIN);\n\n // TODO(wittjosiah): Add skill test confirmation for entering vim mode.\n return (\n <>\n <DeprecatedFormInput label={t('default view mode label')}>\n <Select.Root\n value={settings.defaultViewMode}\n onValueChange={(value) => {\n settings.defaultViewMode = value as EditorViewMode;\n }}\n >\n <Select.TriggerButton />\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n {EditorViewModes.map((mode) => (\n <Select.Option key={mode} value={mode}>\n {t(`${mode} mode label`, { ns: 'react-ui-editor' })}\n </Select.Option>\n ))}\n </Select.Viewport>\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n </DeprecatedFormInput>\n\n <DeprecatedFormInput label={t('editor input mode label')}>\n <Select.Root\n value={settings.editorInputMode ?? 'default'}\n onValueChange={(value) => {\n settings.editorInputMode = value as EditorInputMode;\n }}\n >\n <Select.TriggerButton placeholder={t('select editor input mode placeholder')} />\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n {EditorInputModes.map((mode) => (\n <Select.Option key={mode} value={mode}>\n {t(`settings editor input mode ${mode} label`)}\n </Select.Option>\n ))}\n </Select.Viewport>\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n </DeprecatedFormInput>\n\n <DeprecatedFormInput label={t('settings toolbar label')}>\n <Input.Switch checked={settings.toolbar} onCheckedChange={(checked) => (settings.toolbar = !!checked)} />\n </DeprecatedFormInput>\n\n <DeprecatedFormInput label={t('settings numbered headings label')}>\n <Input.Switch\n checked={settings.numberedHeadings}\n onCheckedChange={(checked) => (settings.numberedHeadings = !!checked)}\n />\n </DeprecatedFormInput>\n\n <DeprecatedFormInput label={t('settings folding label')}>\n <Input.Switch checked={settings.folding} onCheckedChange={(checked) => (settings.folding = !!checked)} />\n </DeprecatedFormInput>\n\n <DeprecatedFormInput label={t('settings experimental label')}>\n <Input.Switch\n checked={settings.experimental}\n onCheckedChange={(checked) => (settings.experimental = !!checked)}\n />\n </DeprecatedFormInput>\n\n <DeprecatedFormInput\n label={t('settings debug label')}\n secondary={\n settings.debug ? (\n <Input.Root>\n <Input.TextArea\n rows={5}\n value={settings.typewriter}\n onChange={({ target: { value } }) => (settings.typewriter = value)}\n placeholder={t('settings debug placeholder')}\n />\n </Input.Root>\n ) : undefined\n }\n >\n <Input.Switch checked={settings.debug} onCheckedChange={(checked) => (settings.debug = !!checked)} />\n </DeprecatedFormInput>\n </>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { MARKDOWN_PLUGIN } from './meta';\nimport { DocumentType } from './types';\n\nexport default [\n {\n 'en-US': {\n [DocumentType.typename]: {\n 'typename label': 'Document',\n },\n [MARKDOWN_PLUGIN]: {\n 'plugin name': 'Editor',\n 'create stack section label': 'Create document',\n 'document title placeholder': 'New document',\n 'choose markdown from space dialog title': 'Choose one or more documents to add',\n // TODO(burdon): Style-guide for user-facing text (e.g., hints, questions, capitalization, etc.)\n 'empty choose markdown from space message': 'None available; try creating a new one instead?',\n 'chooser done label': 'Add selected',\n 'create document label': 'Create document',\n 'editor placeholder': '',\n 'editor input mode label': 'Editor input mode',\n 'select editor input mode placeholder': 'Select editor input mode…',\n 'settings editor input mode default label': 'Default',\n 'settings editor input mode vim label': 'Vim',\n 'settings editor input mode vscode label': 'VS Code',\n 'settings toolbar label': 'Show toolbar',\n 'settings numbered headings label': 'Numbered headings',\n 'settings folding label': 'Folding',\n 'settings experimental label': 'Enable experimental features',\n 'settings debug label': 'Enable debugging features',\n 'settings debug placeholder': 'Typewriter script...',\n 'toggle view mode label': 'Toggle read-only',\n 'default view mode label': 'Default view mode',\n },\n },\n },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { MarkdownPlugin } from './MarkdownPlugin';\n\nexport default MarkdownPlugin;\n\nexport * from './MarkdownPlugin';\nexport * from './types';\nexport * from './util';\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/MarkdownPlugin.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport {\n Capabilities,\n contributes,\n createIntent,\n defineModule,\n definePlugin,\n Events,\n oneOf,\n} from '@dxos/app-framework';\nimport { type BaseObject } from '@dxos/echo-schema';\nimport { RefArray } from '@dxos/live-object';\nimport { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';\nimport { translations as editorTranslations } from '@dxos/react-ui-editor';\nimport { TextType } from '@dxos/schema';\n\nimport {\n MarkdownState,\n MarkdownSettings,\n ReactSurface,\n IntentResolver,\n AppGraphSerializer,\n Thread,\n} from './capabilities';\nimport { MARKDOWN_PLUGIN, meta } from './meta';\nimport translations from './translations';\nimport { DocumentType, MarkdownAction } from './types';\nimport { serializer } from './util';\n\nexport const MarkdownPlugin = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/settings`,\n activatesOn: Events.SetupSettings,\n activate: MarkdownSettings,\n }),\n defineModule({\n id: `${meta.id}/module/state`,\n activatesOn: Events.Startup,\n activate: MarkdownState,\n }),\n defineModule({\n id: `${meta.id}/module/translations`,\n activatesOn: Events.SetupTranslations,\n activate: () => contributes(Capabilities.Translations, [...translations, ...editorTranslations]),\n }),\n defineModule({\n id: `${meta.id}/module/metadata`,\n activatesOn: oneOf(Events.Startup, Events.SetupAppGraph),\n activate: () =>\n contributes(Capabilities.Metadata, {\n id: DocumentType.typename,\n metadata: {\n createObject: (props: { name?: string }) => createIntent(MarkdownAction.Create, props),\n label: (object: any) => (object instanceof DocumentType ? object.name || object.fallbackName : undefined),\n placeholder: ['document title placeholder', { ns: MARKDOWN_PLUGIN }],\n icon: 'ph--text-aa--regular',\n graphProps: {\n managesAutofocus: true,\n },\n // TODO(wittjosiah): Move out of metadata.\n loadReferences: async (doc: DocumentType) =>\n await RefArray.loadAll<BaseObject>([doc.content, ...doc.threads]),\n serializer,\n },\n }),\n }),\n defineModule({\n id: `${meta.id}/module/schema`,\n activatesOn: ClientEvents.SetupClient,\n activate: () => [\n contributes(ClientCapabilities.SystemSchema, [TextType]),\n contributes(ClientCapabilities.Schema, [DocumentType]),\n ],\n }),\n defineModule({\n id: `${meta.id}/module/react-surface`,\n activatesOn: Events.Startup,\n activate: ReactSurface,\n }),\n defineModule({\n id: `${meta.id}/module/intent-resolver`,\n activatesOn: Events.SetupIntents,\n activate: IntentResolver,\n }),\n defineModule({\n id: `${meta.id}/module/app-graph-serializer`,\n activatesOn: Events.Startup,\n activate: AppGraphSerializer,\n }),\n defineModule({\n id: `${meta.id}/module/thread`,\n activatesOn: Events.Startup,\n activate: Thread,\n }),\n ]);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SACEA,cACAC,aACAC,cACAC,cACAC,cACAC,QACAC,aACK;AAEP,SAASC,gBAAgB;AACzB,SAASC,oBAAoBC,oBAAoB;AACjD,SAASC,gBAAgBC,0BAA0B;AACnD,SAASC,gBAAgB;AAelB,IAAMC,iBAAiB,MAC5BC,aAAaC,MAAM;EACjBC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOC;IACpBC,UAAUC;EACZ,CAAA;EACAN,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOI;IACpBF,UAAUG;EACZ,CAAA;EACAR,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOM;IACpBJ,UAAU,MAAMK,YAAYC,aAAaC,cAAc;SAAIC;SAAiBC;KAAmB;EACjG,CAAA;EACAd,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaa,MAAMZ,OAAOI,SAASJ,OAAOa,aAAa;IACvDX,UAAU,MACRK,YAAYC,aAAaM,UAAU;MACjChB,IAAIiB,aAAaC;MACjBC,UAAU;QACRC,cAAc,CAACC,UAA6BC,aAAaC,eAAeC,QAAQH,KAAAA;QAChFI,OAAO,CAACC,WAAiBA,kBAAkBT,eAAeS,OAAOC,QAAQD,OAAOE,eAAeC;QAC/FC,aAAa;UAAC;UAA8B;YAAEC,IAAIC;UAAgB;;QAClEC,MAAM;QACNC,YAAY;UACVC,kBAAkB;QACpB;;QAEAC,gBAAgB,OAAOC,QACrB,MAAMC,SAASC,QAAoB;UAACF,IAAIG;aAAYH,IAAII;SAAQ;QAClEC;MACF;IACF,CAAA;EACJ,CAAA;EACA3C,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAa0C,aAAaC;IAC1BxC,UAAU,MAAM;MACdK,YAAYoC,mBAAmBC,cAAc;QAACC;OAAS;MACvDtC,YAAYoC,mBAAmBG,QAAQ;QAAC/B;OAAa;;EAEzD,CAAA;EACAlB,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOI;IACpBF,UAAU6C;EACZ,CAAA;EACAlD,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOgD;IACpB9C,UAAU+C;EACZ,CAAA;EACApD,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOI;IACpBF,UAAUgD;EACZ,CAAA;EACArD,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOI;IACpBF,UAAUiD;EACZ,CAAA;CACD;",
|
|
6
|
+
"names": ["Capabilities", "contributes", "createIntent", "defineModule", "definePlugin", "Events", "oneOf", "RefArray", "ClientCapabilities", "ClientEvents", "translations", "editorTranslations", "TextType", "MarkdownPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "SetupSettings", "activate", "MarkdownSettings", "Startup", "MarkdownState", "SetupTranslations", "contributes", "Capabilities", "Translations", "translations", "editorTranslations", "oneOf", "SetupAppGraph", "Metadata", "DocumentType", "typename", "metadata", "createObject", "props", "createIntent", "MarkdownAction", "Create", "label", "object", "name", "fallbackName", "undefined", "placeholder", "ns", "MARKDOWN_PLUGIN", "icon", "graphProps", "managesAutofocus", "loadReferences", "doc", "RefArray", "loadAll", "content", "threads", "serializer", "ClientEvents", "SetupClient", "ClientCapabilities", "SystemSchema", "TextType", "Schema", "ReactSurface", "SetupIntents", "IntentResolver", "AppGraphSerializer", "Thread"]
|
|
7
7
|
}
|