Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on:
push:
branches:
- main
pull_request:

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
run: npm install

- name: Build
run: npm run build
21 changes: 17 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"tsc": "tsc -p .",
"bundle": "vite build --config vite.bundle.config.js",
"build": "npm run tsc && npm run bundle",
"build:03": "npm run build"
"build:04": "npm run build"
},
"author": "Dan Marshall",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/host/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"tsc": "tsc -p .",
"bundle": "vite build --config vite.bundle.config.js",
"build": "npm run tsc && npm run bundle",
"build:04": "npm run build",
"build:05": "npm run build",
"preview": "vite preview",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down
12 changes: 12 additions & 0 deletions packages/sandbox-resources/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "sandbox-resources",
"private": true,
"version": "1.0.0",
"scripts": {
"tsc": "tsc -p .",
"build:02": "npm run tsc"
},
"author": "Dan Marshall",
"license": "MIT",
"description": ""
}
6 changes: 6 additions & 0 deletions packages/sandbox-resources/src/idocs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as sandbox from '@microsoft/chartifact-sandbox';
import * as markdown from '@microsoft/interactive-document-markdown';

export as namespace IDocs;

export { markdown, sandbox };
32 changes: 32 additions & 0 deletions packages/sandbox-resources/src/sandbox.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
declare const renderRequest: IDocs.sandbox.SandboxedRenderRequestMessage;

document.addEventListener('DOMContentLoaded', () => {
const renderer = new IDocs.markdown.Renderer(document.body, {
errorHandler: (error: Error, pluginName: string, instanceIndex: number, phase: string, container: Element, detail?: string) => {
console.error(`Error in plugin ${pluginName} at instance ${instanceIndex} during ${phase}:`, error);
if (detail) {
console.error('Detail:', detail);
}
container.innerHTML = `<div style="color: red;">Error: ${error.message}</div>`;
}
});

function render(request) {
if (request.markdown) {
renderer.render(request.markdown);
} else if (request.html) {
renderer.reset();
document.body.innerHTML = request.html;
Comment thread Fixed
renderer.hydrate();
}
}

render(renderRequest);

//add listener for postMessage
window.addEventListener('message', (event) => {
if (!event.data) return;
render(event.data);
});

});
18 changes: 18 additions & 0 deletions packages/sandbox-resources/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"outDir": "dist",
"module": "commonjs",
"typeRoots": [
"./src"
],
"skipLibCheck": true,
"target": "esnext",
"lib": [
"dom",
"esnext"
]
},
"include": [
"src"
]
}
2 changes: 1 addition & 1 deletion packages/sandbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"tsc": "tsc -p .",
"bundle": "vite build --config vite.bundle.config.js",
"build": "npm run tsc && npm run bundle",
"build:02": "npm run build",
"build:03": "npm run build",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Dan Marshall",
Expand Down
4 changes: 2 additions & 2 deletions packages/sandbox/scripts/resources.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const __dirname = path.dirname(__filename);
// Configuration object: key becomes the filename and export name, value is the source path
const resources = {
rendererUmdJs: path.resolve(__dirname, '../../markdown/dist/umd/idocs.markdown.umd.js'),
rendererHtml: path.resolve(__dirname, '../resources/markdown.html'),
sandboxJs: path.resolve(__dirname, '../../webview/dist/sandbox.js'),
rendererHtml: path.resolve(__dirname, '../../sandbox-resources/html/markdown.html'),
sandboxJs: path.resolve(__dirname, '../../sandbox-resources/dist/sandbox.js'),
};

const resourcesDir = path.resolve(__dirname, '../src/resources');
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dev": "tsc -p . -w",
"tsc": "tsc -p .",
"build": "npm run tsc && npm run declaration && npm run strip-blanks && npm run schema && npm run copy-schema",
"build:01": "npm run build"
"build:00": "npm run build"
},
"author": "Dan Marshall",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"pretest": "npm run compile-web",
"vscode:prepublish": "npm run package-web",
"build": "npm run resources && npm run compile-web",
"build:06": "npm run build",
"build:07": "npm run build",
"compile-web": "npm run check-types && npm run lint && npm run resources && node esbuild.js",
"watch-web": "npm-run-all -p watch-web:*",
"watch-web:esbuild": "node esbuild.js --watch",
Expand Down
16 changes: 8 additions & 8 deletions packages/vscode/scripts/resources.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ const resources = [
'../../packages/editor/dist/umd/idocs.editor.umd.js',
'../../docs/assets/examples/grocery-list.idoc.json',
'../../docs/assets/examples/seattle-weather/1.idoc.md',
'../../packages/webview/dist/edit.js',
'../../packages/webview/dist/html-json.js',
'../../packages/webview/dist/html-markdown.js',
'../../packages/webview/dist/preview.js',
'../../packages/webview/html/preview.html',
'../../packages/webview/html/edit.html',
'../../packages/webview/html/html-json.html',
'../../packages/webview/html/html-markdown.html',
'../../packages/vscode-resources/dist/edit.js',
'../../packages/vscode-resources/dist/html-json.js',
'../../packages/vscode-resources/dist/html-markdown.js',
'../../packages/vscode-resources/dist/preview.js',
'../../packages/vscode-resources/html/preview.html',
'../../packages/vscode-resources/html/edit.html',
'../../packages/vscode-resources/html/html-json.html',
'../../packages/vscode-resources/html/html-markdown.html',
];

const errors = [];
Expand Down
4 changes: 2 additions & 2 deletions packages/webview/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "webview",
"name": "vscode-resources",
"private": true,
"version": "1.0.0",
"main": "index.js",
"scripts": {
"tsc": "tsc -p .",
"build:05": "npm run tsc"
"build:06": "npm run tsc"
},
"author": "Dan Marshall",
"license": "MIT",
Expand Down