weml-monaco 0.9.1 → 0.10.0
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/CHANGELOG.md +12 -0
- package/README.md +8 -3
- package/dist/editor.cjs +25 -3
- package/dist/editor.cjs.map +1 -1
- package/dist/editor.d.mts +17 -1
- package/dist/editor.d.ts +17 -1
- package/dist/editor.mjs +25 -3
- package/dist/editor.mjs.map +1 -1
- package/dist/preview.cjs +19 -3
- package/dist/preview.cjs.map +1 -1
- package/dist/preview.d.mts +17 -1
- package/dist/preview.d.ts +17 -1
- package/dist/preview.mjs +19 -3
- package/dist/preview.mjs.map +1 -1
- package/dist/react.cjs +5 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.mts +19 -2
- package/dist/react.d.ts +19 -2
- package/dist/react.mjs +5 -0
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,18 @@ This package shares the language logic of the VS Code extension (`weml-support`)
|
|
|
8
8
|
entries below track the port catching up with its provider changes; since the shared language
|
|
9
9
|
features, both take the same code.
|
|
10
10
|
|
|
11
|
+
## [0.10.0] — 2026-10-14
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- The preview takes the host's direction and language: `createWemlPreview(editor, { language: { dir,
|
|
15
|
+
lang } })` and `preview.setLanguage(...)`, each field over the document's own `<html dir lang>`. A
|
|
16
|
+
fragment has none — a paragraph of a right-to-left publication rendered left to right.
|
|
17
|
+
- The editor passes them on: `preview.language` (`createWemlEditor`), `setPreviewLanguage`; in
|
|
18
|
+
`<WemlEditor>` the prop is followed, as `preview.theme` is.
|
|
19
|
+
|
|
20
|
+
VS Code has no counterpart: its preview shows a file, whose own `<html dir lang>` it already
|
|
21
|
+
follows, and has no host to know a language the file does not declare.
|
|
22
|
+
|
|
11
23
|
## [0.9.1] — 2026-10-14
|
|
12
24
|
|
|
13
25
|
### Fixed
|
package/README.md
CHANGED
|
@@ -240,7 +240,9 @@ weml.dispose();
|
|
|
240
240
|
`.monaco-component`); the workbench colours Monaco lacks (tabs, side bar, status
|
|
241
241
|
bar) are derived from the editor's. The stylesheet is injected, and published as
|
|
242
242
|
`weml-monaco/editor.css` (`injectStyles: false` to link it).
|
|
243
|
-
- The preview renders with `weml-stylesheet`, so this entry needs it installed.
|
|
243
|
+
- The preview renders with `weml-stylesheet`, so this entry needs it installed. The host's
|
|
244
|
+
direction and language go in `preview.language` (`{ dir, lang }`, over the document's own; a
|
|
245
|
+
paragraph has none), changed with `setPreviewLanguage`.
|
|
244
246
|
|
|
245
247
|
## React
|
|
246
248
|
|
|
@@ -253,7 +255,7 @@ import { WemlEditor, type WemlEditorApi } from 'weml-monaco/react';
|
|
|
253
255
|
A thin component over `createWemlEditor` (React is an optional peer dependency,
|
|
254
256
|
`>=18`): the options are its props, `editorRef` gives the editor's API
|
|
255
257
|
(`WemlEditorApi`). Props marked `@mount` are read once — a change to one needs a
|
|
256
|
-
new `key`; `fileName`, `saving`, `saveDisabled` and `preview.
|
|
258
|
+
new `key`; `fileName`, `saving`, `saveDisabled`, `preview.theme` and `preview.language` follow their props.
|
|
257
259
|
`sidePanels` take React content (`content: node | (editor) => node`), rendered into
|
|
258
260
|
their views through portals — inside the application's context. React and react-dom
|
|
259
261
|
are optional peer dependencies (`>=18`).
|
|
@@ -345,7 +347,10 @@ preview.dispose();
|
|
|
345
347
|
It renders at once, then after a pause in typing (`delay`, 300 ms), and at once
|
|
346
348
|
again when the editor gets another model; an unchanged text is not rendered
|
|
347
349
|
twice (a whole book is not cheap). A whole document keeps its `dir` / `lang`
|
|
348
|
-
(right-to-left books render right to left).
|
|
350
|
+
(right-to-left books render right to left). A fragment has none of its own — a
|
|
351
|
+
paragraph of an Arabic publication — so the host gives them: `language: { dir:
|
|
352
|
+
'rtl', lang: 'ar-AE' }`, each field over the document's, changed later with
|
|
353
|
+
`preview.setLanguage(...)`. Blank text shows `emptyText`;
|
|
349
354
|
`transform(text)` picks what to render (e.g. without a wrapper your editor adds).
|
|
350
355
|
|
|
351
356
|
**Scroll sync**, both ways, as in the VS Code preview (and with the same code,
|
package/dist/editor.cjs
CHANGED
|
@@ -36778,12 +36778,23 @@ function createWemlPreview(editor, options = {}) {
|
|
|
36778
36778
|
content.hidden = blank;
|
|
36779
36779
|
empty.hidden = !blank;
|
|
36780
36780
|
};
|
|
36781
|
-
|
|
36781
|
+
let hostLanguage = options.language;
|
|
36782
|
+
let documentDir;
|
|
36783
|
+
let documentLang;
|
|
36784
|
+
const applyLanguage = () => {
|
|
36785
|
+
const dir = hostLanguage?.dir ?? documentDir;
|
|
36786
|
+
const lang = hostLanguage?.lang ?? documentLang;
|
|
36782
36787
|
if (dir) content.dir = dir;
|
|
36783
36788
|
else content.removeAttribute("dir");
|
|
36784
36789
|
if (lang) content.lang = lang;
|
|
36785
36790
|
else content.removeAttribute("lang");
|
|
36786
36791
|
};
|
|
36792
|
+
const setDocumentLanguage = (dir, lang) => {
|
|
36793
|
+
documentDir = dir;
|
|
36794
|
+
documentLang = lang;
|
|
36795
|
+
applyLanguage();
|
|
36796
|
+
};
|
|
36797
|
+
applyLanguage();
|
|
36787
36798
|
const rendered = () => {
|
|
36788
36799
|
anchors = void 0;
|
|
36789
36800
|
if (sync.previewWithEditor) followEditor();
|
|
@@ -36811,7 +36822,7 @@ function createWemlPreview(editor, options = {}) {
|
|
|
36811
36822
|
generation = update2.generation;
|
|
36812
36823
|
shownVersion = { model, version };
|
|
36813
36824
|
showBlank(update2.blank);
|
|
36814
|
-
|
|
36825
|
+
setDocumentLanguage(update2.blank ? void 0 : update2.dir, update2.blank ? void 0 : update2.lang);
|
|
36815
36826
|
rendered();
|
|
36816
36827
|
}
|
|
36817
36828
|
done();
|
|
@@ -36831,7 +36842,7 @@ function createWemlPreview(editor, options = {}) {
|
|
|
36831
36842
|
const blank = markup.trim() === "";
|
|
36832
36843
|
showBlank(blank);
|
|
36833
36844
|
const language = blank ? {} : (0, import_weml_stylesheet.documentLanguage)(markup);
|
|
36834
|
-
|
|
36845
|
+
setDocumentLanguage(language.dir, language.lang);
|
|
36835
36846
|
const { body, bodyLine } = splitDocument(markup);
|
|
36836
36847
|
const next = blank ? [] : splitPreviewChunks(body, firstLine + bodyLine);
|
|
36837
36848
|
chunks.apply(diffPreviewChunks(texts, next));
|
|
@@ -36933,6 +36944,11 @@ function createWemlPreview(editor, options = {}) {
|
|
|
36933
36944
|
return {
|
|
36934
36945
|
element: element2,
|
|
36935
36946
|
setTheme,
|
|
36947
|
+
setLanguage(language) {
|
|
36948
|
+
hostLanguage = language;
|
|
36949
|
+
applyLanguage();
|
|
36950
|
+
anchors = void 0;
|
|
36951
|
+
},
|
|
36936
36952
|
refresh: now,
|
|
36937
36953
|
setScrollSync(next) {
|
|
36938
36954
|
sync = scrollSyncOf(next);
|
|
@@ -38749,6 +38765,7 @@ function createWemlEditor(m2, container, options = {}) {
|
|
|
38749
38765
|
const views = /* @__PURE__ */ new Map();
|
|
38750
38766
|
let previewScrollSync = options.preview?.scrollSync !== false;
|
|
38751
38767
|
let previewTheme = options.preview?.theme;
|
|
38768
|
+
let previewLanguage = options.preview?.language;
|
|
38752
38769
|
const createView = (view) => {
|
|
38753
38770
|
const host = element("div");
|
|
38754
38771
|
if (view === "problems") {
|
|
@@ -38780,6 +38797,7 @@ function createWemlEditor(m2, container, options = {}) {
|
|
|
38780
38797
|
// Cut and compared in the WEML worker when the language runs there (a file: no transform).
|
|
38781
38798
|
analysis,
|
|
38782
38799
|
theme: previewTheme,
|
|
38800
|
+
language: previewLanguage,
|
|
38783
38801
|
scrollSync: previewScrollSync,
|
|
38784
38802
|
container: host,
|
|
38785
38803
|
// A paragraph without its wrapper, from the model's second line (the scroll sync matches
|
|
@@ -39436,6 +39454,10 @@ function createWemlEditor(m2, container, options = {}) {
|
|
|
39436
39454
|
previewTheme = theme;
|
|
39437
39455
|
views.get("preview")?.preview?.setTheme(theme);
|
|
39438
39456
|
},
|
|
39457
|
+
setPreviewLanguage(language2) {
|
|
39458
|
+
previewLanguage = language2;
|
|
39459
|
+
views.get("preview")?.preview?.setLanguage(language2);
|
|
39460
|
+
},
|
|
39439
39461
|
addStatusBarItem(item, alignment = "left") {
|
|
39440
39462
|
item.classList.add("wb-status-item");
|
|
39441
39463
|
(alignment === "left" ? statusLeft : statusRight).append(item);
|