Skip to content
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

[QUESTION] blockquote #83

Closed
haophan1996 opened this issue Jul 3, 2021 · 5 comments
Closed

[QUESTION] blockquote #83

haophan1996 opened this issue Jul 3, 2021 · 5 comments
Labels
question Further information is requested

Comments

@haophan1996
Copy link

haophan1996 commented Jul 3, 2021

hi, i want to custom blockquote that every time user type something in blockquote, i want it to be different color to indicate this is a quote, such as add a box, a color, how can i do it, is there anyway to do so

thank you in advance
Untitled

@haophan1996 haophan1996 added the question Further information is requested label Jul 3, 2021
@tneotia
Copy link
Owner

tneotia commented Jul 8, 2021

You might be able to change the style of blockquote by injecting custom CSS through JavaScript. If you'd like an example for this let me know, sorry for the late response!

@haophan1996
Copy link
Author

haophan1996 commented Jul 8, 2021

You might be able to change the style of blockquote by injecting custom CSS through JavaScript. If you'd like an example for this let me know, sorry for the late response!

yes, please, and I have only 1 more question that how do custom blockquote or youtube, as normal i will input <iframe></iframe> but i want it show different such as <video><\video> and other

thank you very much

@tneotia
Copy link
Owner

tneotia commented Jul 8, 2021

Here is an example for blockquote styling:

HtmlEditor(
  controller: controller,
  callbacks: Callbacks(onInit: () {
    controller.editorController!.evaluateJavascript(source: """
      const style = document.createElement('style');
      style.textContent = 'blockquote { background: #f9f9f9; border-left: 10px solid #ccc; margin: 1.5em 10px; color: black; };';
      document.head.append(style);
    """);
  }),
),
Result

image

For changing how the HTML is inserted for elements like video, you can do this:

HtmlEditor(
    controller: controller,
    toolbarOptions: ToolbarOptions(
      mediaUploadInterceptor: (PlatformFile file, InsertFileType type) async {
        if (file.bytes != null) {
          if (type == InsertFileType.video) {
            String base64Data = base64.encode(file.bytes!);
            String base64Image =
            """<video src="data:video/${file.extension};base64,$base64Data" data-filename="${file.name}"/>""";
            controller.insertHtml(base64Image);
            //tell the package we handled on our own
            return false;
          }
        }
        //tell the package to handle cases other than video on its own
        return true;
      },
    ),
  );

You can insert any different type of HTML as long as it can display base64 content. If you need to show it in an iframe then you will have to upload to server and show the URL, otherwise you can use <video> to show base64 data.

Let me know if you have further questions.

@haophan1996
Copy link
Author

Here is an example for blockquote styling:

HtmlEditor(
  controller: controller,
  callbacks: Callbacks(onInit: () {
    controller.editorController!.evaluateJavascript(source: """
      const style = document.createElement('style');
      style.textContent = 'blockquote { background: #f9f9f9; border-left: 10px solid #ccc; margin: 1.5em 10px; color: black; };';
      document.head.append(style);
    """);
  }),
),

Result
For changing how the HTML is inserted for elements like video, you can do this:

HtmlEditor(
    controller: controller,
    toolbarOptions: ToolbarOptions(
      mediaUploadInterceptor: (PlatformFile file, InsertFileType type) async {
        if (file.bytes != null) {
          if (type == InsertFileType.video) {
            String base64Data = base64.encode(file.bytes!);
            String base64Image =
            """<video src="data:video/${file.extension};base64,$base64Data" data-filename="${file.name}"/>""";
            controller.insertHtml(base64Image);
            //tell the package we handled on our own
            return false;
          }
        }
        //tell the package to handle cases other than video on its own
        return true;
      },
    ),
  );

You can insert any different type of HTML as long as it can display base64 content. If you need to show it in an iframe then you will have to upload to server and show the URL, otherwise you can use <video> to show base64 data.

Let me know if you have further questions.

Thank you so much, your help is very helpful

@tneotia
Copy link
Owner

tneotia commented Jul 9, 2021

No problem. If you have any other questions let me know!

@tneotia tneotia closed this as completed Jul 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants