Skip to content

Commit

Permalink
Process dom with uuid on load (#310)
Browse files Browse the repository at this point in the history
* Process dom with uuid on load

* Assign unique ID by default

* Update insert and remove node after write

* Fix style bug
  • Loading branch information
Kitenite authored Sep 7, 2024
1 parent 445db7e commit e6dbbdb
Show file tree
Hide file tree
Showing 17 changed files with 1,056 additions and 472 deletions.
1 change: 1 addition & 0 deletions app/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export enum WebviewChannels {
STYLE_UPDATED = 'style-updated',
WINDOW_RESIZED = 'window-resized',
WINDOW_MUTATED = 'window-mutated',
DOM_READY = 'custom-dom-ready',
}

export enum MainChannels {
Expand Down
7 changes: 7 additions & 0 deletions app/common/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { EditorAttributes } from '../constants';
import { finder } from '../selector';
import { assignUniqueId } from '/electron/preload/webview/elements/helpers';

export function escapeSelector(selector: string) {
return CSS.escape(selector);
Expand All @@ -11,6 +12,12 @@ export function querySelectorCommand(selector: string) {
export const getUniqueSelector = (el: HTMLElement, root?: Element | undefined): string => {
let selector = el.tagName.toLowerCase();

assignUniqueId(el);

const onlookUniqueId = getOnlookUniqueSelector(el);
if (onlookUniqueId) {
return onlookUniqueId;
}
try {
if (el.nodeType !== Node.ELEMENT_NODE) {
return selector;
Expand Down
2 changes: 1 addition & 1 deletion app/common/selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Author: Anton Medvedev <[email protected]>
// Source: https://github.com/antonmedv/finder
// @ts-expect-error - No declaration
import { generate, parse } from '../electron/preload/webview/changes/csstree.esm.js';
import { generate, parse } from '../electron/preload/webview/bundles/csstree.esm.js';

type Knot = {
name: string;
Expand Down
Loading

0 comments on commit e6dbbdb

Please sign in to comment.