-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(transform): added transform plugin , runtime controller, React hook #1
Conversation
README.md
Outdated
`, { | ||
plugins: [ | ||
htmlExtension.transform({ | ||
sanitize: dirtyHtml => sanitizeHtml(dirty, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Different name for the first argument (dirtyHtml
, dirty
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
package.json
Outdated
}, | ||
"./runtime": { | ||
"types": "./runtime/index.d.ts", | ||
"style": "./runtime/index.css", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should add a separate export path for styles?
"exports": {
"./runtime/styles": "./runtime/index.css"
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted css (it was empty)
src/plugin/transform.ts
Outdated
bundle = true, | ||
sanitize = defaultSanitize, | ||
shouldUseSanitize = false, | ||
shouldUseIframe = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this boolean flag needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted
src/plugin/transform.ts
Outdated
sanitize = defaultSanitize, | ||
shouldUseSanitize = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can combine this two params in one:
transform({sanitize: false});
transform({sanitize: (v) => v});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, now only: transform({sanitize: (v) => v}); or transform({sanitize: undefined});
src/plugin/transform.ts
Outdated
token.attrPush([TokenAttr.style, 'width:100%']); | ||
} | ||
|
||
const resultHtml = shouldUseSanitize ? sanitize(content) : content; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
markdown-editor extension needs original markup. this is necessary so that the editor does not change the markup on its own
so sanitize should be in render step or we need to save original markup in additional token attribute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to render
src/plugin/utils.ts
Outdated
@@ -0,0 +1,18 @@ | |||
import sanitizeHtml from 'sanitize-html'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sanitize-html
needs to be in deps or peerDeps of package
If u wont use pre-configured sanitizer from diplodoc/transform, u need to import it as follows: https://github.com/diplodoc-platform/transform/blob/master/src/transform/highlight.ts#L8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted default sanitizeHtml
src/runtime/utils.ts
Outdated
// @ts-ignore @typescript-eslint/no-explicit-any | ||
type QueueManagerCallback<T> = (...args: T[]) => any | void; | ||
|
||
// @ts-ignore @typescript-eslint/no-explicit-any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is @ts-ignore
used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/runtime/HtmlController.ts
Outdated
const IFRAME_TAG = 'iframe'; | ||
|
||
export type HTMLControllerForEachCallback = ( | ||
block: HtmlDivController | HtmlIFrameController, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it's worth adding an interface that will be implemented by HtmlDivController and HtmlIFrameController?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted HtmlDivController
Added first version html plugin
HtmlIFrameController
class has also been added that can automatically adjust the height of an iframe based on its content, apply styles, and execute callbacks for each of the frames.reinitialize
,forEach