@lvce-editor/preview-worker 2.6.0 → 2.7.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/dist/previewWorkerMain.js +53 -0
- package/package.json +2 -2
|
@@ -90699,6 +90699,51 @@ const handleKeydown = (state, hdId, key, code) => {
|
|
|
90699
90699
|
};
|
|
90700
90700
|
};
|
|
90701
90701
|
|
|
90702
|
+
const dispatchKeyupEvent = (element, window, key, code) => {
|
|
90703
|
+
const keyupEvent = new window.KeyboardEvent('keyup', {
|
|
90704
|
+
bubbles: true,
|
|
90705
|
+
code,
|
|
90706
|
+
key
|
|
90707
|
+
});
|
|
90708
|
+
dispatchEvent(element, keyupEvent);
|
|
90709
|
+
};
|
|
90710
|
+
|
|
90711
|
+
const handleKeyup = (state, hdId, key, code) => {
|
|
90712
|
+
const happyDomInstance = get(state.uid);
|
|
90713
|
+
if (!happyDomInstance) {
|
|
90714
|
+
return state;
|
|
90715
|
+
}
|
|
90716
|
+
const element = hdId ? happyDomInstance.elementMap.get(hdId) : happyDomInstance.document;
|
|
90717
|
+
if (!element) {
|
|
90718
|
+
return state;
|
|
90719
|
+
}
|
|
90720
|
+
|
|
90721
|
+
// Dispatch keyup event in happy-dom so event listeners fire
|
|
90722
|
+
dispatchKeyupEvent(element, happyDomInstance.window, key, code);
|
|
90723
|
+
|
|
90724
|
+
// Re-serialize the (potentially mutated) DOM
|
|
90725
|
+
const elementMap = new Map();
|
|
90726
|
+
const serialized = serialize(happyDomInstance.document, elementMap);
|
|
90727
|
+
|
|
90728
|
+
// Update happy-dom state with new element map
|
|
90729
|
+
set$1(state.uid, {
|
|
90730
|
+
document: happyDomInstance.document,
|
|
90731
|
+
elementMap,
|
|
90732
|
+
window: happyDomInstance.window
|
|
90733
|
+
});
|
|
90734
|
+
const parsedDom = serialized.dom;
|
|
90735
|
+
const {
|
|
90736
|
+
css
|
|
90737
|
+
} = serialized;
|
|
90738
|
+
const parsedNodesChildNodeCount = getParsedNodesChildNodeCount(parsedDom);
|
|
90739
|
+
return {
|
|
90740
|
+
...state,
|
|
90741
|
+
css,
|
|
90742
|
+
parsedDom,
|
|
90743
|
+
parsedNodesChildNodeCount
|
|
90744
|
+
};
|
|
90745
|
+
};
|
|
90746
|
+
|
|
90702
90747
|
const loadContent = async state => {
|
|
90703
90748
|
// Try to register to receive editor change notifications from the editor worker.
|
|
90704
90749
|
// Use dynamic access and ignore errors so this is safe in environments where
|
|
@@ -90789,6 +90834,7 @@ const renderCss = (oldState, newState) => {
|
|
|
90789
90834
|
const HandleInput = 4;
|
|
90790
90835
|
const HandleClick = 11;
|
|
90791
90836
|
const HandleKeydown = 12;
|
|
90837
|
+
const HandleKeyup = 13;
|
|
90792
90838
|
|
|
90793
90839
|
const getEmptyPreviewDom = () => {
|
|
90794
90840
|
return [{
|
|
@@ -90822,6 +90868,7 @@ const getPreviewDom = state => {
|
|
|
90822
90868
|
onClick: HandleClick,
|
|
90823
90869
|
onInput: HandleInput,
|
|
90824
90870
|
onKeyDown: HandleKeydown,
|
|
90871
|
+
onKeyUp: HandleKeyup,
|
|
90825
90872
|
tabIndex: 0,
|
|
90826
90873
|
type: Div$1
|
|
90827
90874
|
}, ...parsedDom];
|
|
@@ -90832,6 +90879,7 @@ const getPreviewDom = state => {
|
|
|
90832
90879
|
onClick: HandleClick,
|
|
90833
90880
|
onInput: HandleInput,
|
|
90834
90881
|
onKeyDown: HandleKeydown,
|
|
90882
|
+
onKeyUp: HandleKeyup,
|
|
90835
90883
|
tabIndex: 0,
|
|
90836
90884
|
type: Div$1
|
|
90837
90885
|
}, {
|
|
@@ -90910,6 +90958,10 @@ const renderEventListeners = () => {
|
|
|
90910
90958
|
capture: true,
|
|
90911
90959
|
name: HandleKeydown,
|
|
90912
90960
|
params: ['handleKeyDown', 'event.target.dataset.id', 'event.key', 'event.code']
|
|
90961
|
+
}, {
|
|
90962
|
+
capture: true,
|
|
90963
|
+
name: HandleKeyup,
|
|
90964
|
+
params: ['handleKeyUp', 'event.target.dataset.id', 'event.key', 'event.code']
|
|
90913
90965
|
}];
|
|
90914
90966
|
};
|
|
90915
90967
|
|
|
@@ -90969,6 +91021,7 @@ const commandMap = {
|
|
|
90969
91021
|
'Preview.handleFileEdited': wrapCommand(handleFileEdited),
|
|
90970
91022
|
'Preview.handleInput': wrapCommand(handleInput),
|
|
90971
91023
|
'Preview.handleKeyDown': wrapCommand(handleKeydown),
|
|
91024
|
+
'Preview.handleKeyUp': wrapCommand(handleKeyup),
|
|
90972
91025
|
'Preview.loadContent': wrapCommand(loadContent),
|
|
90973
91026
|
'Preview.render2': render2,
|
|
90974
91027
|
'Preview.renderEventListeners': renderEventListeners,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/preview-worker",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Preview Worker",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"main": "dist/previewWorkerMain.js",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@lvce-editor/virtual-dom-worker": "^8.
|
|
14
|
+
"@lvce-editor/virtual-dom-worker": "^8.2.0",
|
|
15
15
|
"happy-dom-without-node": "^14.12.3"
|
|
16
16
|
}
|
|
17
17
|
}
|